From 088c6e11b1e691eb6b25e78dbaff669517a3cc95 Mon Sep 17 00:00:00 2001 From: drtshock Date: Tue, 8 Sep 2015 11:39:21 -0500 Subject: [PATCH] Add options to block commands in wilderness and ally territory. Adds #514 --- src/main/java/com/massivecraft/factions/Conf.java | 2 ++ .../java/com/massivecraft/factions/Faction.java | 3 +++ .../factions/listeners/FactionsPlayerListener.java | 13 ++++++++----- .../factions/zcore/persist/MemoryFaction.java | 4 ++++ .../com/massivecraft/factions/zcore/util/TL.java | 2 ++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index 42e16c0a..89d75b1e 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -148,7 +148,9 @@ public class Conf { // commands which will be prevented when in claimed territory of another faction public static Set territoryNeutralDenyCommands = new LinkedHashSet(); public static Set territoryEnemyDenyCommands = new LinkedHashSet(); + public static Set territoryAllyDenyCommands = new LinkedHashSet(); public static Set warzoneDenyCommands = new LinkedHashSet(); + public static Set wildernessDenyCommands = new LinkedHashSet(); public static boolean territoryDenyBuild = true; public static boolean territoryDenyBuildWhenOffline = true; diff --git a/src/main/java/com/massivecraft/factions/Faction.java b/src/main/java/com/massivecraft/factions/Faction.java index 07ad3804..e8a53a62 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -107,8 +107,11 @@ public interface Faction extends EconomyParticipator { public boolean isNormal(); + @Deprecated public boolean isNone(); + public boolean isWilderness(); + public boolean isSafeZone(); public boolean isWarZone(); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 788a1324..84d6948a 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -498,12 +498,15 @@ public class FactionsPlayerListener implements Listener { return true; } - if (!me.isInOthersTerritory()) { - return false; + Faction at = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); + if (at.isWilderness() && !Conf.wildernessDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.wildernessDenyCommands.iterator())) { + me.msg(TL.PLAYER_COMMAND_WILDERNESS, fullCmd); + return true; } - Relation rel = me.getRelationToLocation(); - if (rel.isAtLeast(Relation.ALLY)) { + Relation rel = at.getRelationTo(me); + if (rel.isAlly() && !Conf.territoryAllyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryAllyDenyCommands.iterator())) { + me.msg(TL.PLAYER_COMMAND_ALLY, fullCmd); return false; } @@ -517,7 +520,7 @@ public class FactionsPlayerListener implements Listener { return true; } - if (Board.getInstance().getFactionAt(new FLocation(me)).isWarZone() && !Conf.warzoneDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.warzoneDenyCommands.iterator())) { + if (at.isWarZone() && !Conf.warzoneDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.warzoneDenyCommands.iterator())) { me.msg(TL.PLAYER_COMMAND_WARZONE, fullCmd); return true; } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index d6da8636..d2c5ecf3 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -359,6 +359,10 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return this.getId().equals("0"); } + public boolean isWilderness() { + return this.getId().equals("0"); + } + public boolean isSafeZone() { return this.getId().equals("-1"); } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index fa71409f..3f4c7537 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -659,6 +659,8 @@ public enum TL { PLAYER_COMMAND_NEUTRAL("You can't use the command '%s' in neutral territory."), PLAYER_COMMAND_ENEMY("You can't use the command '%s' in enemy territory."), PLAYER_COMMAND_PERMANENT("You can't use the command '%s' because you are in a permanent faction."), + PLAYER_COMMAND_ALLY("You can't use the command '%s' in ally territory."), + PLAYER_COMMAND_WILDERNESS("You can't use the command '%s' in the wilderness."), PLAYER_POWER_NOLOSS_PEACEFUL("You didn't lose any power since you are in a peaceful faction."), PLAYER_POWER_NOLOSS_WORLD("You didn't lose any power due to the world you died in."),