diff options
author | Dico200 <dico.karssiens@gmail.com> | 2015-05-14 02:46:54 +0200 |
---|---|---|
committer | Dico200 <dico.karssiens@gmail.com> | 2015-05-14 02:46:54 +0200 |
commit | 6fc168eb635c5a19d200359c282af1d204865a14 (patch) | |
tree | c5ab732040c5ea28588a2c3595587921b7866c58 /blockplacemods.py | |
parent | 83eb3a8885a2a1477b46f29a0034f824b59f534f (diff) |
Fixes, tweaks, changes
Diffstat (limited to 'blockplacemods.py')
-rw-r--r-- | blockplacemods.py | 98 |
1 files changed, 48 insertions, 50 deletions
diff --git a/blockplacemods.py b/blockplacemods.py index c167aca..39893d9 100644 --- a/blockplacemods.py +++ b/blockplacemods.py @@ -16,7 +16,7 @@ settingInformation = { ], "furnace": [1, "automatically filling furnaces upon placement", - "Sets your preferred default furnace contents to your currently held itemstack. Use an empty hand to disable this feature." + "Sets your preferred default furnace contents to your currently held itemstack. Use an empty hand to disable this feature. The command is &o/toggle furnace" ] } @@ -45,7 +45,7 @@ def saveSettings(): @simplecommand("toggle", aliases = ["set"], usage = "<setting> [value|info]", - description = "Toggles or sets your preferences for our redstone utilities.\nThe following settings are available:\n" + ", ".join([x for x in settingInformation]), + description = "Toggles or sets your preferences for our redstone \nutilities. The following settings are available:\n" + ", ".join([x for x in settingInformation]), senderLimit = 0, helpNoargs = True, helpSubcmd = True, @@ -54,7 +54,7 @@ def toggle_command(sender, command, label, args): setting = args[0].lower() info = settingInformation.get(setting) if info == None: - return "&cThat setting could not be found. For command help, use &o/toggle" + return " &cThat setting could not be found.\n For command help, use &o/toggle &cor &o/set" values = get(setting) player = server.getPlayer(sender.getName()) @@ -77,28 +77,30 @@ def toggle_command(sender, command, label, args): elif arg2 in ("off", "disable"): new = False else: - return "&cArgument '%s' was not recognized. \nTry one of the following: &oon, off, toggle" % arg2 + return " &cArgument '%s' was not recognized. \nTry one of the following: &oon, off, toggle" % arg2 if enabled == new: - return "&cAlready %s: &a%s" % ("enabled" if enabled else "disabled", info[1]) + return " &cAlready %s: &a%s" % ("enabled" if enabled else "disabled", info[1]) if new: values.remove(uuid) else: values.append(uuid) saveSettings() - return ("&aEnabled " if new else "&aDisabled ") + info[1] + return (" &aEnabled " if new else " &aDisabled ") + info[1] elif info[0] == 1: # Save ItemStack in hand if arglen == 1: item = fromStack(player.getItemInHand()) if 0 in (item[0], item[1]): - del values[uuid] - return "&aDisabled " + info[1] + if uuid in values: + del values[uuid] + return " &aDisabled " + info[1] values[uuid] = item saveSettings() - return "&aEnabled %s, with currently held itemstack" % info[1] - if args[1].lower() == "info": - return "&aSetting %s:\n&9%s" % (setting, info[2]) - return "&cArgument '%s' was not recognized. \nUse /toggle %s info for more information." % setting + return " &aEnabled %s, with currently held itemstack" % info[1] + arg2 = args[1].lower() + if arg2 == "info": + return " &aSetting %s:\n &9%s" % (setting, info[2]) + return " &cArgument '%s' was not recognized. \nUse /toggle %s info for more information." % (arg2, setting) return None #This shouldn't happen @@ -115,46 +117,42 @@ def isEnabled(toggleSetting, uuid): @hook.event("block.BlockPlaceEvent", "monitor") def on_block_place(event): - try: - if event.isCancelled(): - return - player = event.getPlayer() - if not is_creative(player): - return + if event.isCancelled(): + return + player = event.getPlayer() + if not is_creative(player): + return - uuid = uid(player) - block = event.getBlockPlaced() - material = str(block.getType()) - if isEnabled("slab", uuid) and material in ("WOOD_STEP", "STEP") and block.getData() < 8: - block.setData(block.getData() + 8) # Flip upside down - elif isEnabled("cauldron", uuid) and material == "CAULDRON": - block.setData(3) #3 layers of water, 3 signal strength - elif material == "FURNACE": - stack = get("furnace").get(uuid) - if stack == None: - return - state = block.getState() - state.getInventory().setSmelting(toStack(stack)) - state.update() - except: - error(trace()) + uuid = uid(player) + block = event.getBlockPlaced() + material = str(block.getType()) + + if isEnabled("slab", uuid) and material in ("WOOD_STEP", "STEP") and block.getData() < 8: + block.setData(block.getData() + 8) # Flip upside down + + elif isEnabled("cauldron", uuid) and material == "CAULDRON": + block.setData(3) #3 layers of water, 3 signal strength + + elif material == "FURNACE": + stack = get("furnace").get(uuid) + if stack == None: + return + state = block.getState() + state.getInventory().setSmelting(toStack(stack)) + state.update() @hook.event("player.PlayerInteractEvent", "monitor") def on_interact(event): - try: - player = event.getPlayer() - if (isEnabled("cauldron", uid(player)) - and is_creative(player) - and str(event.getAction()) == "RIGHT_CLICK_BLOCK" - and (not event.hasItem() or str(event.getItem().getType()) == "REDSTONE") - and str(event.getClickedBlock().getType()) == "CAULDRON" - ): - block = event.getClickedBlock() - event2 = BlockBreakEvent(block, player) - server.getPluginManager().callEvent(event2) - if not event2.isCancelled(): - block.setData(block.getData() - 1 if block.getData() > 0 else 3) - except: - error(trace()) - + player = event.getPlayer() + if (isEnabled("cauldron", uid(player)) + and is_creative(player) + and str(event.getAction()) == "RIGHT_CLICK_BLOCK" + and (not event.hasItem() or str(event.getItem().getType()) == "REDSTONE") + and str(event.getClickedBlock().getType()) == "CAULDRON" + ): + block = event.getClickedBlock() + event2 = BlockBreakEvent(block, player) + server.getPluginManager().callEvent(event2) + if not event2.isCancelled(): + block.setData(block.getData() - 1 if block.getData() > 0 else 3) |