Dev #29
@ -1,285 +1,64 @@
|
||||
from helpers import *
|
||||
from basecommands import simplecommand, Validate, CommandException
|
||||
from time import sleep
|
||||
from collections import deque
|
||||
import thread
|
||||
import org.bukkit.event.block.BlockBreakEvent as BlockBreakEvent
|
||||
import org.bukkit.block.Furnace as Furnace
|
||||
import org.bukkit.inventory.ItemStack as ItemStack
|
||||
import org.bukkit.Material as Material
|
||||
import org.bukkit.event.block.Action as Action
|
||||
import org.bukkit.block.BlockFace as BlockFace
|
||||
import org.bukkit.scheduler.BukkitRunnable as Runnable
|
||||
|
||||
settingInformation = dict( #[setting type, identifying description, detailed description, aliases, (optional) max slot id], setting types: 0 = toggle, default on. 1 = Set your setting to held itemstack, 2 = toggle, default off
|
||||
cauldron = [0,
|
||||
"easy cauldron water level control",
|
||||
"Toggles whether cauldrons auto-fill upon placement and whether right clicking them with redstone dust or empty hand will cycle their water level",
|
||||
["caul", "water"]
|
||||
],
|
||||
slab = [0,
|
||||
"automatically flipping placed slabs upside-down",
|
||||
"Toggles whether slabs/steps which you place should be automatically flipped upside-down",
|
||||
["step"]
|
||||
],
|
||||
furnace = [1,
|
||||
"automatically filling furnaces upon placement",
|
||||
"Sets your preferred default furnace contents to your currently held itemstack. Use an empty hand to empty a slot, or /toggle dropper clear to clear all slots.",
|
||||
["cooker", "fillf"], 2
|
||||
],
|
||||
#torch = [0,
|
||||
# "removal of torches you place on redstone blocks",
|
||||
# "Toggles whether redstone torches which you place on redstone blocks will be deleted after a short amount of delay.",
|
||||
# ["redstonetorch", "tor"]
|
||||
#],
|
||||
piston = [2,
|
||||
"rotating pistons, droppers and hoppers to face the block you place them against",
|
||||
"Toggles whether pistons or sticky pistons which you place will be rotated to face the block which you placed them against.",
|
||||
["invert", "rp"]
|
||||
],
|
||||
dropper = [1,
|
||||
"automatically filling droppers upon placement",
|
||||
"Sets your preferred default dropper contents to your currently held itemstack. Use an empty hand to empty a slot, or /toggle dropper clear to clear all slots.",
|
||||
["itemshooter", "filld"], 8
|
||||
],
|
||||
hopper = [1,
|
||||
"automatically filling hoppers upon placement",
|
||||
"Sets your preferred default hopper contents to your currently held itemstack. Use an empty hand to empty a slot, or /toggle dropper clear to clear all slots.",
|
||||
["itemtransporter", "fillh"], 4
|
||||
]
|
||||
)
|
||||
tog_perm = "utils.toggle"
|
||||
|
||||
defaults = {
|
||||
0: list,
|
||||
1: dict,
|
||||
2: list
|
||||
}
|
||||
@hook.event("block.BlockPlaceEvent", "low")
|
||||
def block_place(event):
|
||||
block = event.getBlockPlaced()
|
||||
material = block.getType()
|
||||
sender = event.getPlayer()
|
||||
py_player = get_py_player(sender)
|
||||
if (material in (Material.WOOD_STEP, Material.STEP)) and py_player.slab_toggle and block.getData() < 8:
|
||||
block.setData(block.getData() + 8)
|
||||
elif (material == Material.CAULDRON) and py_player.cauldron_toggle:
|
||||
block.setData(block.getData() + 3)
|
||||
|
||||
faces = {
|
||||
BlockFace.DOWN : 0,
|
||||
BlockFace.UP : 1,
|
||||
BlockFace.NORTH : 2,
|
||||
BlockFace.SOUTH : 3,
|
||||
BlockFace.WEST : 4,
|
||||
BlockFace.EAST : 5
|
||||
}
|
||||
|
||||
playerSettings = open_json_file("blockplacemods", {})
|
||||
|
||||
for setting, details in settingInformation.iteritems():
|
||||
if playerSettings.get(setting) == None:
|
||||
playerSettings[setting] = defaults[details[0]]()
|
||||
|
||||
def get(setting):
|
||||
return playerSettings[setting]
|
||||
|
||||
def saveSettings():
|
||||
save_json_file("blockplacemods", playerSettings)
|
||||
|
||||
def getSettingDetails(arg):
|
||||
try:
|
||||
arg = arg.lower()
|
||||
for setting, details in settingInformation.iteritems():
|
||||
if setting == arg or arg in details[3]:
|
||||
return (setting, details)
|
||||
except:
|
||||
error(trace())
|
||||
raise CommandException(" &cThat setting could not be found.\n For command help, use &o/toggle &cor &o/set")
|
||||
|
||||
@simplecommand("toggle",
|
||||
aliases = ["setting", "set", "config"],
|
||||
usage = "<setting> [value|info]",
|
||||
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,
|
||||
amax = 2)
|
||||
def toggle_command(sender, command, label, args):
|
||||
setting, details = getSettingDetails(args[0])
|
||||
Validate.isAuthorized(sender, "utils.toggle." + setting, "that setting")
|
||||
|
||||
values = get(setting)
|
||||
player = server.getPlayer(sender.getName())
|
||||
uuid = uid(player)
|
||||
arglen = len(args)
|
||||
|
||||
if details[0] in (0,2): # Toggle
|
||||
default = details[0] == 0 # If True: toggle on if list doesn't contain the uuid
|
||||
|
||||
enabled = (uuid not in values) == default #Invert if details[0] == 2 (toggle disabled by default)
|
||||
new = None
|
||||
if arglen == 1:
|
||||
new = not enabled
|
||||
else:
|
||||
arg2 = args[1].lower()
|
||||
if arg2 == "info":
|
||||
return " &aSetting %s:\n &9%s\n &6Accepted arguments: [on|enable|off|disable|toggle|switch|info]\n &6Aliases: %s" % (setting, details[2], ", ".join(details[3]))
|
||||
elif arg2 in ("toggle", "switch"):
|
||||
new = not enabled
|
||||
elif arg2 in ("on", "enable"):
|
||||
new = not default
|
||||
elif arg2 in ("off", "disable"):
|
||||
new = default
|
||||
else:
|
||||
return " &cArgument '%s' was not recognized. \n Use &o/toggle %s info &cfor more information" % (arg2, setting)
|
||||
if enabled == new:
|
||||
return " &cAlready %s: &a%s" % ("enabled" if enabled else "disabled", details[1])
|
||||
if new == default:
|
||||
values.remove(uuid)
|
||||
else:
|
||||
values.append(uuid)
|
||||
saveSettings()
|
||||
return (" &aEnabled " if new else " &aDisabled ") + details[1]
|
||||
|
||||
|
||||
elif details[0] == 1: # Save ItemStack in hand
|
||||
arg2 = args[1].lower() if arglen > 1 else ""
|
||||
enabled = uuid in values
|
||||
|
||||
if arg2 == "clear":
|
||||
if enabled:
|
||||
del values[uuid]
|
||||
return " &aDisabled " + details[1]
|
||||
|
||||
if arg2 == "details":
|
||||
return " &aSetting %s:\n &9%s \n&6Accepted arguments: [<slot>|clear|details]" % (setting, details[2])
|
||||
|
||||
slot = int(arg2) if arg2.isdigit() else 0
|
||||
if not (0 <= slot <= details[4]):
|
||||
return " &cSlot number must be more than or equal to 0 and less than or equal to %s!" % details[4]
|
||||
|
||||
item = fromStack(player.getItemInHand())
|
||||
if item[0] == 0 or item[1] <= 0:
|
||||
if enabled:
|
||||
items = values[uuid]
|
||||
if slot in items:
|
||||
del items[slot]
|
||||
saveSettings()
|
||||
if len(items) == 0:
|
||||
del items
|
||||
return " &aDisabled " + details[1]
|
||||
return " &aCleared slot %s of setting %s" % (slot, setting)
|
||||
return " &cSlot %s of setting %s was already cleared!" % (slot, setting)
|
||||
return " &cAlready disabled: " + details[1]
|
||||
|
||||
if arglen == 2 and not arg2.isdigit():
|
||||
return " &cArgument '%s' was not recognized. \nUse &o/toggle %s details &cfor more detailsrmation." % (arg2, setting)
|
||||
|
||||
if not enabled:
|
||||
values[uuid] = {}
|
||||
values[uuid][slot] = item
|
||||
saveSettings()
|
||||
return ((" &aEnabled setting %s, S" % setting) if len(values[uuid]) == 1 else " &aS") + "et itemstack in slot %s to item in hand" % (slot)
|
||||
|
||||
return None #This shouldn't happen
|
||||
|
||||
|
||||
def fromStack(itemStack):
|
||||
return [itemStack.getTypeId(), itemStack.getAmount(), itemStack.getData().getData()]
|
||||
def toStack(lst):
|
||||
return ItemStack(lst[0], lst[1], lst[2])
|
||||
|
||||
def isEnabled(toggleSetting, uuid):
|
||||
return (uuid not in get(toggleSetting)) == (settingInformation[toggleSetting][0] == 0) #Invert if off by default
|
||||
|
||||
|
||||
|
||||
@hook.event("block.BlockPlaceEvent", "monitor")
|
||||
def on_block_place(event):
|
||||
if event.isCancelled():
|
||||
return
|
||||
player = event.getPlayer()
|
||||
if not is_creative(player):
|
||||
return
|
||||
|
||||
uuid = uid(player)
|
||||
block = event.getBlockPlaced()
|
||||
material = block.getType()
|
||||
|
||||
|
||||
if (material in (Material.WOOD_STEP, Material.STEP)
|
||||
and isEnabled("slab", uuid)
|
||||
and player.hasPermission("utils.toggle.slab")
|
||||
and block.getData() < 8
|
||||
):
|
||||
block.setData(block.getData() + 8) # Flip upside down
|
||||
|
||||
|
||||
elif (material == Material.CAULDRON
|
||||
and isEnabled("cauldron", uuid)
|
||||
and player.hasPermission("utils.toggle.cauldron")
|
||||
):
|
||||
block.setData(3) #3 layers of water, 3 signal strength
|
||||
|
||||
|
||||
elif ((material == Material.FURNACE and player.hasPermission("utils.toggle.furnace"))
|
||||
or (material == Material.DROPPER and player.hasPermission("utils.toggle.dropper"))
|
||||
or (material == Material.HOPPER and player.hasPermission("utils.toggle.hopper"))
|
||||
):
|
||||
stacks = get(str(material).lower()).get(uuid)
|
||||
if stacks != None: # Enabled
|
||||
state = block.getState()
|
||||
inv = state.getInventory()
|
||||
for slot, stack in stacks.iteritems():
|
||||
inv.setItem(int(slot), toStack(stack))
|
||||
state.update()
|
||||
|
||||
"""
|
||||
elif (material == Material.REDSTONE_TORCH_ON
|
||||
and event.getBlockAgainst().getType() == Material.REDSTONE_BLOCK
|
||||
and isEnabled("torch", uuid)
|
||||
and player.hasPermission("utils.toggle.torch")
|
||||
):
|
||||
torches_to_break.append(block)
|
||||
"""
|
||||
|
||||
|
||||
if (material in (Material.PISTON_BASE, Material.PISTON_STICKY_BASE)
|
||||
and isEnabled("piston", uuid)
|
||||
and player.hasPermission("utils.toggle.piston")
|
||||
):
|
||||
block.setData(faces[block.getFace(event.getBlockAgainst())])
|
||||
|
||||
|
||||
@hook.event("player.PlayerInteractEvent", "monitor")
|
||||
@hook.event("player.PlayerInteractEvent", "high")
|
||||
def on_interact(event):
|
||||
player = event.getPlayer()
|
||||
if (isEnabled("cauldron", uid(player))
|
||||
and player.hasPermission("utils.toggle.cauldron")
|
||||
and is_creative(player)
|
||||
and event.getAction() == Action.RIGHT_CLICK_BLOCK
|
||||
and (not event.hasItem() or event.getItem().getType() == Material.REDSTONE)
|
||||
and event.getClickedBlock().getType() == Material.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)
|
||||
block = event.getClickedBlock()
|
||||
sender = event.getPlayer()
|
||||
py_player = get_py_player(sender)
|
||||
if str(event.getAction()) != "RIGHT_CLICK_BLOCK":
|
||||
return
|
||||
if block.getType() == Material.CAULDRON and py_player.cauldron_toggle:
|
||||
block.setData(block.getData() - 1 if block.getData() > 0 else 3)
|
||||
else:
|
||||
return
|
||||
|
||||
"""
|
||||
break_torches = True
|
||||
torches_to_break = deque()
|
||||
def help(sender):
|
||||
msg(sender, "&a-=[&6BPM&a]=-")
|
||||
msg(sender, "&6Aliases for /toggle: \n &e/set, /setting and /config\n")
|
||||
msg(sender, "&6Available settings: \n &eSlab and Cauldron\n")
|
||||
msg(sender, "&6Slab: \n&eThe slab setting flips slabs to the top half \nof the block on placing them.\n")
|
||||
msg(sender, "&6Cauldron: \n&eThe cauldron setting fills cauldrons on placing them.\n")
|
||||
|
||||
def stop_breaking_torches():
|
||||
break_torches = False
|
||||
info("Interrupted torch breaking thread")
|
||||
@hook.command("toggle")
|
||||
def toggle_command(sender, cmd, label, args):
|
||||
py_player = get_py_player(sender)
|
||||
if sender.hasPermission(tog_perm) and sender.getWorld().getName() == "creative":
|
||||
if len(args) > 0:
|
||||
if str(args[0]) == "slab":
|
||||
if py_player.slab_toggle == True:
|
||||
msg(sender, "&a Disabled automatically flipping slabs.")
|
||||
py_player.slab_toggle = False
|
||||
else:
|
||||
msg(sender, "&a Enabled automatically flipping slabs.")
|
||||
py_player.slab_toggle = True
|
||||
elif str(args[0]) == "cauldron":
|
||||
if py_player.cauldron_toggle == True:
|
||||
msg(sender, "&a Disabled automatically filling cauldrons.")
|
||||
py_player.cauldron_toggle = False
|
||||
else:
|
||||
msg(sender, "&a Enabled automatically filling cauldrons.")
|
||||
py_player.cauldron_toggle = True
|
||||
else:
|
||||
help(sender)
|
||||
else:
|
||||
help(sender)
|
||||
elif sender.getWorld() != "creative":
|
||||
msg(sender, "&aBPM doesn't work in this world.")
|
||||
else:
|
||||
msg(sender, "&aNo permission.")
|
||||
|
||||
|
||||
class torch_breaker(Runnable):
|
||||
|
||||
def run():
|
||||
|
||||
try:
|
||||
if break_torches:
|
||||
for i in range(len(torches_to_break)):
|
||||
block = torches_to_break.popleft()
|
||||
mat = block.getType()
|
||||
if mat == Material.REDSTONE_TORCH_OFF:
|
||||
block.setTypeId(0)
|
||||
elif mat == Material.REDSTONE_TORCH_ON:
|
||||
torches_to_break.append(block)
|
||||
except:
|
||||
error(trace())
|
||||
"""
|
||||
|
||||
|
285
dicode bpm.py
Normal file
285
dicode bpm.py
Normal file
@ -0,0 +1,285 @@
|
||||
from helpers import *
|
||||
from basecommands import simplecommand, Validate, CommandException
|
||||
from time import sleep
|
||||
from collections import deque
|
||||
import thread
|
||||
import org.bukkit.event.block.BlockBreakEvent as BlockBreakEvent
|
||||
import org.bukkit.block.Furnace as Furnace
|
||||
import org.bukkit.inventory.ItemStack as ItemStack
|
||||
import org.bukkit.Material as Material
|
||||
import org.bukkit.event.block.Action as Action
|
||||
import org.bukkit.block.BlockFace as BlockFace
|
||||
import org.bukkit.scheduler.BukkitRunnable as Runnable
|
||||
|
||||
settingInformation = dict( #[setting type, identifying description, detailed description, aliases, (optional) max slot id], setting types: 0 = toggle, default on. 1 = Set your setting to held itemstack, 2 = toggle, default off
|
||||
cauldron = [0,
|
||||
"easy cauldron water level control",
|
||||
"Toggles whether cauldrons auto-fill upon placement and whether right clicking them with redstone dust or empty hand will cycle their water level",
|
||||
["caul", "water"]
|
||||
],
|
||||
slab = [0,
|
||||
"automatically flipping placed slabs upside-down",
|
||||
"Toggles whether slabs/steps which you place should be automatically flipped upside-down",
|
||||
["step"]
|
||||
],
|
||||
furnace = [1,
|
||||
"automatically filling furnaces upon placement",
|
||||
"Sets your preferred default furnace contents to your currently held itemstack. Use an empty hand to empty a slot, or /toggle dropper clear to clear all slots.",
|
||||
["cooker", "fillf"], 2
|
||||
],
|
||||
#torch = [0,
|
||||
# "removal of torches you place on redstone blocks",
|
||||
# "Toggles whether redstone torches which you place on redstone blocks will be deleted after a short amount of delay.",
|
||||
# ["redstonetorch", "tor"]
|
||||
#],
|
||||
piston = [2,
|
||||
"rotating pistons, droppers and hoppers to face the block you place them against",
|
||||
"Toggles whether pistons or sticky pistons which you place will be rotated to face the block which you placed them against.",
|
||||
["invert", "rp"]
|
||||
],
|
||||
dropper = [1,
|
||||
"automatically filling droppers upon placement",
|
||||
"Sets your preferred default dropper contents to your currently held itemstack. Use an empty hand to empty a slot, or /toggle dropper clear to clear all slots.",
|
||||
["itemshooter", "filld"], 8
|
||||
],
|
||||
hopper = [1,
|
||||
"automatically filling hoppers upon placement",
|
||||
"Sets your preferred default hopper contents to your currently held itemstack. Use an empty hand to empty a slot, or /toggle dropper clear to clear all slots.",
|
||||
["itemtransporter", "fillh"], 4
|
||||
]
|
||||
)
|
||||
|
||||
defaults = {
|
||||
0: list,
|
||||
1: dict,
|
||||
2: list
|
||||
}
|
||||
|
||||
faces = {
|
||||
BlockFace.DOWN : 0,
|
||||
BlockFace.UP : 1,
|
||||
BlockFace.NORTH : 2,
|
||||
BlockFace.SOUTH : 3,
|
||||
BlockFace.WEST : 4,
|
||||
BlockFace.EAST : 5
|
||||
}
|
||||
|
||||
playerSettings = open_json_file("blockplacemods", {})
|
||||
|
||||
for setting, details in settingInformation.iteritems():
|
||||
if playerSettings.get(setting) == None:
|
||||
playerSettings[setting] = defaults[details[0]]()
|
||||
|
||||
def get(setting):
|
||||
return playerSettings[setting]
|
||||
|
||||
def saveSettings():
|
||||
save_json_file("blockplacemods", playerSettings)
|
||||
|
||||
def getSettingDetails(arg):
|
||||
try:
|
||||
arg = arg.lower()
|
||||
for setting, details in settingInformation.iteritems():
|
||||
if setting == arg or arg in details[3]:
|
||||
return (setting, details)
|
||||
except:
|
||||
error(trace())
|
||||
raise CommandException(" &cThat setting could not be found.\n For command help, use &o/toggle &cor &o/set")
|
||||
|
||||
@simplecommand("toggle",
|
||||
aliases = ["setting", "set", "config"],
|
||||
usage = "<setting> [value|info]",
|
||||
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,
|
||||
amax = 2)
|
||||
def toggle_command(sender, command, label, args):
|
||||
setting, details = getSettingDetails(args[0])
|
||||
Validate.isAuthorized(sender, "utils.toggle." + setting, "that setting")
|
||||
|
||||
values = get(setting)
|
||||
player = server.getPlayer(sender.getName())
|
||||
uuid = uid(player)
|
||||
arglen = len(args)
|
||||
|
||||
if details[0] in (0,2): # Toggle
|
||||
default = details[0] == 0 # If True: toggle on if list doesn't contain the uuid
|
||||
|
||||
enabled = (uuid not in values) == default #Invert if details[0] == 2 (toggle disabled by default)
|
||||
new = None
|
||||
if arglen == 1:
|
||||
new = not enabled
|
||||
else:
|
||||
arg2 = args[1].lower()
|
||||
if arg2 == "info":
|
||||
return " &aSetting %s:\n &9%s\n &6Accepted arguments: [on|enable|off|disable|toggle|switch|info]\n &6Aliases: %s" % (setting, details[2], ", ".join(details[3]))
|
||||
elif arg2 in ("toggle", "switch"):
|
||||
new = not enabled
|
||||
elif arg2 in ("on", "enable"):
|
||||
new = not default
|
||||
elif arg2 in ("off", "disable"):
|
||||
new = default
|
||||
else:
|
||||
return " &cArgument '%s' was not recognized. \n Use &o/toggle %s info &cfor more information" % (arg2, setting)
|
||||
if enabled == new:
|
||||
return " &cAlready %s: &a%s" % ("enabled" if enabled else "disabled", details[1])
|
||||
if new == default:
|
||||
values.remove(uuid)
|
||||
else:
|
||||
values.append(uuid)
|
||||
saveSettings()
|
||||
return (" &aEnabled " if new else " &aDisabled ") + details[1]
|
||||
|
||||
|
||||
elif details[0] == 1: # Save ItemStack in hand
|
||||
arg2 = args[1].lower() if arglen > 1 else ""
|
||||
enabled = uuid in values
|
||||
|
||||
if arg2 == "clear":
|
||||
if enabled:
|
||||
del values[uuid]
|
||||
return " &aDisabled " + details[1]
|
||||
|
||||
if arg2 == "details":
|
||||
return " &aSetting %s:\n &9%s \n&6Accepted arguments: [<slot>|clear|details]" % (setting, details[2])
|
||||
|
||||
slot = int(arg2) if arg2.isdigit() else 0
|
||||
if not (0 <= slot <= details[4]):
|
||||
return " &cSlot number must be more than or equal to 0 and less than or equal to %s!" % details[4]
|
||||
|
||||
item = fromStack(player.getItemInHand())
|
||||
if item[0] == 0 or item[1] <= 0:
|
||||
if enabled:
|
||||
items = values[uuid]
|
||||
if slot in items:
|
||||
del items[slot]
|
||||
saveSettings()
|
||||
if len(items) == 0:
|
||||
del items
|
||||
return " &aDisabled " + details[1]
|
||||
return " &aCleared slot %s of setting %s" % (slot, setting)
|
||||
return " &cSlot %s of setting %s was already cleared!" % (slot, setting)
|
||||
return " &cAlready disabled: " + details[1]
|
||||
|
||||
if arglen == 2 and not arg2.isdigit():
|
||||
return " &cArgument '%s' was not recognized. \nUse &o/toggle %s details &cfor more detailsrmation." % (arg2, setting)
|
||||
|
||||
if not enabled:
|
||||
values[uuid] = {}
|
||||
values[uuid][slot] = item
|
||||
saveSettings()
|
||||
return ((" &aEnabled setting %s, S" % setting) if len(values[uuid]) == 1 else " &aS") + "et itemstack in slot %s to item in hand" % (slot)
|
||||
|
||||
return None #This shouldn't happen
|
||||
|
||||
|
||||
def fromStack(itemStack):
|
||||
return [itemStack.getTypeId(), itemStack.getAmount(), itemStack.getData().getData()]
|
||||
def toStack(lst):
|
||||
return ItemStack(lst[0], lst[1], lst[2])
|
||||
|
||||
def isEnabled(toggleSetting, uuid):
|
||||
return (uuid not in get(toggleSetting)) == (settingInformation[toggleSetting][0] == 0) #Invert if off by default
|
||||
|
||||
|
||||
|
||||
@hook.event("block.BlockPlaceEvent", "monitor")
|
||||
def on_block_place(event):
|
||||
if event.isCancelled():
|
||||
return
|
||||
player = event.getPlayer()
|
||||
if not is_creative(player):
|
||||
return
|
||||
|
||||
uuid = uid(player)
|
||||
block = event.getBlockPlaced()
|
||||
material = block.getType()
|
||||
|
||||
|
||||
if (material in (Material.WOOD_STEP, Material.STEP)
|
||||
and isEnabled("slab", uuid)
|
||||
and player.hasPermission("utils.toggle.slab")
|
||||
and block.getData() < 8
|
||||
):
|
||||
block.setData(block.getData() + 8) # Flip upside down
|
||||
|
||||
|
||||
elif (material == Material.CAULDRON
|
||||
and isEnabled("cauldron", uuid)
|
||||
and player.hasPermission("utils.toggle.cauldron")
|
||||
):
|
||||
block.setData(3) #3 layers of water, 3 signal strength
|
||||
|
||||
|
||||
elif ((material == Material.FURNACE and player.hasPermission("utils.toggle.furnace"))
|
||||
or (material == Material.DROPPER and player.hasPermission("utils.toggle.dropper"))
|
||||
or (material == Material.HOPPER and player.hasPermission("utils.toggle.hopper"))
|
||||
):
|
||||
stacks = get(str(material).lower()).get(uuid)
|
||||
if stacks != None: # Enabled
|
||||
state = block.getState()
|
||||
inv = state.getInventory()
|
||||
for slot, stack in stacks.iteritems():
|
||||
inv.setItem(int(slot), toStack(stack))
|
||||
state.update()
|
||||
|
||||
"""
|
||||
elif (material == Material.REDSTONE_TORCH_ON
|
||||
and event.getBlockAgainst().getType() == Material.REDSTONE_BLOCK
|
||||
and isEnabled("torch", uuid)
|
||||
and player.hasPermission("utils.toggle.torch")
|
||||
):
|
||||
torches_to_break.append(block)
|
||||
"""
|
||||
|
||||
|
||||
if (material in (Material.PISTON_BASE, Material.PISTON_STICKY_BASE)
|
||||
and isEnabled("piston", uuid)
|
||||
and player.hasPermission("utils.toggle.piston")
|
||||
):
|
||||
block.setData(faces[block.getFace(event.getBlockAgainst())])
|
||||
|
||||
|
||||
@hook.event("player.PlayerInteractEvent", "monitor")
|
||||
def on_interact(event):
|
||||
player = event.getPlayer()
|
||||
if (isEnabled("cauldron", uid(player))
|
||||
and player.hasPermission("utils.toggle.cauldron")
|
||||
and is_creative(player)
|
||||
and event.getAction() == Action.RIGHT_CLICK_BLOCK
|
||||
and (not event.hasItem() or event.getItem().getType() == Material.REDSTONE)
|
||||
and event.getClickedBlock().getType() == Material.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)
|
||||
|
||||
"""
|
||||
break_torches = True
|
||||
torches_to_break = deque()
|
||||
|
||||
def stop_breaking_torches():
|
||||
break_torches = False
|
||||
info("Interrupted torch breaking thread")
|
||||
|
||||
|
||||
class torch_breaker(Runnable):
|
||||
|
||||
def run():
|
||||
|
||||
try:
|
||||
if break_torches:
|
||||
for i in range(len(torches_to_break)):
|
||||
block = torches_to_break.popleft()
|
||||
mat = block.getType()
|
||||
if mat == Material.REDSTONE_TORCH_OFF:
|
||||
block.setTypeId(0)
|
||||
elif mat == Material.REDSTONE_TORCH_ON:
|
||||
torches_to_break.append(block)
|
||||
except:
|
||||
error(trace())
|
||||
"""
|
||||
|
@ -4,6 +4,7 @@ from helpers import *
|
||||
from org.bukkit.util import Vector
|
||||
from math import sin
|
||||
|
||||
ff_help = "utils.forcefeild.help"
|
||||
ff_perm = "utils.forcefield"
|
||||
pass_perm = "utils.forcefield.ignore"
|
||||
ff_prefix = "&8[&bFF&8] "
|
||||
@ -42,7 +43,7 @@ def on_forcefield_command(sender, command, label, args):
|
||||
else:
|
||||
forcefield_header(sender, "&cInvalid syntax. Use &e/ff ? &cfor info.")
|
||||
|
||||
elif args[0] in ["HELP", "?"]: # /forcefield help
|
||||
elif args[0] in ["HELP", "?"] and sender.hasPermission(ff_help): # /forcefield help
|
||||
forcefield_help(sender)
|
||||
else:
|
||||
forcefield_header(sender, "&cInvalid syntax. Use &e/ff ? &cfor info.")
|
||||
@ -194,4 +195,4 @@ def on_quit(event):
|
||||
player = event.getPlayer()
|
||||
player_id = uid(player)
|
||||
if player_id in ff_users:
|
||||
ff_users.remove(player_id)
|
||||
ff_users.remove(player_id)
|
||||
|
4
main.py
4
main.py
@ -38,8 +38,8 @@ shared["load_modules"] = [
|
||||
"adminchat",
|
||||
# Adds /badge, allows to give players achievements
|
||||
"badges",
|
||||
# Adds a few block placement corrections/mods
|
||||
"blockplacemods",
|
||||
# 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
|
||||
|
16
mentio.py
16
mentio.py
@ -8,6 +8,7 @@ max_amount = 3
|
||||
arrow = colorify(u"&r&7\u2192&r")
|
||||
colors_reg = reg_compile(u"\u00A7[\\da-fk-or]") # finds color codes
|
||||
|
||||
mentio_toggle = []
|
||||
|
||||
def saveMentions():
|
||||
save_json_file("mentio", mentions)
|
||||
@ -19,6 +20,8 @@ def onChat(event):
|
||||
sender = event.getPlayer()
|
||||
words = event.getMessage().split(" ")
|
||||
recipients = event.getRecipients() # set of <Player>, may be a lazy or unmodifiable collection
|
||||
n = sender.getName()
|
||||
|
||||
|
||||
for recipient in list(recipients):
|
||||
recuid = uid(recipient)
|
||||
@ -46,7 +49,7 @@ def onChat(event):
|
||||
break
|
||||
|
||||
# player was mentioned
|
||||
if rec_words != words:
|
||||
if rec_words != words and n not in mentio_toggle:
|
||||
try:
|
||||
recipients.remove(recipient) # don't send original message
|
||||
except:
|
||||
@ -116,6 +119,7 @@ def show_help(player):
|
||||
msg(player, "&a/mentio add <word>")
|
||||
msg(player, "&a/mentio del <word>")
|
||||
msg(player, "&a/mentio list")
|
||||
msg(player, "&a/mentio toggle")
|
||||
|
||||
|
||||
@hook.command("mentio")
|
||||
@ -142,6 +146,16 @@ def onListenCommand(sender, command, label, args):
|
||||
msg(sender, "&c- &3%s" % word)
|
||||
if not keywords:
|
||||
msg(sender, "&cYou are currently listening for no words! Try &6/mentio add <word>")
|
||||
|
||||
# /mentio toggle
|
||||
elif argnum == 1 and cmd == "toggle":
|
||||
n = sender.getName()
|
||||
if n in mentio_toggle:
|
||||
msg(sender,"&aNow listening.")
|
||||
mentio_toggle.remove(n)
|
||||
else:
|
||||
msg(sender,"&aNo longer listening.")
|
||||
mentio_toggle.append(n)
|
||||
else:
|
||||
show_help(sender)
|
||||
else:
|
||||
|
12
player.py
12
player.py
@ -4,10 +4,12 @@ py_players = []
|
||||
|
||||
class py_player:
|
||||
def __init__(self,player):
|
||||
self.player = player
|
||||
self.logging_in = False
|
||||
self.login_time = 0
|
||||
|
||||
self.player = player
|
||||
self.logging_in = False
|
||||
self.login_time = 0
|
||||
self.slab_toggle = False
|
||||
self.cauldron_toggle = False
|
||||
|
||||
def get_py_player(player):
|
||||
#py_player = py_players[py_players.index(player)]
|
||||
|
||||
@ -25,4 +27,4 @@ def on_join(event):
|
||||
|
||||
@hook.event("player.PlayerQuitEvent","highest")
|
||||
def on_leave(event):
|
||||
py_players.remove(get_py_player(event.getPlayer()))
|
||||
py_players.remove(get_py_player(event.getPlayer()))
|
||||
|
Reference in New Issue
Block a user