diff options
author | Dico200 <dico.karssiens@gmail.com> | 2015-04-29 03:27:37 +0200 |
---|---|---|
committer | Dico200 <dico.karssiens@gmail.com> | 2015-04-29 03:27:37 +0200 |
commit | c451b2247b9f5446ef060dab7e22f5f8223c1211 (patch) | |
tree | e551692211da206176777e20de41f0fca2d991e0 /blockplacemods.py | |
parent | 1cac4c6ed5911371595c699f4a626e7ef16c1c50 (diff) |
Added blockplacemods module
Adds a few nifty features with per player customization:
- Placing a slab automatically turns it upside-down
- Placing a cauldron automatically fills it
- Right clicking a cauldron with empty hand or redstone dust lowers
water level
Diffstat (limited to 'blockplacemods.py')
-rw-r--r-- | blockplacemods.py | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/blockplacemods.py b/blockplacemods.py new file mode 100644 index 0000000..6258a13 --- /dev/null +++ b/blockplacemods.py @@ -0,0 +1,118 @@ +from helpers import * +from basecommands import simplecommand + +denyslabcorrection = open_json_file("denyslabcorrection", []) #Players that don't want slabs corrected +denyautofill = open_json_file("denyautocauldronfill", []) +denyautolevel = open_json_file("denyautocauldronlevel", []) + +def saveslabs(): + save_json_file("denyslabcorrection", denyslabcorrection) +def savecauldrons(): + save_json_file("denyautocauldronfill", denyautofill) +def savelevels(): + save_json_file("denyautocauldronlevel", denyautolevel) + +@simplecommand("autofillcauldron", + aliases = ["fillcauldronautomatically"], + usage = "on/off", + helpNoargs = True, + description = "Sets whether you want placed cauldrons to fill \nautomatically", + amax = 1, + senderLimit = 0) +def autofillcauldron_command(sender, command, label, args): + uuid = uid(server.getPlayer(sender.getName())) + if args[0].lower() == "off": + if uuid in denyautofill: + return "&cAuto fillment of cauldrons is already disabled" + denyautofill.append(uuid) + savecauldrons() + return "&aFilling cauldrons will no longer happen automatically" + if args[0].lower() == "on": + if uuid not in denyautofill: + return "&cAuto fillment of cauldrons is already enabled" + denyautofill.remove(uuid) + savecauldrons() + return "&aFilling cauldrons will happen automatically from now" + return "HELP" + + +@simplecommand("autoflipslab", + aliases = ["autoflipstep", "flipslabautomatically", "flipstepautomatically"], + usage = "on/off", + helpNoargs = True, + description = "Sets whether you want placed slabs to be turned \nupside-down", + amax = 1, + senderLimit = 0) +def autoflipslab_command(sender, command, label, args): + uuid = uid(server.getPlayer(sender.getName())) + if args[0].lower() == "off": + if uuid in denyslabcorrection: + return "&cAuto flipping of slabs is already disabled" + denyslabcorrection.append(uuid) + saveslabs() + return "&aFlipping slabs will no longer happen automatically" + if args[0].lower() == "on": + if uuid not in denyslabcorrection: + return "&cAuto flipping of slabs is already enabled" + denyslabcorrection.remove(uuid) + saveslabs() + return "&aFlipping slabs will happen automatically from now" + return "HELP" + + +@simplecommand("autotakewater", + aliases = ["autocauldronlevel"], + usage = "on/off", + helpNoargs = True, + description = "Sets whether you want right clicking cauldrons \nwith empty hand or redstone dust \nto lower water level", + amax = 1, + senderLimit = 0) +def autoflipslab_command(sender, command, label, args): + uuid = uid(server.getPlayer(sender.getName())) + if args[0].lower() == "off": + if uuid in denyautolevel: + return "&cTaking water with hand/redstone is already disabled" + denyautolevel.append(uuid) + savelevels() + return "&aYou can no longer take water with hand/redstone" + if args[0].lower() == "on": + if uuid not in denyautolevel: + return "&cTaking water with hand/redstone is already enabled" + denyautolevel.remove(uuid) + savelevels() + return "&aYou can take water with hand/redstone from now" + return "HELP" + + +@hook.event("block.BlockPlaceEvent", "monitor") +def on_block_place(event): + if event.isCancelled(): + return + player = event.getPlayer() + if player.getWorld().getName() not in ("Creative", "Trusted", "world"): + return + uuid = uid(player) + block = event.getBlockPlaced() + if uuid not in denyslabcorrection and str(block.getType()) in ("WOOD_STEP", "STEP") and block.getData() < 8: + block.setData(block.getData() + 8) # Flip upside down + elif uuid not in denyautofill and str(block.getType()) == "CAULDRON": + block.setData(3) #3 layers of water, 3 signal strength + + +@hook.event("player.PlayerInteractEvent", "monitor") +def on_interact(event): + player = event.getPlayer() + if uid(player) in denyautolevel or player.getWorld().getName() not in ("Creative", "Trusted", "world"): + return + if str(event.getAction()) != "RIGHT_CLICK_BLOCK": + return + if event.hasItem() and not str(event.getItem().getType()) == "REDSTONE": + return + block = event.getClickedBlock() + if str(block.getType()) == "CAULDRON" and block.getData() > 0: + block.setData(block.getData() - 1) #Lower water level by one + + + + + |