diff --git a/Changelog.txt b/Changelog.txt index 5e4ae75aa..0340bfd4c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -17,7 +17,7 @@ Version 1.4.00-dev + Added '/ptp toggle' command, to disable party teleportation. + Added '/ptp accept' and '/ptp acceptall' commands + Added an 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 a permission to allow friendly fire in parties, both attacker and defender must have it for friendly fire to occur + 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 6f5999ae2..4f4796906 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -83,7 +83,6 @@ 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 13973198e..9212d639b 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -112,9 +112,11 @@ public class EntityListener implements Listener { return; } - if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker) && !Config.getInstance().getPartyFriendlyFire()) { - event.setCancelled(true); - return; + if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker)) { + if (!(Permissions.friendlyFire((Player) attacker) && Permissions.friendlyFire(defendingPlayer))) { + 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 7f5aff6a8..c9665c4d9 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -588,7 +588,7 @@ public final class CombatTools { return false; } - if (PartyManager.inSameParty(player, defender) && !Config.getInstance().getPartyFriendlyFire()) { + if (PartyManager.inSameParty(player, defender) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) { return false; } @@ -601,8 +601,13 @@ public final class CombatTools { } } else if (entity instanceof Tameable) { - if (Misc.isFriendlyPet(player, (Tameable) entity) && !Config.getInstance().getPartyFriendlyFire()) { - return false; + if (Misc.isFriendlyPet(player, (Tameable) entity)) { + // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party + // So we can make some assumptions here, about our casting and our check + Player owner = (Player) ((Tameable) entity).getOwner(); + if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire(owner))) { + return false; + } } } diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index 7d72507f6..4efc2fe13 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -689,4 +689,12 @@ public final class Permissions { public static boolean smelting(Player player) { return hasPermission(player, "mcmmo.skills.smelting"); } + + /* + * MCMMO.PARTY.* + */ + + public static boolean friendlyFire(Player player) { + return hasPermission(player, "mcmmo.party.friendlyfire"); + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a147570bc..204696402 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -67,8 +67,6 @@ 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 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 92df7d3c3..841e4b695 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -116,6 +116,7 @@ permissions: mcmmo.defaults: true mcmmo.defaultsop: true mcmmo.perks.all: true + mcmmo.party.all: true mcmmo.ability.*: default: false description: Implies all mcmmo.ability permissions. @@ -1032,6 +1033,19 @@ permissions: mcmmo.tools.all: true mcmmo.motd: description: Allows access to the motd + mcmmo.party.*: + default: false + description: Implies access to all mcmmo party permissions + children: + mcmmo.party.all: true + mcmmo.party.all: + default: false + description: Implies access to all mcmmo party permissions + children: + mcmmo.party.friendlyfire: true + mcmmo.party.friendlyfire: + default: false + description: Allows in-party friendly fire if both attacker and victim have this permission mcmmo.perks.*: default: false description: implies access to all mcmmo perks