feat: disable Potion Brewing for all forbidden types

This commit is contained in:
Simon Giesel 2020-05-19 23:47:18 +02:00
parent 199e1efae5
commit e8ef3d85af
2 changed files with 31 additions and 0 deletions

View file

@ -17,6 +17,7 @@ import de.cliffbreak.varo.listeners.BannedActionListener;
import de.cliffbreak.varo.listeners.BannedItemListener; import de.cliffbreak.varo.listeners.BannedItemListener;
import de.cliffbreak.varo.listeners.ChatListener; import de.cliffbreak.varo.listeners.ChatListener;
import de.cliffbreak.varo.listeners.EntityRegainHealthListener; import de.cliffbreak.varo.listeners.EntityRegainHealthListener;
import de.cliffbreak.varo.listeners.InventoryClickListener;
import de.cliffbreak.varo.listeners.PlayerClientOptionsChangeListener; import de.cliffbreak.varo.listeners.PlayerClientOptionsChangeListener;
import de.cliffbreak.varo.listeners.PlayerDeathListener; import de.cliffbreak.varo.listeners.PlayerDeathListener;
import de.cliffbreak.varo.listeners.PlayerInteractNPCListener; 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 BannedItemListener(), this);
this.getServer().getPluginManager().registerEvents(new BannedActionListener(this), this); this.getServer().getPluginManager().registerEvents(new BannedActionListener(this), this);
this.getServer().getPluginManager().registerEvents(new PlayerInteractNPCListener(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").setExecutor(new VaroCommand(this));
this.getCommand("varo").setTabCompleter(new VaroTabCompleter(this)); this.getCommand("varo").setTabCompleter(new VaroTabCompleter(this));

View file

@ -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.");
}
}
}
}