Dont confuse constants and configuration options.

This commit is contained in:
Olof Larsson 2013-04-10 12:52:22 +02:00
parent 44493bbea3
commit c4868935ed
8 changed files with 99 additions and 79 deletions

View File

@ -190,8 +190,8 @@ public class Board
Faction factionLoc = getFactionAt(flocation); Faction factionLoc = getFactionAt(flocation);
ret.add(Txt.titleize("("+flocation.getCoordString()+") "+factionLoc.getTag(observer))); ret.add(Txt.titleize("("+flocation.getCoordString()+") "+factionLoc.getTag(observer)));
int halfWidth = ConfServer.mapWidth / 2; int halfWidth = Const.MAP_WIDTH / 2;
int halfHeight = ConfServer.mapHeight / 2; int halfHeight = Const.MAP_HEIGHT / 2;
FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight); FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight);
int width = halfWidth * 2 + 1; int width = halfWidth * 2 + 1;
int height = halfHeight * 2 + 1; int height = halfHeight * 2 + 1;
@ -225,7 +225,7 @@ public class Board
else else
{ {
if (!fList.containsKey(factionHere)) if (!fList.containsKey(factionHere))
fList.put(factionHere, ConfServer.mapKeyChrs[chrIdx++]); fList.put(factionHere, Const.MAP_KEY_CHARS[chrIdx++]);
char fchar = fList.get(factionHere); char fchar = fList.get(factionHere);
row += factionHere.getColorTo(observer) + "" + fchar; row += factionHere.getColorTo(observer) + "" + fchar;
} }

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions;
import java.util.*; import java.util.*;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.EntityType;
import com.massivecraft.mcore.SimpleConfig; import com.massivecraft.mcore.SimpleConfig;
import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.MUtil;
@ -83,7 +82,6 @@ public class ConfServer extends SimpleConfig
public static boolean chatParseTags = true; public static boolean chatParseTags = true;
public static boolean chatParseTagsColored = false; public static boolean chatParseTagsColored = false;
public static Map<String, String> chatSingleFormats = new HashMap<String, String>(); public static Map<String, String> chatSingleFormats = new HashMap<String, String>();
public static transient boolean chatTagHandledByAnotherPlugin = false; // Why do we need this? (Olof asks)
public static String chatTagFormat = "%s"+ChatColor.WHITE; // This one is almost deprecated now right? or is it? public static String chatTagFormat = "%s"+ChatColor.WHITE; // This one is almost deprecated now right? or is it?
// Herochat // Herochat
@ -188,17 +186,6 @@ public class ConfServer extends SimpleConfig
public static boolean pistonProtectionThroughDenyBuild = true; public static boolean pistonProtectionThroughDenyBuild = true;
public final transient static Set<Material> materialsEditOnInteract = EnumSet.noneOf(Material.class);
public final transient static Set<Material> materialsEditTools = EnumSet.noneOf(Material.class);
public final transient static Set<Material> materialsDoor = EnumSet.noneOf(Material.class);
public final transient static Set<Material> materialsContainer = EnumSet.noneOf(Material.class);
//public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
//public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class);
// TODO: Rename to monsterCreatureTypes
public static transient Set<EntityType> monsters = EnumSet.noneOf(EntityType.class);
// Spout features // Spout features
public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads
public static boolean spoutFactionTitlesOverNames = true; // whether to include player's title in that public static boolean spoutFactionTitlesOverNames = true; // whether to include player's title in that
@ -211,7 +198,16 @@ public class ConfServer extends SimpleConfig
public static double spoutHealthBarSolidsPerEmpty = 1d; public static double spoutHealthBarSolidsPerEmpty = 1d;
public static String spoutHealthBarColorTag = "{c}"; public static String spoutHealthBarColorTag = "{c}";
public static int spoutHealthBarWidth = 30; public static int spoutHealthBarWidth = 30;
public static Map<Double, String> spoutHealthBarColorUnderQuota = new LinkedHashMap<Double, String>();
public static Map<Double, String> spoutHealthBarColorUnderQuota = MUtil.map(
1.0d, "&2",
0.8d, "&a",
0.5d, "&e",
0.4d, "&6",
0.3d, "&c",
0.2d, "&4"
);
public static boolean spoutCapes = true; // Show faction capes public static boolean spoutCapes = true; // Show faction capes
public static int spoutTerritoryDisplayPosition = 1; // permanent territory display, instead of by chat; 0 = disabled, 1 = top left, 2 = top center, 3+ = top right public static int spoutTerritoryDisplayPosition = 1; // permanent territory display, instead of by chat; 0 = disabled, 1 = top left, 2 = top center, 3+ = top right
public static float spoutTerritoryDisplaySize = 1.0f; // text scale (size) for territory display public static float spoutTerritoryDisplaySize = 1.0f; // text scale (size) for territory display
@ -269,9 +265,7 @@ public class ConfServer extends SimpleConfig
// TODO: A better solution Would be to have One wilderness faction per world. // TODO: A better solution Would be to have One wilderness faction per world.
//public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>(); //public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>();
public static transient int mapHeight = 8;
public static transient int mapWidth = 39;
public static transient char[] mapKeyChrs = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray();
static static
{ {
@ -290,56 +284,6 @@ public class ConfServer extends SimpleConfig
chatSingleFormats.put("pl", " %s"); chatSingleFormats.put("pl", " %s");
chatSingleFormats.put("pr", "%s "); chatSingleFormats.put("pr", "%s ");
chatSingleFormats.put("pb", " %s "); chatSingleFormats.put("pb", " %s ");
materialsContainer.add(Material.DISPENSER);
materialsContainer.add(Material.CHEST);
materialsContainer.add(Material.FURNACE);
materialsContainer.add(Material.BURNING_FURNACE);
materialsContainer.add(Material.JUKEBOX);
materialsContainer.add(Material.BREWING_STAND);
materialsContainer.add(Material.ENCHANTMENT_TABLE);
materialsContainer.add(Material.ANVIL);
materialsContainer.add(Material.BEACON);
materialsEditOnInteract.add(Material.DIODE_BLOCK_OFF);
materialsEditOnInteract.add(Material.DIODE_BLOCK_ON);
materialsEditOnInteract.add(Material.NOTE_BLOCK);
materialsEditOnInteract.add(Material.CAULDRON);
materialsEditOnInteract.add(Material.SOIL);
materialsDoor.add(Material.WOODEN_DOOR);
materialsDoor.add(Material.TRAP_DOOR);
materialsDoor.add(Material.FENCE_GATE);
materialsEditTools.add(Material.FIREBALL);
materialsEditTools.add(Material.FLINT_AND_STEEL);
materialsEditTools.add(Material.BUCKET);
materialsEditTools.add(Material.WATER_BUCKET);
materialsEditTools.add(Material.LAVA_BUCKET);
monsters.add(EntityType.BLAZE);
monsters.add(EntityType.CAVE_SPIDER);
monsters.add(EntityType.CREEPER);
monsters.add(EntityType.ENDERMAN);
monsters.add(EntityType.ENDER_DRAGON);
monsters.add(EntityType.GHAST);
monsters.add(EntityType.GIANT);
monsters.add(EntityType.MAGMA_CUBE);
monsters.add(EntityType.PIG_ZOMBIE);
monsters.add(EntityType.SILVERFISH);
monsters.add(EntityType.SKELETON);
monsters.add(EntityType.SLIME);
monsters.add(EntityType.SPIDER);
monsters.add(EntityType.WITCH);
monsters.add(EntityType.WITHER);
monsters.add(EntityType.ZOMBIE);
spoutHealthBarColorUnderQuota.put(1.0d, "&2");
spoutHealthBarColorUnderQuota.put(0.8d, "&a");
spoutHealthBarColorUnderQuota.put(0.5d, "&e");
spoutHealthBarColorUnderQuota.put(0.4d, "&6");
spoutHealthBarColorUnderQuota.put(0.3d, "&c");
spoutHealthBarColorUnderQuota.put(0.2d, "&4");
} }
} }

