diff --git a/src/main/java/dev/j3fftw/worldeditslimefun/WorldEditSlimefun.java b/src/main/java/dev/j3fftw/worldeditslimefun/WorldEditSlimefun.java index 450de01..31fd18f 100644 --- a/src/main/java/dev/j3fftw/worldeditslimefun/WorldEditSlimefun.java +++ b/src/main/java/dev/j3fftw/worldeditslimefun/WorldEditSlimefun.java @@ -1,12 +1,14 @@ package dev.j3fftw.worldeditslimefun; import dev.j3fftw.worldeditslimefun.commands.WorldEditSlimefunCommands; +import dev.j3fftw.worldeditslimefun.listeners.RegistryListener; import dev.j3fftw.worldeditslimefun.slimefun.Items; -import dev.j3fftw.worldeditslimefun.slimefun.WandListener; +import dev.j3fftw.worldeditslimefun.listeners.WandListener; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.BlobBuildUpdater; import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; +import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import javax.annotation.Nonnull; @@ -32,7 +34,10 @@ public void onEnable() { Items.init(this); WorldEditSlimefunCommands.init(this); - Bukkit.getPluginManager().registerEvents(new WandListener(), this); + + PluginManager manager = Bukkit.getPluginManager(); + manager.registerEvents(new WandListener(), this); + manager.registerEvents(new RegistryListener(), this); } @Override diff --git a/src/main/java/dev/j3fftw/worldeditslimefun/listeners/RegistryListener.java b/src/main/java/dev/j3fftw/worldeditslimefun/listeners/RegistryListener.java new file mode 100644 index 0000000..9fb3ed7 --- /dev/null +++ b/src/main/java/dev/j3fftw/worldeditslimefun/listeners/RegistryListener.java @@ -0,0 +1,14 @@ +package dev.j3fftw.worldeditslimefun.listeners; + +import dev.j3fftw.worldeditslimefun.utils.Utils; +import io.github.thebusybiscuit.slimefun4.api.events.SlimefunItemRegistryFinalizedEvent; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; + +public class RegistryListener implements Listener { + @EventHandler(priority = EventPriority.MONITOR) + public void onRegistryInitialized(SlimefunItemRegistryFinalizedEvent event) { + Utils.init(); + } +} diff --git a/src/main/java/dev/j3fftw/worldeditslimefun/slimefun/WandListener.java b/src/main/java/dev/j3fftw/worldeditslimefun/listeners/WandListener.java similarity index 97% rename from src/main/java/dev/j3fftw/worldeditslimefun/slimefun/WandListener.java rename to src/main/java/dev/j3fftw/worldeditslimefun/listeners/WandListener.java index 80945b3..d80aa22 100644 --- a/src/main/java/dev/j3fftw/worldeditslimefun/slimefun/WandListener.java +++ b/src/main/java/dev/j3fftw/worldeditslimefun/listeners/WandListener.java @@ -1,4 +1,4 @@ -package dev.j3fftw.worldeditslimefun.slimefun; +package dev.j3fftw.worldeditslimefun.listeners; import dev.j3fftw.worldeditslimefun.utils.PositionManager; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; diff --git a/src/main/java/dev/j3fftw/worldeditslimefun/slimefun/Items.java b/src/main/java/dev/j3fftw/worldeditslimefun/slimefun/Items.java index c445863..aa2f5b9 100644 --- a/src/main/java/dev/j3fftw/worldeditslimefun/slimefun/Items.java +++ b/src/main/java/dev/j3fftw/worldeditslimefun/slimefun/Items.java @@ -8,14 +8,22 @@ import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import javax.annotation.Nonnull; + public class Items { public static void init(WorldEditSlimefun plugin) { ItemGroup WESF_GROUP = new ItemGroup( new NamespacedKey(plugin, "world_edit_slimefun"), - new CustomItemStack(Material.STONE_AXE, "&fWorld Edit Slimefun (Dummy Group)") - ); + new CustomItemStack(Material.STONE_AXE, "&fWorld Edit Slimefun") + ) { + @Override + public boolean isVisible(@Nonnull Player ignored) { + return false; + } + }; new SlimefunItem( WESF_GROUP, diff --git a/src/main/java/dev/j3fftw/worldeditslimefun/utils/Utils.java b/src/main/java/dev/j3fftw/worldeditslimefun/utils/Utils.java index bd9a854..68d661e 100644 --- a/src/main/java/dev/j3fftw/worldeditslimefun/utils/Utils.java +++ b/src/main/java/dev/j3fftw/worldeditslimefun/utils/Utils.java @@ -19,7 +19,7 @@ public class Utils { public static final List SLIMEFUN_ITEMS = new ArrayList<>(); public static final Map MATERIALS = new HashMap<>(); - static { + public static void init() { for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) { if (!(item instanceof UnplaceableBlock) && item.getItem().getType().isBlock()) { SLIMEFUN_BLOCKS.add(item.getId());