From ff6970debabf45d2187f8e0655b2a01de2e50eee Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 17 Jan 2023 16:04:48 +0100 Subject: [PATCH] Hotfix DefaultHotbar Signed-off-by: yoyosource --- .../steamwar/bausystem/features/hotbar/DefaultHotbar.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/DefaultHotbar.java b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/DefaultHotbar.java index 25760ccb..9e374ee4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/DefaultHotbar.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/DefaultHotbar.java @@ -31,6 +31,9 @@ import yapion.parser.YAPIONParser; import yapion.serializing.YAPIONDeserializer; import yapion.serializing.YAPIONSerializer; +import java.util.HashSet; +import java.util.Set; + @UtilityClass public class DefaultHotbar { @@ -66,6 +69,7 @@ public class DefaultHotbar { Config.getInstance().get(p).remap("hotbar", "hotbar-19"); YAPIONArray yapionArray = Config.getInstance().get(p).getYAPIONArrayOrSetDefault("hotbar-" + Core.getVersion(), defaultHotbar()); ItemStack[] hotbar = new ItemStack[13]; + Set invalid = new HashSet<>(); yapionArray.forEach((integer, yapionAnyType) -> { if (yapionAnyType instanceof YAPIONValue) { hotbar[integer] = null; @@ -73,10 +77,13 @@ public class DefaultHotbar { try { hotbar[integer] = YAPIONDeserializer.deserialize((YAPIONObject) yapionAnyType); } catch (Exception e) { + invalid.add(integer); hotbar[integer] = null; } } }); + invalid.forEach(i -> yapionArray.set(i, new YAPIONValue<>(null))); + if (!invalid.isEmpty()) Config.getInstance().save(p); return hotbar; }