minor changes. @Sheep: Take a look at the changes I made to helpers module and tell me if I'm stupid.

This commit is contained in:
Dico
2014-07-18 03:45:28 +02:00
parent c5a6d0b52b
commit c01caf04a9
2 changed files with 21 additions and 28 deletions

View File

@@ -1,6 +1,5 @@
#pylint: disable = F0401 #pylint: disable = F0401
from helpers import * from helpers import *
from java.util.UUID import fromString as id_to_player
from org.bukkit.util import Vector from org.bukkit.util import Vector
from math import sin from math import sin
@@ -93,7 +92,7 @@ def whitelist_list(player):
forcefield_header(player, "&bForcefield whitelist:") forcefield_header(player, "&bForcefield whitelist:")
for user_id in whitelists.get(player_id, []): for user_id in whitelists.get(player_id, []):
count += 1 count += 1
pname = server.getOfflinePlayer(id_to_player(user_id)).getName() pname = retrieve_player(user_id).getName()
msg(player, "&b %s. &f%s" % (count, pname)) msg(player, "&b %s. &f%s" % (count, pname))
if count == 0: if count == 0:
msg(player, "&c Your whitelist has no entries.") msg(player, "&c Your whitelist has no entries.")
@@ -110,19 +109,16 @@ def whitelist_clear(player):
def forcefield_help(player): def forcefield_help(player):
msg(player, " ") msg(player, " ")
forcefield_header(player, "&b&l/Forcefield help: %s" % forcefield_check(player)) forcefield_header(player, "&b&l/Forcefield help: Your forcefield is %s" % ("&2&lON" if uid(player) in ff_users else "&c&lOFF"))
msg(player, "&b You can use the forcefield to keep players on distance.") msg(player, "&b You can use the forcefield to keep players on distance.")
msg(player, "&b Commands:") msg(player, "&b Commands:")
msg(player, "&b 1. &6/ff &ohelp &b: aliases: &6?") msg(player, "&b 1. &6/ff &ohelp &b aliases: &6?")
msg(player, "&b 2. &6/ff &o(on off)") msg(player, "&b 2. &6/ff &o(on off)")
msg(player, "&b 3. &6/ff &owhitelist (list) &b: aliases: &6wlist, wl") msg(player, "&b 3. &6/ff &owhitelist (list) &b aliases: &6wlist, wl")
msg(player, "&b 4. &6/ff wl &oclear") msg(player, "&b 4. &6/ff wl &oclear")
msg(player, "&b 5. &6/ff wl &oadd <players> &b: aliases: &6+") msg(player, "&b 5. &6/ff wl &oadd <players> &b aliases: &6+")
msg(player, "&b 6. &6/ff wl &oremove <players> &b: aliases: &6delete, rem, del, - \n") msg(player, "&b 6. &6/ff wl &oremove <players> &b aliases: &6delete, rem, del, -")
msg(player, " ")
def forcefield_check(player): # Returns a string to tell the player its forcefield status
return "&eYour forcefield is %s" % "&2ON" if uid(player) in ff_users else "&cOFF"
def forcefield_toggle(player, arg): # arg is a list with max 1 string def forcefield_toggle(player, arg): # arg is a list with max 1 string
@@ -131,22 +127,12 @@ def forcefield_toggle(player, arg): # arg is a list with max 1 string
argoff = arg[0].upper() == "OFF" if arg else False argoff = arg[0].upper() == "OFF" if arg else False
if enabled and (not arg or argoff): # 3 possibilities for arg: [], ["OFF"], ["ON"]. This is the most efficient way. (Case insensitive) if enabled and (not arg or argoff): # 3 possibilities for arg: [], ["OFF"], ["ON"]. This is the most efficient way. (Case insensitive)
ff_users.remove(player_id) ff_users.remove(player_id)
forcefield_header(player, "&bForcefield toggle: &cOFF") forcefield_header(player, "&bForcefield toggle: &c&lOFF")
elif not enabled and not argoff: elif not enabled and not argoff:
ff_users.append(player_id) ff_users.append(player_id)
forcefield_header(player, "&bForcefield toggle: &2ON") forcefield_header(player, "&bForcefield toggle: &2&lON")
else:
forcefield_header(player, "&cYour forcefield is already %s!" % arg[0].lower())
def forcefield_help(sender):
msg(sender, "%s &a&l/ForceField Help:" % ff_prefix)
msg(sender, "&aYou can use the forcefield to keep players on distance.")
msg(sender, "&2Commands:")
msg(sender, "&a1. &6/ff &ohelp &a: aliases: ?")
msg(sender, "&a2. &6/ff &o(toggle)")
msg(sender, "&a3. &6/ff &owhitelist (list) &a: aliases: wlist, wl")
msg(sender, "&a4. &6/ff wl &oclear")
msg(sender, "&a5. &6/ff wl &oadd <players> &a: aliases: &o+")
msg(sender, "&a6. &6/ff wl &oremove <players> &a: aliases: &odelete, rem, del, -")
def forcefield_header(player, message): def forcefield_header(player, message):

View File

@@ -1,5 +1,6 @@
#pylint: disable = F0401 #pylint: disable = F0401
from re import sub from re import sub
from java.util.UUID import fromString as id_to_player
import org.bukkit as bukkit import org.bukkit as bukkit
import org.bukkit.Location as Location import org.bukkit.Location as Location
import org.bukkit.entity.Player as Player import org.bukkit.entity.Player as Player
@@ -92,9 +93,11 @@ def checkargs(sender, args, amin, amax):
def warp(player, args, warpname): def warp(player, args, warpname):
if not checkargs(player, args, 0, 1): if not checkargs(player, args, 0, 1):
return False # You can check if it worked
runas(player, "warp %s" % warpname)
return True return True
runas(player, " ".join(["warp", warpname, player.getName()])) """ Changed to this, from runas(player, " ".join(["warp", warpname])) because it doesnt make sense
return True to make the player add its own name to the command to warp that name which is the same player """
def is_creative(player): def is_creative(player):
@@ -103,3 +106,7 @@ def is_creative(player):
def uid(player): def uid(player):
return str(player.getUniqueId()) return str(player.getUniqueId())
def retrieve_player(uid):
return server.getOfflinePlayer(id_to_player(uid))