diff --git a/src/main/java/us/tastybento/bskyblock/api/addons/Addon.java b/src/main/java/us/tastybento/bskyblock/api/addons/Addon.java index f924ad73e..e90a8e516 100644 --- a/src/main/java/us/tastybento/bskyblock/api/addons/Addon.java +++ b/src/main/java/us/tastybento/bskyblock/api/addons/Addon.java @@ -3,6 +3,7 @@ package us.tastybento.bskyblock.api.addons; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.Optional; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.logging.Logger; @@ -254,4 +255,12 @@ public abstract class Addon implements AddonInterface { public IslandsManager getIslands() { return getBSkyBlock().getIslands(); } + + /** + * Get the Addon By Name + * @return Optional Addon + */ + public Optional getAddonByName(String name) { + return getBSkyBlock().getAddonsManager().getAddonByName(name); + } } diff --git a/src/main/java/us/tastybento/bskyblock/api/addons/AddonClassLoader.java b/src/main/java/us/tastybento/bskyblock/api/addons/AddonClassLoader.java index 368d8120d..9d242f16d 100644 --- a/src/main/java/us/tastybento/bskyblock/api/addons/AddonClassLoader.java +++ b/src/main/java/us/tastybento/bskyblock/api/addons/AddonClassLoader.java @@ -7,7 +7,6 @@ import java.net.URLClassLoader; import java.util.HashMap; import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.plugin.InvalidDescriptionException; import us.tastybento.bskyblock.BSkyBlock; diff --git a/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelItemBuilder.java b/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelItemBuilder.java index 64ec249ad..99bbfa512 100644 --- a/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelItemBuilder.java +++ b/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelItemBuilder.java @@ -29,7 +29,7 @@ public class PanelItemBuilder { this.icon = icon; return this; } - + /** * Set icon to player's head * @param playerUUID - player's UUID @@ -38,7 +38,7 @@ public class PanelItemBuilder { public PanelItemBuilder icon(UUID playerUUID) { return icon(Bukkit.getServer().getOfflinePlayer(playerUUID).getName()); } - + /** * Set icon to player's head * @param playerName - player's name diff --git a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java index b42a18d08..1d0286533 100644 --- a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java +++ b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java @@ -444,6 +444,7 @@ public class FlatFileDatabaseHandler extends AbstractDatabaseHandler { return object; } + @SuppressWarnings({ "unchecked", "rawtypes" }) private Object deserialize(Object value, Class clazz) { if (DEBUG) { plugin.getLogger().info("DEBUG: deserialize - class is " + clazz.getCanonicalName()); diff --git a/src/main/java/us/tastybento/bskyblock/database/objects/adapters/FlagSerializer.java b/src/main/java/us/tastybento/bskyblock/database/objects/adapters/FlagSerializer.java index e9bed17ea..4f9cfdb60 100644 --- a/src/main/java/us/tastybento/bskyblock/database/objects/adapters/FlagSerializer.java +++ b/src/main/java/us/tastybento/bskyblock/database/objects/adapters/FlagSerializer.java @@ -19,6 +19,7 @@ import us.tastybento.bskyblock.api.flags.Flag; */ public class FlagSerializer implements AdapterInterface, Map> { + @SuppressWarnings("unchecked") @Override public Map serialize(Object object) { Map result = new HashMap<>(); @@ -41,6 +42,7 @@ public class FlagSerializer implements AdapterInterface, Map< return result; } + @SuppressWarnings("unchecked") @Override public Map deserialize(Object object) { Map result = new HashMap<>(); diff --git a/src/main/java/us/tastybento/bskyblock/listeners/PanelListenerManager.java b/src/main/java/us/tastybento/bskyblock/listeners/PanelListenerManager.java index dd212dc2f..12c6a0ede 100644 --- a/src/main/java/us/tastybento/bskyblock/listeners/PanelListenerManager.java +++ b/src/main/java/us/tastybento/bskyblock/listeners/PanelListenerManager.java @@ -24,12 +24,13 @@ public class PanelListenerManager implements Listener { public void onInventoryClick(InventoryClickEvent event) { User user = User.getInstance(event.getWhoClicked()); // The player that // clicked the item - //UUID playerUUID = player.getUniqueId(); Inventory inventory = event.getInventory(); // The inventory that was // Open the inventory panel that this player has open (they can only ever have one) if (openPanels.containsKey(user.getUniqueId())) { // Check the name of the panel if (inventory.getName().equals(openPanels.get(user.getUniqueId()).getInventory().getName())) { + // Cancel the event. If they don't want it to be canceled then the click handler(s) should uncancel it + event.setCancelled(true); // Get the panel itself Panel panel = openPanels.get(user.getUniqueId()); // Check that they clicked on a specific item diff --git a/src/test/java/us/tastybento/bskyblock/api/panels/builders/PanelItemBuilderTest.java b/src/test/java/us/tastybento/bskyblock/api/panels/builders/PanelItemBuilderTest.java index 8c3d70ed5..db6c89e84 100644 --- a/src/test/java/us/tastybento/bskyblock/api/panels/builders/PanelItemBuilderTest.java +++ b/src/test/java/us/tastybento/bskyblock/api/panels/builders/PanelItemBuilderTest.java @@ -35,12 +35,10 @@ import us.tastybento.bskyblock.api.panels.PanelItem; @RunWith(PowerMockRunner.class) public class PanelItemBuilderTest { - private static PanelItemBuilder builder; @SuppressWarnings("deprecation") @BeforeClass - public static void setUp() throws Exception { - builder = new PanelItemBuilder(); + public static void setUp() throws Exception { Server server = mock(Server.class); World world = mock(World.class); world = mock(World.class); @@ -71,6 +69,7 @@ public class PanelItemBuilderTest { @Test public void testIconMaterial() { + PanelItemBuilder builder = new PanelItemBuilder(); builder.icon(Material.STONE); PanelItem item = builder.build(); assertNotNull(item.getItem().getType()); @@ -79,6 +78,7 @@ public class PanelItemBuilderTest { @Test public void testIconItemStack() { + PanelItemBuilder builder = new PanelItemBuilder(); builder.icon(new ItemStack(Material.IRON_ORE)); PanelItem item = builder.build(); assertNotNull(item.getItem().getType()); @@ -87,6 +87,7 @@ public class PanelItemBuilderTest { @Test public void testIconUUID() { + PanelItemBuilder builder = new PanelItemBuilder(); builder.icon(UUID.fromString("5988eecd-1dcd-4080-a843-785b62419")); PanelItem item = builder.build(); assertNotNull(item.getItem().getType()); @@ -96,6 +97,7 @@ public class PanelItemBuilderTest { @SuppressWarnings("deprecation") @Test public void testIconString() { + PanelItemBuilder builder = new PanelItemBuilder(); builder.icon("tastybento"); PanelItem item = builder.build(); assertNotNull(item.getItem().getType()); @@ -106,6 +108,7 @@ public class PanelItemBuilderTest { @Test public void testName() { + PanelItemBuilder builder = new PanelItemBuilder(); builder.name("test"); PanelItem item = builder.build(); assertEquals("test",item.getName()); @@ -113,6 +116,7 @@ public class PanelItemBuilderTest { @Test public void testDescriptionListOfString() { + PanelItemBuilder builder = new PanelItemBuilder(); List test = Arrays.asList("test line 1", "test line 2"); builder.description(test); PanelItem item = builder.build(); @@ -121,7 +125,8 @@ public class PanelItemBuilderTest { @Test public void testDescriptionStringArray() { - List test = Arrays.asList("test line 1", "test line 2", "test line 3", "test line 4"); + PanelItemBuilder builder = new PanelItemBuilder(); + List test = Arrays.asList("test line 3", "test line 4"); builder.description("test line 3", "test line 4"); PanelItem item = builder.build(); assertEquals(test, item.getDescription()); @@ -129,7 +134,8 @@ public class PanelItemBuilderTest { @Test public void testDescriptionString() { - List test = Arrays.asList("test line 1", "test line 2", "test line 3", "test line 4", "test line 5"); + PanelItemBuilder builder = new PanelItemBuilder(); + List test = Arrays.asList("test line 5"); builder.description("test line 5"); PanelItem item = builder.build(); assertEquals(test, item.getDescription()); @@ -137,6 +143,7 @@ public class PanelItemBuilderTest { @Test public void testClickHandler() { + PanelItemBuilder builder = new PanelItemBuilder(); // Test without click handler PanelItem item = builder.clickHandler(null).build(); assertFalse(item.getClickHandler().isPresent());