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.
This commit is contained in:
ryanhamshire 2015-12-03 17:48:44 -08:00
parent bf9f18e11c
commit 280db0e352
5 changed files with 35 additions and 13 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package me.ryanhamshire.GriefPrevention;
public enum CustomLogEntryTypes
{
SocialActivity,
SuspiciousActivity,
AdminActivity,
Debug,
Exception
}

View File

@ -180,12 +180,3 @@ class CustomLogger
} }
} }
} }
public enum CustomLogEntryTypes
{
SocialActivity,
SuspiciousActivity,
AdminActivity,
Debug,
Exception
}

View File

@ -763,8 +763,8 @@ public class EntityEventHandler implements Listener
PlayerData attackerData = this.dataStore.getPlayerData(attacker.getUniqueId()); PlayerData attackerData = this.dataStore.getPlayerData(attacker.getUniqueId());
if(attackerData.ignoreClaims) return; if(attackerData.ignoreClaims) return;
//otherwise disallow in non-pvp worlds //otherwise disallow in non-pvp worlds (and also pvp worlds if configured to do so)
if(!GriefPrevention.instance.pvpRulesApply(subEvent.getEntity().getLocation().getWorld())) if(!GriefPrevention.instance.pvpRulesApply(subEvent.getEntity().getLocation().getWorld()) || (GriefPrevention.instance.config_pvp_protectPets && subEvent.getEntityType() != EntityType.WOLF))
{ {
OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID); OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID);
String ownerName = owner.getName(); String ownerName = owner.getName();

View File

@ -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_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_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_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_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 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_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_allowLavaNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers", true);
this.config_pvp_allowFireNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers", true); this.config_pvp_allowFireNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers", true);
this.config_pvp_protectPets = config.getBoolean("GriefPrevention.PvP.ProtectPetsOutsideLandClaims", false);
//optional database settings //optional database settings
this.databaseUrl = config.getString("GriefPrevention.Database.URL", ""); this.databaseUrl = config.getString("GriefPrevention.Database.URL", "");
@ -777,6 +779,7 @@ public class GriefPrevention extends JavaPlugin
outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeSubdivisions", this.config_pvp_noCombatInAdminSubdivisions); outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeSubdivisions", this.config_pvp_noCombatInAdminSubdivisions);
outConfig.set("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers", this.config_pvp_allowLavaNearPlayers); 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.ClaimBlocksPurchaseCost", this.config_economy_claimBlocksPurchaseCost);
outConfig.set("GriefPrevention.Economy.ClaimBlocksSellValue", this.config_economy_claimBlocksSellValue); outConfig.set("GriefPrevention.Economy.ClaimBlocksSellValue", this.config_economy_claimBlocksSellValue);

View File

@ -1218,7 +1218,7 @@ class PlayerEventHandler implements Listener
return; return;
} }
if(!GriefPrevention.instance.pvpRulesApply(entity.getLocation().getWorld())) if(!GriefPrevention.instance.pvpRulesApply(entity.getLocation().getWorld()) || GriefPrevention.instance.config_pvp_protectPets)
{ {
//otherwise disallow //otherwise disallow
OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID); OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID);