remove try/except. fix code if it doesn't work ;)

This commit is contained in:
jomo
2014-07-27 23:55:15 +02:00
parent 180680422a
commit 08cae3213e
4 changed files with 137 additions and 155 deletions

View File

@@ -10,7 +10,7 @@ def adminchat(sender, msg):
name = "&7{unknown}" name = "&7{unknown}"
try: try:
name = sender.getDisplayName() name = sender.getDisplayName()
except: except AttributeError:
name = sender.getName() name = sender.getName()
broadcast(ac_permission, "%s &9%s&8: &b%s" % (ac_prefix, name, msg)) broadcast(ac_permission, "%s &9%s&8: &b%s" % (ac_prefix, name, msg))

View File

@@ -10,7 +10,6 @@ cg_toggle_list = []
@hook.command("chatgroup") @hook.command("chatgroup")
def on_chatgroup_command(sender, args): def on_chatgroup_command(sender, args):
try:
plugin_header(sender, "ChatGroups") plugin_header(sender, "ChatGroups")
sender_id = uid(sender) sender_id = uid(sender)
if len(args) == 1 and args[0] == "leave": if len(args) == 1 and args[0] == "leave":
@@ -45,8 +44,6 @@ def on_chatgroup_command(sender, args):
msg(sender, "&e/chatgroup join <name>") msg(sender, "&e/chatgroup join <name>")
msg(sender, "&e/chatgroup leave") msg(sender, "&e/chatgroup leave")
msg(sender, "&e/chatgroup info") msg(sender, "&e/chatgroup info")
except Exception, e:
error(e)
@hook.command("cgt") @hook.command("cgt")
@@ -62,7 +59,6 @@ def on_cgt_command(sender, args):
def groupchat(sender, message, ann = False): def groupchat(sender, message, ann = False):
#try:
group = groups.get(uid(sender)) group = groups.get(uid(sender))
if group == None: if group == None:
msg(sender, "&cYou are not in a group!") msg(sender, "&cYou are not in a group!")
@@ -75,8 +71,7 @@ def groupchat(sender, message, ann = False):
info("[ChatGroups] %s (%s): %s" % (sender.getDisplayName(), group, message)) info("[ChatGroups] %s (%s): %s" % (sender.getDisplayName(), group, message))
for receiver in server.getOnlinePlayers(): for receiver in server.getOnlinePlayers():
groups.get(uid(receiver)) == group and msg(receiver, mesg) groups.get(uid(receiver)) == group and msg(receiver, mesg)
#except Exception, e:
# error(e)
def save_groups(): def save_groups():

View File

@@ -12,7 +12,6 @@ def print_help(sender):
def scan_chunks(amount): def scan_chunks(amount):
try:
global lagchunks global lagchunks
chunks = [] chunks = []
for world in bukkit.Bukkit.getServer().getWorlds(): for world in bukkit.Bukkit.getServer().getWorlds():
@@ -23,8 +22,6 @@ def scan_chunks(amount):
chunks.append([chunk.getWorld(), int(ents[-1].getLocation().getX()), int(ents[0].getLocation().getY()), int(ents[0].getLocation().getZ()), len(ents)]) chunks.append([chunk.getWorld(), int(ents[-1].getLocation().getX()), int(ents[0].getLocation().getY()), int(ents[0].getLocation().getZ()), len(ents)])
chunks.sort(key = lambda entry: entry[4], reverse = True) chunks.sort(key = lambda entry: entry[4], reverse = True)
lagchunks = chunks lagchunks = chunks
except Exception, e:
error(e)
def list_chunks(sender): def list_chunks(sender):
@@ -41,7 +38,6 @@ def tp_chunk(sender, id):
@hook.command("lagchunks") @hook.command("lagchunks")
def on_lagchunks_command(sender, args): def on_lagchunks_command(sender, args):
try:
if sender.hasPermission("utils.lagchunks"): if sender.hasPermission("utils.lagchunks"):
plugin_header(sender, "Lagchunks") plugin_header(sender, "Lagchunks")
global lagchunks global lagchunks
@@ -62,5 +58,3 @@ def on_lagchunks_command(sender, args):
else: else:
noperm(sender) noperm(sender)
return True return True
except Exception, e:
error(e)

View File

@@ -11,7 +11,6 @@ colors_reg = reg_compile(u"\u00A7[\\da-fk-or]")
@hook.event("player.AsyncPlayerChatEvent", "high") @hook.event("player.AsyncPlayerChatEvent", "high")
def onChat(event): def onChat(event):
try:
if not event.isCancelled(): if not event.isCancelled():
sender = event.getPlayer() sender = event.getPlayer()
words = event.getMessage().split(" ") words = event.getMessage().split(" ")
@@ -46,14 +45,10 @@ def onChat(event):
message = " ".join([sender.getDisplayName(), arrow] + rec_words) message = " ".join([sender.getDisplayName(), arrow] + rec_words)
msg(recipient, message, usecolor = False) msg(recipient, message, usecolor = False)
recipient.playSound(recipient.getLocation(), "liquid.lavapop", 1, 2) recipient.playSound(recipient.getLocation(), "liquid.lavapop", 1, 2)
except:
error("Failed to handle PlayerChatEvent:")
error(print_traceback())
@hook.command("listen") @hook.command("listen")
def onListenCommand(sender, args): def onListenCommand(sender, args):
try:
currWords = [] currWords = []
if str(sender.getUniqueId()) in mentions.keys(): if str(sender.getUniqueId()) in mentions.keys():
currWords = mentions[str(sender.getUniqueId())] currWords = mentions[str(sender.getUniqueId())]
@@ -104,8 +99,6 @@ def onListenCommand(sender, args):
msg(sender, "&6/listen add <word>") msg(sender, "&6/listen add <word>")
msg(sender, "&6/listen del <word>") msg(sender, "&6/listen del <word>")
msg(sender, "&6/listen list") msg(sender, "&6/listen list")
except Exception, e:
error(e)
def saveMentions(): def saveMentions():