View File

@ -0,0 +1,71 @@
package com.massivecraft.factions;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import com.massivecraft.mcore.util.MUtil;
public class Const
{
public static final int MAP_HEIGHT = 8;
public static final int MAP_WIDTH = 39;
public static final char[] MAP_KEY_CHARS = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray();
public static final Set<Material> MATERIALS_EDIT_ON_INTERACT = MUtil.set(
Material.DIODE_BLOCK_OFF,
Material.DIODE_BLOCK_ON,
Material.NOTE_BLOCK,
Material.CAULDRON,
Material.SOIL
);
public static final Set<Material> MATERIALS_EDIT_TOOLS = MUtil.set(
Material.FIREBALL,
Material.FLINT_AND_STEEL,
Material.BUCKET,
Material.WATER_BUCKET,
Material.LAVA_BUCKET
);
public static final Set<Material> MATERIALS_DOOR = MUtil.set(
Material.WOODEN_DOOR,
Material.TRAP_DOOR,
Material.FENCE_GATE
);
public static final Set<Material> MATERIALS_CONTAINER = MUtil.set(
Material.DISPENSER,
Material.CHEST,
Material.FURNACE,
Material.BURNING_FURNACE,
Material.JUKEBOX,
Material.BREWING_STAND,
Material.ENCHANTMENT_TABLE,
Material.ANVIL,
Material.BEACON
);
//public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
//public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class);
public static final Set<EntityType> ENTITY_TYPES_MONSTERS = MUtil.set(
EntityType.BLAZE,
EntityType.CAVE_SPIDER,
EntityType.CREEPER,
EntityType.ENDERMAN,
EntityType.ENDER_DRAGON,
EntityType.GHAST,
EntityType.GIANT,
EntityType.MAGMA_CUBE,
EntityType.PIG_ZOMBIE,
EntityType.SILVERFISH,
EntityType.SKELETON,
EntityType.SLIME,
EntityType.SPIDER,
EntityType.WITCH,
EntityType.WITHER,
EntityType.ZOMBIE
);
}

