From 6b7312bcf8e002e6e7a255b0b32dd618be00c86f Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 23 Apr 2013 09:17:30 +0200 Subject: [PATCH] Move deny commands from ConfServer to UConf. --- src/com/massivecraft/factions/ConfServer.java | 33 ++++++++++++++----- .../massivecraft/factions/entity/MPlayer.java | 1 + .../massivecraft/factions/entity/UConf.java | 22 +++++++++++++ .../listeners/FactionsListenerMain.java | 6 ++-- 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/com/massivecraft/factions/ConfServer.java b/src/com/massivecraft/factions/ConfServer.java index 34bd6145..35e677ef 100644 --- a/src/com/massivecraft/factions/ConfServer.java +++ b/src/com/massivecraft/factions/ConfServer.java @@ -42,13 +42,23 @@ public class ConfServer extends SimpleConfig public static double homesTeleportAllowedEnemyDistance = 32.0; public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; + // -------------------------------------------- // + // PVP + // -------------------------------------------- // + public static boolean disablePVPForFactionlessPlayers = false; public static boolean enablePVPAgainstFactionlessInAttackersLand = false; - - //public static boolean peacefulMembersDisablePowerLoss = true; + + // -------------------------------------------- // + // ASSORTED + // -------------------------------------------- // public static boolean permanentFactionsDisableLeaderPromotion = false; + // -------------------------------------------- // + // CLAIMS + // -------------------------------------------- // + public static boolean claimsMustBeConnected = false; public static boolean claimingFromOthersAllowed = true; public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true; @@ -60,19 +70,24 @@ public class ConfServer extends SimpleConfig //public static double considerFactionsReallyOfflineAfterXMinutes = 0.0; + // -------------------------------------------- // + // ASSORTED + // -------------------------------------------- // + public static int actionDeniedPainAmount = 2; - - // commands which will be prevented if the player is a member of a permanent faction - public static Set permanentFactionMemberDenyCommands = new LinkedHashSet(); - - // commands which will be prevented when in claimed territory of another faction - public static Set territoryNeutralDenyCommands = new LinkedHashSet(); - public static Set territoryEnemyDenyCommands = MUtil.set("home", "sethome", "spawn", "tpahere", "tpaccept", "tpa", "warp"); + + // -------------------------------------------- // + // ASSORTED + // -------------------------------------------- // public static double territoryShieldFactor = 0.3; // for claimed areas where further faction-member ownership can be defined + // -------------------------------------------- // + // ASSORTED + // -------------------------------------------- // + public static boolean pistonProtectionThroughDenyBuild = true; // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/entity/MPlayer.java b/src/com/massivecraft/factions/entity/MPlayer.java index dd4d0c8b..8cec823f 100644 --- a/src/com/massivecraft/factions/entity/MPlayer.java +++ b/src/com/massivecraft/factions/entity/MPlayer.java @@ -37,5 +37,6 @@ public class MPlayer extends SenderEntity // -------------------------------------------- // // FIELDS // -------------------------------------------- // + } diff --git a/src/com/massivecraft/factions/entity/UConf.java b/src/com/massivecraft/factions/entity/UConf.java index c0ebcc27..c7bd32ad 100644 --- a/src/com/massivecraft/factions/entity/UConf.java +++ b/src/com/massivecraft/factions/entity/UConf.java @@ -1,5 +1,7 @@ package com.massivecraft.factions.entity; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Set; @@ -8,6 +10,7 @@ import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Rel; import com.massivecraft.mcore.store.Entity; +import com.massivecraft.mcore.util.MUtil; public class UConf extends Entity { @@ -64,4 +67,23 @@ public class UConf extends Entity public double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts) + // -------------------------------------------- // + // DENY COMMANDS + // -------------------------------------------- // + + // commands which will be prevented if the player is a member of a permanent faction + public List denyCommandsPermanentFactionMember = new ArrayList(); + + // commands which will be prevented when in claimed territory of another faction + public List denyCommandsTerritoryNeutral = new ArrayList(); + public List denyCommandsTerritoryEnemy = MUtil.list( + "home", + "sethome", + "spawn", + "tpahere", + "tpaccept", + "tpa", + "warp" + ); + } diff --git a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java index eddd92ed..8c618c8d 100644 --- a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -342,7 +342,7 @@ public class FactionsListenerMain implements Listener command = command.toLowerCase(); command = command.trim(); - if (uplayer.hasFaction() && uplayer.getFaction().getFlag(FFlag.PERMANENT) && containsCommand(command, ConfServer.permanentFactionMemberDenyCommands)) + if (uplayer.hasFaction() && uplayer.getFaction().getFlag(FFlag.PERMANENT) && containsCommand(command, UConf.get(player).denyCommandsPermanentFactionMember)) { uplayer.msg("You can't use \"/%s\" as member of a permanent faction.", command); event.setCancelled(true); @@ -353,14 +353,14 @@ public class FactionsListenerMain implements Listener PS ps = PS.valueOf(player).getChunk(true); if (BoardColls.get().getFactionAt(ps).isNone()) return; - if (rel == Rel.NEUTRAL && containsCommand(command, ConfServer.territoryNeutralDenyCommands)) + if (rel == Rel.NEUTRAL && containsCommand(command, UConf.get(player).denyCommandsTerritoryNeutral)) { uplayer.msg("You can't use \"/%s\" in neutral territory.", command); event.setCancelled(true); return; } - if (rel == Rel.ENEMY && containsCommand(command, ConfServer.territoryEnemyDenyCommands)) + if (rel == Rel.ENEMY && containsCommand(command, UConf.get(player).denyCommandsTerritoryEnemy)) { uplayer.msg("You can't use \"/%s\" in enemy territory.", command); event.setCancelled(true);