diff options
author | jomo <github@jomo.tv> | 2014-08-07 02:49:34 +0200 |
---|---|---|
committer | jomo <github@jomo.tv> | 2014-08-07 02:49:34 +0200 |
commit | adaddd7500bf7ea695e004501e3121471146b67c (patch) | |
tree | 4d3e71d8e98ab20c821d7b64be611c78138dc1ce /forcefield.py | |
parent | 0cf6c5340549e53ac3bae40a881724cc308112aa (diff) |
use threading for offline players
Diffstat (limited to 'forcefield.py')
-rw-r--r-- | forcefield.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/forcefield.py b/forcefield.py index 94f7747..497c853 100644 --- a/forcefield.py +++ b/forcefield.py @@ -1,4 +1,5 @@ #pylint: disable = F0401 +import thread from helpers import * from org.bukkit.util import Vector 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). if args[0] in ["WHITELIST", "WL", "WLIST"]: # Whitelist commands if not args[1:] or args[1].upper() == "LIST": - whitelist_list(sender) + thread.start_new_thread(whitelist_list, (sender,)) return True 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): - player_id = uid(player) - count = 0 - forcefield_header(player, "&bForcefield whitelist:") - for user_id in whitelists.get(player_id, []): - count += 1 - pname = retrieve_player(user_id).getName() - msg(player, "&b %s. &f%s" % (count, pname)) - if count == 0: - msg(player, "&c Your whitelist has no entries.") + try: + player_id = uid(player) + count = 0 + forcefield_header(player, "&bForcefield whitelist:") + for user_id in whitelists.get(player_id, []): + count += 1 + pname = retrieve_player(user_id).getName() + msg(player, "&b %s. &f%s" % (count, pname)) + if count == 0: + msg(player, "&c Your whitelist has no entries.") + except: + warn("Unable to finish whitelist_list process") def whitelist_clear(player): |