From 280db0e35209c086953ea8a4eb4b9ae241cc8aed Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Thu, 3 Dec 2015 17:48:44 -0800 Subject: [PATCH] Config option to protect pets in PvP. Was previously always not protecting pets in PvP worlds. That is still the default, but added an option to protect them (except wolves which can attack players) in those worlds. --- .../GriefPrevention/CustomLogEntryTypes.java | 28 +++++++++++++++++++ .../GriefPrevention/CustomLogger.java | 9 ------ .../GriefPrevention/EntityEventHandler.java | 4 +-- .../GriefPrevention/GriefPrevention.java | 5 +++- .../GriefPrevention/PlayerEventHandler.java | 2 +- 5 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 src/me/ryanhamshire/GriefPrevention/CustomLogEntryTypes.java diff --git a/src/me/ryanhamshire/GriefPrevention/CustomLogEntryTypes.java b/src/me/ryanhamshire/GriefPrevention/CustomLogEntryTypes.java new file mode 100644 index 0000000..1db8e90 --- /dev/null +++ b/src/me/ryanhamshire/GriefPrevention/CustomLogEntryTypes.java @@ -0,0 +1,28 @@ +/* + GriefPrevention Server Plugin for Minecraft + Copyright (C) 2015 Ryan Hamshire + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +package me.ryanhamshire.GriefPrevention; + +public enum CustomLogEntryTypes +{ + SocialActivity, + SuspiciousActivity, + AdminActivity, + Debug, + Exception +} diff --git a/src/me/ryanhamshire/GriefPrevention/CustomLogger.java b/src/me/ryanhamshire/GriefPrevention/CustomLogger.java index 9a56faf..a547f42 100644 --- a/src/me/ryanhamshire/GriefPrevention/CustomLogger.java +++ b/src/me/ryanhamshire/GriefPrevention/CustomLogger.java @@ -180,12 +180,3 @@ class CustomLogger } } } - -public enum CustomLogEntryTypes -{ - SocialActivity, - SuspiciousActivity, - AdminActivity, - Debug, - Exception -} diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index e62bbb1..e51091a 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -763,8 +763,8 @@ public class EntityEventHandler implements Listener PlayerData attackerData = this.dataStore.getPlayerData(attacker.getUniqueId()); if(attackerData.ignoreClaims) return; - //otherwise disallow in non-pvp worlds - if(!GriefPrevention.instance.pvpRulesApply(subEvent.getEntity().getLocation().getWorld())) + //otherwise disallow in non-pvp worlds (and also pvp worlds if configured to do so) + if(!GriefPrevention.instance.pvpRulesApply(subEvent.getEntity().getLocation().getWorld()) || (GriefPrevention.instance.config_pvp_protectPets && subEvent.getEntityType() != EntityType.WOLF)) { OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID); String ownerName = owner.getName(); diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 106857d..cd149da 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -138,6 +138,7 @@ public class GriefPrevention extends JavaPlugin public boolean config_pvp_noCombatInAdminSubdivisions; //whether players may fight in subdivisions of admin-owned land claims public boolean config_pvp_allowLavaNearPlayers; //whether players may dump lava near other players in pvp worlds public boolean config_pvp_allowFireNearPlayers; //whether players may start flint/steel fires near other players in pvp worlds + public boolean config_pvp_protectPets; //whether players may damage pets outside of land claims in pvp worlds public boolean config_lockDeathDropsInPvpWorlds; //whether players' dropped on death items are protected in pvp worlds public boolean config_lockDeathDropsInNonPvpWorlds; //whether players' dropped on death items are protected in non-pvp worlds @@ -701,6 +702,7 @@ public class GriefPrevention extends JavaPlugin this.config_pvp_noCombatInAdminSubdivisions = config.getBoolean("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeSubdivisions", this.config_siege_enabledWorlds.size() == 0); this.config_pvp_allowLavaNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers", true); this.config_pvp_allowFireNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers", true); + this.config_pvp_protectPets = config.getBoolean("GriefPrevention.PvP.ProtectPetsOutsideLandClaims", false); //optional database settings this.databaseUrl = config.getString("GriefPrevention.Database.URL", ""); @@ -776,7 +778,8 @@ public class GriefPrevention extends JavaPlugin outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeClaims", this.config_pvp_noCombatInAdminLandClaims); outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeSubdivisions", this.config_pvp_noCombatInAdminSubdivisions); outConfig.set("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers", this.config_pvp_allowLavaNearPlayers); - outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers", this.config_pvp_allowFireNearPlayers); + outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers", this.config_pvp_allowFireNearPlayers); + outConfig.set("GriefPrevention.PvP.ProtectPetsOutsideLandClaims", this.config_pvp_protectPets); outConfig.set("GriefPrevention.Economy.ClaimBlocksPurchaseCost", this.config_economy_claimBlocksPurchaseCost); outConfig.set("GriefPrevention.Economy.ClaimBlocksSellValue", this.config_economy_claimBlocksSellValue); diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 6f84fa4..a3f74b8 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -1218,7 +1218,7 @@ class PlayerEventHandler implements Listener return; } - if(!GriefPrevention.instance.pvpRulesApply(entity.getLocation().getWorld())) + if(!GriefPrevention.instance.pvpRulesApply(entity.getLocation().getWorld()) || GriefPrevention.instance.config_pvp_protectPets) { //otherwise disallow OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID);