diff options
author | jomo <github@jomo.tv> | 2014-07-14 05:20:30 +0200 |
---|---|---|
committer | jomo <github@jomo.tv> | 2014-07-14 05:20:30 +0200 |
commit | a33e9ef88f3ae33a6402b5b19f4c637ec53ce9b1 (patch) | |
tree | 15c7d2feda04d6c4483322c217864005c6b134de /damnspam.py | |
parent | 60c5bb9672d458305bcd2c8a5222fc019711f62c (diff) |
don't accept 0 args, remove try
Diffstat (limited to 'damnspam.py')
-rw-r--r-- | damnspam.py | 89 |
1 files changed, 43 insertions, 46 deletions
diff --git a/damnspam.py b/damnspam.py index 46c9a44..e617317 100644 --- a/damnspam.py +++ b/damnspam.py @@ -40,59 +40,56 @@ def add_input(creator, block, timeout_off, timeout_on): def onDammnspamCommand(sender, args): global inputs - try: - plugHeader(sender, "DamnSpam") - if len(args) <= 2: + plugHeader(sender, "DamnSpam") + if len(args) in range(2): - if not str(sender.getGameMode()) == "CREATIVE": - msg(sender, "&cYou can only do this in Creative mode.") - return True + if not str(sender.getGameMode()) == "CREATIVE": + msg(sender, "&cYou can only do this in Creative mode.") + return True - # /damnspam <secs> - if len(args) == 1: - timeout_on = args[0] - if not timeout_on.isdigit(): - msg(sender, "&cThe timeout must be a digit.") - return True - else: - timeout_on = int(timeout_on) - timeout_off = timeout_on - if not 0 <= timeout_on <= 60: - msg(sender, "&cThe timeout must be within 0-60.") - return True - - # /damnspam <off> <on> - elif len(args) == 2: - timeout_on = args[0] - timeout_off = args[1] - if not timeout_on.isdigit() or not timeout_off.isdigit(): - msg(sender, "&cThe timeout must be a digit.") + # /damnspam <secs> + if len(args) == 1: + timeout_on = args[0] + if not timeout_on.isdigit(): + msg(sender, "&cThe timeout must be a digit.") + return True + else: + timeout_on = int(timeout_on) + timeout_off = timeout_on + if not 0 <= timeout_on <= 60: + msg(sender, "&cThe timeout must be within 0-60.") return True - else: - timeout_on = int(timeout_on) - timeout_off = int(timeout_off) - if not 0 <= timeout_on <= 60 or not 0 <= timeout_off <= 60: - msg(sender, "&cThe timeout must be within 0-60.") - return True - - # get the block we're looking at - target = sender.getTargetBlock(None, 10) - ttype = str(target.getType()) - if ttype not in accepted_inputs: - msg(sender, "&cPlease look at a button or lever while executing this command!") + + # /damnspam <off> <on> + elif len(args) == 2: + timeout_on = args[0] + timeout_off = args[1] + if not timeout_on.isdigit() or not timeout_off.isdigit(): + msg(sender, "&cThe timeout must be a digit.") return True + else: + timeout_on = int(timeout_on) + timeout_off = int(timeout_off) + if not 0 <= timeout_on <= 60 or not 0 <= timeout_off <= 60: + msg(sender, "&cThe timeout must be within 0-60.") + return True - # add block to inputs - add_input(sender, target, timeout_off, timeout_on) - saveInputs() - msg(sender, "&aSuccessfully set a timeout for this %s." % ttype.lower()) + # get the block we're looking at + target = sender.getTargetBlock(None, 10) + ttype = str(target.getType()) + if ttype not in accepted_inputs: + msg(sender, "&cPlease look at a button or lever while executing this command!") return True - else: - msg(sender, "&c/damnspam <seconds> &e(Buttons/Levers)") - msg(sender, "&c/damnspam <seconds after off> <seconds after on> &e(Levers only)") - except Exception, e: - error(e) + # add block to inputs + add_input(sender, target, timeout_off, timeout_on) + saveInputs() + msg(sender, "&aSuccessfully set a timeout for this %s." % ttype.lower()) + return True + + else: + msg(sender, "&c/damnspam <seconds> &e(Buttons/Levers)") + msg(sender, "&c/damnspam <seconds after off> <seconds after on> &e(Levers only)") @hook.event("block.BlockBreakEvent", "normal") |