From 1b935486234d787628983db89cc1ddb32a6a1d65 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 3 May 2021 09:23:10 +0200 Subject: [PATCH] More Refactoring and Fix the InventoryListener Signed-off-by: Chaoscaot --- .../src/de/steamwar/bausystem/BauSystem.java | 1 - .../features/autostart/AutoStartGuiItem.java | 6 +++--- .../features/countingwand/CountingwandGuiItem.java | 14 +++++++------- .../redstonetester/RedstoneTesterGuiItem.java | 6 +++--- .../features/world/InventoryListener.java | 12 ++++-------- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index af39406f..646056d9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -31,7 +31,6 @@ import org.bukkit.plugin.java.JavaPlugin; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; -import java.util.logging.Level; public class BauSystem extends JavaPlugin implements Listener { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java index a3013c96..d047a12f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.features.autostart; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.GuiItem; +import de.steamwar.bausystem.linkage.BauGuiItem; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.inventory.SWItem; @@ -31,8 +31,8 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.GUI_ITEM) -public class AutoStartGuiItem extends GuiItem { +@Linked(LinkageType.BAU_GUI_ITEM) +public class AutoStartGuiItem extends BauGuiItem { public AutoStartGuiItem() { super(24); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java index 97e88047..6b1506bd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java @@ -21,20 +21,20 @@ package de.steamwar.bausystem.features.countingwand; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.ColorConfig; -import de.steamwar.bausystem.features.gui.BauGUI; -import de.steamwar.bausystem.linkage.GuiItem; +import de.steamwar.bausystem.linkage.BauGuiItem; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.inventory.SWItem; -import java.util.Arrays; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import java.util.Arrays; -@Linked(LinkageType.GUI_ITEM) -public class CountingwandGuiItem extends GuiItem { + +@Linked(LinkageType.BAU_GUI_ITEM) +public class CountingwandGuiItem extends BauGuiItem { public CountingwandGuiItem() { super(22); @@ -43,8 +43,8 @@ public class CountingwandGuiItem extends GuiItem { @Override public ItemStack getItem(Player player) { return new SWItem(Material.STICK, - ColorConfig.HIGHLIGHT + "Counting Wand", - Arrays.asList(ColorConfig.HIGHLIGHT + "Linksklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 1. Position", + ColorConfig.HIGHLIGHT + "Counting Wand", + Arrays.asList(ColorConfig.HIGHLIGHT + "Linksklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 1. Position", ColorConfig.HIGHLIGHT + "Rechtsklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 2. Position"), false, clickType -> { }).getItemStack(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java index 9650ad49..86e83a71 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.features.redstonetester; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.ColorConfig; -import de.steamwar.bausystem.linkage.GuiItem; +import de.steamwar.bausystem.linkage.BauGuiItem; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.inventory.SWItem; @@ -32,8 +32,8 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.GUI_ITEM) -public class RedstoneTesterGuiItem extends GuiItem { +@Linked(LinkageType.BAU_GUI_ITEM) +public class RedstoneTesterGuiItem extends BauGuiItem { public RedstoneTesterGuiItem() { super(23); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java index a06ed3c1..efc0ac8e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java @@ -19,8 +19,9 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; import de.steamwar.core.Core; -import org.bukkit.Material; import org.bukkit.attribute.Attribute; import org.bukkit.enchantments.Enchantment; import org.bukkit.event.EventHandler; @@ -29,12 +30,12 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -//@Linked(LinkageType.LISTENER) +@Linked(LinkageType.LISTENER) public class InventoryListener implements Listener { @EventHandler public void onInventoryClick(InventoryClickEvent e) { - ItemStack stack = e.getCursor(); + ItemStack stack = e.getCurrentItem(); if (stack == null || !stack.hasItemMeta()) { return; } @@ -47,11 +48,6 @@ public class InventoryListener implements Listener { } } - Material material = stack.getType(); - if (material == Material.POTION || material == Material.SPLASH_POTION || material == Material.LINGERING_POTION) { - stack.setType(Material.MILK_BUCKET); - } - if (Core.getVersion() < 15) { e.setCurrentItem(stack); return;