From e32add7ec5077152ebb4e8ddbec2f3fe1c2d423a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Szab=C3=B3?= Date: Fri, 15 Nov 2024 10:14:03 +0100 Subject: [PATCH] Add MM item resolver and return items from external resolvers everywhere --- .../bukkit/hooks/mythicmobs/MythicMobsHook.java | 7 +++++++ .../auraskills/bukkit/item/BukkitItemRegistry.java | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/hooks/mythicmobs/MythicMobsHook.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/hooks/mythicmobs/MythicMobsHook.java index 8aec7f5a5..538f7d766 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/hooks/mythicmobs/MythicMobsHook.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/hooks/mythicmobs/MythicMobsHook.java @@ -32,11 +32,18 @@ public MythicMobsHook(AuraSkills plugin, ConfigurationNode config) { this.plugin = plugin; this.damageHandler = new DamageHandler(); + registerItemProvider(); + // Wait for loot manager to be created, but add parser before it is loaded plugin.getScheduler().executeSync(() -> plugin.getLootTableManager().getLootManager().registerCustomEntityParser(new MythicEntityLootParser(plugin))); } + private void registerItemProvider() { + plugin.getItemRegistry().registerExternalItemProvider("mythicmobs", + (id) -> MythicBukkit.inst().getItemManager().getItemStack(id)); + } + @EventHandler public void onMythicSkillDamage(MythicDamageEvent event) { // This is always some sort of skill/mechanic damage. diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/item/BukkitItemRegistry.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/item/BukkitItemRegistry.java index 4681257f7..afe1ff315 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/item/BukkitItemRegistry.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/item/BukkitItemRegistry.java @@ -58,9 +58,14 @@ public ItemStack getItem(NamespacedId key) { ItemStack item = items.get(key); if (item != null) { return item.clone(); - } else { - return null; } + + ExternalItemProvider provider = externalItemProviders.get(key.getNamespace()); + if(provider != null) { + return provider.getItem(key.getKey()); + } + + return null; } public Map getItems() {