Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Convert Essentials homes to SpawnControl
#!/usr/bin/env python
import sys
import sqlite3
import yaml
import os
import time
from os import path
# Make sure paths exist
if len(sys.argv) != 2:
print "Usage: %s pluginpath" % (sys.argv[0])
sys.exit()
pluginDir = sys.argv[1]
if not path.exists(pluginDir):
print "Path %s doesn't exist" % (pluginDir)
sys.exit()
essentialsDir = path.join(pluginDir,'Essentials')
scDir = path.join(pluginDir,'SpawnControl')
if not path.exists(essentialsDir):
print "Essentials path %s doesn't exist" % essentialsDir
sys.exit()
if not path.exists(scDir):
print "SpawnControl path % doesn't exist" % scDir
sys.exit()
userdir = path.join(essentialsDir,'userdata')
if not path.exists(userdir):
print "Can't find essentials userdata directory"
sys.exit()
# Connect to DB and start the loop
scdb = sqlite3.connect(path.join(scDir,'spawncontrol.db'))
c = scdb.cursor()
userfiles = os.listdir(userdir)
for userfile in userfiles:
user = open(path.join(userdir,userfile))
useryaml = yaml.load(user)
if not useryaml or 'home' not in useryaml:
continue
print "Adding %s's home" % userfile[0:-4]
for world in useryaml["home"]["worlds"]:
h = useryaml["home"]["worlds"][world]
c.execute('insert into players (name, world, x, y, z, r, p, updated, updated_by) values (?, ?, ?, ?, ?, ?, ?, ?, ?)',(userfile[0:-4], world, h["x"],h["y"],h["z"],h["yaw"],h["pitch"],int(time.time()),"Essentials Import"))
user.close()
scdb.commit()
c.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.