From 206e205d1b8aca1dd93c4747420e676a7ae3286d Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Mon, 13 Sep 2021 13:26:35 +0100 Subject: [PATCH 01/21] Deny using Slimefun Netherite in the SmithingTable + Tests --- .../slimefun4/implementation/Slimefun.java | 2 + .../crafting/SmithingTableListener.java | 42 ++++++ .../listeners/crafting/package-info.java | 2 +- src/main/resources/languages/en/messages.yml | 3 + .../listeners/TestSmithingTableListener.java | 135 ++++++++++++++++++ 5 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java index 0522e3920..6b6bf9a01 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java @@ -101,6 +101,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.Cart import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CauldronListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CraftingTableListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.SmithingTableListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.BeeListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.EntityInteractionListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.FireworksListener; @@ -610,6 +611,7 @@ public final class Slimefun extends JavaPlugin implements SlimefunAddon { new CauldronListener(this); new GrindstoneListener(this); new CartographyTableListener(this); + new SmithingTableListener(this); new ButcherAndroidListener(this); new MiningAndroidListener(this); new NetworkListener(this, networkManager); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java new file mode 100644 index 000000000..7803dd4c0 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java @@ -0,0 +1,42 @@ +package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; + +import javax.annotation.Nonnull; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event.Result; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; + +/** + * This {@link Listener} prevents any {@link SlimefunItem} from being used in a + * cartography table. + * + * @author Sefiraat + * + */ +public class SmithingTableListener implements SlimefunCraftingListener { + + public SmithingTableListener(@Nonnull Slimefun plugin) { + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + @EventHandler(ignoreCancelled = true) + public void onSmith(InventoryClickEvent e) { + if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.SMITHING) { + ItemStack itemStack = e.getInventory().getContents()[1]; + + if (isUnallowed(itemStack)) { + e.setResult(Result.DENY); + Slimefun.getLocalization().sendMessage(e.getWhoClicked(), "smithing_table.not-working", true); + } + } + + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java index 8c8f08ecc..0d777f377 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java @@ -1,5 +1,5 @@ /** * This package holds every {@link org.bukkit.event.Listener} which is responsible for preventing that a - * {@link me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem} is used in an unallowed crafting operation + * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} is used in an unallowed crafting operation */ package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; \ No newline at end of file diff --git a/src/main/resources/languages/en/messages.yml b/src/main/resources/languages/en/messages.yml index e721c3f1b..14b52086d 100644 --- a/src/main/resources/languages/en/messages.yml +++ b/src/main/resources/languages/en/messages.yml @@ -329,6 +329,9 @@ brewing_stand: cartography_table: not-working: '&4You cannot use Slimefun items in a cartography table!' +smithing_table: + not-working: '&4You cannot use Slimefun items as a smithing material!' + villagers: no-trading: '&4You cannot trade Slimefun items with Villagers!' diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java new file mode 100644 index 000000000..1de1ddfac --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java @@ -0,0 +1,135 @@ +package io.github.thebusybiscuit.slimefun4.implementation.listeners; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Event.Result; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.InventoryType.SlotType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; + +import io.github.bakedlibs.dough.items.CustomItemStack; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.SmithingTableListener; +import io.github.thebusybiscuit.slimefun4.test.TestUtilities; + +import be.seeseemelk.mockbukkit.MockBukkit; +import be.seeseemelk.mockbukkit.ServerMock; + +class TestSmithingTableListener { + + private static SmithingTableListener listener; + private static ServerMock server; + + private static SlimefunItem slimefunIngot; + private static SlimefunItem slimefunTool; + private static VanillaItem vanillaIngot; + private static VanillaItem vanillaTool; + + @BeforeAll + public static void load() { + server = MockBukkit.mock(); + Slimefun plugin = MockBukkit.load(Slimefun.class); + listener = new SmithingTableListener(plugin); + + slimefunTool = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND_SWORD", new CustomItemStack(Material.DIAMOND_SWORD, "&6Mock")); + slimefunIngot = TestUtilities.mockSlimefunItem(plugin, "MOCK_NETHERITE_INGOT", new CustomItemStack(Material.NETHERITE_INGOT, "&6Mock")); + vanillaTool = TestUtilities.mockVanillaItem(plugin, Material.DIAMOND_SWORD, true); + vanillaIngot = TestUtilities.mockVanillaItem(plugin, Material.NETHERITE_INGOT, true); + + slimefunTool.register(plugin); + slimefunIngot.register(plugin); + vanillaTool.register(plugin); + vanillaIngot.register(plugin); + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + private InventoryClickEvent mockSmithingEvent(ItemStack tool, ItemStack material) { + Player player = server.addPlayer(); + Inventory inv = TestUtilities.mockInventory(InventoryType.SMITHING, tool, material, null); + InventoryView view = player.openInventory(inv); + InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE); + + listener.onSmith(event); + return event; + } + + @Test + @DisplayName("Test that vanilla is unchanged (ItemStack tool x ItemStack material)") + void testSmithingTableWithItemStacks() { + InventoryClickEvent event = mockSmithingEvent(new ItemStack(Material.DIAMOND_SWORD), new ItemStack(Material.NETHERITE_INGOT)); + Assertions.assertEquals(Result.DEFAULT, event.getResult()); + } + + @Test + @DisplayName("Test that SlimefunItem material doesn't work (ItemStack tool x SlimefunItem material)") + void testSmithingTableWithItemStackAndSlimefunItem() { + InventoryClickEvent event = mockSmithingEvent(new ItemStack(Material.DIAMOND_SWORD), slimefunIngot.getItem()); + Assertions.assertEquals(Result.DENY, event.getResult()); + } + + @Test + @DisplayName("Test that VanillaItem material works (ItemStack tool x VanillaItem material)") + void testSmithingTableWithItemStackAndVanillaItem() { + InventoryClickEvent event = mockSmithingEvent(new ItemStack(Material.DIAMOND_SWORD), vanillaIngot.getItem()); + Assertions.assertEquals(Result.DEFAULT, event.getResult()); + } + + @Test + @DisplayName("Test that SlimefunItems can upgrade with vanilla (SlimefunItem tool x ItemStack material)") + void testSmithingTableWithSlimefunItemAndItemStack() { + InventoryClickEvent event = mockSmithingEvent(slimefunTool.getItem(), new ItemStack(Material.NETHERITE_INGOT)); + Assertions.assertEquals(Result.DEFAULT, event.getResult()); + } + + @Test + @DisplayName("Test that SlimefunItems can't upgrade with SlimefunItem materials (SlimefunItem tool x SlimefunItem material)") + void testSmithingTableWithSlimefunItems() { + InventoryClickEvent event = mockSmithingEvent(slimefunTool.getItem(), slimefunIngot.getItem()); + Assertions.assertEquals(Result.DENY, event.getResult()); + } + + @Test + @DisplayName("Test that SlimefunItems can upgrade with VanillaItems (SlimefunItem tool x VanillaItem material)") + void testSmithingTableWithSlimefunItemAndVanillaItem() { + InventoryClickEvent event = mockSmithingEvent(slimefunTool.getItem(), vanillaIngot.getItem()); + Assertions.assertEquals(Result.DEFAULT, event.getResult()); + } + + @Test + @DisplayName("Test that SlimefunItems can upgrade with vanilla (SlimefunItem tool x ItemStack material)") + void testSmithingTableWithVanillaItemAndItemStack() { + InventoryClickEvent event = mockSmithingEvent(vanillaTool.getItem(), new ItemStack(Material.NETHERITE_INGOT)); + Assertions.assertEquals(Result.DEFAULT, event.getResult()); + } + + @Test + @DisplayName("Test that SlimefunItems can't upgrade with SlimefunItem materials (SlimefunItem tool x SlimefunItem material)") + void testSmithingTableWithVanillaItemAndSlimefunItem() { + InventoryClickEvent event = mockSmithingEvent(vanillaTool.getItem(), slimefunIngot.getItem()); + Assertions.assertEquals(Result.DENY, event.getResult()); + } + + @Test + @DisplayName("Test that SlimefunItems can upgrade with VanillaItems (SlimefunItem tool x VanillaItem material)") + void testSmithingTableWithVanillaItemAndVanillaItem() { + InventoryClickEvent event = mockSmithingEvent(vanillaTool.getItem(), vanillaIngot.getItem()); + Assertions.assertEquals(Result.DEFAULT, event.getResult()); + } + +} From 13db44011b1cd0cbca9476e1ec38c15b5956a7cb Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Mon, 13 Sep 2021 14:02:09 +0100 Subject: [PATCH 02/21] Slight wording change --- src/main/resources/languages/en/messages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/languages/en/messages.yml b/src/main/resources/languages/en/messages.yml index 14b52086d..6346ef367 100644 --- a/src/main/resources/languages/en/messages.yml +++ b/src/main/resources/languages/en/messages.yml @@ -330,7 +330,7 @@ cartography_table: not-working: '&4You cannot use Slimefun items in a cartography table!' smithing_table: - not-working: '&4You cannot use Slimefun items as a smithing material!' + not-working: '&4You cannot use a Slimefun item as a smithing material!' villagers: no-trading: '&4You cannot trade Slimefun items with Villagers!' From 20beabcc3be62ed94bd4aa38ec756ffc91d9ae86 Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Mon, 13 Sep 2021 14:13:27 +0100 Subject: [PATCH 03/21] Apply suggestions from code review Co-authored-by: Daniel Walsh --- .../listeners/crafting/SmithingTableListener.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java index 7803dd4c0..466c811a6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java @@ -18,7 +18,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; * cartography table. * * @author Sefiraat - * */ public class SmithingTableListener implements SlimefunCraftingListener { @@ -28,7 +27,7 @@ public class SmithingTableListener implements SlimefunCraftingListener { @EventHandler(ignoreCancelled = true) public void onSmith(InventoryClickEvent e) { - if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.SMITHING) { + if (e.getInventory().getType() == InventoryType.SMITHING && e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player &&) { ItemStack itemStack = e.getInventory().getContents()[1]; if (isUnallowed(itemStack)) { @@ -36,7 +35,5 @@ public class SmithingTableListener implements SlimefunCraftingListener { Slimefun.getLocalization().sendMessage(e.getWhoClicked(), "smithing_table.not-working", true); } } - } - } From 153f33a72b7ff19ac1b5da268961ec8f9ee35601 Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Mon, 13 Sep 2021 14:36:17 +0100 Subject: [PATCH 04/21] Message indentation and remove random && --- .../listeners/crafting/SmithingTableListener.java | 2 +- src/main/resources/languages/en/messages.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java index 466c811a6..12f78007c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java @@ -27,7 +27,7 @@ public class SmithingTableListener implements SlimefunCraftingListener { @EventHandler(ignoreCancelled = true) public void onSmith(InventoryClickEvent e) { - if (e.getInventory().getType() == InventoryType.SMITHING && e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player &&) { + if (e.getInventory().getType() == InventoryType.SMITHING && e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player) { ItemStack itemStack = e.getInventory().getContents()[1]; if (isUnallowed(itemStack)) { diff --git a/src/main/resources/languages/en/messages.yml b/src/main/resources/languages/en/messages.yml index 6346ef367..290f8cde7 100644 --- a/src/main/resources/languages/en/messages.yml +++ b/src/main/resources/languages/en/messages.yml @@ -330,7 +330,7 @@ cartography_table: not-working: '&4You cannot use Slimefun items in a cartography table!' smithing_table: - not-working: '&4You cannot use a Slimefun item as a smithing material!' + not-working: '&4You cannot use a Slimefun item as a smithing material!' villagers: no-trading: '&4You cannot trade Slimefun items with Villagers!' From 83a4d1b65d1f4f697cea4d19ed135f39da8938f3 Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Mon, 13 Sep 2021 14:42:50 +0100 Subject: [PATCH 05/21] Comment to show it's the Material/Netherite slot --- .../listeners/crafting/SmithingTableListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java index 12f78007c..b422f96c9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java @@ -28,9 +28,10 @@ public class SmithingTableListener implements SlimefunCraftingListener { @EventHandler(ignoreCancelled = true) public void onSmith(InventoryClickEvent e) { if (e.getInventory().getType() == InventoryType.SMITHING && e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player) { - ItemStack itemStack = e.getInventory().getContents()[1]; + ItemStack materialItem = e.getInventory().getContents()[1]; - if (isUnallowed(itemStack)) { + // Checks if the Item in the Material/Netherite slot is allowed to be used. + if (isUnallowed(materialItem)) { e.setResult(Result.DENY); Slimefun.getLocalization().sendMessage(e.getWhoClicked(), "smithing_table.not-working", true); } From cc0add11372d707fb9e31bf13839b6a9721eec7b Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Tue, 14 Sep 2021 02:16:55 +0800 Subject: [PATCH 06/21] Hercules' Pickaxe now supports 1.17 deepslate ores and copper --- .../items/tools/HerculesPickaxe.java | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java index c3e935f3a..4ec837425 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java @@ -3,6 +3,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -25,16 +27,36 @@ public class HerculesPickaxe extends SimpleSlimefunItem { @Override public @Nonnull ToolUseHandler getItemHandler() { return (e, tool, fortune, drops) -> { - if (SlimefunTag.ORES.isTagged(e.getBlock().getType())) { - if (e.getBlock().getType() == Material.IRON_ORE) { - drops.add(new CustomItemStack(SlimefunItems.IRON_DUST, 2)); - } else if (e.getBlock().getType() == Material.GOLD_ORE) { - drops.add(new CustomItemStack(SlimefunItems.GOLD_DUST, 2)); - } else { - for (ItemStack drop : e.getBlock().getDrops(tool)) { - drops.add(new CustomItemStack(drop, drop.getAmount() * 2)); + Material mat = e.getBlock().getType(); + + if (SlimefunTag.ORES.isTagged(mat)) { + if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { + switch(mat) { + case DEEPSLATE_IRON_ORE: + drops.add(new CustomItemStack(SlimefunItems.IRON_DUST, 2)); + break; + case DEEPSLATE_GOLD_ORE: + drops.add(new CustomItemStack(SlimefunItems.GOLD_DUST, 2)); + break; + case COPPER_ORE: + case DEEPSLATE_COPPER_ORE: + drops.add(new CustomItemStack(SlimefunItems.COPPER_DUST, 2)); + break; } } + + switch(mat) { + case IRON_ORE: + drops.add(new CustomItemStack(SlimefunItems.IRON_DUST, 2)); + break; + case GOLD_ORE: + drops.add(new CustomItemStack(SlimefunItems.GOLD_DUST, 2)); + break; + default: + for (ItemStack drop : e.getBlock().getDrops(tool)) { + drops.add(new CustomItemStack(drop, drop.getAmount() * 2)); + } + } } }; } From fbc625317553cb056bca04c2afec5d5ebc3d6b3e Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Tue, 14 Sep 2021 02:20:31 +0800 Subject: [PATCH 07/21] move imports --- .../slimefun4/implementation/items/tools/HerculesPickaxe.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java index 4ec837425..28a74500d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java @@ -3,16 +3,16 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; From 002a0e3e465a9abf85b2bf60ccf782834971dd8e Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Tue, 14 Sep 2021 07:07:58 +0100 Subject: [PATCH 08/21] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java Co-authored-by: Daniel Walsh --- .../listeners/crafting/SmithingTableListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java index b422f96c9..7b09e659e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java @@ -30,7 +30,7 @@ public class SmithingTableListener implements SlimefunCraftingListener { if (e.getInventory().getType() == InventoryType.SMITHING && e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player) { ItemStack materialItem = e.getInventory().getContents()[1]; - // Checks if the Item in the Material/Netherite slot is allowed to be used. + // Checks if the item in the Material/Netherite slot is allowed to be used. if (isUnallowed(materialItem)) { e.setResult(Result.DENY); Slimefun.getLocalization().sendMessage(e.getWhoClicked(), "smithing_table.not-working", true); From 5d6b7e6acebf8f7dfddff06e2263c0db51547793 Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Tue, 14 Sep 2021 10:05:55 +0100 Subject: [PATCH 09/21] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java Co-authored-by: svr333 --- .../listeners/crafting/SmithingTableListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java index 7b09e659e..745a63736 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java @@ -15,7 +15,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; /** * This {@link Listener} prevents any {@link SlimefunItem} from being used in a - * cartography table. + * smithing table. * * @author Sefiraat */ From 2c8a40cb26afe1918ed024b9a4725766ebe23df2 Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Tue, 14 Sep 2021 18:10:08 +0800 Subject: [PATCH 10/21] add default to switch --- .../slimefun4/implementation/items/tools/HerculesPickaxe.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java index 28a74500d..5f283a21f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java @@ -42,6 +42,8 @@ public class HerculesPickaxe extends SimpleSlimefunItem { case DEEPSLATE_COPPER_ORE: drops.add(new CustomItemStack(SlimefunItems.COPPER_DUST, 2)); break; + default: + break; } } From e9b5ea5e814732a7bf264b35f00251602c7655a4 Mon Sep 17 00:00:00 2001 From: ybw0014 Date: Tue, 14 Sep 2021 18:11:18 +0800 Subject: [PATCH 11/21] add break to switch default --- .../slimefun4/implementation/items/tools/HerculesPickaxe.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java index 5f283a21f..a4c3858ec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java @@ -58,6 +58,7 @@ public class HerculesPickaxe extends SimpleSlimefunItem { for (ItemStack drop : e.getBlock().getDrops(tool)) { drops.add(new CustomItemStack(drop, drop.getAmount() * 2)); } + break; } } }; From fc8c02c7776df6ef55e709a58f70843eafd2e996 Mon Sep 17 00:00:00 2001 From: Varian Anora Date: Tue, 21 Sep 2021 21:52:01 +0700 Subject: [PATCH 12/21] Add missing recipes to Electrified Crucible This will make normal crucible and electrified crucible have the same recipe. Fixes #3273 --- .../items/electric/machines/ElectrifiedCrucible.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java index 2592f7e99..e7be0631b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java @@ -22,6 +22,8 @@ public class ElectrifiedCrucible extends AContainer { @Override protected void registerDefaultRecipes() { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.COBBLESTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.NETHERRACK, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.STONE, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.TERRACOTTA, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.OBSIDIAN) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); From f89e9d4ebd53c83373ceb210189c249dd52de122 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 22 Sep 2021 20:21:04 +0000 Subject: [PATCH 13/21] Update dependency org.junit.jupiter:junit-jupiter to v5.8.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea8c64cbb..062d97962 100644 --- a/pom.xml +++ b/pom.xml @@ -376,7 +376,7 @@ org.junit.jupiter junit-jupiter - 5.8.0 + 5.8.1 test From c2ab3b55ba4ccf6d30e90ed074c20a2edeec4729 Mon Sep 17 00:00:00 2001 From: Daniel Walsh Date: Thu, 23 Sep 2021 11:54:47 +0100 Subject: [PATCH 14/21] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdfcd6bb3..f82437592 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ ## Release Candidate 29 (TBD) #### Additions +* Added support for deepslate ores and copper with the Hercules' Pickaxe #### Changes * Massive performance improvements for Cargo networks From cc018582a61ad92c2260d4afa1340fceac45a79c Mon Sep 17 00:00:00 2001 From: Varian Anora Date: Thu, 23 Sep 2021 18:05:42 +0700 Subject: [PATCH 15/21] Fixed #3265 Add checks for off hand items. --- .../implementation/listeners/BackpackListener.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java index 36ec5e4a7..7a4d5d3be 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java @@ -103,6 +103,14 @@ public class BackpackListener implements Listener { e.setCancelled(true); } } + } else if (e.getClick() == ClickType.SWAP_OFFHAND) { // Fixes #3265 + if (e.getClickedInventory().getType() != InventoryType.PLAYER) { + ItemStack offHandItem = e.getWhoClicked().getInventory().getItemInOffHand(); + + if (!isAllowed((SlimefunBackpack) backpack, offHandItem)) { + e.setCancelled(true); + } + } } else if (!isAllowed((SlimefunBackpack) backpack, e.getCurrentItem())) { e.setCancelled(true); } From 1da20d0846c5cf83f5d181545bb966a760cbee19 Mon Sep 17 00:00:00 2001 From: Varian Anora Date: Thu, 23 Sep 2021 18:37:06 +0700 Subject: [PATCH 16/21] Better formatting --- .../implementation/listeners/BackpackListener.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java index 7a4d5d3be..a3ff32e05 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java @@ -103,13 +103,12 @@ public class BackpackListener implements Listener { e.setCancelled(true); } } - } else if (e.getClick() == ClickType.SWAP_OFFHAND) { // Fixes #3265 - if (e.getClickedInventory().getType() != InventoryType.PLAYER) { - ItemStack offHandItem = e.getWhoClicked().getInventory().getItemInOffHand(); + } else if (e.getClick() == ClickType.SWAP_OFFHAND && e.getClickedInventory().getType() != InventoryType.PLAYER) { + // Fixes #3265 + ItemStack offHandItem = e.getWhoClicked().getInventory().getItemInOffHand(); - if (!isAllowed((SlimefunBackpack) backpack, offHandItem)) { - e.setCancelled(true); - } + if (!isAllowed((SlimefunBackpack) backpack, offHandItem)) { + e.setCancelled(true); } } else if (!isAllowed((SlimefunBackpack) backpack, e.getCurrentItem())) { e.setCancelled(true); From 80dc5a5e51be7ff24561a39467c9f74f4cb794fd Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 24 Sep 2021 08:11:24 +0000 Subject: [PATCH 17/21] Update dependency com.github.seeseemelk:MockBukkit-v1.16 to v1.5.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 062d97962..bb770df60 100644 --- a/pom.xml +++ b/pom.xml @@ -388,7 +388,7 @@ com.github.seeseemelk MockBukkit-v1.16 - 1.5.0 + 1.5.2 test From bf6acd37af226d224ca68a8870714501c9b8f6f7 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 25 Sep 2021 20:58:51 +0200 Subject: [PATCH 18/21] [CI skip] Updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f82437592..bdcd5dada 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ #### Additions * Added support for deepslate ores and copper with the Hercules' Pickaxe +* The Electric Crucible now also accepts Netherrack +* The Electric Crucible now also accepts Stone #### Changes * Massive performance improvements for Cargo networks @@ -41,6 +43,7 @@ * Fixed #3218 * Fixed #3241 * Fixed #3248 +* Fixed #3273 ## Release Candidate 28 (06 Sep 2021) From b4ca3fc40ffaeaf056d4da5e035240faa347470c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 25 Sep 2021 21:15:06 +0200 Subject: [PATCH 19/21] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdcd5dada..c05dd97b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ * Fixed #3241 * Fixed #3248 * Fixed #3273 +* Fixed an exploit regarding the Smithing Table ## Release Candidate 28 (06 Sep 2021) From a1cd40998b60fa17c063c9537fd1e13f42ceaf07 Mon Sep 17 00:00:00 2001 From: Sfiguz7 Date: Sun, 26 Sep 2021 14:32:08 +0200 Subject: [PATCH 20/21] Removed unneeded final: added in a fix, limits extensibility --- .../items/electric/generators/SolarGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java index 867a98324..0bcd6cb0c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java @@ -65,7 +65,7 @@ public class SolarGenerator extends SlimefunItem implements EnergyNetProvider { } @Override - public final int getCapacity() { + public int getCapacity() { return 0; } From 215ac668e0c180c48354b9dc1e36871d901559ab Mon Sep 17 00:00:00 2001 From: Sfiguz7 Date: Sun, 26 Sep 2021 14:45:30 +0200 Subject: [PATCH 21/21] Added capaciy to solargens --- .../items/electric/generators/SolarGenerator.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java index 0bcd6cb0c..6ab335d39 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java @@ -35,13 +35,20 @@ public class SolarGenerator extends SlimefunItem implements EnergyNetProvider { private final int dayEnergy; private final int nightEnergy; + private final int capacity; @ParametersAreNonnullByDefault - public SolarGenerator(ItemGroup itemGroup, int dayEnergy, int nightEnergy, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public SolarGenerator(ItemGroup itemGroup, int dayEnergy, int nightEnergy, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, int capacity) { super(itemGroup, item, recipeType, recipe); this.dayEnergy = dayEnergy; this.nightEnergy = nightEnergy; + this.capacity = capacity; + } + + @ParametersAreNonnullByDefault + public SolarGenerator(ItemGroup itemGroup, int dayEnergy, int nightEnergy, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + this(itemGroup, dayEnergy, nightEnergy, item, recipeType, recipe, 0); } /** @@ -66,7 +73,7 @@ public class SolarGenerator extends SlimefunItem implements EnergyNetProvider { @Override public int getCapacity() { - return 0; + return capacity; } @Override