@EventHandler public void PlaceCheckDoor(BlockPlaceEvent e) { if(ConfigPatch.AntiInfSuagrenable){ if(e.isCancelled()){ Player p = e.getPlayer(); List<Entity> entities = p.getNearbyEntities(2, 2, 2); for(int i=0;i<entities.size();i++){ Entity ent = entities.get(i); if(ent.getType() == EntityType.DROPPED_ITEM){ Item item = (Item)ent; if(item.getItemStack().getType() == Material.SUGAR_CANE||item.getItemStack().getType() == Material.CACTUS){ ent.remove(); } } } } } }
public void onBlockPlace(BlockPlaceEvent e) { Map cpl = RegionMapGen.getPlayerLocations(); cpl.put(e.getPlayer().getUniqueId(), RegionMapGen.getMap()[(int)e.getPlayer().getLocation().getX()][(int)e.getPlayer().getLocation().getZ()]); RegionMapGen.setPlayerLocations(cpl); if (cpl.get(e.getPlayer().getUniqueId()).equals("lava")) { Broadcast.toPlayer(e.getPlayer(), Broadcast.BroadcastType.FAILURE, "You cannot build in Warvale's territory."); e.setCancelled(true); } else if (cpl.get(e.getPlayer().getUniqueId()).equals(Main.get().getConfig().getString("Player-Data."+e.getPlayer().getUniqueId()+"Guild-Name"))) { e.setCancelled(false); } else { Broadcast.toPlayer(e.getPlayer(), Broadcast.BroadcastType.FAILURE, "You cannot build in "+cpl.get(e.getPlayer().getUniqueId())+"'s territory."); e.setCancelled(true); } }
/** * Prevents placing of blocks * * @param e */ @EventHandler(priority = EventPriority.LOW) public void onPlayerBlockPlace(final BlockPlaceEvent e) { if (DEBUG) plugin.getLogger().info("DEBUG: " + e.getEventName()); if (!Settings.netherIslands) { if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) { if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { return; } if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) { e.setCancelled(true); } } } }
@EventHandler public void onPlace(BlockPlaceEvent event) { Game game = Chambers.getInstance().getGameManager().getGame(); if (!game.hasStarted()) { return; } Location location = event.getBlock().getLocation(); Profile profile = Chambers.getInstance().getProfileManager().getProfileByUuid(event.getPlayer().getUniqueId()); if (profile.isBypassMode()) { event.setCancelled(false); return; } if (profile.getTeam() == null) { event.setCancelled(true); return; } Team team = Chambers.getInstance().getClaimManager().getTeamAt(location); if (team.isRaidable()) { event.setCancelled(false); return; } if (team != profile.getTeam()) { event.setCancelled(true); profile.sendMessage(ChatColor.YELLOW + "You cannot do that in the territory of " + team.getFormattedName() + ChatColor.YELLOW + "."); } }
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true) public void onBlockRegister(BlockPlaceEvent e) { if (BlockStorage.hasBlockInfo(e.getBlock())) { e.setCancelled(true); return; } ItemStack item = e.getItemInHand(); if (item != null && item.getType() == Material.INK_SACK) return; SlimefunItem sfItem = SlimefunItem.getByItem(item); if (sfItem != null && !(sfItem instanceof NotPlaceable)){ BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true); if (SlimefunItem.blockhandler.containsKey(sfItem.getID())) { SlimefunItem.blockhandler.get(sfItem.getID()).onPlace(e.getPlayer(), e.getBlock(), sfItem); } } else { for (ItemHandler handler: SlimefunItem.getHandlers("BlockPlaceHandler")) { if (((BlockPlaceHandler) handler).onBlockPlace(e, item)) break; } } }
@EventHandler public void onPlace(BlockPlaceEvent e){ WCUser p = WCSurvival.getPlayer(e.getPlayer()); if (e.getBlock().getType() == Material.DROPPER && plugin.getCreando().contains(p.getPlayer())){ if (plugin.getCasinos().contains(e.getBlock().getLocation())) { p.sendMessagePrefix(ChatColor.RED + "Este espacio esta ocupado por otra maquina"); return; } plugin.getCreando().remove(p.getPlayer()); plugin.getFiles().getConfig().set("casino.id_" + plugin.getFiles().getID(), Utils.locationToString(e.getBlock().getLocation())); plugin.getFiles().saveFiles(); p.sendMessagePrefix(ChatColor.GREEN + "Máquina añadida " + plugin.getFiles().getCurrentID()); plugin.getCasinos().add(e.getBlock().getLocation()); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlace(BlockPlaceEvent e) { if (haulted) { if (!e.getPlayer().isOp()) { e.getPlayer().sendMessage(TAG + ChatColor.RED + "Server Haulted!"); e.setCancelled(true); return; } } if (!e.getPlayer().hasPermission("behave.build.place")) { e.setCancelled(true); if(getConfig().getBoolean("msgbb")){ e.getPlayer().sendMessage(ChatColor.BLUE + "[Behave] " + ChatColor.RED + "you dont have permision"); } } }
@EventHandler public void onBlockPlace(BlockPlaceEvent event) { if (Walls.getSpectators().contains(event.getPlayer().getName())) { event.setCancelled(true); return; } if (State.PVP) return; Block b = event.getBlock(); if (b.getType()==Material.TNT && !State.PVP) { Chat.player(event.getPlayer(), "&cYou are not allowed to use TNT before the walls drop!"); event.setCancelled(true); } Team team = Team.getTeam(event.getPlayer()); if (b.getX() < team.getMin().getX() + 1 || b.getZ() < team.getMin().getZ() + 1) { event.setCancelled(true); } if (b.getX() > team.getMax().getX() - 1 || b.getZ() > team.getMax().getZ() - 1) { event.setCancelled(true); } }
/** * Handle Towers * * @param event Event */ @EventHandler public void onBlockPlace(BlockPlaceEvent event) { /*if (this.game.isPvPActivated() && event.getBlockPlaced().getY() > event.getBlock().getWorld().getHighestBlockYAt(event.getBlockPlaced().getX(), event.getBlockPlaced().getZ()) + 15) { event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.DARK_RED + "[" + ChatColor.RED + "Tours" + ChatColor.DARK_RED + "] " + ChatColor.RED + "Les Tours sont interdites !"); return; }*/ if (!this.game.isPvPActivated() && event.getBlock().getType() == Material.TNT) { event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.RED + "Vous ne pouvez pas utiliser de la TNT tant que le PvP est désactivé !"); } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { int x = event.getBlock().getX() + this.data.length / 2; int z = event.getBlock().getZ() + this.data.length / 2; if (x >= 0 && z >= 0 && x < this.data.length && z < this.data.length) { byte high = this.data[x][z]; if (event.getBlock().getY() > high + 15 && event.getBlock().getRelative(BlockFace.EAST).getType() == Material.AIR && event.getBlock().getRelative(BlockFace.WEST).getType() == Material.AIR && event.getBlock().getRelative(BlockFace.SOUTH).getType() == Material.AIR && event.getBlock().getRelative(BlockFace.NORTH).getType() == Material.AIR) { event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.RED + "Les towers sont interdites."); } } }
@EventHandler public void onBlockPlace(BlockPlaceEvent e) { User user = MWAPI.getUserHandler().findById(e.getPlayer().getUniqueId()); if (user.getGame() != null) { if (user.getGame().getSpectators().contains(user) || user.getGame().getState().equals(GameState.LOBBY)) { e.setCancelled(true); return; } // TODO handle other stuff like the castles and walls } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlaceDispenser(final BlockPlaceEvent e) { if (!cm.tileLimitEnabled) { return; } if (e.getBlock().getType() == Material.DISPENSER) { Player p = e.getPlayer(); if (p.isOp()) { return; } int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.dispenser."); if (limit <= 0) { limit = cm.tileLimitDefaultDispenser; } if (isLimit(e.getBlock().getLocation(), Material.DISPENSER, limit)) { e.setCancelled(true); p.sendMessage(i18n.tr("message", limit)); } } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlaceDropper(final BlockPlaceEvent e) { if (!cm.tileLimitEnabled) { return; } if (e.getBlock().getType() == Material.DROPPER) { Player p = e.getPlayer(); if (p.isOp()) { return; } int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.dropper."); if (limit <= 0) { limit = cm.tileLimitDefaultDropper; } if (isLimit(e.getBlock().getLocation(), Material.DROPPER, limit)) { e.setCancelled(true); p.sendMessage(i18n.tr("message", limit)); } } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlaceHopper(final BlockPlaceEvent e) { if (!cm.tileLimitEnabled) { return; } if (e.getBlock().getType() == Material.HOPPER) { Player p = e.getPlayer(); if (p.isOp()) { return; } int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.hopper."); if (limit <= 0) { limit = cm.tileLimitDefaultHopper; } if (isLimit(e.getBlock().getLocation(), Material.HOPPER, limit)) { e.setCancelled(true); p.sendMessage(i18n.tr("message", limit)); } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlace(BlockPlaceEvent e) { if (!cm.isAntiPlaceDoorDupe) { return; } // 判断手里的物品是否为门 if (e.getItemInHand().getType() == Material.WOOD_DOOR || e.getItemInHand().getType() == Material.IRON_DOOR) { // 清理所在区块的甘蔗掉落物 for (Entity entity : e.getPlayer().getLocation().getChunk().getEntities()) { if (entity instanceof Item) { Material itemType = ((Item) entity).getItemStack().getType(); if (itemType == Material.SUGAR_CANE || itemType == Material.CACTUS) { entity.remove(); } } } } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlaceChest(BlockPlaceEvent e) { if (!cm.isAntiQuickDoubleChest) { return; } Block block = e.getBlock(); if (block == null) { return; } Material blockType = block.getType(); if (Material.CHEST == blockType || Material.TRAPPED_CHEST == blockType) { if (isShopBlockNearby(block)) { e.setCancelled(true); e.getPlayer().sendMessage(i18n.tr("antiQuickShopDoubleChest")); } } }
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST) public void onBlockPlace(BlockPlaceEvent event) { ItemStack stack = event.getItemInHand(); BlockState state = event.getBlock().getState(); if (((state instanceof Sign)) && (stack.hasItemMeta())) { ItemMeta meta = stack.getItemMeta(); if ((meta.hasDisplayName()) && (meta.getDisplayName().equals(EVENT_SIGN_ITEM_NAME))) { Sign sign = (Sign)state; List<String> lore = meta.getLore(); int count = 0; for (String loreLine : lore) { sign.setLine(count++, loreLine); if (count == 4) { break; } } sign.update(); } } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onBlockPlace(BlockPlaceEvent event) { ItemStack stack = event.getItemInHand(); BlockState state = event.getBlock().getState(); if (state instanceof Sign && stack.hasItemMeta()) { ItemMeta meta = stack.getItemMeta(); if (meta.hasDisplayName() && meta.getDisplayName().equals(DEATH_SIGN_ITEM_NAME)) { Sign sign = (Sign) state; List<String> lore = meta.getLore(); int count = 0; for (String loreLine : lore) { sign.setLine(count++, loreLine); if (count == 4) break; } sign.update(); //sign.setEditible(false); } } }
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR) public void onBlockBreak(BlockPlaceEvent event) { if (event.isCancelled()) { Player player = event.getPlayer(); if (player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight()) { return; } Block block = event.getBlockPlaced(); if (block.getType().isSolid() && !(block.getState() instanceof Sign)) { int playerY = player.getLocation().getBlockY(); int blockY = block.getLocation().getBlockY(); if (playerY > blockY) { Vector vector = player.getVelocity(); vector.setX(-0.1); vector.setZ(-0.1); player.setVelocity(vector.setY(vector.getY() - 0.41999998688697815D)); // Magic number acquired from EntityLiving#bj() } } } }
@EventHandler public void BlockPlaceEvent(BlockPlaceEvent e){ Player p = e.getPlayer(); Block b = e.getBlock(); if (e.getItemInHand().getType() == Material.DROPPER && e.getItemInHand().getEnchantments() != null && e.getItemInHand().getEnchantments().containsKey(Enchantment.ARROW_DAMAGE)) { Casino c = new Casino(e.getBlockPlaced().getLocation()); c.effect(); } for(Entity en : p.getNearbyEntities (4D, 4D, 4D)){ if (en instanceof Player){ if(en == p) continue; if(b.getType() == Material.FIRE){ if(Files.user.getBoolean("Users." + en.getName() + ".pvp") == false){ p.sendMessage(Utils.colorize(PAData.SURVIVAL.getPrefix() + ChatColor.DARK_RED + " No puedes poner ese bloque cerca de un jugador con el pvp desactivado.")); e.setCancelled(true); } } } } }
@EventHandler public void onPlace(BlockPlaceEvent e) { if (e.isCancelled()) { return; } if (!e.getBlock().getType().equals(Material.CAULDRON)) { return; } Block b = e.getBlock(); Location loc = b.getLocation(); loc.setY(loc.getY() + 1); Block upon = loc.getBlock(); if (upon.getType().equals(Material.AIR)) { return; } e.setCancelled(true); e.getPlayer().sendMessage(Messages.getMessages().getNoPlace().replace("&", "§")); }
@EventHandler public void onBlockPlaced (BlockPlaceEvent event) { Player player = event.getPlayer (); player.sendMessage (player.getDisplayName() + " Placed " + event.getBlockPlaced ().toString ()); if (mEconomy != null) { mEconomy.depositPlayer (player, 100D); mEconomy.getBalance (player); } }
@EventHandler public void onPlace(BlockPlaceEvent event) { if (event.getBlockPlaced().getType() == Material.WOOL && event.getBlockPlaced().getState().getData().getData() == color) { if (!completed) { if (!podium.contains(event.getBlockPlaced().getLocation())) { return; } if (!owner.containsPlayer(event.getPlayer())) { return; } event.setCancelled(false); //override filter setCompleted(true); TeamManagerModule teamManagerModule = TGM.get().getModule(TeamManagerModule.class); MatchTeam matchTeam = teamManagerModule.getTeam(event.getPlayer()); for (WoolObjectiveService woolObjectiveService : services) { woolObjectiveService.place(event.getPlayer(), matchTeam, event.getBlock()); } } } else { if (podium.contains(event.getBlockPlaced().getLocation())) { event.setCancelled(true); } } }
@EventHandler public void onPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); if (!((player.hasPermission("practice.admin") || player.isOp()) && player.getGameMode() == GameMode.CREATIVE)) { event.setCancelled(true); } }
@EventHandler public void blockPlace(BlockPlaceEvent event) { ListIterator<BlockPlaceRunnable> in = placerun.update(); while (in.hasNext()) { BlockPlaceRunnable r = in.next(); r.setEvent(event); r.run(); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { if (!this.tracker.isEnabled(event.getBlock().getWorld())) return; if (event.getBlock().getType() == Material.DISPENSER) { this.tracker.setPlacer(event.getBlock(), event.getPlayer()); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { if (!this.tracker.isEnabled(event.getBlock().getWorld())) return; if (event.getBlock().getType() == Material.ANVIL) { this.tracker.setPlacer(event.getBlock(), Bukkit.getOfflinePlayer(event.getPlayer().getUniqueId())); } }
@EventHandler public void onBlockPlace(BlockPlaceEvent event) { PlayerDataRPG pd = plugin.getPD(event.getPlayer()); if (pd == null) event.setCancelled(true); if (event.getPlayer().getGameMode() != GameMode.CREATIVE) event.setCancelled(true); if (!canBuild(pd)) event.setCancelled(true); event.getPlayer().updateInventory(); }
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent e) { Block b = e.getBlockPlaced().getRelative(0, -1, 0); SlimefunItem item = BlockStorage.check(b); if(item == null) return; if(item.getID().equalsIgnoreCase("ANCIENT_PEDESTAL")) { Messages.local.sendTranslation(e.getPlayer(), "messages.cannot-place", true); e.setCancelled(true); } }
@EventHandler public void onBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); Block b = event.getBlock(); b.setMetadata("blockBreaker", new FixedMetadataValue(PrisonPicks.getInstance(), player.getUniqueId())); }
@EventHandler public void onBlockPlace(BlockPlaceEvent e) { Player player = e.getPlayer(); if (!player.hasPermission("superiorcraft.editworld")) { e.setCancelled(true); player.sendMessage(ChatColor.RED + "You may not place blocks here"); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onContainerPlace(BlockPlaceEvent event) { // Blacklist any placed container blocks if(event.getBlock().getState() instanceof InventoryHolder) { this.chests.put(((InventoryHolder) event.getBlock().getState()).getInventory(), false); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void handleInstantActivation(BlockPlaceEvent event) { if(this.properties.instantIgnite && event.getBlock().getType() == Material.TNT) { World world = event.getBlock().getWorld(); TNTPrimed tnt = world.spawn(BlockUtils.base(event.getBlock()), TNTPrimed.class); if(this.properties.fuse != null) { tnt.setFuseTicks(this.getFuseTicks()); } if(this.properties.power != null) { tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield } if(callPrimeEvent(tnt, event.getPlayer(), true)) { // Only cancel the block placement if the prime event is NOT cancelled. // If priming is cancelled, the block is allowed to stay (unless some // other handler has already cancelled the place event). event.setCancelled(true); world.playSound(tnt.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); ItemStack inHand = event.getItemInHand(); if(inHand.getAmount() == 1) { inHand = null; } else { inHand.setAmount(inHand.getAmount() - 1); } event.getPlayer().getInventory().setItem(event.getHand(), inHand); } } }
/** * Return true if the block transformation was performed "by hand". * * Handled: * - place * - mine * - bucket fill/empty * - flint & steel fire/tnt * * Not handled: * - bonemeal * - probably lots of other things */ public boolean isManual() { final Event event = getCause(); if(Types.instanceOfAny( event, BlockPlaceEvent.class, BlockBreakEvent.class, PlayerBucketEmptyEvent.class, PlayerBucketFillEvent.class )) return true; if(event instanceof BlockIgniteEvent) { BlockIgniteEvent igniteEvent = (BlockIgniteEvent) event; if(igniteEvent.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && igniteEvent.getIgnitingEntity() != null) { return true; } } if(event instanceof ExplosionPrimeByEntityEvent && ((ExplosionPrimeByEntityEvent) event).getPrimer() instanceof Player) { return true; } return false; }
@EventWrapper public void onBlockPlace(final BlockPlaceEvent event) { if(event instanceof BlockMultiPlaceEvent) { for(BlockState oldState : ((BlockMultiPlaceEvent) event).getReplacedBlockStates()) { callEvent(event, oldState, oldState.getBlock().getState(), event.getPlayer()); } } else { callEvent(event, event.getBlockReplacedState(), event.getBlock().getState(), event.getPlayer()); } }
@EventHandler public void onPlace(BlockPlaceEvent e) { KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer()); if(p.hasBuildAction()) e.setCancelled(true); if(p.isVanished()) return; if(e.isCancelled()) return; if(!p.canBuild(e.getBlock().getLocation())) { e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 200, e.getBlock())); } }
@EventHandler public void onBlockPlace(BlockPlaceEvent event) { if (event.getItemInHand().getType() != Material.MOB_SPAWNER) return; ItemStack is = event.getItemInHand(); if (!is.hasItemMeta()) return; ItemMeta im = is.getItemMeta(); if (!im.hasLore()) return; String lore = im.getLore().toString(); if (!lore.contains("Spawner:")) return; EntityType entity = getEntity(lore); if (entity == EntityType.AREA_EFFECT_CLOUD) { event.setCancelled(true); return; } setSpawner(event.getBlock(), entity); }
@SuppressWarnings("deprecation") public boolean ignite(Player igniter, Location loc, IgniteCause cause) { Random rand = new Random(); loc.add(0.5, 0.5, 0.5); BlockIgniteEvent igniteEvent = new BlockIgniteEvent(loc.getBlock(), cause, (org.bukkit.entity.Entity) igniter); Bukkit.getServer().getPluginManager().callEvent(igniteEvent); if (igniteEvent.isCancelled()) { return false; } BlockState blockState = loc.getBlock().getState(); BlockPlaceEvent placeEvent = new BlockPlaceEvent(loc.getBlock(), blockState, loc.getBlock(), igniter.getItemInHand(), igniter, true); Bukkit.getServer().getPluginManager().callEvent(placeEvent); if (placeEvent.isCancelled() || !placeEvent.canBuild()) { placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false); return false; } loc.getWorld().playSound(loc, Sound.ITEM_FLINTANDSTEEL_USE, 1.0F, rand.nextFloat() * 0.4F + 0.8F); loc.getBlock().setType(Material.FIRE); return true; }