mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Fixes #1226
This commit is contained in:
parent
e859a7f56c
commit
ca776b2912
@ -1816,14 +1816,7 @@ public class SQLManager implements AbstractDB {
|
||||
String[] split = element.split(":");
|
||||
try {
|
||||
String flag_str = split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
|
||||
Flag<?> flag = FlagManager.getFlag(split[0],true);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(split[0]) {
|
||||
@Override public String getValueDescription() {
|
||||
return "Generic Filler Flag";
|
||||
}
|
||||
};
|
||||
}
|
||||
Flag<?> flag = FlagManager.getOrCreateFlag(split[0]);
|
||||
flags.put(flag, flag.parseValue(flag_str));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -1832,7 +1825,7 @@ public class SQLManager implements AbstractDB {
|
||||
} else {
|
||||
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
|
||||
if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
||||
Flag flag = FlagManager.getFlag(element,true);
|
||||
Flag flag = FlagManager.getOrCreateFlag(element);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(element) {
|
||||
@Override public String getValueDescription() {
|
||||
@ -2634,7 +2627,7 @@ public class SQLManager implements AbstractDB {
|
||||
if (element.contains(":")) {
|
||||
String[] split = element.split(":");
|
||||
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
|
||||
Flag flag = FlagManager.getFlag(split[0],true);
|
||||
Flag flag = FlagManager.getOrCreateFlag(split[0]);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(split[0]) {
|
||||
@Override public String getValueDescription() {
|
||||
@ -2644,7 +2637,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
flags.put(flag, flag.parseValue(flag_str));
|
||||
} else {
|
||||
Flag flag = FlagManager.getFlag(element,true);
|
||||
Flag flag = FlagManager.getOrCreateFlag(element);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(element) {
|
||||
@Override public String getValueDescription() {
|
||||
|
@ -317,6 +317,19 @@ public class FlagManager {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static Flag<?> getOrCreateFlag(String string) {
|
||||
Flag<?> flag = Flags.getFlag(string);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(string) {
|
||||
@Override public String getValueDescription() {
|
||||
return "Generic Filler Flag";
|
||||
}
|
||||
};
|
||||
flag.register();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
public static Map<Flag<?>, Object> parseFlags(List<String> flagStrings) {
|
||||
HashMap<Flag<?>, Object> map = new HashMap<>();
|
||||
|
@ -152,35 +152,25 @@ public final class Flags {
|
||||
|
||||
public static void registerFlag(final Flag<?> flag) {
|
||||
final Flag<?> duplicate = flags.put(flag.getName(), flag);
|
||||
if (duplicate != null) {
|
||||
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||
@Override public void run(PlotArea value) {
|
||||
if (duplicate != null) {
|
||||
Object remove;
|
||||
if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
|
||||
remove = value.DEFAULT_FLAGS.remove(duplicate);
|
||||
if (!(remove instanceof String)) {
|
||||
//error message? maybe?
|
||||
return;
|
||||
}
|
||||
value.DEFAULT_FLAGS.put(flag,flag.parseValue((String) remove));
|
||||
}
|
||||
value.DEFAULT_FLAGS.put(flag,flag.parseValue("" + remove));
|
||||
}
|
||||
}
|
||||
});
|
||||
PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
||||
@Override public void run(Plot value) {
|
||||
if (duplicate != null) {
|
||||
Object remove = null;
|
||||
if (value.getFlags().containsKey(duplicate)) {
|
||||
remove = value.getFlags().remove(duplicate);
|
||||
}
|
||||
if (!(remove instanceof String)) {
|
||||
//error message? maybe?
|
||||
return;
|
||||
}
|
||||
value.getFlags().put(flag,flag.parseValue((String) remove));
|
||||
}
|
||||
value.getFlags().put(flag,flag.parseValue("" + remove));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user