Updated FlagSerializers to use FlagsManager#getFlag(String)

This commit is contained in:
Florian CUNY 2019-01-18 17:40:55 +01:00
parent c5f561c816
commit a29bcd457e
2 changed files with 4 additions and 10 deletions

View File

@ -29,17 +29,11 @@ public class FlagSerializer implements AdapterInterface<Map<Flag, Integer>, Map<
if (object instanceof MemorySection) {
MemorySection section = (MemorySection) object;
for (String key : section.getKeys(false)) {
Flag flag = BentoBox.getInstance().getFlagsManager().getFlagByID(key);
if (flag != null) {
result.put(flag, section.getInt(key));
}
BentoBox.getInstance().getFlagsManager().getFlag(key).ifPresent(flag -> result.put(flag, section.getInt(key)));
}
} else {
for (Entry<String, Integer> en : ((Map<String, Integer>)object).entrySet()) {
Flag flag = BentoBox.getInstance().getFlagsManager().getFlagByID(en.getKey());
if (flag != null) {
result.put(flag, en.getValue());
}
BentoBox.getInstance().getFlagsManager().getFlag(en.getKey()).ifPresent(flag -> result.put(flag, en.getValue()));
}
}
return result;

View File

@ -26,11 +26,11 @@ public class FlagSerializer2 implements AdapterInterface<Map<Flag, Integer>, Map
if (object instanceof MemorySection) {
MemorySection section = (MemorySection) object;
for (String key : section.getKeys(false)) {
result.put(BentoBox.getInstance().getFlagsManager().getFlagByID(key), section.getBoolean(key) ? 0 : -1);
BentoBox.getInstance().getFlagsManager().getFlag(key).ifPresent(flag -> result.put(flag, section.getBoolean(key) ? 0 : -1));
}
} else {
for (Entry<String, Boolean> en : ((Map<String, Boolean>)object).entrySet()) {
result.put(BentoBox.getInstance().getFlagsManager().getFlagByID(en.getKey()), en.getValue() ? 0 : -1);
BentoBox.getInstance().getFlagsManager().getFlag(en.getKey()).ifPresent(flag -> result.put(flag, en.getValue() ? 0 : -1));
}
}
return result;