From 998d43d6e3f7e652577a8e3e4f13fe82aadd1709 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 5 Jul 2021 10:40:21 +0200 Subject: [PATCH] Optimize FlagStorage Signed-off-by: yoyosource --- .../de/steamwar/bausystem/region/FlagStorage.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java b/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java index aac277b8..b89f3df5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/FlagStorage.java @@ -54,10 +54,18 @@ public class FlagStorage { public static YAPIONObject toYAPION(FlagStorage flagStorage) { YAPIONObject yapionObject = new YAPIONObject(); for (final Flag flag : Flag.getFlags()) { - yapionObject.add(flag.name(), flagStorage.get(flag).getValue().name()); + if (flag.getDefaultValue() == flagStorage.flags.getOrDefault(flag, flag.getDefaultValue())) { + yapionObject.remove(flag.name()); + } else { + yapionObject.add(flag.name(), flagStorage.get(flag).getValue().name()); + } } - for (Tag tag : flagStorage.tagSet) { - yapionObject.add(tag.name(), ""); + for (Tag tag : Tag.values()) { + if (flagStorage.tagSet.contains(tag)) { + yapionObject.add(tag.name(), ""); + } else { + yapionObject.remove(tag.name()); + } } return yapionObject; }