Add options to block commands in wilderness and ally territory. Adds #514

This commit is contained in:
drtshock 2015-09-08 11:39:21 -05:00
parent 1fa2abcc88
commit 088c6e11b1
5 changed files with 19 additions and 5 deletions

View File

@ -148,7 +148,9 @@ public class Conf {
// commands which will be prevented when in claimed territory of another faction
public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<String>();
public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<String>();
public static Set<String> territoryAllyDenyCommands = new LinkedHashSet<String>();
public static Set<String> warzoneDenyCommands = new LinkedHashSet<String>();
public static Set<String> wildernessDenyCommands = new LinkedHashSet<String>();
public static boolean territoryDenyBuild = true;
public static boolean territoryDenyBuildWhenOffline = true;

View File

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

View File

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

View File

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

View File

@ -659,6 +659,8 @@ public enum TL {
PLAYER_COMMAND_NEUTRAL("<b>You can't use the command '%s' in neutral territory."),
PLAYER_COMMAND_ENEMY("<b>You can't use the command '%s' in enemy territory."),
PLAYER_COMMAND_PERMANENT("<b>You can't use the command '%s' because you are in a permanent faction."),
PLAYER_COMMAND_ALLY("<b>You can't use the command '%s' in ally territory."),
PLAYER_COMMAND_WILDERNESS("<b>You can't use the command '%s' in the wilderness."),
PLAYER_POWER_NOLOSS_PEACEFUL("<i>You didn't lose any power since you are in a peaceful faction."),
PLAYER_POWER_NOLOSS_WORLD("<i>You didn't lose any power due to the world you died in."),