|
3 | 3 | import dev.lrxh.api.arena.IArena; |
4 | 4 | import dev.lrxh.api.kit.IKit; |
5 | 5 | import dev.lrxh.api.kit.IKitService; |
| 6 | +import dev.lrxh.neptune.Neptune; |
6 | 7 | import dev.lrxh.neptune.configs.ConfigService; |
7 | 8 | import dev.lrxh.neptune.game.arena.Arena; |
8 | 9 | import dev.lrxh.neptune.game.arena.ArenaService; |
@@ -36,41 +37,47 @@ public void load() { |
36 | 37 | FileConfiguration config = ConfigService.get().getKitsConfig().getConfiguration(); |
37 | 38 | if (config.contains("kits")) { |
38 | 39 | for (String kitName : getKeys("kits")) { |
39 | | - String path = "kits." + kitName + "."; |
40 | | - String displayName = config.getString(path + "displayName", kitName); |
41 | | - ItemStack icon = ItemUtils.deserializeItem(config.getString(path + "icon", "")); |
42 | | - |
43 | | - List<ItemStack> items = ItemUtils.deserialize(config.getString(path + "items", "")); |
44 | | - int slot = config.getInt(path + "slot", kits.size() + 1); |
45 | | - int kitEditorSlot = config.getInt(path + "kitEditor-slot", slot); |
46 | | - double health = config.getDouble(path + "health", 20); |
47 | | - double damageMultiplier = config.getDouble(path + "damage-multiplier", 1.0); |
48 | | - |
49 | | - HashSet<Arena> arenas = new HashSet<>(); |
50 | | - if (!config.getStringList(path + "arenas").isEmpty()) { |
51 | | - for (String arenaName : config.getStringList(path + "arenas")) { |
52 | | - Arena arena = ArenaService.get().getArenaByName(arenaName); |
53 | | - if (arena == null) { |
54 | | - ServerUtils.error("KitService: Arena " + arenaName + " not found for kit " + kitName); |
55 | | - continue; |
| 40 | + try { |
| 41 | + String path = "kits." + kitName + "."; |
| 42 | + String displayName = config.getString(path + "displayName", kitName); |
| 43 | + ItemStack icon = ItemUtils.deserializeItem(config.getString(path + "icon", "")); |
| 44 | + |
| 45 | + List<ItemStack> items = ItemUtils.deserialize(config.getString(path + "items", "")); |
| 46 | + int slot = config.getInt(path + "slot", kits.size() + 1); |
| 47 | + int kitEditorSlot = config.getInt(path + "kitEditor-slot", slot); |
| 48 | + double health = config.getDouble(path + "health", 20); |
| 49 | + double damageMultiplier = config.getDouble(path + "damage-multiplier", 1.0); |
| 50 | + |
| 51 | + HashSet<Arena> arenas = new HashSet<>(); |
| 52 | + if (!config.getStringList(path + "arenas").isEmpty()) { |
| 53 | + for (String arenaName : config.getStringList(path + "arenas")) { |
| 54 | + Arena arena = ArenaService.get().getArenaByName(arenaName); |
| 55 | + if (arena == null) { |
| 56 | + ServerUtils.error("KitService: Arena " + arenaName + " not found for kit " + kitName); |
| 57 | + continue; |
| 58 | + } |
| 59 | + arenas.add(arena); |
56 | 60 | } |
57 | | - arenas.add(arena); |
58 | 61 | } |
59 | | - } |
60 | 62 |
|
61 | | - HashMap<KitRule, Boolean> rules = new HashMap<>(); |
62 | | - for (KitRule kitRule : KitRule.values()) { |
63 | | - rules.put(kitRule, config.getBoolean(path + kitRule.getSaveName(), false)); |
64 | | - } |
| 63 | + HashMap<KitRule, Boolean> rules = new HashMap<>(); |
| 64 | + for (KitRule kitRule : KitRule.values()) { |
| 65 | + rules.put(kitRule, config.getBoolean(path + kitRule.getSaveName(), false)); |
| 66 | + } |
65 | 67 |
|
66 | | - List<PotionEffect> potionEffects = new ArrayList<>(); |
67 | | - if (!config.getStringList(path + "potionEffects").isEmpty()) { |
68 | | - for (String potion : config.getStringList(path + "potionEffects")) { |
69 | | - potionEffects.add(PotionEffectUtils.deserialize(potion)); |
| 68 | + List<PotionEffect> potionEffects = new ArrayList<>(); |
| 69 | + if (!config.getStringList(path + "potionEffects").isEmpty()) { |
| 70 | + for (String potion : config.getStringList(path + "potionEffects")) { |
| 71 | + potionEffects.add(PotionEffectUtils.deserialize(potion)); |
| 72 | + } |
70 | 73 | } |
71 | | - } |
72 | 74 |
|
73 | | - kits.add(new Kit(kitName, displayName, items, arenas, icon, rules, slot, health, kitEditorSlot, potionEffects, damageMultiplier)); |
| 75 | + kits.add(new Kit(kitName, displayName, items, arenas, icon, rules, slot, health, kitEditorSlot, potionEffects, damageMultiplier)); |
| 76 | + } catch (Exception e) { |
| 77 | + Neptune.get().getLogger().severe("Error occurred while loading a kit with key: " + kitName); |
| 78 | + Neptune.get().setErrored(); |
| 79 | + throw e; |
| 80 | + } |
74 | 81 | } |
75 | 82 | } |
76 | 83 | } |
|
0 commit comments