New setting "playersWhoBypassAllProtection" (default empty), which is a list of player names that should always bypass normal faction protections such as block destruction and placement. This is primarily for use with other plugins/mods which use a fake player to take action, which shouldn't necessarily be subject to protections provided by Factions. Note that case is important; you must preserve the exact capitalization of the name.

As with every other setting, you are advised to use /f config to modify it. Example: /f config playersWhoBypassAllProtection fakePluginPlayerName  - add/remove the specified player name

Also switched several HashSets in Conf.java to LinkedHashSets. LinkedHashSets do have slower insertion and deletion than HashSets, but importantly they have faster lookup speed (at least until you get up to several hundred entries).
This commit is contained in:
Brettflan 2012-03-11 13:36:07 -05:00
parent 6931b3e204
commit 4db904182e
4 changed files with 28 additions and 18 deletions

View File

@ -126,11 +126,11 @@ public class Conf
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>();
public static Set<String> permanentFactionMemberDenyCommands = new LinkedHashSet<String>();
// commands which will be prevented when in claimed territory of another faction
public static Set<String> territoryNeutralDenyCommands = new HashSet<String>();
public static Set<String> territoryEnemyDenyCommands = new HashSet<String>();
public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<String>();
public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<String>();
public static double territoryShieldFactor = 0.3;
public static boolean territoryDenyBuild = true;
@ -262,10 +262,13 @@ public class Conf
public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
public static Set<String> worldsNoClaiming = new HashSet<String>();
public static Set<String> worldsNoPowerLoss = new HashSet<String>();
public static Set<String> worldsIgnorePvP = new HashSet<String>();
public static Set<String> worldsNoWildernessProtection = new HashSet<String>();
// mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections
public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<String>();
public static Set<String> worldsNoClaiming = new LinkedHashSet<String>();
public static Set<String> worldsNoPowerLoss = new LinkedHashSet<String>();
public static Set<String> worldsIgnorePvP = new LinkedHashSet<String>();
public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>();
public static transient int mapHeight = 8;
public static transient int mapWidth = 39;

View File

@ -170,10 +170,11 @@ public class FactionsBlockListener implements Listener
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck)
{
FPlayer me = FPlayers.i.get(player);
String name = player.getName();
if (Conf.playersWhoBypassAllProtection.contains(name)) return true;
if (me.isAdminBypassing())
return true;
FPlayer me = FPlayers.i.get(name);
if (me.isAdminBypassing()) return true;
FLocation loc = new FLocation(location);
Faction otherFaction = Board.getFactionAt(loc);

View File

@ -330,6 +330,8 @@ public class FactionsEntityListener implements Listener
if (attacker == null || attacker.getPlayer() == null)
return true;
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
if (attacker.hasLoginPvpDisabled())
{
if (notify) attacker.msg("<i>You can't hurt other players for " + Conf.noPVPDamageToOthersForXSecondsAfterLogin + " seconds after logging in.");

View File

@ -260,9 +260,11 @@ public class FactionsPlayerListener implements Listener
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck)
{
FPlayer me = FPlayers.i.get(player);
if (me.isAdminBypassing())
return true;
String name = player.getName();
if (Conf.playersWhoBypassAllProtection.contains(name)) return true;
FPlayer me = FPlayers.i.get(name);
if (me.isAdminBypassing()) return true;
FLocation loc = new FLocation(location);
Faction otherFaction = Board.getFactionAt(loc);
@ -335,9 +337,11 @@ public class FactionsPlayerListener implements Listener
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck)
{
FPlayer me = FPlayers.i.get(player);
if (me.isAdminBypassing())
return true;
String name = player.getName();
if (Conf.playersWhoBypassAllProtection.contains(name)) return true;
FPlayer me = FPlayers.i.get(name);
if (me.isAdminBypassing()) return true;
Material material = block.getType();
FLocation loc = new FLocation(block);