Browse Source

Added new config options to allow friendly fire in parties.

TfT_02 12 years ago
parent
commit
89eef2ce07

+ 1 - 0
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

+ 1 - 0
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); }

+ 2 - 1
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;
             }

+ 6 - 2
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;
             }
         }

+ 3 - 0
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