@EventHandler(priority = EventPriority.LOW) public void onPistonExtend(BlockPistonExtendEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } Location pistonLoc = e.getBlock().getLocation(); if (Settings.allowPistonPush || !Util.inWorld(pistonLoc)) { //plugin.getLogger().info("DEBUG: Not in world"); return; } Island island = plugin.getIslands().getProtectedIslandAt(pistonLoc); if (island == null || !island.onIsland(pistonLoc)) { //plugin.getLogger().info("DEBUG: Not on is island protection zone"); return; } // We need to check where the blocks are going to go, not where they are for (Block b : e.getBlocks()) { if (!island.onIsland(b.getRelative(e.getDirection()).getLocation())) { //plugin.getLogger().info("DEBUG: Block is outside protected area"); e.setCancelled(true); return; } } }
/** * @return if we have walked onto a fence. */ public static boolean walkedOnFence(Location location) { // check if were already under that block. Location subtracted = location.clone().subtract(0, 1, 0); Block groundBlock = subtracted.getBlock(); if (MaterialHelper.isFence(groundBlock.getType()) || MaterialHelper.isFenceGate(groundBlock.getType())) { return true; } LocationBit bit = new LocationBit(0.5); for (int i = 1; i <= 4; i++) { Location newLocation = location.clone().add(bit.getX(), -1, bit.getZ()); Block block = newLocation.getBlock(); if (MaterialHelper.isFence(block.getType()) || MaterialHelper.isFenceGate(block.getType())) { return true; } bit.shift(i); } return false; }
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) { Block block = event.getClickedBlock(); // Don't prevent opening chests, etc, as these won't throw the Enderpearls anyway if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) { Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation()); if (!(factionAt instanceof ClaimableFaction)) { return; } event.setCancelled(true); Player player = event.getPlayer(); player.setItemInHand(event.getItem()); // required to update Enderpearl count } } }
/** * So far specifically handles these cases: * * 1) Block burnt is tracked * 2) Block burnt is under a tracked block (probably only mushrooms eligible) * 3) Block burnt was a jungle tree, checks for cocoa. * 4) Burnt block had mushroom on top and cocoa on the sides * * @param e The event */ @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockBurn(BlockBurnEvent e) { Block block = e.getBlock(); if (maybeSideTracked(block)) { trySideBreak(block, BreakType.FIRE, null); } if (maybeBelowTracked(block)) { block = block.getRelative(BlockFace.UP); } Location loc = block.getLocation(); if (!pendingChecks.contains(loc)) { pendingChecks.add(loc); handleBreak(block, BreakType.FIRE, null, null); } }
public Arena(String name, String worldName, int id, Block sign, List<Map> maps) { this.name = name; this.id = id; this.worldName = worldName; this.maps = maps; this.index = 0; this.signBlock = sign; this.state = ArenaState.WAITING; this.schedule = new ArenaSchedule(this); this.schedule.runTaskTimerAsynchronously(Walls.getInstance(), 0, 20); registerTeams(); loadWorld(); list.add(this); }
@SuppressWarnings("deprecation") public void reloadWeapons(Player p) { for (DataBlock dataBlock : craft.dataBlocks) { Block theBlock = getWorldBlock(dataBlock.x, dataBlock.y, dataBlock.z); if (theBlock.getTypeId() == 23) { for (OneCannon onec : AimCannon.getCannons()) { if (onec.isThisCannon(theBlock.getLocation(), false)) { onec.reload(p); } } } } }
@EventHandler(priority = EventPriority.HIGH) public void upElevator(PlayerMoveEvent e) { Player p = e.getPlayer(); Block b = e.getTo().getBlock().getRelative(BlockFace.DOWN); if (p.hasPermission("ironelevators.use") && e.getFrom().getY() < e.getTo().getY() && b.getType() == elevatorMaterial) { b = b.getRelative(BlockFace.UP, minElevation); int i = maxElevation; while (i > 0 && !( b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent() ) ) { i--; b = b.getRelative(BlockFace.UP); } if (i > 0) { Location l = p.getLocation(); l.setY(l.getY() + maxElevation + 3 - i); p.teleport(l); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1); } } }
@EventHandler public void onPlayerInteract2(PlayerInteractEvent e) { Player player = e.getPlayer(); PlayerInventory inventory = player.getInventory(); if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) { Material material = inventory.getItemInHand().getType(); if(material == Material.BOW) { DynamicAC.getManager().getBackend().logBowWindUp(player, System.currentTimeMillis()); } else if(Utilities.isFood(material)) { DynamicAC.getManager().getBackend().logEatingStart(player); } } Block block = e.getClickedBlock(); if(block != null) { Distance distance = new Distance(player.getLocation(), block.getLocation()); DynamicAC.getManager().getBackend().checkLongReachBlock(player,distance.getXDifference(),distance .getYDifference(),distance.getZDifference()); } }
@EventHandler public void onBlockBreak(BlockBreakEvent event) { if (Walls.getSpectators().contains(event.getPlayer().getName())) { event.setCancelled(true); return; } if (State.PVP) return; Block b = event.getBlock(); if (b == null) return; 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); } }
/** * Clears a visual block at a given location for a player. * * @param player * the player to clear for * @param location * the location to clear at * @param sendRemovalPacket * if a packet to send a block change should be sent (this is used to prevent unnecessary packets sent when disconnecting or changing worlds, for example) * @return if the visual block was shown in the first place */ public boolean clearVisualBlock(Player player, Location location, boolean sendRemovalPacket) { synchronized (storedVisualises) { VisualBlock visualBlock = this.storedVisualises.remove(player.getUniqueId(), location); if (sendRemovalPacket && visualBlock != null) { // Have to send a packet to the original block type, don't send if the fake block has the same data properties though. Block block = location.getBlock(); VisualBlockData visualBlockData = visualBlock.getBlockData(); if (visualBlockData.getBlockType() != block.getType() || visualBlockData.getData() != block.getData()) { player.sendBlockChange(location, block.getType(), block.getData()); } return true; } } return false; }
public static boolean hitBlock(Player player, Block block) { if (player.getGameMode() == GameMode.CREATIVE) return true; PlayerBlockTracking playerBlockTracking = getPlayerBlockTracking(player); if (playerBlockTracking.isBlock(block)) { return true; } long time = playerBlockTracking.getTimeDifference(); playerBlockTracking.incrementHackingIndicator(); playerBlockTracking.setBlock(block); playerBlockTracking.updateTime(); int decrement = (int) (time / OrebfuscatorConfig.AntiHitHackDecrementFactor); playerBlockTracking.decrementHackingIndicator(decrement); if (playerBlockTracking.getHackingIndicator() == OrebfuscatorConfig.AntiHitHackMaxViolation) playerBlockTracking.incrementHackingIndicator(OrebfuscatorConfig.AntiHitHackMaxViolation); if (playerBlockTracking.getHackingIndicator() > OrebfuscatorConfig.AntiHitHackMaxViolation) return false; return true; }
@EventHandler(priority = EventPriority.HIGH) public void downElevator(PlayerToggleSneakEvent e) { Player p = e.getPlayer(); Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN); if (p.hasPermission("ironelevators.use") && !p.isSneaking() && b.getType() == elevatorMaterial) { b = b.getRelative(BlockFace.DOWN, minElevation); int i = maxElevation; //16 while (i > 0 && !( b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent() ) ) { //e.getPlayer().sendMessage("" + b.getLocation() + b.getType()); i--; b = b.getRelative(BlockFace.DOWN); } if (i > 0) { Location l = p.getLocation(); l.setY(l.getY() - maxElevation - 3 + i); p.teleport(l); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1); } } }
public InventoryView openWorkbench(Location location, boolean force) { if (!force) { Block block = location.getBlock(); if (block.getType() != Material.WORKBENCH) { return null; } } if (location == null) { location = getLocation(); } getHandle().displayGUIWorkbench(location.getBlockX(), location.getBlockY(), location.getBlockZ()); if (force) { getHandle().openContainer.checkReachable = false; } return getHandle().openContainer.getBukkitView(); }
/** * Return the number of unsupported blocks connected to any blocks neighboring the given location. * An air block is placed there temporarily if it is not already air. The search may bail out early * when the count is >= the given limit, though this cannot be guaranteed. */ public int countUnsupportedNeighbors(Block block, int limit) { BlockState state = null; if(block.getType() != Material.AIR) { state = block.getState(); block.setTypeIdAndData(0, (byte) 0, false); } int count = countUnsupportedNeighbors(encodePos(block), limit); if(state != null) { block.setTypeIdAndData(state.getTypeId(), state.getRawData(), false); } return count; }
private List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance, int maxLength) { if (maxDistance > 120) { maxDistance = 120; } ArrayList<Block> blocks = new ArrayList<Block>(); Iterator<Block> itr = new BlockIterator(this, maxDistance); while (itr.hasNext()) { Block block = itr.next(); blocks.add(block); if (maxLength != 0 && blocks.size() > maxLength) { blocks.remove(0); } byte id = (byte)block.getTypeId(); if (transparent == null) { if (id != 0) { break; } } else { if (!transparent.contains(id)) { break; } } } return blocks; }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onBlockPlace(BlockPlaceEvent event) { Block block = event.getBlockPlaced(); ItemStack stack = event.getItemInHand(); Player player = event.getPlayer(); if (block.getState() instanceof CreatureSpawner && stack.hasItemMeta()) { ItemMeta meta = stack.getItemMeta(); if (meta.hasLore() && meta.hasDisplayName()) { CreatureSpawner spawner = (CreatureSpawner) block.getState(); List<String> lore = meta.getLore(); if (!lore.isEmpty()) { String spawnerName = ChatColor.stripColor(lore.get(0).toUpperCase()); Optional<EntityType> entityTypeOptional = GuavaCompat.getIfPresent(EntityType.class, spawnerName); if (entityTypeOptional.isPresent()) { spawner.setSpawnedType(entityTypeOptional.get()); spawner.update(true, true); player.sendMessage(ChatColor.AQUA + "Placed a " + ChatColor.BLUE + spawnerName + ChatColor.AQUA + " spawner."); } } } } }
public boolean update(boolean force, boolean applyPhysics) { Block block = getBlock(); if (block.getType() != getType()) { if (force) { block.setTypeId(getTypeId(), applyPhysics); } else { return false; } } block.setData(getRawData(), applyPhysics); world.getHandle().markBlockForUpdate(x, y, z); // Cauldron start - restore TE data from snapshot if (nbt != null) { TileEntity te = world.getHandle().getTileEntity(x, y, z); if (te != null) { te.readFromNBT(nbt); } } // Cauldron end return true; }
@EventHandler public void onDespawn(ItemDespawnEvent event) { for (Entry<Block, CraftingOperation> entry : operations.entrySet()) { CraftingOperation op = entry.getValue(); for (Item item : op.getItemEntities()) { if (item == event.getEntity()) { op.clear(true); operations.remove(entry.getKey()); return; } } } }
@SuppressWarnings("deprecation") public void removeSupportBlocks() { short blockId; Block block; for (int x = 0; x < craft.sizeX; x++) { for (int z = 0; z < craft.sizeZ; z++) { for (int y = craft.sizeY - 1; y > -1; y--) { //for (int y = 0; y < craft.sizeY; y++) { blockId = craft.matrix[x][y][z]; // craft block, replace by air if (BlocksInfo.needsSupport(blockId)) { //Block block = world.getBlockAt(posX + x, posY + y, posZ + z); block = getWorldBlock(x, y, z); // special case for doors // we need to remove the lower part of the door only, or the door will pop // lower part have data 0 - 7, upper part have data 8 - 15 if (blockId == 64 || blockId == 71) { // wooden door and steel door if (block.getData() >= 8) continue; } if(blockId == 26) { //bed if(block.getData() >= 4) continue; } setBlock(0, block); } } } } }
public boolean canBypass(Player player, Block block) { Region region = plugin.getBoard().getByLocation(block.getLocation()); if (region == null || region.isNeutral()) { return false; } Faction faction = region.getOwner(); return faction.isAdmin(player); }
public Sign getKitSign(Sign s) { for (Block b : kitSigns) if (b.getX() == s.getX() && b.getY() == s.getY() && b.getZ() == s.getZ()) if (b.getType() == Material.SIGN || b.getType() == Material.WALL_SIGN) return (Sign) b.getState(); return null; }
/** * Addresses cocoa on sides of trees; can be on any side, but not top, not bottom * * @param block The block to test type on * @return True if maybe could possible contain cocoa */ @SuppressWarnings("deprecation") private boolean maybeSideTracked(Block block) { if (Material.LOG.equals(block.getType()) && block.getData() == 3) { return true; } else { return false; } }
public Block getBlock(String s) { String base = s + "."; String world = config.getString(base + "world"); int x = config.getInt(base + "x"); int y = config.getInt(base + "y"); int z = config.getInt(base + "z"); new WorldCreator(world).createWorld(); Block r = Bukkit.getWorld(world).getBlockAt(x, y, z); return r; }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlace(BlockPlaceEvent evt) { Block source = evt.getBlock(); Structure s = match(source); if (s == null) return; s.onCreate(evt); }
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityChangeBlock(EntityChangeBlockEvent e) { Block block = e.getBlock(); if (maybeSideTracked(block)) { trySideBreak(block, BreakType.NATURAL, null); } if (maybeBelowTracked(block)) { block = block.getRelative(BlockFace.UP); } Location loc = block.getLocation(); if (!pendingChecks.contains(loc)) { pendingChecks.add(loc); handleBreak(block, BreakType.NATURAL, null, null); } }
/** * Handle blocks that need special treatment * Tilling of coarse dirt into dirt using off-hand (regular hand is in 1.8) * Usually prevented because it could lead to an endless supply of dirt with gravel * * @param e */ @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onPlayerInteract(final PlayerInteractEvent e) { if (DEBUG) { plugin.getLogger().info("1.9 " + e.getEventName()); } if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { return; } if (!Util.inWorld(e.getPlayer())) { return; } if (e.getPlayer().isOp()) { return; } // This permission bypasses protection if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) { return; } // Prevents tilling of coarse dirt into dirt ItemStack inHand = e.getPlayer().getInventory().getItemInOffHand(); if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) { // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand"); Block block = e.getClickedBlock(); // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() + // ":" + block.getData()); // Check if coarse dirt if (block.getType() == Material.DIRT && block.getData() == (byte) 1) { // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!"); e.setCancelled(true); } } }
/** * CastleGates has custom block voiding when you "draw" a gate. * * @param e CastleGates post-action event. */ @EventHandler public void onDrawEvent(CastleGatesDrawGateEvent e) { try { List<Block> blocks = new ArrayList<Block>(); for (Location location : e.getImpacted()) { blocks.add(location.getBlock()); } CropControl.getPlugin().getEventHandler().doMultiblockHandler(blocks, BreakType.PISTON, null); } catch (Exception g) { CropControl.getPlugin().warning("Failed to handle CastleGates Draw Gate Event:", g); } }
public boolean isBuilding(Block block) { if(block == null) { return false; } if(block.getType() != Material.COAL_BLOCK) { return false; } return getBuilding(block) != null; }
public static void breakBlock(Player player, Block block) { if (player.getGameMode() == GameMode.CREATIVE) return; PlayerBlockTracking playerBlockTracking = getPlayerBlockTracking(player); if (playerBlockTracking.isBlock(block)) { playerBlockTracking.decrementHackingIndicator(2); } }
@SuppressWarnings("deprecation") public void delayedRestoreSigns(int dx, int dy, int dz) { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { if (NavyCraft.shutDown || craft.sinking) { return; } Block theBlock; for (DataBlock complexBlock : craft.complexBlocks) { theBlock = getWorldBlock(dx + complexBlock.x, dy + complexBlock.y, dz + complexBlock.z); theBlock.setData((byte) complexBlock.data); if (((complexBlock.id == 63) || (complexBlock.id == 68))) { NavyCraft.instance.DebugMessage("Restoring a sign.", 4); setBlock(complexBlock.id, theBlock); // theBlock.setcraft.typeId(complexBlock.id); theBlock.setData((byte) complexBlock.data); // Sign sign = (Sign) theBlock; if ((theBlock.getTypeId() == 63) || (theBlock.getTypeId() == 68)) { Sign sign = (Sign) theBlock.getState(); sign.setLine(0, complexBlock.signLines[0]); sign.setLine(1, complexBlock.signLines[1]); sign.setLine(2, complexBlock.signLines[2]); sign.setLine(3, complexBlock.signLines[3]); sign.update(); } } } structureUpdate(null, false); }); }
@Override public void onGameStart() { Iterator<Block> glassBlocks = glass.iterator(); while(glassBlocks.hasNext()) { glassBlocks.next().setType(Material.AIR); } }
/** * Retrieves the metadata for a {@link Block}, ensuring the block being asked for actually belongs to this BlockMetadataStore's * owning world. * @see MetadataStoreBase#getMetadata(Object, String) */ @Override public List<MetadataValue> getMetadata(Block block, String metadataKey) { if(block.getWorld() == owningWorld) { return super.getMetadata(block, metadataKey); } else { throw new IllegalArgumentException("Block does not belong to world " + owningWorld.getName()); } }
@EventHandler(priority = EventPriority.MONITOR) public void cloneCraftingWindow(final PlayerInteractEvent event) { if(!AntiGrief.CraftProtect.enabled()) { return; } if(!event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getPlayer().getOpenInventory().getType() == InventoryType.CRAFTING /* nothing open */) { Block block = event.getClickedBlock(); if(block != null && block.getType() == Material.WORKBENCH && !event.getPlayer().isSneaking()) { // create the window ourself event.setCancelled(true); event.getPlayer().openWorkbench(null, true); // doesn't check reachable } } }
public boolean execute(CommandSender sender, String[] args) { if (args.length != 1) { Chat.player(sender, "&cPlease include the name."); return true; } Course c = Course.get(args[0]); if (c == null) { Chat.player(sender, "&7[Parkour] Couldn't find the course, " + args[0]); return true; } Player p = (Player) sender; Block b = p.getTargetBlock(null, 10); if (b == null || b.getType() != Material.STONE_BUTTON) { Chat.player(sender, "&2[SG] &cThat is not a button"); return true; } Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.x", b.getX()); Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.y", b.getY()); Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.z", b.getZ()); Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.world", b.getWorld().getName()); Chat.player(sender, "&7[Parkour] &aEnd button added to " + c.getName()); Parkour.getInstance().saveConfig(); Parkour.getInstance().loadCourses(); return true; }
/** * Check if the Cuboid contains only blocks of the given type * * @param blockId - The block ID to check for * @return true if this Cuboid contains only blocks of the given type */ public boolean containsOnly(int blockId) { for (Block b : this) { if (b.getTypeId() != blockId) return false; } return true; }
protected void tick(Block b) { if (BlockStorage.getBlockInfo(b, "enabled").equals("false")) return; if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return; BlockMenu menu = BlockStorage.getInventory(b); StringBuilder builder = new StringBuilder(); int i = 0; for (int j = 0; j < 9; j++) { if (i > 0) { builder.append(" </slot> "); } ItemStack item = menu.getItemInSlot(getInputSlots()[j]); if (item != null && item.getAmount() == 1) return; builder.append(CustomItemSerializer.serialize(item, ItemFlag.DATA, ItemFlag.ITEMMETA_DISPLAY_NAME, ItemFlag.ITEMMETA_LORE, ItemFlag.MATERIAL)); i++; } String input = builder.toString(); if (recipes.containsKey(input)) { ItemStack output = recipes.get(input).clone(); if (fits(b, new ItemStack[] {output})) { pushItems(b, new ItemStack[] {output}); ChargableBlock.addCharge(b, -getEnergyConsumption()); for (int j = 0; j < 9; j++) { if (menu.getItemInSlot(getInputSlots()[j]) != null) menu.replaceExistingItem(getInputSlots()[j], InvUtils.decreaseItem(menu.getItemInSlot(getInputSlots()[j]), 1)); } } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockPistonRetract(BlockPistonRetractEvent event) { if(!this.tracker.isEnabled(event.getBlock().getWorld())) return; if(event.isSticky()) { Block newBlock = event.getBlock().getRelative(event.getDirection()); Block oldBlock = newBlock.getRelative(event.getDirection()); Player player = this.tracker.getPlacer(oldBlock); if(player != null) { this.tracker.setPlacer(oldBlock, null); this.tracker.setPlacer(newBlock, player); } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockExplode(EntityExplodeEvent event) { if (!this.tracker.isEnabled(event.getLocation().getWorld())) return; // Remove all blocks that are destroyed from explosion for (Block block : event.blockList()) { if (block.getType() == Material.DISPENSER) this.tracker.clearPlacer(block); } }
@EventWrapper public void onPrimeTNT(ExplosionPrimeEvent event) { if(event.getEntity() instanceof TNTPrimed && !(event instanceof InstantTNTPlaceEvent)) { Block block = event.getEntity().getLocation().getBlock(); if(block.getType() == Material.TNT) { ParticipantState player; if(event instanceof ExplosionPrimeByEntityEvent) { player = entityResolver.getOwner(((ExplosionPrimeByEntityEvent) event).getPrimer()); } else { player = null; } callEvent(event, block.getState(), BlockStateUtils.toAir(block), player); } } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void damageCheck(BlockDamageEvent event) { Block block = event.getBlock(); if(block.getWorld() != this.match.getWorld()) return; MatchPlayer player = this.match.getPlayer(event.getPlayer()); Vector center = BlockUtils.center(block).toVector(); for(Core core : this.cores) { if(!core.hasLeaked() && core.getCasingRegion().contains(center) && player.getParty() == core.getOwner()) { event.setCancelled(true); player.sendWarning(PGMTranslations.t("match.core.damageOwn", player), true); } } }