From d861688c043e3cbe44c18299979b82b22695bd57 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Sun, 3 May 2015 13:17:45 -0700 Subject: [PATCH] Better config control over villager protections. Now disabling creature protections allows players to injure villagers without permission in land claims, and whether trading with villagers requires permission is now an option in the config file, with default on. --- src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java | 3 +++ src/me/ryanhamshire/GriefPrevention/GriefPrevention.java | 3 +++ src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index 7a93b39..220581b 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -662,6 +662,9 @@ class EntityEventHandler implements Listener || subEvent.getEntityType() == EntityType.ARMOR_STAND || subEvent.getEntityType() == EntityType.VILLAGER) { + //allow for disabling villager protections in the config + if(subEvent.getEntityType() == EntityType.VILLAGER && !GriefPrevention.instance.config_claims_protectCreatures) return; + //decide whether it's claimed Claim cachedClaim = null; PlayerData playerData = null; diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 1912cca..d929aaa 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -89,6 +89,7 @@ public class GriefPrevention extends JavaPlugin public int config_claims_maxClaimsPerPlayer; //maximum number of claims per player public boolean config_claims_respectWorldGuard; //whether claim creations requires WG build permission in creation area public boolean config_claims_portalsRequirePermission; //whether nether portals require permission to generate. defaults to off for performance reasons + public boolean config_claims_villagerTradingRequiresTrust; //whether trading with a claimed villager requires permission public int config_claims_initialBlocks; //the number of claim blocks a new player starts with public double config_claims_abandonReturnRatio; //the portion of claim blocks returned to a player when a claim is abandoned @@ -506,6 +507,7 @@ public class GriefPrevention extends JavaPlugin this.config_claims_maxClaimsPerPlayer = config.getInt("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", 0); this.config_claims_respectWorldGuard = config.getBoolean("GriefPrevention.Claims.CreationRequiresWorldGuardBuildPermission", true); this.config_claims_portalsRequirePermission = config.getBoolean("GriefPrevention.Claims.PortalGenerationRequiresPermission", false); + this.config_claims_villagerTradingRequiresTrust = config.getBoolean("GriefPrevention.Claims.VillagerTradingRequiresPermission", true); String accessTrustSlashCommands = config.getString("GriefPrevention.Claims.CommandsRequiringAccessTrust", "/sethome"); this.config_spam_enabled = config.getBoolean("GriefPrevention.Spam.Enabled", true); @@ -728,6 +730,7 @@ public class GriefPrevention extends JavaPlugin outConfig.set("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", this.config_claims_maxClaimsPerPlayer); outConfig.set("GriefPrevention.Claims.CreationRequiresWorldGuardBuildPermission", this.config_claims_respectWorldGuard); outConfig.set("GriefPrevention.Claims.PortalGenerationRequiresPermission", this.config_claims_portalsRequirePermission); + outConfig.set("GriefPrevention.Claims.VillagerTradingRequiresPermission", this.config_claims_villagerTradingRequiresTrust); outConfig.set("GriefPrevention.Claims.CommandsRequiringAccessTrust", accessTrustSlashCommands); outConfig.set("GriefPrevention.Spam.Enabled", this.config_spam_enabled); diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index f222877..09ad9e4 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -1125,7 +1125,7 @@ class PlayerEventHandler implements Listener } //if the entity is an animal, apply container rules - if(GriefPrevention.instance.config_claims_preventTheft && (entity instanceof Animals || entity.getType() == EntityType.VILLAGER)) + if((GriefPrevention.instance.config_claims_preventTheft && entity instanceof Animals) || (entity.getType() == EntityType.VILLAGER && GriefPrevention.instance.config_claims_villagerTradingRequiresTrust)) { //if the entity is in a claim Claim claim = this.dataStore.getClaimAt(entity.getLocation(), false, null);