From e8ef3d85af026808c3fd73d56df79ae75ca2d569 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 19 May 2020 23:47:18 +0200 Subject: [PATCH] feat: disable Potion Brewing for all forbidden types --- .../main/java/de/cliffbreak/varo/Varo.java | 2 ++ .../listeners/InventoryClickListener.java | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 varo/src/main/java/de/cliffbreak/varo/listeners/InventoryClickListener.java diff --git a/varo/src/main/java/de/cliffbreak/varo/Varo.java b/varo/src/main/java/de/cliffbreak/varo/Varo.java index b74eca3..1ded222 100644 --- a/varo/src/main/java/de/cliffbreak/varo/Varo.java +++ b/varo/src/main/java/de/cliffbreak/varo/Varo.java @@ -17,6 +17,7 @@ import de.cliffbreak.varo.listeners.BannedActionListener; import de.cliffbreak.varo.listeners.BannedItemListener; import de.cliffbreak.varo.listeners.ChatListener; import de.cliffbreak.varo.listeners.EntityRegainHealthListener; +import de.cliffbreak.varo.listeners.InventoryClickListener; import de.cliffbreak.varo.listeners.PlayerClientOptionsChangeListener; import de.cliffbreak.varo.listeners.PlayerDeathListener; import de.cliffbreak.varo.listeners.PlayerInteractNPCListener; @@ -80,6 +81,7 @@ public class Varo extends JavaPlugin { this.getServer().getPluginManager().registerEvents(new BannedItemListener(), this); this.getServer().getPluginManager().registerEvents(new BannedActionListener(this), this); this.getServer().getPluginManager().registerEvents(new PlayerInteractNPCListener(this), this); + this.getServer().getPluginManager().registerEvents(new InventoryClickListener(), this); this.getCommand("varo").setExecutor(new VaroCommand(this)); this.getCommand("varo").setTabCompleter(new VaroTabCompleter(this)); diff --git a/varo/src/main/java/de/cliffbreak/varo/listeners/InventoryClickListener.java b/varo/src/main/java/de/cliffbreak/varo/listeners/InventoryClickListener.java new file mode 100644 index 0000000..d1814e9 --- /dev/null +++ b/varo/src/main/java/de/cliffbreak/varo/listeners/InventoryClickListener.java @@ -0,0 +1,29 @@ +package de.cliffbreak.varo.listeners; + +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; + +public class InventoryClickListener implements Listener { + + @EventHandler + public void onInventoryClick(final InventoryClickEvent e) { + if (e.getInventory().getType().equals(InventoryType.BREWING)) { + if (e.getCurrentItem() == null) { + return; + } + final Material mat = e.getCurrentItem().getType(); + System.out.println(mat); + if (mat.equals(Material.AIR) || mat.equals(Material.BLAZE_POWDER) || mat.equals(Material.POTION) + || mat.equals(Material.NETHER_WART) || mat.equals(Material.GLISTERING_MELON_SLICE)) { + + } else { + e.setCancelled(true); + e.getWhoClicked().sendMessage("§cEs kann nur ein Heilungstrank gebraut werden."); + } + } + } + +} \ No newline at end of file