Cleaned up Multiverse-Inventories integration
This commit is contained in:
@@ -35,7 +35,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.multiverseinventories.MultiverseInventoriesIntegration
|
||||
import com.willfp.eco.spigot.integrations.shop.ShopShopGuiPlus
|
||||
import com.willfp.eco.spigot.recipes.ShapedRecipeListener
|
||||
import com.willfp.eco.util.BlockUtils
|
||||
@@ -158,7 +158,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
|
||||
// Misc
|
||||
IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) },
|
||||
IntegrationLoader("Multiverse-Inventories") { this.eventManager.registerListener(MultiverseInventoriesEvent(this)) }
|
||||
IntegrationLoader("Multiverse-Inventories") { this.eventManager.registerListener(MultiverseInventoriesIntegration(this)) }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
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<EcoPlugin> 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<ItemStack> before = new ArrayList<>(Arrays.asList(event.getPlayer().getInventory().getArmorContents()));
|
||||
|
||||
this.getPlugin().getScheduler().runLater(() -> {
|
||||
List<ItemStack> after = new ArrayList<>(Arrays.asList(event.getPlayer().getInventory().getArmorContents()));
|
||||
|
||||
ArmorChangeEvent armorChangeEvent = new ArmorChangeEvent(event.getPlayer(), before, after);
|
||||
Bukkit.getPluginManager().callEvent(armorChangeEvent);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.willfp.eco.spigot.integrations.multiverseinventories
|
||||
|
||||
import com.onarandombox.multiverseinventories.event.WorldChangeShareHandlingEvent
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.events.ArmorChangeEvent
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
class MultiverseInventoriesIntegration(
|
||||
private val plugin: EcoPlugin
|
||||
): Listener {
|
||||
@EventHandler
|
||||
fun onWorldChange(event: WorldChangeShareHandlingEvent) {
|
||||
val before = event.player.inventory.armorContents.toMutableList()
|
||||
this.plugin.scheduler.run {
|
||||
val after = event.player.inventory.armorContents.toMutableList()
|
||||
Bukkit.getPluginManager().callEvent(ArmorChangeEvent(event.player, before, after))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ softdepend:
|
||||
- ItemsAdder
|
||||
- Oraxen
|
||||
- HeadDatabase
|
||||
- Multiverse-Inventories
|
||||
libraries:
|
||||
- 'org.reflections:reflections:0.9.12'
|
||||
- 'org.apache.maven:maven-artifact:3.0.3'
|
||||
|
||||
Reference in New Issue
Block a user