mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-30 22:44:07 +01:00
some more fixes for the new flag containers
This commit is contained in:
parent
0ff24627ca
commit
03d0f962e5
@ -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);
|
sender.sendMessage(ChatColor.RED + "Invalid value '" + valueStr + "' for flag " + nameStr);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
*/
|
*/
|
||||||
public class FlagDatabase {
|
public class FlagDatabase {
|
||||||
|
|
||||||
|
private static Map<FlagType, RegionFlagInfo> flagByFlagType;
|
||||||
|
private static Map<String, RegionFlagInfo> flagByName;
|
||||||
|
|
||||||
public enum FlagType {
|
public enum FlagType {
|
||||||
|
|
||||||
PASSTHROUGH, BUILD, PVP, MOB_DAMAGE, CREEPER_EXPLOSION,
|
PASSTHROUGH, BUILD, PVP, MOB_DAMAGE, CREEPER_EXPLOSION,
|
||||||
@ -42,6 +45,9 @@ public enum FlagType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
flagByFlagType = new EnumMap<FlagType, RegionFlagInfo>(FlagType.class);
|
||||||
|
flagByName = new HashMap<String, RegionFlagInfo>();
|
||||||
|
|
||||||
registerFlag("passthrough", FlagType.PASSTHROUGH, FlagDataType.STATE);
|
registerFlag("passthrough", FlagType.PASSTHROUGH, FlagDataType.STATE);
|
||||||
registerFlag("build", FlagType.BUILD, FlagDataType.STATE);
|
registerFlag("build", FlagType.BUILD, FlagDataType.STATE);
|
||||||
registerFlag("pvp", FlagType.PVP, 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>();
|
|
||||||
}
|
}
|
||||||
|
@ -60,4 +60,6 @@ public String getName() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract String toString();
|
public abstract String toString();
|
||||||
|
|
||||||
|
public abstract boolean setValue(String newVal);
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,13 @@ public class RegionFlagContainer {
|
|||||||
|
|
||||||
private Map<String, String> flags = new HashMap<String, String>();
|
private Map<String, String> flags = new HashMap<String, String>();
|
||||||
private transient Map<FlagType, RegionFlag> flagData = new EnumMap<FlagType, RegionFlag>(FlagType.class);
|
private transient Map<FlagType, RegionFlag> flagData = new EnumMap<FlagType, RegionFlag>(FlagType.class);
|
||||||
|
private transient boolean hasInit = false;
|
||||||
|
|
||||||
public RegionFlag getFlag(FlagType type) {
|
public RegionFlag getFlag(FlagType type) {
|
||||||
|
|
||||||
if (this.flagData == null) {
|
if (!this.hasInit) {
|
||||||
this.initFlagData();
|
this.initFlagData();
|
||||||
|
this.hasInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionFlag ret = this.flagData.get(type);
|
RegionFlag ret = this.flagData.get(type);
|
||||||
|
@ -28,6 +28,7 @@ public final class StateRegionFlag extends RegionFlag {
|
|||||||
|
|
||||||
public StateRegionFlag(RegionFlagContainer container, RegionFlagInfo info, String value) {
|
public StateRegionFlag(RegionFlagContainer container, RegionFlagInfo info, String value) {
|
||||||
super(container, info);
|
super(container, info);
|
||||||
|
System.out.println("new state value : " + value);
|
||||||
this.setValue(value);
|
this.setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user