SteamWar/BauSystem2.0
Archiviert
12
0

Hotfix DefaultHotbar
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-01-17 16:04:48 +01:00
Ursprung 558da3b6a0
Commit ff6970deba

Datei anzeigen

@ -31,6 +31,9 @@ import yapion.parser.YAPIONParser;
import yapion.serializing.YAPIONDeserializer; import yapion.serializing.YAPIONDeserializer;
import yapion.serializing.YAPIONSerializer; import yapion.serializing.YAPIONSerializer;
import java.util.HashSet;
import java.util.Set;
@UtilityClass @UtilityClass
public class DefaultHotbar { public class DefaultHotbar {
@ -66,6 +69,7 @@ public class DefaultHotbar {
Config.getInstance().get(p).remap("hotbar", "hotbar-19"); Config.getInstance().get(p).remap("hotbar", "hotbar-19");
YAPIONArray yapionArray = Config.getInstance().get(p).getYAPIONArrayOrSetDefault("hotbar-" + Core.getVersion(), defaultHotbar()); YAPIONArray yapionArray = Config.getInstance().get(p).getYAPIONArrayOrSetDefault("hotbar-" + Core.getVersion(), defaultHotbar());
ItemStack[] hotbar = new ItemStack[13]; ItemStack[] hotbar = new ItemStack[13];
Set<Integer> invalid = new HashSet<>();
yapionArray.forEach((integer, yapionAnyType) -> { yapionArray.forEach((integer, yapionAnyType) -> {
if (yapionAnyType instanceof YAPIONValue) { if (yapionAnyType instanceof YAPIONValue) {
hotbar[integer] = null; hotbar[integer] = null;
@ -73,10 +77,13 @@ public class DefaultHotbar {
try { try {
hotbar[integer] = YAPIONDeserializer.deserialize((YAPIONObject) yapionAnyType); hotbar[integer] = YAPIONDeserializer.deserialize((YAPIONObject) yapionAnyType);
} catch (Exception e) { } catch (Exception e) {
invalid.add(integer);
hotbar[integer] = null; hotbar[integer] = null;
} }
} }
}); });
invalid.forEach(i -> yapionArray.set(i, new YAPIONValue<>(null)));
if (!invalid.isEmpty()) Config.getInstance().save(p);
return hotbar; return hotbar;
} }