Add Friendly Fire permission for parties

This removes the friendly fire config option previously created
Both attacker and defender must have this option

Closes #648
This commit is contained in:
NuclearW 2013-02-07 18:46:41 -05:00
parent 366940fc14
commit af1288b6f8
7 changed files with 36 additions and 10 deletions

View File

@ -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

View File

@ -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); }

View File

@ -112,11 +112,13 @@ public class EntityListener implements Listener {
return;
}
if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker) && !Config.getInstance().getPartyFriendlyFire()) {
if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker)) {
if (!(Permissions.friendlyFire((Player) attacker) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true);
return;
}
}
}
/* Check for invincibility */
if (defender instanceof LivingEntity) {

View File

@ -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,10 +601,15 @@ public final class CombatTools {
}
}
else if (entity instanceof Tameable) {
if (Misc.isFriendlyPet(player, (Tameable) entity) && !Config.getInstance().getPartyFriendlyFire()) {
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;
}
}
}
return true;
}

View File

@ -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");
}
}

View File

@ -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

View File

@ -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