mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-26 09:11:39 +01:00
Updated FlagSerializers to use FlagsManager#getFlag(String)
This commit is contained in:
parent
c5f561c816
commit
a29bcd457e
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user