New conf.json setting "permanentFactionMemberDenyCommands" (list, default empty), which can be used to prevent members of permanent factions from using specific commands.
Also, a minor fix for the help page regarding faction banks being shown if "bankEnabled" setting was enabled but "econEnabled" setting was false (economy as a whole disabled).
This commit is contained in:
parent
90d91180af
commit
03b368e9c4
@ -118,6 +118,9 @@ public class Conf
|
|||||||
|
|
||||||
public static int actionDeniedPainAmount = 1;
|
public static int actionDeniedPainAmount = 1;
|
||||||
|
|
||||||
|
// commands which will be prevented if the player is a member of a permanent faction
|
||||||
|
public static Set<String> permanentFactionMemberDenyCommands = new HashSet<String>();
|
||||||
|
|
||||||
// commands which will be prevented when in claimed territory of another faction
|
// commands which will be prevented when in claimed territory of another faction
|
||||||
public static Set<String> territoryNeutralDenyCommands = new HashSet<String>();
|
public static Set<String> territoryNeutralDenyCommands = new HashSet<String>();
|
||||||
public static Set<String> territoryEnemyDenyCommands = new HashSet<String>();
|
public static Set<String> territoryEnemyDenyCommands = new HashSet<String>();
|
||||||
|
@ -84,7 +84,7 @@ public class CmdHelp extends FCommand
|
|||||||
pageLines.add( p.cmdBase.cmdSethome.getUseageTemplate(true) );
|
pageLines.add( p.cmdBase.cmdSethome.getUseageTemplate(true) );
|
||||||
helpPages.add(pageLines);
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
if (Econ.isSetup() && Conf.bankEnabled)
|
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled)
|
||||||
{
|
{
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add( "" );
|
pageLines.add( "" );
|
||||||
|
@ -515,24 +515,11 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
|
|
||||||
public static boolean preventCommand(String fullCmd, Player player)
|
public static boolean preventCommand(String fullCmd, Player player)
|
||||||
{
|
{
|
||||||
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty()))
|
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty()))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer me = FPlayers.i.get(player);
|
FPlayer me = FPlayers.i.get(player);
|
||||||
|
|
||||||
if (!me.isInOthersTerritory())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Relation rel = me.getRelationToLocation();
|
|
||||||
if (rel.isAtLeast(Relation.ALLY))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String shortCmd; // command without the slash at the beginning
|
String shortCmd; // command without the slash at the beginning
|
||||||
if (fullCmd.startsWith("/"))
|
if (fullCmd.startsWith("/"))
|
||||||
shortCmd = fullCmd.substring(1);
|
shortCmd = fullCmd.substring(1);
|
||||||
@ -542,6 +529,34 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
fullCmd = "/" + fullCmd;
|
fullCmd = "/" + fullCmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
me.hasFaction()
|
||||||
|
&&
|
||||||
|
! me.isAdminBypassing()
|
||||||
|
&&
|
||||||
|
! Conf.permanentFactionMemberDenyCommands.isEmpty()
|
||||||
|
&&
|
||||||
|
me.getFaction().isPermanent()
|
||||||
|
&&
|
||||||
|
isCommandInList(fullCmd, shortCmd, Conf.permanentFactionMemberDenyCommands.iterator())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
me.msg("<b>You can't use the command \""+fullCmd+"\" because you are in a permanent faction.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!me.isInOthersTerritory())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Relation rel = me.getRelationToLocation();
|
||||||
|
if (rel.isAtLeast(Relation.ALLY))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
rel.isNeutral()
|
rel.isNeutral()
|
||||||
@ -549,37 +564,34 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
! Conf.territoryNeutralDenyCommands.isEmpty()
|
! Conf.territoryNeutralDenyCommands.isEmpty()
|
||||||
&&
|
&&
|
||||||
! me.isAdminBypassing()
|
! me.isAdminBypassing()
|
||||||
|
&&
|
||||||
|
isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())
|
||||||
)
|
)
|
||||||
{
|
|
||||||
Iterator<String> iter = Conf.territoryNeutralDenyCommands.iterator();
|
|
||||||
String cmdCheck;
|
|
||||||
while (iter.hasNext())
|
|
||||||
{
|
|
||||||
cmdCheck = iter.next();
|
|
||||||
if (cmdCheck == null)
|
|
||||||
{
|
|
||||||
iter.remove();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmdCheck = cmdCheck.toLowerCase();
|
|
||||||
if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck))
|
|
||||||
{
|
{
|
||||||
me.msg("<b>You can't use the command \""+fullCmd+"\" in neutral territory.");
|
me.msg("<b>You can't use the command \""+fullCmd+"\" in neutral territory.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if
|
||||||
else if
|
|
||||||
(
|
(
|
||||||
rel.isEnemy()
|
rel.isEnemy()
|
||||||
&&
|
&&
|
||||||
! Conf.territoryEnemyDenyCommands.isEmpty()
|
! Conf.territoryEnemyDenyCommands.isEmpty()
|
||||||
&&
|
&&
|
||||||
! me.isAdminBypassing()
|
! me.isAdminBypassing()
|
||||||
|
&&
|
||||||
|
isCommandInList(fullCmd, shortCmd, Conf.territoryEnemyDenyCommands.iterator())
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Iterator<String> iter = Conf.territoryEnemyDenyCommands.iterator();
|
me.msg("<b>You can't use the command \""+fullCmd+"\" in enemy territory.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isCommandInList(String fullCmd, String shortCmd, Iterator<String> iter)
|
||||||
|
{
|
||||||
String cmdCheck;
|
String cmdCheck;
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
@ -592,12 +604,8 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
|
|
||||||
cmdCheck = cmdCheck.toLowerCase();
|
cmdCheck = cmdCheck.toLowerCase();
|
||||||
if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck))
|
if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck))
|
||||||
{
|
|
||||||
me.msg("<b>You can't use the command \""+fullCmd+"\" in enemy territory.");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user