From e52627f08db679bdd9a3d5f7bb2655d46e7c6556 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Wed, 21 Oct 2015 12:58:21 -0700 Subject: [PATCH] Added an option to prevent rabbits eating crops. --- src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java | 5 +++++ src/me/ryanhamshire/GriefPrevention/GriefPrevention.java | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index aea150f..e62bbb1 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -108,6 +108,11 @@ public class EntityEventHandler implements Listener { event.setCancelled(true); } + + else if(!GriefPrevention.instance.config_rabbitsEatCrops && event.getEntityType() == EntityType.RABBIT) + { + event.setCancelled(true); + } //don't allow the wither to break blocks, when the wither is determined, too expensive to constantly check for claimed blocks else if(event.getEntityType() == EntityType.WITHER && GriefPrevention.instance.config_claims_worldModes.get(event.getBlock().getWorld()) != ClaimsMode.Disabled) diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index b7d2b6d..606d9fd 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -162,6 +162,7 @@ public class GriefPrevention extends JavaPlugin public boolean config_endermenMoveBlocks; //whether or not endermen may move blocks around public boolean config_silverfishBreakBlocks; //whether silverfish may break blocks public boolean config_creaturesTrampleCrops; //whether or not non-player entities may trample crops + public boolean config_rabbitsEatCrops; //whether or not rabbits may eat crops public boolean config_zombiesBreakDoors; //whether or not hard-mode zombies may break down wooden doors public int config_ipLimit; //how many players can share an IP address @@ -562,6 +563,7 @@ public class GriefPrevention extends JavaPlugin this.config_endermenMoveBlocks = config.getBoolean("GriefPrevention.EndermenMoveBlocks", false); this.config_silverfishBreakBlocks = config.getBoolean("GriefPrevention.SilverfishBreakBlocks", false); this.config_creaturesTrampleCrops = config.getBoolean("GriefPrevention.CreaturesTrampleCrops", false); + this.config_rabbitsEatCrops = config.getBoolean("GriefPrevention.RabbitsEatCrops", true); this.config_zombiesBreakDoors = config.getBoolean("GriefPrevention.HardModeZombiesBreakDoors", false); this.config_mods_ignoreClaimsAccounts = config.getStringList("GriefPrevention.Mods.PlayersIgnoringAllClaims"); @@ -801,6 +803,7 @@ public class GriefPrevention extends JavaPlugin outConfig.set("GriefPrevention.EndermenMoveBlocks", this.config_endermenMoveBlocks); outConfig.set("GriefPrevention.SilverfishBreakBlocks", this.config_silverfishBreakBlocks); outConfig.set("GriefPrevention.CreaturesTrampleCrops", this.config_creaturesTrampleCrops); + outConfig.set("GriefPrevention.RabbitsEatCrops", this.config_rabbitsEatCrops); outConfig.set("GriefPrevention.HardModeZombiesBreakDoors", this.config_zombiesBreakDoors); outConfig.set("GriefPrevention.Database.URL", this.databaseUrl); @@ -2546,7 +2549,7 @@ public class GriefPrevention extends JavaPlugin //helper method to resolve a player by name ConcurrentHashMap playerNameToIDMap = new ConcurrentHashMap(); - //thread to build the above cache + //thread to build the above cache private class CacheOfflinePlayerNamesThread extends Thread { private OfflinePlayer [] offlinePlayers;