View File

@ -38,6 +38,8 @@ public class MainListener implements Listener
// -------------------------------------------- // // -------------------------------------------- //
// SPOUT // SPOUT
// -------------------------------------------- // // -------------------------------------------- //
// TODO: These spout related methods should not be in here.
// The spout integration needs to be moved elsewhere.
// Setup // Setup

View File

@ -31,7 +31,6 @@ public class HerochatListener implements Listener
{ {
// Should we even parse? // Should we even parse?
if ( ! ConfServer.chatParseTags) return; if ( ! ConfServer.chatParseTags) return;
if (ConfServer.chatTagHandledByAnotherPlugin) return;
Player from = event.getSender().getPlayer(); Player from = event.getSender().getPlayer();
FPlayer fpfrom = FPlayerColl.i.get(from); FPlayer fpfrom = FPlayerColl.i.get(from);

View File

@ -79,7 +79,9 @@ public class FactionsChatListener implements Listener
{ {
// Should we even parse? // Should we even parse?
if ( ! ConfServer.chatParseTags) return; if ( ! ConfServer.chatParseTags) return;
if (ConfServer.chatTagHandledByAnotherPlugin) return;
// TODO: Replace this one with a detailed EventPriority + boolean.
//if (ConfServer.chatTagHandledByAnotherPlugin) return;
Player from = event.getPlayer(); Player from = event.getPlayer();
FPlayer fpfrom = FPlayerColl.i.get(from); FPlayer fpfrom = FPlayerColl.i.get(from);

View File

@ -40,6 +40,7 @@ import org.bukkit.potion.PotionEffectType;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
@ -353,7 +354,7 @@ public class FactionsEntityListener implements Listener
Faction faction = Board.getFactionAt(floc); Faction faction = Board.getFactionAt(floc);
if (faction.getFlag(FFlag.MONSTERS)) return; if (faction.getFlag(FFlag.MONSTERS)) return;
if ( ! ConfServer.monsters.contains(event.getEntityType())) return; if ( ! Const.ENTITY_TYPES_MONSTERS.contains(event.getEntityType())) return;
event.setCancelled(true); event.setCancelled(true);
} }
@ -370,7 +371,7 @@ public class FactionsEntityListener implements Listener
// We are interested in blocking targeting for certain mobs: // We are interested in blocking targeting for certain mobs:
if ( ! ConfServer.monsters.contains(event.getEntity().getType())) return; if ( ! Const.ENTITY_TYPES_MONSTERS.contains(event.getEntity().getType())) return;
FLocation floc = new FLocation(target.getLocation()); FLocation floc = new FLocation(target.getLocation());
Faction faction = Board.getFactionAt(floc); Faction faction = Board.getFactionAt(floc);

View File

@ -26,6 +26,7 @@ import org.bukkit.util.NumberConversions;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
@ -202,7 +203,7 @@ public class FactionsPlayerListener implements Listener
FPlayer me = FPlayerColl.i.get(name); FPlayer me = FPlayerColl.i.get(name);
if (me.hasAdminMode()) return true; if (me.hasAdminMode()) return true;
if (ConfServer.materialsEditTools.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false; if (Const.MATERIALS_EDIT_TOOLS.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false;
return true; return true;
} }
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck)
@ -215,9 +216,9 @@ public class FactionsPlayerListener implements Listener
Location loc = block.getLocation(); Location loc = block.getLocation();
Material material = block.getType(); Material material = block.getType();
if (ConfServer.materialsEditOnInteract.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false; if (Const.MATERIALS_EDIT_ON_INTERACT.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false;
if (ConfServer.materialsContainer.contains(material) && ! FPerm.CONTAINER.has(me, loc, ! justCheck)) return false; if (Const.MATERIALS_CONTAINER.contains(material) && ! FPerm.CONTAINER.has(me, loc, ! justCheck)) return false;
if (ConfServer.materialsDoor.contains(material) && ! FPerm.DOOR.has(me, loc, ! justCheck)) return false; if (Const.MATERIALS_DOOR.contains(material) && ! FPerm.DOOR.has(me, loc, ! justCheck)) return false;
if (material == Material.STONE_BUTTON && ! FPerm.BUTTON.has(me, loc, ! justCheck)) return false; if (material == Material.STONE_BUTTON && ! FPerm.BUTTON.has(me, loc, ! justCheck)) return false;
if (material == Material.LEVER && ! FPerm.LEVER.has(me, loc, ! justCheck)) return false; if (material == Material.LEVER && ! FPerm.LEVER.has(me, loc, ! justCheck)) return false;
return true; return true;