Skip to content

Commit

Permalink
Fix ArmorMechanics not reloading on the first enable
Browse files Browse the repository at this point in the history
  • Loading branch information
CJCrafter committed Aug 14, 2022
1 parent 625ed56 commit 650ca61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/me/cjcrafter/armormechanics/ArmorMechanics.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public void onEnable() {

Command.register();

reload();

// Automatically reload ArmorMechanics if WeaponMechanics reloads.
new Listener() {
@EventHandler
public void onQueue(QueueSerializerEvent event) {
Expand Down Expand Up @@ -124,6 +127,12 @@ public TaskChain reload() {
}
}

if (armors.isEmpty()) {
debug.error("Couldn't find any armors from '" + armorFile + "'",
"Keys: " + armorConfig.getKeys(false));
return;
}

File setFile = new File(getDataFolder(), "Set.yml");
FileConfiguration setConfig = YamlConfiguration.loadConfiguration(setFile);

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/cjcrafter/armormechanics/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ public static void give(CommandSender sender, List<Entity> entities, String titl

title = StringUtil.didYouMean(title, startsWith.isEmpty() ? options : startsWith);
ItemStack armor = ArmorMechanics.INSTANCE.armors.get(title);

if (armor == null) {
sender.sendMessage(RED + "Couldn't find armor '" + title + "'... Choose from " + options);
return;
}

EquipmentSlot slot = ArmorMechanicsAPI.getEquipmentSlot(armor.getType());

boolean force = 1 == (int) data.getOrDefault("forceEquip", 0);
Expand Down

0 comments on commit 650ca61

Please # to comment.