Some tweaks and updates
This commit is contained in:
@@ -104,7 +104,8 @@ def advancedcommand(cmd,
|
|||||||
return called.call(sender, command, label, args)
|
return called.call(sender, command, label, args)
|
||||||
|
|
||||||
def decorator(function):
|
def decorator(function):
|
||||||
functions = [new.function(c, globals()) for c in function.func_code.co_consts if inspect.iscode(c)]
|
#functions = [new.function(c, globals()) for c in function.func_code.co_consts if inspect.iscode(c)]
|
||||||
|
functions = function()
|
||||||
for sub in subCommands:
|
for sub in subCommands:
|
||||||
sub.setParent(cmd)
|
sub.setParent(cmd)
|
||||||
for func in functions:
|
for func in functions:
|
||||||
@@ -149,7 +150,7 @@ class subcommand():
|
|||||||
def isCalled(self, subcmd):
|
def isCalled(self, subcmd):
|
||||||
alias = self.cmd
|
alias = self.cmd
|
||||||
i = 0
|
i = 0
|
||||||
while (i <= len(self.aliases)):
|
while i <= len(self.aliases):
|
||||||
if alias == subcmd:
|
if alias == subcmd:
|
||||||
return True
|
return True
|
||||||
alias = self.aliases[i]
|
alias = self.aliases[i]
|
||||||
|
|||||||
@@ -17,40 +17,34 @@ ranks = {
|
|||||||
@hook.event("player.PlayerJoinEvent", "normal")
|
@hook.event("player.PlayerJoinEvent", "normal")
|
||||||
def on_player_join(event):
|
def on_player_join(event):
|
||||||
user = event.getPlayer()
|
user = event.getPlayer()
|
||||||
uuid = uid(player)
|
uuid = uid(player).replace("-", "")
|
||||||
role = get_role(uuid)
|
role = get_role(uuid)
|
||||||
if role in [1, 2, 6]: #Disabled/Banned/Superadmin
|
if role in [1, 2, 6]: #Disabled/Banned/Superadmin
|
||||||
return
|
return
|
||||||
if role != None:
|
if role:
|
||||||
for rank in ranks:
|
for rank in ranks:
|
||||||
if user.hasPermission("group." + rank):
|
if user.hasPermission("group." + rank):
|
||||||
set_role(uuid, ranks[rank])
|
if role != ranks[rank]:
|
||||||
|
set_role(uuid, ranks[rank])
|
||||||
return
|
return
|
||||||
if not user.hasPlayedBefore():
|
if not user.hasPlayedBefore():
|
||||||
return
|
return
|
||||||
if role == None:
|
if role == None:
|
||||||
msg(user, "&cYou haven't registed yet! Make sure to do so on redstoner.com")
|
msg(user, "&cYou haven't registed yet! Make sure to do so on redstoner.com")
|
||||||
elif not is_email_confirmed(uuid):
|
|
||||||
msg(user, "&cWe noticed that you haven't confirmed your website email! Don't forget to do so!")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_role(uuid):
|
def get_role(uuid):
|
||||||
return execute_query("SELECT `role_id` FROM users WHERE `uuid` = ? LIMIT 1")[0][17]
|
return execute_query("SELECT `role_id` FROM users WHERE `uuid` = ? LIMIT 1", uuid)[0][17]
|
||||||
|
|
||||||
|
|
||||||
def set_role(uuid, role_id):
|
def set_role(uuid, role_id):
|
||||||
execute_query("UPDATE users SET `role_id` = %d WHERE `uuid` = ?" % role_id)
|
execute_update("UPDATE users SET `role_id` = %d WHERE `uuid` = ?" % role_id, uuid)
|
||||||
|
|
||||||
|
|
||||||
def is_email_confirmed(uuid):
|
|
||||||
return execute_query("SELECT `confirmed` FROM users WHERE `uuid` = ? LIMIT 1")[0][15]
|
|
||||||
|
|
||||||
|
|
||||||
def execute_query(query, uuid):
|
def execute_query(query, uuid):
|
||||||
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
|
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
|
||||||
curs = conn.cursor()
|
curs = conn.cursor()
|
||||||
uuid = uid(player).replace("-", "")
|
|
||||||
curs.execute(query, (uuid,))
|
curs.execute(query, (uuid,))
|
||||||
results = curs.fetchall()
|
results = curs.fetchall()
|
||||||
curs.close()
|
curs.close()
|
||||||
@@ -58,4 +52,9 @@ def execute_query(query, uuid):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def execute_update(update, uuid):
|
||||||
|
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
|
||||||
|
curs = conn.cursor()
|
||||||
|
curs.execute(update, (uuid,))
|
||||||
|
curs.close()
|
||||||
|
conn.close()
|
||||||
Reference in New Issue
Block a user