use threading for offline players
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#pylint: disable = F0401
|
#pylint: disable = F0401
|
||||||
|
import thread
|
||||||
from helpers import *
|
from helpers import *
|
||||||
from org.bukkit.util import Vector
|
from org.bukkit.util import Vector
|
||||||
from math import sin
|
from math import sin
|
||||||
@@ -28,7 +29,7 @@ def on_forcefield_command(sender, args):
|
|||||||
args[0] = args[0].upper() # If it gets to this point, there are argument(s).
|
args[0] = args[0].upper() # If it gets to this point, there are argument(s).
|
||||||
if args[0] in ["WHITELIST", "WL", "WLIST"]: # Whitelist commands
|
if args[0] in ["WHITELIST", "WL", "WLIST"]: # Whitelist commands
|
||||||
if not args[1:] or args[1].upper() == "LIST":
|
if not args[1:] or args[1].upper() == "LIST":
|
||||||
whitelist_list(sender)
|
thread.start_new_thread(whitelist_list, (sender,))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
args[1] = args[1].upper() # If it gets too this point, there is a second argument.
|
args[1] = args[1].upper() # If it gets too this point, there is a second argument.
|
||||||
@@ -88,15 +89,18 @@ def change_whitelist(sender, add, names): #Add names if add == True else Remove
|
|||||||
|
|
||||||
|
|
||||||
def whitelist_list(player):
|
def whitelist_list(player):
|
||||||
player_id = uid(player)
|
try:
|
||||||
count = 0
|
player_id = uid(player)
|
||||||
forcefield_header(player, "&bForcefield whitelist:")
|
count = 0
|
||||||
for user_id in whitelists.get(player_id, []):
|
forcefield_header(player, "&bForcefield whitelist:")
|
||||||
count += 1
|
for user_id in whitelists.get(player_id, []):
|
||||||
pname = retrieve_player(user_id).getName()
|
count += 1
|
||||||
msg(player, "&b %s. &f%s" % (count, pname))
|
pname = retrieve_player(user_id).getName()
|
||||||
if count == 0:
|
msg(player, "&b %s. &f%s" % (count, pname))
|
||||||
msg(player, "&c Your whitelist has no entries.")
|
if count == 0:
|
||||||
|
msg(player, "&c Your whitelist has no entries.")
|
||||||
|
except:
|
||||||
|
warn("Unable to finish whitelist_list process")
|
||||||
|
|
||||||
|
|
||||||
def whitelist_clear(player):
|
def whitelist_clear(player):
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def print_list(sender):
|
|||||||
try: # new thread, anything can happen.
|
try: # new thread, anything can happen.
|
||||||
msg(sender, "&a" + str(len(reports)) + " reports:")
|
msg(sender, "&a" + str(len(reports)) + " reports:")
|
||||||
for i, report in enumerate(reports):
|
for i, report in enumerate(reports):
|
||||||
name = server.getOfflinePlayer(juuid(report["uuid"])).getName()
|
name = retrieve_player(report["uuid"]).getName()
|
||||||
msg(sender, "&8[&e%s&c%s&8] &3%s&f: &a%s" % (i, report["time"], name, report["msg"]))
|
msg(sender, "&8[&e%s&c%s&8] &3%s&f: &a%s" % (i, report["time"], name, report["msg"]))
|
||||||
except:
|
except:
|
||||||
warn("Failed to complete report's print_list() thread")
|
warn("Failed to complete report's print_list() thread")
|
||||||
@@ -62,7 +62,7 @@ def on_rp_command(sender, args):
|
|||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
if args[0] == "list":
|
if args[0] == "list":
|
||||||
# needs to run in seperate thread because of getOfflinePlayer
|
# needs to run in seperate thread because of getOfflinePlayer
|
||||||
thread.start_new_thread(print_list, (sender))
|
thread.start_new_thread(print_list, (sender,))
|
||||||
else:
|
else:
|
||||||
if not checkargs(sender, args, 2, 2):
|
if not checkargs(sender, args, 2, 2):
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user