def on_break_block(event): if not event.isCancelled(): player = event.getPlayer() block = event.getBlock() for th in tilehelpers: area = th.get("area") if th.get("owner") == uid(player) and str(block.getWorld().getUID()) == th.get("world") and block.getX() in range(area[0][0], area[0][1]+1) and block.getY() in range(area[1][0], area[1][1]+1) and block.getZ() in range(area[2][0], area[2][1]+1): # stack block in directions for direction in th.get("directions"): directions = dirmap[direction] size = [ 1 + abs(area[0][1] - area[0][0]), 1 + abs(area[1][1] - area[1][0]), 1 + abs(area[2][1] - area[2][0]) ] newblock = block.getWorld().getBlockAt( block.getX() + size[0] * directions[0], block.getY() + size[1] * directions[1], block.getZ() + size[2] * directions[2] ) event = BlockBreakEvent(newblock, player) server.getPluginManager().callEvent(event) if not event.isCancelled(): newblock.setTypeId(0)
def on_block_break(event): global removing_input if removing_input: return sender = event.getPlayer() block = event.getBlock() btype = str(block.getType()).lower() if str(block.getType()) in accepted_inputs and not event.isCancelled(): pos_str = location_str(block) if inputs.get(pos_str): if sender.isSneaking(): # test if player is allowed to build here removing_input = True test_event = BlockBreakEvent(block, sender) server.getPluginManager().callEvent(test_event) removing_input = False if test_event.isCancelled(): event.setCancelled(True) msg(sender, "&cYou are not allowed to remove this %s" % btype) return True inputs.pop(pos_str) # remove save_inputs() msg(sender, "&eSuccessfully removed this %s!" % btype) return True elif not changing_input: event.setCancelled(True) msg(sender, "&cYou cannot destroy this %s!" % btype) msg(sender, "&c&nSneak&c and break if you want to remove it.") return True
def can_build(player, block): """ return True if the player can change/build at the location of given block """ event = BlockBreakEvent(block, player) server.getPluginManager().callEvent(event) return not event.isCancelled()
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)
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)
def on_dammnspam_command(sender, command, label, args): global changing_input plugin_header(sender, "DamnSpam") if not checkargs(sender, args, 1, 2): msg(sender, "&c/damnspam <seconds> &e(Buttons/Levers)") msg(sender, "&c/damnspam <seconds after off> <seconds after on> &e(Levers only)") return True #Gittestlol if not is_creative(sender): msg(sender, "&cYou can only do this in Creative mode.") return True # /damnspam <secs> if len(args) == 1: timeout_on = args[0] try: timeout_on = round(float(timeout_on), 2) timeout_off = timeout_on if 60 >= timeout_on <= -2 or timeout_on == 0: timeout_on = False if timeout_on == False: msg(sender, "&cThe timeout must be within 0-60 or -1.") return True except ValueError: msg(sender, "&cThe timeout must be a number") return True # /damnspam <off> <on> elif len(args) == 2: timeout_on = args[0] timeout_off = args[1] try: timeout_on = round(float(timeout_on), 2) timeout_off = round(float(timeout_off), 2) if 60 >= timeout_on <= -2 or timeout_on == 0: timeout_on = False if 60 >= timeout_off <= -2 or timeout_off == 0: timeout_off = False if timeout_on == False or timeout_off == False: msg(sender, "&cThe timeout must be within 0-60 or -1.") return True except ValueError: msg(sender, "&cThe timeout must be a number") return True # get the block we're looking at target = sender.getTargetBlock(None, 10) ttype = str(target.getType()) if ttype not in accepted_inputs: msg(sender, "&cPlease look at a button or lever while executing this command!") return True if location_str(target) in inputs: changing_input = True # this input already has a timeout # test if player is allowed to build here test_event = BlockBreakEvent(target, sender) server.getPluginManager().callEvent(test_event) changing_input = False if test_event.isCancelled(): msg(sender, "&cYou are not allowed to modify this %s" % str(target.getType()).lower()) return True # add block to inputs add_input(sender, target, timeout_off, timeout_on) save_inputs() msg(sender, "&aSuccessfully set a timeout for this %s." % ttype.lower().replace("_", " ")) return True