some more fixes for the new flag containers

This commit is contained in:
Redecouverte 2011-02-28 18:08:52 +01:00
parent 0ff24627ca
commit 03d0f962e5
5 changed files with 13 additions and 4 deletions

View File

@ -116,7 +116,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
}
}
if (!region.getFlags().getLocationFlag(nfo.type).setValue(valueStr)) {
if (!region.getFlags().getFlag(nfo.type).setValue(valueStr)) {
sender.sendMessage(ChatColor.RED + "Invalid value '" + valueStr + "' for flag " + nameStr);
return true;
} else {

View File

@ -31,6 +31,9 @@
*/
public class FlagDatabase {
private static Map<FlagType, RegionFlagInfo> flagByFlagType;
private static Map<String, RegionFlagInfo> flagByName;
public enum FlagType {
PASSTHROUGH, BUILD, PVP, MOB_DAMAGE, CREEPER_EXPLOSION,
@ -42,6 +45,9 @@ public enum FlagType {
};
static {
flagByFlagType = new EnumMap<FlagType, RegionFlagInfo>(FlagType.class);
flagByName = new HashMap<String, RegionFlagInfo>();
registerFlag("passthrough", FlagType.PASSTHROUGH, FlagDataType.STATE);
registerFlag("build", FlagType.BUILD, FlagDataType.STATE);
registerFlag("pvp", FlagType.PVP, FlagDataType.STATE);
@ -152,6 +158,4 @@ public static RegionFlag getNewInstanceOf(String name, String value, RegionFlagC
}
private static Map<FlagType, RegionFlagInfo> flagByFlagType = new EnumMap<FlagType, RegionFlagInfo>(FlagType.class);
private static Map<String, RegionFlagInfo> flagByName = new HashMap<String, RegionFlagInfo>();
}

View File

@ -60,4 +60,6 @@ public String getName() {
@Override
public abstract String toString();
public abstract boolean setValue(String newVal);
}

View File

@ -35,11 +35,13 @@ public class RegionFlagContainer {
private Map<String, String> flags = new HashMap<String, String>();
private transient Map<FlagType, RegionFlag> flagData = new EnumMap<FlagType, RegionFlag>(FlagType.class);
private transient boolean hasInit = false;
public RegionFlag getFlag(FlagType type) {
if (this.flagData == null) {
if (!this.hasInit) {
this.initFlagData();
this.hasInit = true;
}
RegionFlag ret = this.flagData.get(type);

View File

@ -28,6 +28,7 @@ public final class StateRegionFlag extends RegionFlag {
public StateRegionFlag(RegionFlagContainer container, RegionFlagInfo info, String value) {
super(container, info);
System.out.println("new state value : " + value);
this.setValue(value);
}