Dev #29

Closed
Evanus wants to merge 13 commits from dev into dev
Showing only changes of commit 28f8340ef0 - Show all commits

118
bpm.py
View File

@ -6,89 +6,85 @@ import org.bukkit.Material as Material
remake of dicodes blockplacemods remake of dicodes blockplacemods
""" """
slab_toggle_list = [] slabToggle = []
cauldron_toggle_list = [] cauldronToggle = []
inventory_toggle_list = [] inventoryToggle = []
sides = {
BlockSide.DOWN : 0,
BlockSide.UP : 1,
BlockSide.NORTH : 2,
BlockSide.SOUTH : 3,
BlockSide.WEST : 4,
BlockSide.EAST : 5
}
blocks = {Material.DROPPER, Material.HOPPER, Material.FURNACE, Material.DISPENSER} blocks = {Material.DROPPER, Material.HOPPER, Material.FURNACE, Material.DISPENSER}
info = "please use: &9Slab&3, &9Inventory&3, &9Cauldron &3or &9Help&3."
tog_perm = "utils.toggle" togPerm = "utils.toggle"
@hook.event("block.BlockPlaceEvent", "monitor") @hook.event("block.BlockPlaceEvent", "monitor")
def on_block_place(event): def blockPlace(event):
block = event.getBlockPlaced()
material = block.getType() material = block.getType()
user = server.getPlayer().getName() n = event.getPlayer().getName()
if (material in (Material.WOOD_STEP, Material.STEP)) and user in slab_toggle_list:
if (material in (Material.WOOD_STEP, Material.STEP)) and n in slabToggle:
block.setData(block.getData() + 8) block.setData(block.getData() + 8)
elif (material == Material.CAULDRON) and user in cauldron_toggle_list:
elif (material == Material.CAULDRON) and n in cauldronToggle:
block.setData(block.getData() + 3) block.setData(block.getData() + 3)
elif (material in blocks) and user in inventory_toggle_list:
elif (material in blocks) and n in inventoryToggle:
inv = user.getInventory().getItemInHand() inv = user.getInventory().getItemInHand()
state = block.getState() state = block.getState()
block_inv = state.getInventory() blockInv = state.getInventory()
block_inv.setItem(int(slot), toStack(inv)) blockInv.setItem(int(slot), toStack(inv))
def help():
""" msg(sender, "&a-=[&6BPM&a]=-")
Idk if this is needed, but meh. makes it look cleaner msg(sender, "&6Aliases for /toggle: \n &e/set, /setting and /config\n")
""" msg(sender, "&6Available settings: \n &eSlab, Cauldron and Inventory\n")
msg(sender, "&6Slab: \n&eThe slab setting flips slabs to the top half \nof the block on placing them.\n")
# block handelling msg(sender, "&6Cauldron: \n&eThe cauldron setting fills cauldrons on placing them.\n")
msg(sender, "&6Inventory: \n&eThe inventory setting puts a block in an item with an inventory.\n")
def slab(): @hook.command("toggle")
user = server.getPlayer().getName() def toggleCommand(sender, cmd, label, args):
if user in slab_toggle_list: name = sender.getName()
try:
if sender.hasPermission(togPerm) and sender.getWorld().getName() == "creative":
if len(args) > 0:
if str(args[0]) == "slab":
if name in slabToggle:
msg(sender, "&a Disabled automatically flipping slabs.") msg(sender, "&a Disabled automatically flipping slabs.")
slab_toggle_list.remove(name) slabToggle.remove(name)
else: else:
msg(sender, "&a Enabled automatically flipping slabs.") msg(sender, "&a Enabled automatically flipping slabs.")
slab_toggle_list.remove(name) slabToggle.append(name)
def cauldron(): elif str(args[0]) == "cauldron":
user = server.getPlayer().getName() if name in cauldronToggle:
if user in cauldron_toggle_list:
msg(sender, "&a Disabled automatically filling cauldrons.") msg(sender, "&a Disabled automatically filling cauldrons.")
cauldron_toggle_list.remove(name) cauldronToggle.remove(name)
else: else:
msg(sender, "&a Enabled automatically filling cauldrons.") msg(sender, "&a Enabled automatically filling cauldrons.")
cauldron_toggle_list.remove(name) cauldronToggle.append(name)
def inventory(): elif str(args[0]) == "inv" or "inventory":
user = server.getPlayer().getName() if name in cauldronToggle:
if user in inventory_toggle_list: msg(sender, "&a Disabled automatically putting items in inventories.")
msg(sender, "&a disabled automatically putting items in inventories.") cauldronToggle.remove(name)
inventory_toggle_list.remove(name)
else: else:
msg(sender, "&a Enabled automatically putting items in inventories.") msg(sender, "&a Enabled automatically putting items in inventories.")
inventory_toggle_list.remove(name) cauldronToggle.append(name)
# Command handelling elif str(args[0]) == "help" or "?" or "wut":
help()
elif len(args) > 1:
msg(sender,"&aToo many arguments, \n&3&s") % info
@hook.command("toggle")
def toggle_command(sender, args):
name = sender.getName()
if sender.hasPermission(togPerm) and sender.getWorld(Creative):
if args[0] == "slab":
slab()
elif args[0] == "cauldron":
cauldron()
elif args[0] == "inv" or "inventory":
inventory()
else: else:
msg(sender, "&9Unknown argument \n &3please use: &9slab&3, &9inventory &3or &9cauldron&3.") msg(sender, "&9Unknown argument \n &3%s") % info
else:
help()
@hook.command("set")
def set_command(sender, args):
return toggle_command(sender, args)
@hook.command("setting") elif sender.getWorld() != "creative":
def set_command(sender, args): msg(sender, "&aBPM doesn't work in this world.")
return toggle_command(sender, args) print sender.getWorld().getName()
else:
msg(sender, "&aNo permission.")
except:
print trace()