diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt index d8164290..e5febd6c 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt @@ -34,6 +34,7 @@ import com.willfp.eco.spigot.integrations.customitems.CustomItemsHeadDatabase import com.willfp.eco.spigot.integrations.customitems.CustomItemsItemsAdder import com.willfp.eco.spigot.integrations.customitems.CustomItemsOraxen import com.willfp.eco.spigot.integrations.mcmmo.McmmoIntegrationImpl +import com.willfp.eco.spigot.integrations.multiverseinventories.MultiverseInventoriesEvent import com.willfp.eco.spigot.integrations.shop.ShopShopGuiPlus import com.willfp.eco.spigot.recipes.ShapedRecipeListener import com.willfp.eco.util.BlockUtils @@ -150,7 +151,8 @@ abstract class EcoSpigotPlugin : EcoPlugin( IntegrationLoader("ShopGUIPlus") { ShopManager.register(ShopShopGuiPlus()) }, // Misc - IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) } + IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) }, + IntegrationLoader("Multiverse-Inventories") { this.eventManager.registerListener(MultiverseInventoriesEvent(this)) } ) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/multiverseinventories/MultiverseInventoriesEvent.java b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/multiverseinventories/MultiverseInventoriesEvent.java new file mode 100644 index 00000000..7a799310 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/multiverseinventories/MultiverseInventoriesEvent.java @@ -0,0 +1,40 @@ +package com.willfp.eco.spigot.integrations.multiverseinventories; + +import com.onarandombox.multiverseinventories.event.WorldChangeShareHandlingEvent; +import com.willfp.eco.core.EcoPlugin; +import com.willfp.eco.core.PluginDependent; +import com.willfp.eco.core.events.ArmorChangeEvent; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class MultiverseInventoriesEvent extends PluginDependent implements Listener { + + /** + * Pass an {@link EcoPlugin} in order to interface with it. + * + * @param plugin The plugin to manage. + */ + public MultiverseInventoriesEvent(@NotNull EcoPlugin plugin) { + super(plugin); + } + + @EventHandler + public void onWorldChange(WorldChangeShareHandlingEvent event) { + List before = new ArrayList<>(Arrays.asList(event.getPlayer().getInventory().getArmorContents())); + + this.getPlugin().getScheduler().runLater(() -> { + List after = new ArrayList<>(Arrays.asList(event.getPlayer().getInventory().getArmorContents())); + + ArmorChangeEvent armorChangeEvent = new ArmorChangeEvent(event.getPlayer(), before, after); + Bukkit.getPluginManager().callEvent(armorChangeEvent); + }, 1); + } + +} diff --git a/lib/Multiverse-Inventories-4.2.2.jar b/lib/Multiverse-Inventories-4.2.2.jar new file mode 100644 index 00000000..a6218563 Binary files /dev/null and b/lib/Multiverse-Inventories-4.2.2.jar differ