Skip to content

Commit

Permalink
Fix ModManager reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo56958 committed Feb 29, 2024
1 parent f56d52e commit 5dbc20e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/de/flo56958/minetinker/modifiers/ModManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ public void reload() {
layout = ConfigurationManager.getConfig("layout.yml");

removeRecipes();
mods.forEach(mod -> {
if (mod instanceof Listener listener) //Disable Events
HandlerList.unregisterAll(listener);});
mods.clear();
mods.addAll(allMods);
mods.removeIf(mod -> !mod.isAllowed());
Expand All @@ -269,11 +272,16 @@ public void reload() {
this.ArmorIdentifier = config.getString("ArmorIdentifier");

removeRecipes();
this.allMods.forEach(Modifier::reload);
this.mods.forEach(Modifier::registerCraftingRecipe);

//get Modifier incompatibilities
this.reloadIncompatibilities();

mods.forEach(mod -> {
if (mod instanceof Listener listener) //Enable Events
Bukkit.getPluginManager().registerEvents(listener, mod.getSource());});

if (layout.getBoolean("OverrideLanguagesystem", false)) {
this.loreScheme = layout.getStringList("LoreLayout");

Expand Down Expand Up @@ -370,7 +378,7 @@ public boolean register(@Nullable final Modifier mod) {
mods.sort(Comparator.comparing(Modifier::getName));
mod.registerCraftingRecipe();
if (mod instanceof Listener listener) //Enable Events
Bukkit.getPluginManager().registerEvents(listener, MineTinker.getPlugin());
Bukkit.getPluginManager().registerEvents(listener, mod.getSource());
}
reloadIncompatibilities();
if (!mod.getSource().equals(MineTinker.getPlugin())) GUIs.reload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public static boolean triggerItemDamage(@NotNull Player player, @NotNull ItemSta

meta = itemStack.getItemMeta();
if (meta instanceof Damageable damageable) {
if (damageable.getDamage() + damageEvent.getDamage() >= itemStack.getType().getMaxDurability())
return false;

damageable.setDamage(damageable.getDamage() + damageEvent.getDamage());
itemStack.setItemMeta(meta);
}
Expand Down

0 comments on commit 5dbc20e

Please sign in to comment.