From ed3188b37afd2fca05083afc654e067611096f80 Mon Sep 17 00:00:00 2001 From: destro174 <40720638+destro174@users.noreply.github.com> Date: Sat, 19 Feb 2022 21:06:41 +0100 Subject: [PATCH] Remove unused code --- .../ryanhamshire/GriefPrevention/Claim.java | 133 ------------------ .../CleanupUnusedClaimTask.java | 1 - .../GriefPrevention/DataStore.java | 4 - .../GriefPrevention/EntityEventHandler.java | 18 --- .../GriefPrevention/GriefPrevention.java | 2 - .../GriefPrevention/PlayerEventHandler.java | 3 +- 6 files changed, 1 insertion(+), 160 deletions(-) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java b/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java index 5f5fdfb..3b491c0 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/Claim.java @@ -116,66 +116,6 @@ public class Claim this.modifiedDate = Calendar.getInstance().getTime(); } - //players may only siege someone when he's not in an admin claim - //and when he has some level of permission in the claim - public boolean canSiege(Player defender) - { - if (this.isAdminClaim()) return false; - - if (this.checkPermission(defender, ClaimPermission.Access, null) != null) return false; - - return true; - } - - //removes any lava above sea level in a claim - //exclusionClaim is another claim indicating an sub-area to be excluded from this operation - //it may be null - public void removeSurfaceFluids(Claim exclusionClaim) - { - //don't do this for administrative claims - if (this.isAdminClaim()) return; - - //don't do it for very large claims - if (this.getArea() > 10000) return; - - } - - //determines whether or not a claim has surface lava - //used to warn players when they abandon their claims about automatic fluid cleanup - boolean hasSurfaceFluids() - { - Location lesser = this.getLesserBoundaryCorner(); - Location greater = this.getGreaterBoundaryCorner(); - - //don't bother for very large claims, too expensive - if (this.getArea() > 10000) return false; - - int seaLevel = 0; //clean up all fluids in the end - - //respect sea level in normal worlds - if (lesser.getWorld().getEnvironment() == Environment.NORMAL) - seaLevel = GriefPrevention.instance.getSeaLevel(lesser.getWorld()); - - for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) - { - for (int z = lesser.getBlockZ(); z <= greater.getBlockZ(); z++) - { - for (int y = seaLevel - 1; y <= lesser.getWorld().getMaxHeight(); y++) - { - //dodge the exclusion claim - Block block = lesser.getWorld().getBlockAt(x, y, z); - - if (block.getType() == Material.WATER || block.getType() == Material.LAVA) - { - return true; - } - } - } - } - - return false; - } - //main constructor. note that only creating a claim instance does nothing - a claim must be added to the data store to be effective Claim(Location lesserBoundaryCorner, Location greaterBoundaryCorner, UUID ownerID, List builderIDs, List containerIDs, List accessorIDs, List managerIDs, boolean inheritNothing, Long id) { @@ -753,79 +693,6 @@ public class Claim return new BoundingBox(this).intersects(new BoundingBox(otherClaim)); } - //whether more entities may be added to a claim - public String allowMoreEntities(boolean remove) - { - if (this.parent != null) return this.parent.allowMoreEntities(remove); - - //this rule only applies to creative mode worlds - if (!GriefPrevention.instance.creativeRulesApply(this.getLesserBoundaryCorner())) return null; - - //admin claims aren't restricted - if (this.isAdminClaim()) return null; - - //don't apply this rule to very large claims - if (this.getArea() > 10000) return null; - - //determine maximum allowable entity count, based on claim size - int maxEntities = this.getArea() / 50; - if (maxEntities == 0) return GriefPrevention.instance.dataStore.getMessage(Messages.ClaimTooSmallForEntities); - - //count current entities (ignoring players) - int totalEntities = 0; - ArrayList chunks = this.getChunks(); - for (Chunk chunk : chunks) - { - Entity[] entities = chunk.getEntities(); - for (Entity entity : entities) - { - if (!(entity instanceof Player) && this.contains(entity.getLocation(), false, false)) - { - totalEntities++; - if (remove && totalEntities > maxEntities) entity.remove(); - } - } - } - - if (totalEntities >= maxEntities) - return GriefPrevention.instance.dataStore.getMessage(Messages.TooManyEntitiesInClaim); - - return null; - } - - public String allowMoreActiveBlocks() - { - if (this.parent != null) return this.parent.allowMoreActiveBlocks(); - - //determine maximum allowable entity count, based on claim size - int maxActives = this.getArea() / 100; - if (maxActives == 0) - return GriefPrevention.instance.dataStore.getMessage(Messages.ClaimTooSmallForActiveBlocks); - - //count current actives - int totalActives = 0; - ArrayList chunks = this.getChunks(); - for (Chunk chunk : chunks) - { - BlockState[] actives = chunk.getTileEntities(); - for (BlockState active : actives) - { - if (BlockEventHandler.isActiveBlock(active)) - { - if (this.contains(active.getLocation(), false, false)) - { - totalActives++; - } - } - } - } - - if (totalActives >= maxActives) - return GriefPrevention.instance.dataStore.getMessage(Messages.TooManyActiveBlocksInClaim); - - return null; - } - //implements a strict ordering of claims, used to keep the claims collection sorted for faster searching boolean greaterThan(Claim otherClaim) { diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/CleanupUnusedClaimTask.java b/src/main/java/me/ryanhamshire/GriefPrevention/CleanupUnusedClaimTask.java index 5824968..dea34e1 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/CleanupUnusedClaimTask.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/CleanupUnusedClaimTask.java @@ -69,7 +69,6 @@ class CleanupUnusedClaimTask implements Runnable { if (expireEventCanceled()) return; - claim.removeSurfaceFluids(null); GriefPrevention.instance.dataStore.deleteClaim(claim, true, true); GriefPrevention.AddLogEntry(" " + claim.getOwnerName() + "'s new player claim expired.", CustomLogEntryTypes.AdminActivity); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java index 3450190..a00ec3b 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java @@ -1134,8 +1134,6 @@ public abstract class DataStore //delete them one by one for (Claim claim : claimsToDelete) { - claim.removeSurfaceFluids(null); - this.deleteClaim(claim, releasePets); } } @@ -1228,8 +1226,6 @@ public abstract class DataStore { smaller = true; - //remove surface fluids about to be unclaimed - oldClaim.removeSurfaceFluids(newClaim); } } diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index 5de2dcd..1834836 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -273,13 +273,6 @@ public class EntityEventHandler implements Listener return; } - // No modification in the wilderness in creative mode. - if (instance.creativeRulesApply(block.getLocation())) - { - event.setCancelled(true); - return; - } - // Unclaimed area is fair game. return; } @@ -479,17 +472,6 @@ public class EntityEventHandler implements Listener } } - //when an experience bottle explodes... - @EventHandler(priority = EventPriority.LOWEST) - public void onExpBottle(ExpBottleEvent event) - { - //if in a creative world, cancel the event (don't drop exp on the ground) - if (GriefPrevention.instance.creativeRulesApply(event.getEntity().getLocation())) - { - event.setExperience(0); - } - } - //when an entity dies... @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityDeath(EntityDeathEvent event) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 99a5127..a8b19bf 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -1893,7 +1893,6 @@ public class GriefPrevention extends JavaPlugin } else { - claim.removeSurfaceFluids(null); this.dataStore.deleteClaim(claim, true, true); GriefPrevention.sendMessage(player, TextMode.Success, Messages.DeleteSuccess); @@ -2733,7 +2732,6 @@ public class GriefPrevention extends JavaPlugin else { //delete it - claim.removeSurfaceFluids(null); this.dataStore.deleteClaim(claim, true, false); //adjust claim blocks when abandoning a top level claim diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 86ccc55..aef8e0b 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -1363,8 +1363,7 @@ class PlayerEventHandler implements Listener materialInHand == Material.FURNACE_MINECART || materialInHand == Material.CHEST_MINECART || materialInHand == Material.TNT_MINECART || - materialInHand == Material.HOPPER_MINECART) && - !instance.creativeRulesApply(clickedBlock.getLocation())) + materialInHand == Material.HOPPER_MINECART)) { if (playerData == null) playerData = this.dataStore.getPlayerData(player.getUniqueId()); Claim claim = this.dataStore.getClaimAt(clickedBlock.getLocation(), false, playerData.lastClaim);