From 89eef2ce07e307a429908bb4509648fb1f797cbe Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Tue, 5 Feb 2013 14:35:51 +0100 Subject: [PATCH] Added new config options to allow friendly fire in parties. --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/config/Config.java | 1 + .../java/com/gmail/nossr50/listeners/EntityListener.java | 3 ++- .../com/gmail/nossr50/skills/utilities/CombatTools.java | 8 ++++++-- src/main/resources/config.yml | 3 +++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 179d3d907..bbe77a706 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -17,6 +17,7 @@ Version 1.4.00-dev + Added '/ptp toggle' command, to disable party teleportation. + Added '/ptp accept' and '/ptp acceptall' commands + Added a automatic party kick when a party member has been offline for 7 days (default) + + Added a config option to allow friendly fire in parties. + Added timeout on party teleport requests + Added XP bonus for Archery based on distance from shooter to target + Added ability to config Hylian Luck drops through treasures.yml diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 25ab5dbd4..b3bb507ae 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -82,6 +82,7 @@ public class Config extends ConfigLoader { /* PARTY SETTINGS */ public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); } public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); } + public boolean getPartyFriendlyFire() { return config.getBoolean("Party.FriendlyFire_Enabled", false); } public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); } public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1); } public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05); } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index bc9fdf379..13973198e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -27,6 +27,7 @@ import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; @@ -111,7 +112,7 @@ public class EntityListener implements Listener { return; } - if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker)) { + if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker) && !Config.getInstance().getPartyFriendlyFire()) { event.setCancelled(true); return; } diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index e851e4a55..87dc7deae 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -569,7 +569,11 @@ public final class CombatTools { if (entity instanceof Player) { Player defender = (Player) entity; - if (!defender.getWorld().getPVP() || defender == player || PartyManager.inSameParty(player, defender) || Users.getPlayer(defender).getProfile().getGodMode()) { + if (!defender.getWorld().getPVP() || defender == player || Users.getPlayer(defender).getProfile().getGodMode()) { + return false; + } + + if (PartyManager.inSameParty(player, defender) && !Config.getInstance().getPartyFriendlyFire()) { return false; } @@ -582,7 +586,7 @@ public final class CombatTools { } } else if (entity instanceof Tameable) { - if (Misc.isFriendlyPet(player, (Tameable) entity)) { + if (Misc.isFriendlyPet(player, (Tameable) entity) && !Config.getInstance().getPartyFriendlyFire()) { return false; } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0cf6f7599..a28ae0555 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -66,6 +66,9 @@ Party: AutoKick_Interval: 12 #Any user who hasn't connected in this many days will get kicked from their party Old_Party_Member_Cutoff: 7 + #Set this to true to allow party members to attack each other. + FriendlyFire_Enabled: false + #Settings for party share modes Sharing: ExpShare_enabled: true ExpShare_bonus_base: 1.1