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
This commit is contained in:
Dico200
2015-04-29 03:27:37 +02:00
parent 1cac4c6ed5
commit c451b2247b
2 changed files with 120 additions and 0 deletions

118
blockplacemods.py Normal file
View File

@@ -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

View File

@@ -38,6 +38,8 @@ shared["load_modules"] = [
"adminchat",
# Adds /badge, allows to give players achievements
"badges",
# Adds a few block placement corrections/mods
"blockplacemods",
# Adds /calc, toggles automatic solving of Math expressions in chat
"calc",
# Plugin to locate laggy chunks. /lc <n> lists chunks with more than n entities