From 0937391220934783ac58fb3a3e3d9a6b581092af Mon Sep 17 00:00:00 2001 From: Senne Date: Wed, 6 Oct 2021 23:24:33 +0200 Subject: [PATCH 01/56] Initial tryout --- .../implementation/listeners/BlockListener.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index fcc75e0464..3616857a61 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -10,6 +10,7 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -20,6 +21,9 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCreativeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -129,6 +133,18 @@ public void onBlockBreak(BlockBreakEvent e) { dropItems(e, drops); } + @EventHandler + public void onInventoryCreativeEvent(InventoryCreativeEvent e) { + Bukkit.broadcastMessage(String.valueOf(e.isLeftClick())); + Bukkit.broadcastMessage(String.valueOf(e.isRightClick())); + if (e.getClick() == ClickType.CREATIVE) { + + Bukkit.broadcastMessage("kaas"); + ItemStack a = e.getCursor(); + //Bukkit.broadcastMessage(a.getType() + " " + a.getItemMeta().getLore().toString() + a.getItemMeta()); + } + } + @ParametersAreNonnullByDefault private void callToolHandler(BlockBreakEvent e, ItemStack item, int fortune, List drops) { SlimefunItem tool = SlimefunItem.getByItem(item); From 6978bdfe0db0caf8debb6f9a54fc3ed4ffb551aa Mon Sep 17 00:00:00 2001 From: Senne Date: Thu, 7 Oct 2021 15:11:42 +0200 Subject: [PATCH 02/56] Implement feature --- .../listeners/BlockListener.java | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 3616857a61..544f85b581 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -10,11 +10,11 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -22,8 +22,8 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCreativeEvent; +import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -39,12 +39,13 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; /** - * The {@link BlockListener} is responsible for listening to the {@link BlockPlaceEvent} - * and {@link BlockBreakEvent}. + * The {@link BlockListener} is responsible for listening to the {@link BlockPlaceEvent}, + * {@link BlockBreakEvent} abd {@link InventoryCreativeEvent}. * * @author TheBusyBiscuit * @author Linox * @author Patbox + * @author svr333 * * @see BlockPlaceHandler * @see BlockBreakHandler @@ -135,13 +136,40 @@ public void onBlockBreak(BlockBreakEvent e) { @EventHandler public void onInventoryCreativeEvent(InventoryCreativeEvent e) { - Bukkit.broadcastMessage(String.valueOf(e.isLeftClick())); - Bukkit.broadcastMessage(String.valueOf(e.isRightClick())); - if (e.getClick() == ClickType.CREATIVE) { + if (e.getClick() == ClickType.CREATIVE && e.getSlotType() == SlotType.QUICKBAR) { + HumanEntity player = e.getWhoClicked(); + Block b = player.getTargetBlockExact(5); - Bukkit.broadcastMessage("kaas"); - ItemStack a = e.getCursor(); - //Bukkit.broadcastMessage(a.getType() + " " + a.getItemMeta().getLore().toString() + a.getItemMeta()); + /* + * This check is really weird due to the weird nature of this event's behaviour. + * It checks if the block the player is looking at is of the same type as the cursor; + * after this we can make sure that it is a middle click outside of the inventory + * currentItem should also be air, otherwise it is not outside of the inventory + * the second line is the edge case where the player is looking at a WALL_HEAD but + * it is actually the same as a regular HEAD + */ + if (e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR || + (b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD)) { + Optional blockData = Slimefun.getBlockDataService().getBlockData(b); + + if (!blockData.isPresent()) { + return; + } + + SlimefunItem sfItem = SlimefunItem.getById(blockData.get()); + + // Check hotbar for a similar item two 'swap' to + for (int i = 0; i < 9; i++) { + SlimefunItem hotbarItem = SlimefunItem.getByItem(player.getInventory().getItem(i)); + if (hotbarItem != null && hotbarItem.getId() == sfItem.getId()) { + player.getInventory().setHeldItemSlot(i); + e.setCancelled(true); + return; + } + } + + e.setCursor(sfItem.getItem()); + } } } From 02b0411d5734ce6ff0f634c6f1adfe536f9bca22 Mon Sep 17 00:00:00 2001 From: Senne Date: Thu, 7 Oct 2021 15:21:33 +0200 Subject: [PATCH 03/56] Clone item --- .../slimefun4/implementation/listeners/BlockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 544f85b581..7d6d502dce 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -168,7 +168,7 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { } } - e.setCursor(sfItem.getItem()); + e.setCursor(sfItem.getItem().clone()); } } } From c8821548606b1eadec1f96358c5390e6b77fdc3f Mon Sep 17 00:00:00 2001 From: Senne Date: Thu, 7 Oct 2021 15:22:14 +0200 Subject: [PATCH 04/56] Typos --- .../slimefun4/implementation/listeners/BlockListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 7d6d502dce..bfdbd0e0e7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -40,7 +40,7 @@ /** * The {@link BlockListener} is responsible for listening to the {@link BlockPlaceEvent}, - * {@link BlockBreakEvent} abd {@link InventoryCreativeEvent}. + * {@link BlockBreakEvent} and {@link InventoryCreativeEvent}. * * @author TheBusyBiscuit * @author Linox @@ -158,7 +158,7 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { SlimefunItem sfItem = SlimefunItem.getById(blockData.get()); - // Check hotbar for a similar item two 'swap' to + // Check hotbar for a similar item to 'swap' to for (int i = 0; i < 9; i++) { SlimefunItem hotbarItem = SlimefunItem.getByItem(player.getInventory().getItem(i)); if (hotbarItem != null && hotbarItem.getId() == sfItem.getId()) { From eb790b232b773d61349c36f42ac9bdbc5b1836f1 Mon Sep 17 00:00:00 2001 From: svr333 Date: Thu, 7 Oct 2021 17:19:24 +0200 Subject: [PATCH 05/56] rename blockData to blockId Co-authored-by: Daniel Walsh --- .../slimefun4/implementation/listeners/BlockListener.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index bfdbd0e0e7..19f15c3ffd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -150,13 +150,13 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { */ if (e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR || (b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD)) { - Optional blockData = Slimefun.getBlockDataService().getBlockData(b); + Optional blockId = Slimefun.getBlockDataService().getBlockData(b); - if (!blockData.isPresent()) { + if (!blockId.isPresent()) { return; } - SlimefunItem sfItem = SlimefunItem.getById(blockData.get()); + SlimefunItem sfItem = SlimefunItem.getById(blockId.get()); // Check hotbar for a similar item to 'swap' to for (int i = 0; i < 9; i++) { From bdf2a1b8a1bac2b2dad6b1bceafefa85d97d3c8d Mon Sep 17 00:00:00 2001 From: Senne Date: Thu, 7 Oct 2021 17:25:20 +0200 Subject: [PATCH 06/56] Clean up if --- .../implementation/listeners/BlockListener.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index bfdbd0e0e7..e451c7cb1e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -145,11 +145,13 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { * It checks if the block the player is looking at is of the same type as the cursor; * after this we can make sure that it is a middle click outside of the inventory * currentItem should also be air, otherwise it is not outside of the inventory - * the second line is the edge case where the player is looking at a WALL_HEAD but - * it is actually the same as a regular HEAD */ - if (e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR || - (b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD)) { + boolean isOutsideInventoryClick = e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR; + + // player is looking at WALL_HEAD but it's actually a player head + boolean isPlayerWallhead = b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD; + + if (isOutsideInventoryClick || isPlayerWallhead) { Optional blockData = Slimefun.getBlockDataService().getBlockData(b); if (!blockData.isPresent()) { From f320fe5d9fb95c2729e7140bfa14c71c522d0cf3 Mon Sep 17 00:00:00 2001 From: svr333 Date: Sat, 9 Oct 2021 12:47:56 +0200 Subject: [PATCH 07/56] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java Co-authored-by: Daniel Walsh --- .../slimefun4/implementation/listeners/BlockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 0da0e0c9fe..62222fca31 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -163,7 +163,7 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { // Check hotbar for a similar item to 'swap' to for (int i = 0; i < 9; i++) { SlimefunItem hotbarItem = SlimefunItem.getByItem(player.getInventory().getItem(i)); - if (hotbarItem != null && hotbarItem.getId() == sfItem.getId()) { + if (hotbarItem != null && hotbarItem.getId().equals(sfItem.getId())) { player.getInventory().setHeldItemSlot(i); e.setCancelled(true); return; From da46794ac43ff30c0a4ff0b33ad61d56d408860d Mon Sep 17 00:00:00 2001 From: svr333 Date: Sat, 9 Oct 2021 15:46:50 +0200 Subject: [PATCH 08/56] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java Co-authored-by: Daniel Walsh --- .../implementation/listeners/BlockListener.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 62222fca31..7c71d9e6c0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -141,11 +141,11 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { Block b = player.getTargetBlockExact(5); /* - * This check is really weird due to the weird nature of this event's behaviour. - * It checks if the block the player is looking at is of the same type as the cursor; - * after this we can make sure that it is a middle click outside of the inventory - * currentItem should also be air, otherwise it is not outside of the inventory - */ + * This check is really weird due to the weird nature of this event's behaviour. + * It checks if the block the player is looking at is of the same type as the cursor; + * after this we can make sure that it is a middle click outside of the inventory + * currentItem should also be air, otherwise it is not outside of the inventory + */ boolean isOutsideInventoryClick = e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR; // player is looking at WALL_HEAD but it's actually a player head From fc6805d943dc3e5577202c0a443f2e0478b45642 Mon Sep 17 00:00:00 2001 From: Senne Date: Sat, 23 Oct 2021 15:17:12 +0200 Subject: [PATCH 09/56] Move to separate class --- .../slimefun4/implementation/Slimefun.java | 2 + .../listeners/BlockListener.java | 48 +--------- .../listeners/MiddleClickListener.java | 95 +++++++++++++++++++ 3 files changed, 98 insertions(+), 47 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.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 6b6bf9a016..789eb68abb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java @@ -81,6 +81,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.HopperListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemDropListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.MiddleClickListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.MiningAndroidListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener; @@ -620,6 +621,7 @@ private void registerListeners() { new SoulboundListener(this); new AutoCrafterListener(this); new SlimefunItemHitListener(this); + new MiddleClickListener(this); // Bees were added in 1.15 if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 0da0e0c9fe..6bcf943cd4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -14,16 +14,12 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryCreativeEvent; -import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -40,12 +36,11 @@ /** * The {@link BlockListener} is responsible for listening to the {@link BlockPlaceEvent}, - * {@link BlockBreakEvent} and {@link InventoryCreativeEvent}. + * and {@link BlockBreakEvent}. * * @author TheBusyBiscuit * @author Linox * @author Patbox - * @author svr333 * * @see BlockPlaceHandler * @see BlockBreakHandler @@ -134,47 +129,6 @@ public void onBlockBreak(BlockBreakEvent e) { dropItems(e, drops); } - @EventHandler - public void onInventoryCreativeEvent(InventoryCreativeEvent e) { - if (e.getClick() == ClickType.CREATIVE && e.getSlotType() == SlotType.QUICKBAR) { - HumanEntity player = e.getWhoClicked(); - Block b = player.getTargetBlockExact(5); - - /* - * This check is really weird due to the weird nature of this event's behaviour. - * It checks if the block the player is looking at is of the same type as the cursor; - * after this we can make sure that it is a middle click outside of the inventory - * currentItem should also be air, otherwise it is not outside of the inventory - */ - boolean isOutsideInventoryClick = e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR; - - // player is looking at WALL_HEAD but it's actually a player head - boolean isPlayerWallhead = b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD; - - if (isOutsideInventoryClick || isPlayerWallhead) { - Optional blockId = Slimefun.getBlockDataService().getBlockData(b); - - if (!blockId.isPresent()) { - return; - } - - SlimefunItem sfItem = SlimefunItem.getById(blockId.get()); - - // Check hotbar for a similar item to 'swap' to - for (int i = 0; i < 9; i++) { - SlimefunItem hotbarItem = SlimefunItem.getByItem(player.getInventory().getItem(i)); - if (hotbarItem != null && hotbarItem.getId() == sfItem.getId()) { - player.getInventory().setHeldItemSlot(i); - e.setCancelled(true); - return; - } - } - - e.setCursor(sfItem.getItem().clone()); - } - } - } - @ParametersAreNonnullByDefault private void callToolHandler(BlockBreakEvent e, ItemStack item, int fortune, List drops) { SlimefunItem tool = SlimefunItem.getByItem(item); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java new file mode 100644 index 0000000000..bc5d62bc60 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -0,0 +1,95 @@ +package io.github.thebusybiscuit.slimefun4.implementation.listeners; + +import java.util.Optional; + +import javax.annotation.Nonnull; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.HumanEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryCreativeEvent; +import org.bukkit.event.inventory.InventoryType.SlotType; + +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; + +/** + * The {@link MiddleClickListener} is responsible for listening to the {@link InventoryCreativeEvent}. + * + * @author svr333 + * + */ +public class MiddleClickListener implements Listener { + + public MiddleClickListener(@Nonnull Slimefun plugin) { + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + /* + * General Discloser: this event has really really really weird behavior on middle click. + * Has been tested thoroughly to make sure it doesnt break anything else. + */ + @EventHandler + public void onInventoryCreativeEvent(InventoryCreativeEvent e) { + /* + * When clicking outside of an inventory with middle click, + * ClickType is not MIDDLE but CREATIVE (because this ClickType covers + * multiple cases, we have to filter out more) + */ + if (e.getClick() == ClickType.CREATIVE && e.getSlotType() == SlotType.QUICKBAR) { + HumanEntity player = e.getWhoClicked(); + // get the block the player is looking at for later + Block b = player.getTargetBlockExact(5); + + /* + * In the case on a middle click outside the user inventory, cursor will be set + * to the actual block that is middle clicked, while currentItem will be AIR. + * + * This check is really weird due to the weird nature of this event's behaviour. + * It checks if the block the player is looking at is of the same type as the cursor; + * after this we can make sure that it is a middle click outside of the inventory + * currentItem should also be air, otherwise it is not outside of the inventory + */ + boolean isOutsideInventoryClick = e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR; + + /* + * This is an edge case where the player is looking at a WALL_HEAD (eg. cargo) + * and then the boolean above wont match because WALL_HEAD != PLAYER_HEAD. + * This check makes up for that lack. + */ + boolean isPlayerWallhead = b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD; + + if (isOutsideInventoryClick || isPlayerWallhead) { + Optional blockId = Slimefun.getBlockDataService().getBlockData(b); + + if (!blockId.isPresent()) { + return; + } + + // find the actual slimefun item the user is looking at + SlimefunItem sfItem = SlimefunItem.getById(blockId.get()); + + /* + * Before giving the item to the user, check if you can swap + * to the item instead (user already has item in inventory). + * This is sometimes bypassed by the client itself (not fixable though). + */ + for (int i = 0; i < 9; i++) { + SlimefunItem hotbarItem = SlimefunItem.getByItem(player.getInventory().getItem(i)); + if (hotbarItem != null && hotbarItem.getId() == sfItem.getId()) { + player.getInventory().setHeldItemSlot(i); + // Has to be cancelled in order for it to work properly. + e.setCancelled(true); + return; + } + } + + // Give the item, doing it like this will not alter any other cases. + e.setCursor(sfItem.getItem().clone()); + } + } + } +} From 4e92102a38b44f565e9789a3390130e65485e8e1 Mon Sep 17 00:00:00 2001 From: Senne Date: Sat, 23 Oct 2021 15:18:46 +0200 Subject: [PATCH 10/56] Fix typo --- .../slimefun4/implementation/listeners/BlockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 6bcf943cd4..fcc75e0464 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -35,7 +35,7 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; /** - * The {@link BlockListener} is responsible for listening to the {@link BlockPlaceEvent}, + * The {@link BlockListener} is responsible for listening to the {@link BlockPlaceEvent} * and {@link BlockBreakEvent}. * * @author TheBusyBiscuit From 4792124224fcd7c8dc30b44a32883d139fe0114e Mon Sep 17 00:00:00 2001 From: Senne Date: Sat, 1 Jan 2022 22:46:11 +0100 Subject: [PATCH 11/56] Refactor MiddleClickListener --- .../listeners/MiddleClickListener.java | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java index bc5d62bc60..3c212392d6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -15,6 +15,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import me.mrCookieSlime.Slimefun.api.BlockStorage; /** * The {@link MiddleClickListener} is responsible for listening to the {@link InventoryCreativeEvent}. @@ -37,44 +38,26 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { /* * When clicking outside of an inventory with middle click, * ClickType is not MIDDLE but CREATIVE (because this ClickType covers - * multiple cases, we have to filter out more) + * multiple cases, we have to filter out more later on) */ if (e.getClick() == ClickType.CREATIVE && e.getSlotType() == SlotType.QUICKBAR) { HumanEntity player = e.getWhoClicked(); // get the block the player is looking at for later Block b = player.getTargetBlockExact(5); - /* - * In the case on a middle click outside the user inventory, cursor will be set - * to the actual block that is middle clicked, while currentItem will be AIR. - * - * This check is really weird due to the weird nature of this event's behaviour. - * It checks if the block the player is looking at is of the same type as the cursor; - * after this we can make sure that it is a middle click outside of the inventory - * currentItem should also be air, otherwise it is not outside of the inventory - */ - boolean isOutsideInventoryClick = e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR; - - /* - * This is an edge case where the player is looking at a WALL_HEAD (eg. cargo) - * and then the boolean above wont match because WALL_HEAD != PLAYER_HEAD. - * This check makes up for that lack. - */ - boolean isPlayerWallhead = b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD; - - if (isOutsideInventoryClick || isPlayerWallhead) { - Optional blockId = Slimefun.getBlockDataService().getBlockData(b); + if (isActualMiddleClick(e, b)) { + // find the actual slimefun item the user is looking at + String id = BlockStorage.checkID(b); + SlimefunItem sfItem = SlimefunItem.getById(id); - if (!blockId.isPresent()) { + // vanilla block -> ignore + if (sfItem == null) { return; } - - // find the actual slimefun item the user is looking at - SlimefunItem sfItem = SlimefunItem.getById(blockId.get()); /* * Before giving the item to the user, check if you can swap - * to the item instead (user already has item in inventory). + * to the item instead (user already has item in hotbar). * This is sometimes bypassed by the client itself (not fixable though). */ for (int i = 0; i < 9; i++) { @@ -92,4 +75,26 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { } } } + + private boolean isActualMiddleClick(InventoryCreativeEvent e, Block b) { + /* + * On a middle click outside the user inventory, cursor will be set + * to the actual block that is middle clicked, while currentItem will be AIR. + * + * This check is really weird due to the weird nature of this event's behaviour. + * It checks if the block the player is looking at is of the same type as the cursor; + * after this we can make sure that it is a middle click outside of the inventory + * currentItem should also be air, otherwise it is not outside of the inventory + */ + boolean isOutsideInventoryClick = e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR; + + /* + * This is an edge case where the player is looking at a WALL_HEAD (eg. cargo) + * and then the boolean above wont match because WALL_HEAD != PLAYER_HEAD. + * This check makes up for that lack. + */ + boolean isPlayerWallhead = b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD; + + return isOutsideInventoryClick || isPlayerWallhead; + } } From ef8e84a3504546f77f8c02380e06f18f6e9d6d6a Mon Sep 17 00:00:00 2001 From: Senne Date: Sat, 1 Jan 2022 22:48:16 +0100 Subject: [PATCH 12/56] Invert if statement --- .../listeners/MiddleClickListener.java | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java index 3c212392d6..2300dc54ef 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -45,34 +45,36 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { // get the block the player is looking at for later Block b = player.getTargetBlockExact(5); - if (isActualMiddleClick(e, b)) { - // find the actual slimefun item the user is looking at - String id = BlockStorage.checkID(b); - SlimefunItem sfItem = SlimefunItem.getById(id); + if (!isActualMiddleClick(e, b)) { + return; + } + + // find the actual slimefun item the user is looking at + String id = BlockStorage.checkID(b); + SlimefunItem sfItem = SlimefunItem.getById(id); - // vanilla block -> ignore - if (sfItem == null) { + // vanilla block -> ignore + if (sfItem == null) { + return; + } + + /* + * Before giving the item to the user, check if you can swap + * to the item instead (user already has item in hotbar). + * This is sometimes bypassed by the client itself (not fixable though). + */ + for (int i = 0; i < 9; i++) { + SlimefunItem hotbarItem = SlimefunItem.getByItem(player.getInventory().getItem(i)); + if (hotbarItem != null && hotbarItem.getId() == sfItem.getId()) { + player.getInventory().setHeldItemSlot(i); + // Has to be cancelled in order for it to work properly. + e.setCancelled(true); return; } - - /* - * Before giving the item to the user, check if you can swap - * to the item instead (user already has item in hotbar). - * This is sometimes bypassed by the client itself (not fixable though). - */ - for (int i = 0; i < 9; i++) { - SlimefunItem hotbarItem = SlimefunItem.getByItem(player.getInventory().getItem(i)); - if (hotbarItem != null && hotbarItem.getId() == sfItem.getId()) { - player.getInventory().setHeldItemSlot(i); - // Has to be cancelled in order for it to work properly. - e.setCancelled(true); - return; - } - } - - // Give the item, doing it like this will not alter any other cases. - e.setCursor(sfItem.getItem().clone()); } + + // Give the item, doing it like this will not alter any other cases. + e.setCursor(sfItem.getItem().clone()); } } From 7f8ef8be84ff127eb3e4c4d167481f2117967b45 Mon Sep 17 00:00:00 2001 From: svr333 Date: Sun, 2 Jan 2022 15:17:45 +0100 Subject: [PATCH 13/56] Minor tweaks Co-authored-by: TheBusyBiscuit --- .../implementation/listeners/MiddleClickListener.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java index 2300dc54ef..be1fe4c73a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -50,8 +50,7 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { } // find the actual slimefun item the user is looking at - String id = BlockStorage.checkID(b); - SlimefunItem sfItem = SlimefunItem.getById(id); + SlimefunItem sfItem = BlockStorage.check(b); // vanilla block -> ignore if (sfItem == null) { @@ -59,10 +58,10 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { } /* - * Before giving the item to the user, check if you can swap - * to the item instead (user already has item in hotbar). - * This is sometimes bypassed by the client itself (not fixable though). - */ + * Before giving the item to the user, check if you can swap + * to the item instead (user already has item in hotbar). + * This is sometimes bypassed by the client itself (not fixable though). + */ for (int i = 0; i < 9; i++) { SlimefunItem hotbarItem = SlimefunItem.getByItem(player.getInventory().getItem(i)); if (hotbarItem != null && hotbarItem.getId() == sfItem.getId()) { From fc8ffabbcfa5e1d21314a71e2a3864c9e29bb0de Mon Sep 17 00:00:00 2001 From: Senne Date: Wed, 12 Jan 2022 22:23:19 +0100 Subject: [PATCH 14/56] Switch to sfItem.isItem() --- .../implementation/listeners/MiddleClickListener.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java index be1fe4c73a..910bc95872 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -63,8 +63,7 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { * This is sometimes bypassed by the client itself (not fixable though). */ for (int i = 0; i < 9; i++) { - SlimefunItem hotbarItem = SlimefunItem.getByItem(player.getInventory().getItem(i)); - if (hotbarItem != null && hotbarItem.getId() == sfItem.getId()) { + if (sfItem.isItem(player.getInventory().getItem(i))) { player.getInventory().setHeldItemSlot(i); // Has to be cancelled in order for it to work properly. e.setCancelled(true); From 3ac8cadbc1f00cf9c5cbab544dc18b39806eacc5 Mon Sep 17 00:00:00 2001 From: Daniel Walsh Date: Tue, 18 Jan 2022 14:02:50 +0000 Subject: [PATCH 15/56] Fix multi-line comment --- .../listeners/MiddleClickListener.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java index 910bc95872..1087fb4994 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -78,21 +78,21 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { private boolean isActualMiddleClick(InventoryCreativeEvent e, Block b) { /* - * On a middle click outside the user inventory, cursor will be set - * to the actual block that is middle clicked, while currentItem will be AIR. - * - * This check is really weird due to the weird nature of this event's behaviour. - * It checks if the block the player is looking at is of the same type as the cursor; - * after this we can make sure that it is a middle click outside of the inventory - * currentItem should also be air, otherwise it is not outside of the inventory - */ + * On a middle click outside the user inventory, cursor will be set + * to the actual block that is middle clicked, while currentItem will be AIR. + * + * This check is really weird due to the weird nature of this event's behaviour. + * It checks if the block the player is looking at is of the same type as the cursor; + * after this we can make sure that it is a middle click outside of the inventory + * currentItem should also be air, otherwise it is not outside of the inventory + */ boolean isOutsideInventoryClick = e.getCursor().getType() == b.getType() && e.getCurrentItem().getType() == Material.AIR; /* - * This is an edge case where the player is looking at a WALL_HEAD (eg. cargo) - * and then the boolean above wont match because WALL_HEAD != PLAYER_HEAD. - * This check makes up for that lack. - */ + * This is an edge case where the player is looking at a WALL_HEAD (eg. cargo) + * and then the boolean above wont match because WALL_HEAD != PLAYER_HEAD. + * This check makes up for that lack. + */ boolean isPlayerWallhead = b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD; return isOutsideInventoryClick || isPlayerWallhead; From e02e089b7fe7a5b3d472a108d7787f5da403581e Mon Sep 17 00:00:00 2001 From: Senne Date: Wed, 19 Jan 2022 17:37:48 +0100 Subject: [PATCH 16/56] Add ParamsAreNonNullByDefault --- .../slimefun4/implementation/listeners/MiddleClickListener.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java index 1087fb4994..e30697a76f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -3,6 +3,7 @@ import java.util.Optional; import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; import org.bukkit.block.Block; @@ -76,6 +77,7 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { } } + @ParametersAreNonnullByDefault private boolean isActualMiddleClick(InventoryCreativeEvent e, Block b) { /* * On a middle click outside the user inventory, cursor will be set From ae18ec1114816aab0d899cf77effb2668327454d Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Fri, 28 Jan 2022 18:39:14 +0800 Subject: [PATCH 17/56] chore(guide): don't display item that its itemGroup not be unlocked --- .../slimefun4/implementation/guide/SurvivalSlimefunGuide.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index 9d1f39ab5a..c132f74281 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -358,7 +358,7 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory break; } - if (!slimefunItem.isHidden() && isSearchFilterApplicable(slimefunItem, searchTerm)) { + if (!slimefunItem.isHidden() && !slimefunItem.getItemGroup().isHidden(p) && isSearchFilterApplicable(slimefunItem, searchTerm)) { ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); From ee34322dec2a989a934dd967fb5bfedd43cf02a6 Mon Sep 17 00:00:00 2001 From: FN-FAL113 <88238718+FN-FAL113@users.noreply.github.com> Date: Sun, 30 Jan 2022 10:49:55 +0800 Subject: [PATCH 18/56] Added support for glass bottle --- .../items/electric/machines/FluidPump.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java index 87f948bcbf..c96678691b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java @@ -38,6 +38,9 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionType; /** * This machine collects liquids from the {@link World} and puts them @@ -57,6 +60,17 @@ public class FluidPump extends SimpleSlimefunItem implements Invent private final int[] outputBorder = { 14, 15, 16, 17, 23, 26, 32, 33, 34, 35 }; private final ItemStack emptyBucket = ItemStackWrapper.wrap(new ItemStack(Material.BUCKET)); + private final ItemStack emptyBottle = ItemStackWrapper.wrap(new ItemStack(Material.GLASS_BOTTLE)); + + private static final ItemStack waterBottle = new ItemStack(Material.POTION); + + static { + PotionMeta meta = (PotionMeta) waterBottle.getItemMeta(); + if(meta != null) { + meta.setBasePotionData(new PotionData(PotionType.WATER)); + waterBottle.setItemMeta(meta); + } + } @ParametersAreNonnullByDefault public FluidPump(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -153,6 +167,24 @@ protected void tick(@Nonnull Block b) { nextFluid.setType(Material.AIR); } + return; + } + if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), emptyBottle, true, false)) { + ItemStack glassBottle = getFilledBottle(fluid); + + if (!menu.fits(glassBottle, getOutputSlots())) { + return; + } + + Block nextFluid = findNextFluid(fluid); + + if (nextFluid != null) { + removeCharge(b.getLocation(), ENERGY_CONSUMPTION); + menu.consumeItem(slot); + menu.pushItem(glassBottle, getOutputSlots()); + nextFluid.setType(Material.AIR); + } + return; } } @@ -185,6 +217,17 @@ private Block findNextFluid(@Nonnull Block fluid) { return null; } + @Nonnull + private ItemStack getFilledBottle(@Nonnull Block fluid){ + switch(fluid.getType()){ + case WATER: + case BUBBLE_COLUMN: + return waterBottle; + default: + return new ItemStack(Material.GLASS_BOTTLE); + } + } + @Nonnull private ItemStack getFilledBucket(@Nonnull Block fluid) { switch (fluid.getType()) { From da37209bb8c4eb938da3ec8da454c0528c00ea16 Mon Sep 17 00:00:00 2001 From: FN-FAL113 <88238718+FN-FAL113@users.noreply.github.com> Date: Sun, 30 Jan 2022 19:09:16 +0800 Subject: [PATCH 19/56] Hopefully resolve request changes --- .../items/electric/machines/FluidPump.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java index c96678691b..55a41c9477 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java @@ -1,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; import java.util.List; +import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -55,6 +56,8 @@ public class FluidPump extends SimpleSlimefunItem implements Invent private static final int ENERGY_CONSUMPTION = 32; private static final int RANGE = 42; + private final ItemStack WATER_BOTTLE = new ItemStack(Material.POTION); + private final int[] border = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44, 22 }; private final int[] inputBorder = { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 }; private final int[] outputBorder = { 14, 15, 16, 17, 23, 26, 32, 33, 34, 35 }; @@ -62,22 +65,15 @@ public class FluidPump extends SimpleSlimefunItem implements Invent private final ItemStack emptyBucket = ItemStackWrapper.wrap(new ItemStack(Material.BUCKET)); private final ItemStack emptyBottle = ItemStackWrapper.wrap(new ItemStack(Material.GLASS_BOTTLE)); - private static final ItemStack waterBottle = new ItemStack(Material.POTION); - - static { - PotionMeta meta = (PotionMeta) waterBottle.getItemMeta(); - if(meta != null) { - meta.setBasePotionData(new PotionData(PotionType.WATER)); - waterBottle.setItemMeta(meta); - } - } - @ParametersAreNonnullByDefault public FluidPump(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, item, recipeType, recipe); addItemHandler(onBreak()); createPreset(this, this::constructMenu); + PotionMeta meta = (PotionMeta) this.WATER_BOTTLE.getItemMeta(); + meta.setBasePotionData(new PotionData(PotionType.WATER)); + this.WATER_BOTTLE.setItemMeta(meta); } @Nonnull @@ -170,9 +166,9 @@ protected void tick(@Nonnull Block b) { return; } if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), emptyBottle, true, false)) { - ItemStack glassBottle = getFilledBottle(fluid); + ItemStack bottle = getFilledBottle(fluid); - if (!menu.fits(glassBottle, getOutputSlots())) { + if (!menu.fits(bottle, getOutputSlots())) { return; } @@ -181,8 +177,10 @@ protected void tick(@Nonnull Block b) { if (nextFluid != null) { removeCharge(b.getLocation(), ENERGY_CONSUMPTION); menu.consumeItem(slot); - menu.pushItem(glassBottle, getOutputSlots()); - nextFluid.setType(Material.AIR); + menu.pushItem(bottle, getOutputSlots()); + if(ThreadLocalRandom.current().nextInt(100) < 30) { + nextFluid.setType(Material.AIR); + } } return; @@ -222,7 +220,7 @@ private ItemStack getFilledBottle(@Nonnull Block fluid){ switch(fluid.getType()){ case WATER: case BUBBLE_COLUMN: - return waterBottle; + return WATER_BOTTLE.clone(); default: return new ItemStack(Material.GLASS_BOTTLE); } From 6132683f0030cbcc27796e842125b0ab33c2fc0d Mon Sep 17 00:00:00 2001 From: FN-FAL113 <88238718+FN-FAL113@users.noreply.github.com> Date: Sun, 30 Jan 2022 19:32:36 +0800 Subject: [PATCH 20/56] camelCase non static instance variable --- .../items/electric/machines/FluidPump.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java index 55a41c9477..12d431e89e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java @@ -56,14 +56,13 @@ public class FluidPump extends SimpleSlimefunItem implements Invent private static final int ENERGY_CONSUMPTION = 32; private static final int RANGE = 42; - private final ItemStack WATER_BOTTLE = new ItemStack(Material.POTION); - private final int[] border = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44, 22 }; private final int[] inputBorder = { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 }; private final int[] outputBorder = { 14, 15, 16, 17, 23, 26, 32, 33, 34, 35 }; private final ItemStack emptyBucket = ItemStackWrapper.wrap(new ItemStack(Material.BUCKET)); private final ItemStack emptyBottle = ItemStackWrapper.wrap(new ItemStack(Material.GLASS_BOTTLE)); + private final ItemStack waterBottle = new ItemStack(Material.POTION); @ParametersAreNonnullByDefault public FluidPump(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -71,9 +70,9 @@ public FluidPump(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeT addItemHandler(onBreak()); createPreset(this, this::constructMenu); - PotionMeta meta = (PotionMeta) this.WATER_BOTTLE.getItemMeta(); + PotionMeta meta = (PotionMeta) this.waterBottle.getItemMeta(); meta.setBasePotionData(new PotionData(PotionType.WATER)); - this.WATER_BOTTLE.setItemMeta(meta); + this.waterBottle.setItemMeta(meta); } @Nonnull @@ -220,7 +219,7 @@ private ItemStack getFilledBottle(@Nonnull Block fluid){ switch(fluid.getType()){ case WATER: case BUBBLE_COLUMN: - return WATER_BOTTLE.clone(); + return waterBottle.clone(); default: return new ItemStack(Material.GLASS_BOTTLE); } From c3cc30e23ce1709c77cd2d264a7ca072cd572ac8 Mon Sep 17 00:00:00 2001 From: FN-FAL113 <88238718+FN-FAL113@users.noreply.github.com> Date: Sun, 30 Jan 2022 20:18:14 +0800 Subject: [PATCH 21/56] local variables and formatting --- .../items/electric/machines/FluidPump.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java index 12d431e89e..3a009b2043 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java @@ -62,7 +62,6 @@ public class FluidPump extends SimpleSlimefunItem implements Invent private final ItemStack emptyBucket = ItemStackWrapper.wrap(new ItemStack(Material.BUCKET)); private final ItemStack emptyBottle = ItemStackWrapper.wrap(new ItemStack(Material.GLASS_BOTTLE)); - private final ItemStack waterBottle = new ItemStack(Material.POTION); @ParametersAreNonnullByDefault public FluidPump(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -70,9 +69,6 @@ public FluidPump(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeT addItemHandler(onBreak()); createPreset(this, this::constructMenu); - PotionMeta meta = (PotionMeta) this.waterBottle.getItemMeta(); - meta.setBasePotionData(new PotionData(PotionType.WATER)); - this.waterBottle.setItemMeta(meta); } @Nonnull @@ -146,7 +142,9 @@ protected void tick(@Nonnull Block b) { BlockMenu menu = BlockStorage.getInventory(b); for (int slot : getInputSlots()) { - if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), emptyBucket, true, false)) { + ItemStack itemInSlot = menu.getItemInSlot(slot); + + if (SlimefunUtils.isItemSimilar(itemInSlot, emptyBucket, true, false)) { ItemStack bucket = getFilledBucket(fluid); if (!menu.fits(bucket, getOutputSlots())) { @@ -163,8 +161,7 @@ protected void tick(@Nonnull Block b) { } return; - } - if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), emptyBottle, true, false)) { + } else if (SlimefunUtils.isItemSimilar(itemInSlot, emptyBottle, true, false)) { ItemStack bottle = getFilledBottle(fluid); if (!menu.fits(bottle, getOutputSlots())) { @@ -177,6 +174,7 @@ protected void tick(@Nonnull Block b) { removeCharge(b.getLocation(), ENERGY_CONSUMPTION); menu.consumeItem(slot); menu.pushItem(bottle, getOutputSlots()); + if(ThreadLocalRandom.current().nextInt(100) < 30) { nextFluid.setType(Material.AIR); } @@ -214,19 +212,21 @@ private Block findNextFluid(@Nonnull Block fluid) { return null; } - @Nonnull - private ItemStack getFilledBottle(@Nonnull Block fluid){ + private @Nonnull ItemStack getFilledBottle(@Nonnull Block fluid){ switch(fluid.getType()){ case WATER: case BUBBLE_COLUMN: - return waterBottle.clone(); + ItemStack waterBottle = new ItemStack(Material.POTION); + PotionMeta meta = (PotionMeta) waterBottle.getItemMeta(); + meta.setBasePotionData(new PotionData(PotionType.WATER)); + waterBottle.setItemMeta(meta); + return waterBottle; default: return new ItemStack(Material.GLASS_BOTTLE); } } - @Nonnull - private ItemStack getFilledBucket(@Nonnull Block fluid) { + private @Nonnull ItemStack getFilledBucket(@Nonnull Block fluid) { switch (fluid.getType()) { case LAVA: return new ItemStack(Material.LAVA_BUCKET); From 44cf96b7f3e1c44337f8d7a8dd2c758b1c816af4 Mon Sep 17 00:00:00 2001 From: FN-FAL113 <88238718+FN-FAL113@users.noreply.github.com> Date: Sun, 30 Jan 2022 22:24:47 +0800 Subject: [PATCH 22/56] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java Co-authored-by: TheBusyBiscuit --- .../implementation/items/electric/machines/FluidPump.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java index 3a009b2043..458924ff34 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java @@ -212,8 +212,8 @@ private Block findNextFluid(@Nonnull Block fluid) { return null; } - private @Nonnull ItemStack getFilledBottle(@Nonnull Block fluid){ - switch(fluid.getType()){ + private @Nonnull ItemStack getFilledBottle(@Nonnull Block fluid) { + switch (fluid.getType()) { case WATER: case BUBBLE_COLUMN: ItemStack waterBottle = new ItemStack(Material.POTION); From edeb4aa1c712c3d9a593d8d28a13152eef7a98a0 Mon Sep 17 00:00:00 2001 From: FN-FAL113 <88238718+FN-FAL113@users.noreply.github.com> Date: Sun, 30 Jan 2022 22:25:02 +0800 Subject: [PATCH 23/56] Update src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java Co-authored-by: TheBusyBiscuit --- .../implementation/items/electric/machines/FluidPump.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java index 458924ff34..7879c0bff0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java @@ -175,7 +175,7 @@ protected void tick(@Nonnull Block b) { menu.consumeItem(slot); menu.pushItem(bottle, getOutputSlots()); - if(ThreadLocalRandom.current().nextInt(100) < 30) { + if (ThreadLocalRandom.current().nextInt(100) < 30) { nextFluid.setType(Material.AIR); } } From 23a11b2f930a8152fe975e258e7aa21facd1b2a1 Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Mon, 31 Jan 2022 12:45:45 +0800 Subject: [PATCH 24/56] feat(guide): add config options for show hidden item --- .../thebusybiscuit/slimefun4/core/SlimefunRegistry.java | 3 ++- .../implementation/guide/CheatSheetSlimefunGuide.java | 2 +- .../implementation/guide/SurvivalSlimefunGuide.java | 9 +++++++-- src/main/resources/config.yml | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index bf896ecac6..336c1d24e8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -103,7 +103,8 @@ public void load(@Nonnull Slimefun plugin, @Nonnull Config cfg) { guideKey = new NamespacedKey(plugin, "slimefun_guide_mode"); boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes"); - guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes)); + boolean showHiddenItemInSearch = cfg.getBoolean("guide.show-hidden-items-in-search"); + guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes, showHiddenItemInSearch)); guides.put(SlimefunGuideMode.CHEAT_MODE, new CheatSheetSlimefunGuide()); researchRanks.addAll(cfg.getStringList("research-ranks")); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java index 5904126f6d..d28987a8a7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java @@ -34,7 +34,7 @@ public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide { private final ItemStack item; public CheatSheetSlimefunGuide() { - super(false); + super(false, true); item = new SlimefunGuideItem(this, "&cSlimefun Guide &4(Cheat Sheet)"); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index c132f74281..a13e830bc8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -72,9 +72,11 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { private final int[] recipeSlots = { 3, 4, 5, 12, 13, 14, 21, 22, 23 }; private final ItemStack item; private final boolean showVanillaRecipes; + private final boolean showHiddenItemInSearch; - public SurvivalSlimefunGuide(boolean showVanillaRecipes) { + public SurvivalSlimefunGuide(boolean showVanillaRecipes, boolean showHiddenItemInSearch) { this.showVanillaRecipes = showVanillaRecipes; + this.showHiddenItemInSearch = showHiddenItemInSearch; item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)"); } @@ -358,7 +360,10 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory break; } - if (!slimefunItem.isHidden() && !slimefunItem.getItemGroup().isHidden(p) && isSearchFilterApplicable(slimefunItem, searchTerm)) { + if (!slimefunItem.isHidden() + && (showHiddenItemInSearch || !slimefunItem.getItemGroup().isHidden(p)) + && isSearchFilterApplicable(slimefunItem, searchTerm) + ) { ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c9df7c3bae..848fc0864c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -23,6 +23,7 @@ options: guide: show-vanilla-recipes: true receive-on-first-join: true + show-hidden-items-in-search: true researches: free-in-creative-mode: true From c7539c5990692c29ab976cfb5d1c97b59a63204a Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Tue, 1 Feb 2022 11:39:50 +0800 Subject: [PATCH 25/56] improve(guide): rename `showHiddenItemInSearch` to `showHiddenItemGroupsInSearch` --- .../slimefun4/core/SlimefunRegistry.java | 4 ++-- .../implementation/guide/SurvivalSlimefunGuide.java | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index 336c1d24e8..a02bd420c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -103,8 +103,8 @@ public void load(@Nonnull Slimefun plugin, @Nonnull Config cfg) { guideKey = new NamespacedKey(plugin, "slimefun_guide_mode"); boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes"); - boolean showHiddenItemInSearch = cfg.getBoolean("guide.show-hidden-items-in-search"); - guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes, showHiddenItemInSearch)); + boolean showHiddenItemGroupsInSearch = cfg.getBoolean("guide.show-hidden-item-groups-in-search"); + guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes, showHiddenItemGroupsInSearch)); guides.put(SlimefunGuideMode.CHEAT_MODE, new CheatSheetSlimefunGuide()); researchRanks.addAll(cfg.getStringList("research-ranks")); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index a13e830bc8..f59e736591 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -72,11 +72,11 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { private final int[] recipeSlots = { 3, 4, 5, 12, 13, 14, 21, 22, 23 }; private final ItemStack item; private final boolean showVanillaRecipes; - private final boolean showHiddenItemInSearch; + private final boolean showHiddenItemGroupsInSearch; - public SurvivalSlimefunGuide(boolean showVanillaRecipes, boolean showHiddenItemInSearch) { + public SurvivalSlimefunGuide(boolean showVanillaRecipes, boolean showHiddenItemGroupsInSearch) { this.showVanillaRecipes = showVanillaRecipes; - this.showHiddenItemInSearch = showHiddenItemInSearch; + this.showHiddenItemGroupsInSearch = showHiddenItemGroupsInSearch; item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)"); } @@ -360,10 +360,9 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory break; } - if (!slimefunItem.isHidden() - && (showHiddenItemInSearch || !slimefunItem.getItemGroup().isHidden(p)) - && isSearchFilterApplicable(slimefunItem, searchTerm) - ) { + boolean isHiddenItemGroup = showHiddenItemGroupsInSearch || !slimefunItem.getItemGroup().isHidden(p); + + if (!slimefunItem.isHidden() && isHiddenItemGroup && isSearchFilterApplicable(slimefunItem, searchTerm)) { ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); From 1af533733c1fa432eac1661374deb14c18780e7f Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Tue, 1 Feb 2022 19:11:44 +0800 Subject: [PATCH 26/56] chore(typo): fix config type Co-authored-by: TheBusyBiscuit --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 848fc0864c..d066d699a2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -23,7 +23,7 @@ options: guide: show-vanilla-recipes: true receive-on-first-join: true - show-hidden-items-in-search: true + show-hidden-item-groups-in-search: true researches: free-in-creative-mode: true From d82ae5bad61782f08c57ab50ed90d0f01fa3630f Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Tue, 1 Feb 2022 19:12:06 +0800 Subject: [PATCH 27/56] chore(typo): fix `isHiddenItemGroup` typo Co-authored-by: TheBusyBiscuit --- .../slimefun4/implementation/guide/SurvivalSlimefunGuide.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index f59e736591..3ff27e6192 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -360,9 +360,9 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory break; } - boolean isHiddenItemGroup = showHiddenItemGroupsInSearch || !slimefunItem.getItemGroup().isHidden(p); + boolean isItemGroupHidden = showHiddenItemGroupsInSearch || !slimefunItem.getItemGroup().isHidden(p); - if (!slimefunItem.isHidden() && isHiddenItemGroup && isSearchFilterApplicable(slimefunItem, searchTerm)) { + if (!slimefunItem.isHidden() && isItemGroupHidden && isSearchFilterApplicable(slimefunItem, searchTerm)) { ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); From 78660f01f41e516430ff4e3f412e41ec37372439 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 2 Feb 2022 14:22:54 +0100 Subject: [PATCH 28/56] Update default value --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d066d699a2..04815081fa 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -23,7 +23,7 @@ options: guide: show-vanilla-recipes: true receive-on-first-join: true - show-hidden-item-groups-in-search: true + show-hidden-item-groups-in-search: false researches: free-in-creative-mode: true From 7dd9cc9d111f39067c700018ded18ee0c24abec9 Mon Sep 17 00:00:00 2001 From: Jeffrey Kosse Date: Sun, 20 Feb 2022 21:46:28 +0100 Subject: [PATCH 29/56] added rooted dirt to dirt variants --- src/main/resources/tags/dirt_variants.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/tags/dirt_variants.json b/src/main/resources/tags/dirt_variants.json index b55559c65f..b44b040ab2 100644 --- a/src/main/resources/tags/dirt_variants.json +++ b/src/main/resources/tags/dirt_variants.json @@ -11,6 +11,10 @@ "id": "minecraft:dirt_path", "required": false }, + { + "id": "minecraft:rooted_dirt", + "required": false + }, "minecraft:farmland", "minecraft:podzol", "minecraft:mycelium" From 8fe6f762036d496cad0c48f33bb1fd58f5cb7767 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 24 Feb 2022 15:22:34 +0000 Subject: [PATCH 30/56] Update actions/setup-java action to v3 --- .github/workflows/discord-webhook.yml | 2 +- .github/workflows/maven-compiler.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml index 371f4903cb..dedf367d5a 100644 --- a/.github/workflows/discord-webhook.yml +++ b/.github/workflows/discord-webhook.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v2.4.0 - name: Set up Java JDK 17 - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v3.0.0 with: distribution: 'adopt' java-version: '17' diff --git a/.github/workflows/maven-compiler.yml b/.github/workflows/maven-compiler.yml index 163f0309ba..5d8dd42b9e 100644 --- a/.github/workflows/maven-compiler.yml +++ b/.github/workflows/maven-compiler.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@v2 - name: Set up JDK 17 - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v3.0.0 with: distribution: 'adopt' java-version: '17' diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 8274ddd3f0..0dcfeed588 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -21,7 +21,7 @@ jobs: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v3.0.0 with: distribution: 'adopt' java-version: '17' From 8d193467f4253a6b5a03717aeefb43a04cdaa5c4 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 1 Mar 2022 18:57:28 +0000 Subject: [PATCH 31/56] Update actions/checkout action --- .github/workflows/discord-webhook.yml | 2 +- .github/workflows/json-validator.yml | 2 +- .github/workflows/maven-compiler.yml | 2 +- .github/workflows/release-candidates.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- .github/workflows/yaml-linter.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml index 371f4903cb..04d12e59de 100644 --- a/.github/workflows/discord-webhook.yml +++ b/.github/workflows/discord-webhook.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v3.0.0 - name: Set up Java JDK 17 uses: actions/setup-java@v2.5.0 diff --git a/.github/workflows/json-validator.yml b/.github/workflows/json-validator.yml index caebee9fb7..99616de007 100644 --- a/.github/workflows/json-validator.yml +++ b/.github/workflows/json-validator.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Validate wiki.json uses: docker://orrosenblatt/validate-json-action:latest@sha256:02370758b8b199e0477da11ecfdd498c75c561685056b5c31b925a4ab95df7f4 env: diff --git a/.github/workflows/maven-compiler.yml b/.github/workflows/maven-compiler.yml index 163f0309ba..6593287fb7 100644 --- a/.github/workflows/maven-compiler.yml +++ b/.github/workflows/maven-compiler.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up JDK 17 uses: actions/setup-java@v2.5.0 diff --git a/.github/workflows/release-candidates.yml b/.github/workflows/release-candidates.yml index 6dfa374329..1c279e172e 100644 --- a/.github/workflows/release-candidates.yml +++ b/.github/workflows/release-candidates.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: 'stable' diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 8274ddd3f0..942d939d70 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v3.0.0 with: fetch-depth: 0 diff --git a/.github/workflows/yaml-linter.yml b/.github/workflows/yaml-linter.yml index 9af97ce4f9..d81a60d1c9 100644 --- a/.github/workflows/yaml-linter.yml +++ b/.github/workflows/yaml-linter.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: YAML Linter uses: ibiqlik/action-yamllint@v3.1.0 with: From 0c4cd0fff2f168775dd97789ac9dfe82a874e60e Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 2 Mar 2022 13:03:23 +0000 Subject: [PATCH 32/56] Update dependency com.github.LoneDev6:itemsadder-api to v3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 959c359708..622b9dbef3 100644 --- a/pom.xml +++ b/pom.xml @@ -477,7 +477,7 @@ com.github.LoneDev6 itemsadder-api - 2.5.5 + 3.0.0 provided From b7c90fe400d83066dcda4aab6aab2baa42ff526a Mon Sep 17 00:00:00 2001 From: Silent Date: Wed, 2 Mar 2022 17:02:10 +0100 Subject: [PATCH 33/56] unlocalized name and some docs --- .../slimefun4/api/items/SlimefunItem.java | 29 ++++++++++++++++++- .../slimefun4/api/researches/Research.java | 10 +++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java index edfd06ebd0..ec07e61430 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java @@ -221,6 +221,11 @@ protected SlimefunItem(ItemGroup itemGroup, ItemStack item, String id, RecipeTyp return itemGroup; } + /** + * Retrieve the recipe for this {@link SlimefunItem}. + * + * @return An {@link ItemStack} array of 9 which represents the recipe for this {@link SlimefunItem} + */ public @Nonnull ItemStack[] getRecipe() { return recipe; } @@ -655,7 +660,12 @@ public void setResearch(@Nullable Research research) { this.research = research; } - public void setRecipe(ItemStack[] recipe) { + /** + * Sets the recipe for this {@link SlimefunItem}. + * + * @param recipe The recipe for this {@link ItemStack} + */ + public void setRecipe(@Nonnull ItemStack[] recipe) { if (recipe == null || recipe.length != 9) { throw new IllegalArgumentException("Recipes must be of length 9"); } @@ -663,6 +673,11 @@ public void setRecipe(ItemStack[] recipe) { this.recipe = recipe; } + /** + * Sets the {@link RecipeType} for this {@link SlimefunItem}. + * + * @param type The {@link RecipeType} for this {@link SlimefunItem} + */ public void setRecipeType(@Nonnull RecipeType type) { Validate.notNull(type, "The RecipeType is not allowed to be null!"); this.recipeType = type; @@ -1117,10 +1132,22 @@ public final int hashCode() { return getId().hashCode(); } + /** + * Retrieve a {@link SlimefunItem} by its id. + * + * @param id The id of the {@link SlimefunItem} + * @return The {@link SlimefunItem} associated with that id. Null if non-existent + */ public static @Nullable SlimefunItem getById(@Nonnull String id) { return Slimefun.getRegistry().getSlimefunItemIds().get(id); } + /** + * Retrieve a {@link SlimefunItem} from an {@link ItemStack}. + * + * @param item The {@link ItemStack} to check + * @return The {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise null + */ public static @Nullable SlimefunItem getByItem(@Nullable ItemStack item) { if (item == null || item.getType() == Material.AIR) { return null; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java index 6c013f9c37..99b13f7bd6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java @@ -12,6 +12,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; @@ -119,6 +120,15 @@ public int getID() { return localized != null ? localized : name; } + /** + * Retrieve the name of this {@link Research} without any localization nor coloring + * + * @return The unlocalized, decolorized name for this {@link Research} + */ + public @Nonnull String getUnlocalizedName() { + return ChatColor.stripColor(name); + } + /** * Gets the cost in XP levels to unlock this {@link Research}. * From e2cefce50da89d84b7978f03360af202694dd50f Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 3 Mar 2022 10:12:16 +0000 Subject: [PATCH 34/56] Update dependency com.github.seeseemelk:MockBukkit-v1.18 to v1.18.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 959c359708..4bb2cd06d0 100644 --- a/pom.xml +++ b/pom.xml @@ -390,7 +390,7 @@ com.github.seeseemelk MockBukkit-v1.18 - 1.15.5 + 1.18.1 test From de5524ad9ab8754d71c64481cf29520654d991a9 Mon Sep 17 00:00:00 2001 From: FN-FAL113 Date: Sat, 5 Mar 2022 11:51:45 +0800 Subject: [PATCH 35/56] Fix pedestal bug --- .../listeners/AncientAltarListener.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 7c2a865a0e..aeae13ef98 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -156,8 +156,19 @@ private void usePedestal(@Nonnull Block pedestal, @Nonnull Player p) { Slimefun.runSync(() -> removedItems.remove(uuid), 30L); entity.remove(); - p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); p.playSound(pedestal.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1F, 1F); + + /* + * Fixes #3476 + * Drop the item instead if the player's + * inventory is full + */ + if (p.getInventory().firstEmpty() != -1) { + p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); + + } else { + p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), pedestalItem.getOriginalItemStack(entity)); + } } } From f83fedadbdd55d82f57c0d1fc686eaf7e3c87f7a Mon Sep 17 00:00:00 2001 From: svr333 Date: Sat, 5 Mar 2022 13:42:14 +0100 Subject: [PATCH 36/56] Add '.' after summary --- .../thebusybiscuit/slimefun4/api/researches/Research.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java index 99b13f7bd6..6a4ee6b528 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java @@ -121,7 +121,7 @@ public int getID() { } /** - * Retrieve the name of this {@link Research} without any localization nor coloring + * Retrieve the name of this {@link Research} without any localization nor coloring. * * @return The unlocalized, decolorized name for this {@link Research} */ From 9ea414bd04d08049585482f3705465fd7ef9c72f Mon Sep 17 00:00:00 2001 From: FN-FAL113 Date: Mon, 7 Mar 2022 08:39:19 +0800 Subject: [PATCH 37/56] Update AncientAltarListener.java --- .../slimefun4/implementation/listeners/AncientAltarListener.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index aeae13ef98..44f940a4f5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -165,7 +165,6 @@ private void usePedestal(@Nonnull Block pedestal, @Nonnull Player p) { */ if (p.getInventory().firstEmpty() != -1) { p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); - } else { p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), pedestalItem.getOriginalItemStack(entity)); } From a11ca349fa9bbd30b8d780976af3c5cb2726c58c Mon Sep 17 00:00:00 2001 From: FN-FAL113 Date: Tue, 8 Mar 2022 10:06:58 +0800 Subject: [PATCH 38/56] Use the return value of addItem as basis for dropping left overs --- .../listeners/AncientAltarListener.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 44f940a4f5..abfdfee54f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -160,13 +160,13 @@ private void usePedestal(@Nonnull Block pedestal, @Nonnull Player p) { /* * Fixes #3476 - * Drop the item instead if the player's - * inventory is full + * Drop the item instead if the player's inventory is full and + * no stack space left else add remaining items from the returned map value */ - if (p.getInventory().firstEmpty() != -1) { - p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); - } else { - p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), pedestalItem.getOriginalItemStack(entity)); + for (Map.Entry stackEntry : p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)).entrySet()) { + if (stackEntry != null) { + p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), stackEntry.getValue().clone()); + } } } } From 82941dd8e89bbfcd87bcfef6749c2786453a1647 Mon Sep 17 00:00:00 2001 From: FN-FAL113 Date: Tue, 8 Mar 2022 10:10:54 +0800 Subject: [PATCH 39/56] fix a little typo from a comment --- .../implementation/listeners/AncientAltarListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index abfdfee54f..19284fd6d1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -115,7 +115,7 @@ public void onInteract(PlayerRightClickEvent e) { return; } - // Make altarinuse simply because that was the last block clicked. + // Make altar in use simply because that was the last block clicked. altarsInUse.add(b.getLocation()); e.cancel(); From f657016aa8764daaa5a9dac0421ece4f6128d308 Mon Sep 17 00:00:00 2001 From: FN-FAL113 Date: Tue, 8 Mar 2022 10:12:05 +0800 Subject: [PATCH 40/56] Update fix comment --- .../implementation/listeners/AncientAltarListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 19284fd6d1..0c42be2946 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -161,7 +161,7 @@ private void usePedestal(@Nonnull Block pedestal, @Nonnull Player p) { /* * Fixes #3476 * Drop the item instead if the player's inventory is full and - * no stack space left else add remaining items from the returned map value + * no stack space left else add the item in the inventory */ for (Map.Entry stackEntry : p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)).entrySet()) { if (stackEntry != null) { From de36da446f1c1204e26ab4388ad6af2efffa202e Mon Sep 17 00:00:00 2001 From: FN-FAL113 Date: Tue, 8 Mar 2022 21:05:52 +0800 Subject: [PATCH 41/56] assign return value to a variable and loop values --- .../implementation/listeners/AncientAltarListener.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 0c42be2946..8ed9f26f86 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -161,12 +161,12 @@ private void usePedestal(@Nonnull Block pedestal, @Nonnull Player p) { /* * Fixes #3476 * Drop the item instead if the player's inventory is full and - * no stack space left else add the item in the inventory + * no stack space left else add remaining items from the returned map value */ - for (Map.Entry stackEntry : p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)).entrySet()) { - if (stackEntry != null) { - p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), stackEntry.getValue().clone()); - } + Map remainingItemMap = p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); + + for (ItemStack item : remainingItemMap.values()) { + p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), item.clone()); } } } From 2acfa590267f935fe85a268822fbecd66abe5c67 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 8 Mar 2022 17:44:46 +0000 Subject: [PATCH 42/56] Update dependency org.mockito:mockito-core to v4.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 51e11eae09..17735027c3 100644 --- a/pom.xml +++ b/pom.xml @@ -384,7 +384,7 @@ org.mockito mockito-core - 4.3.1 + 4.4.0 test From 3c0dadef337eb12fe6857a3a782c2925e70de899 Mon Sep 17 00:00:00 2001 From: FN-FAL113 Date: Wed, 9 Mar 2022 08:21:20 +0800 Subject: [PATCH 43/56] Added missing map import --- .../slimefun4/implementation/listeners/AncientAltarListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 8ed9f26f86..4187d19b68 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -6,6 +6,7 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; +import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; From 1e40932dabbd055a869889da7f3c565a47bb6cfa Mon Sep 17 00:00:00 2001 From: The Busy Bot Date: Wed, 9 Mar 2022 13:12:32 +0100 Subject: [PATCH 44/56] [CI skip] New locale updates from Crowdin --- src/main/resources/languages/es/messages.yml | 44 +++++++-- src/main/resources/languages/es/recipes.yml | 24 +++++ .../resources/languages/es/researches.yml | 16 ++++ src/main/resources/languages/he/messages.yml | 19 ++++ src/main/resources/languages/he/recipes.yml | 90 +++++++++++++++++++ 5 files changed, 188 insertions(+), 5 deletions(-) diff --git a/src/main/resources/languages/es/messages.yml b/src/main/resources/languages/es/messages.yml index 1b97091978..f7cb875f05 100644 --- a/src/main/resources/languages/es/messages.yml +++ b/src/main/resources/languages/es/messages.yml @@ -29,7 +29,11 @@ commands: verbose-player: '&4La flag verbose no puede ser usada por un jugador!' unknown-flag: '&4flag desconocida: &c%flag%' debug: + description: 'Ejecutar registro de depuración para los desarolladores' + current: '&7Caso de prueba actual: &6%test_case%' + none-running: '&7Actualmente no se está ejecutando ningún caso de prueba!' running: '&7Ejecutando el modo de depuración con prueba: &6%test%' + disabled: '&7Desactivar Modo de Depuración.' placeholderapi: profile-loading: 'Cargando...' guide: @@ -81,12 +85,20 @@ guide: learning-animation: enabled: text: - - '&bLearning Animation: &aYes' + - '&bAnimación de Aprendizaje: &aSí' - '' - '&7Ahora puedes seleccionar si' - - '&7will see information about your pondering in chat' - - '&7upon researching an item.' + - '&7podrás ver el avance de tu meditación en el chat' + - '&7al investigar un objeto.' click: '&eCliquea para desactivar la animación de aprendizaje' + disabled: + text: + - '&bAnimación de Aprendizaje: &4No' + - '' + - '&7Ahora puedes seleccionar si' + - '&7podrás ver el avance de tu meditación en el chat' + - '&7al investigar un objeto.' + click: '&eHaz clic para activar la animación de aprendizaje' title: main: 'Guía de Slimefun.' settings: 'Configuración e Información.' @@ -113,6 +125,7 @@ guide: resourcepack: '&cArtista de Resourcepack' translator: '&9Traductor' messages: + not-researched: '&4No tienes el conocimiento suficiente para entender esto. &cNecesitas desbloquear: &f"%item%&f"' not-enough-xp: '&4No tienes suficiente XP para desbloquear esto.' unlocked: '&bHas desbloqueado &7"%research%"' only-players: '&4Este comando es solo para jugadores.' @@ -138,16 +151,31 @@ messages: not-shears: '&c¡Una Multi Tool no puede ser usada como tijeras!' auto-crafting: select-a-recipe: '&eAgáchate y haz Clic Derecho &7a este bloque con el objeto que quieres crear.' + recipe-set: '&aHas configurado con éxito la receta para esta máquina.' + recipe-removed: '&eHas eliminado con éxito la receta de esta máquina. ¡Puedes establecer una receta en cualquier momento!' no-recipes: '&cNo se han encontrado recetas validas para el objeto que estás sosteniendo.' + missing-chest: '&c¡Cofre no encontrado! Los crafteos automaticos tienen que estar colocados encima de un cofre.' + select: 'Selecciona esta receta' + temporarily-disabled: '&e¡Este Auto-Crafter ha sido temporalmente desactivado. Puedes re-activarlo de nuevo en cualquier momento!' + re-enabled: '&e¡Este Auto-Crafter ha sido re-activado!' + recipe-unavailable: | + &cEste objeto esta deshabilitado en el servidor, o aun no lo has desbloqueado. + &7Intenta fabricar el objeto si no lo has hecho antes para desbloquear la receta. tooltips: enabled: - - '&aThis recipe is currently enabled' + - '&aEsta receta esta actualmente activada' - '' - '&eClic izquierdo &7para desactivar temporalmente la receta' - - '&eRight Click &7to remove this recipe' + - '&eClick derecho &7para eliminar esta receta' + disabled: + - '&cEsta receta está actualmente desactivada' + - '' + - '&eClick izquierdo &7para re-activar esta receta' + - '&eClick Derecho &7para eliminar esta receta' talisman: anvil: '&a&oEl talismán salvó tu herramienta de ser destruida.' miner: '&a&oTu talismán ha duplicado los minerales.' + farmer: '&a&Tu Talismán acaba de duplicar tus objetos' hunter: '&a&oTu talismán ha duplicado el botín' lava: '&a&oTu talismán ha evitado que te quemes en lava.' water: '&a&oTu talismán ha evitado que mueras ahogado.' @@ -203,6 +231,9 @@ messages: - '&7¡Siempre mira el lado bueno de la vida!' - '&7Esta era un bizcocho y no una galleta' - '&7¡Los signos de neón son lo MEJOR!' + above-limit-level: '&c¡No puedes (des)encantar un nivel de encantamiento superior a %level%!' + pickaxe-of-the-seeker: + no-ores: '&c¡No se encuentra ningún mineral cerca!' machines: pattern-not-found: '&eLo siento, no puedo reconocer esta receta. Por favor coloca el objeto en el patrón correcto dentro del dispensador.' unknown-material: '&eLo siento, no puedo reconocer el objeto en mi dispensador. Por favor coloca algo que si conozca.' @@ -258,6 +289,8 @@ brewing_stand: not-working: '&4¡No puedes usar objetos de Slimefun en un soporte para pociones!' cartography_table: not-working: '&4No puedes usar items de Slimefun en una Mesa de Cartografía!' +smithing_table: + not-working: '&4! No puedes usar este objeto de Slimefun, como un material de herrería!' villagers: no-trading: '&4¡No puedes comerciar objetos de Slimefun con los aldeanos!' backpack: @@ -359,6 +392,7 @@ languages: ja: 'Japonés' fa: 'Persa' th: 'Tailandés' + tl: 'Tagalog' ro: 'Rumano' bg: 'Búlgaro' ko: 'Coreano' diff --git a/src/main/resources/languages/es/recipes.yml b/src/main/resources/languages/es/recipes.yml index 0b6a4ea469..7e65308b0a 100644 --- a/src/main/resources/languages/es/recipes.yml +++ b/src/main/resources/languages/es/recipes.yml @@ -1,27 +1,33 @@ --- slimefun: multiblock: + name: 'Multibloque' lore: - 'Construye la estructura tal como se muestra' - 'como se muestra. No es una receta.' enhanced_crafting_table: + name: 'Mesa de crafteo mejorada' lore: - 'Haz este objeto tal como se muestra' - 'en una Enhanced Crafting Table.' - '¡Una Tabla de Crafteo normal no servirá!' armor_forge: + name: 'Forja de armaduras' lore: - 'Haz este objeto tal como se muestra' - 'usando una Armor Forge' grind_stone: + name: 'Piedra de Moler' lore: - 'Haz este objeto tal como se muestra' - 'usando una Grind Stone' smeltery: + name: 'Fundición' lore: - 'Haz este objeto tal como se muestra' - 'usando un Smeltery' ore_crusher: + name: 'Trituradora de mineral' lore: - 'Haz este objeto tal como se muestra' - 'usando un Ore Crusher' @@ -31,72 +37,89 @@ slimefun: - 'Mata ese Mob para' - 'obtener este objeto.' gold_pan: + name: 'Colador' lore: - 'Usa un Gold Pan para' - 'obtener este objeto.' compressor: + name: 'Compresor' lore: - 'Haz este objeto tal como se muestra' - 'usando un Compressor' pressure_chamber: + name: 'Cámara de Presión' lore: - 'Haz este objeto tal como se muestra' - 'usando un Pressure Chamber' ore_washer: + name: 'Lavador de Minerales' lore: - 'Haz este objeto tal como se muestra' - 'usando un Ore Washer' juicer: + name: 'Exprimidor' lore: - 'Haz este jugo tal como se muestra' - 'usando un Juicer' magic_workbench: + name: 'Mesa de Trabajo Mágica' lore: - 'Haz este objeto tal como se muestra' - 'Usando una Magic Workbench' ancient_altar: + name: 'Altar Antiguo' lore: - 'Haz este objeto tal como se muestra' - 'usando un Ancient Altar.' - 'Busca Ancient Altar para mas info.' heated_pressure_chamber: + name: 'Cámara de Presión Caliente' lore: - 'Haz este objeto tal como se muestra' - 'usando una Heated Pressure Chamber' food_fabricator: + name: 'Fabricador de alimentos' lore: - 'Haz este objeto tal como se muestra' - 'usando un Food Fabricator' food_composter: + name: 'Compostador de Comida' lore: - 'Haz este objeto tal como se muestra' - 'usando un Food Composter' freezer: + name: 'Congelador' lore: - 'Congela este objeto tal como se muestra' - 'usando un Freezer' geo_miner: + name: 'GEO-Minador' lore: - 'Este objeto se puede obtener' - 'usando un GEO Miner' nuclear_reactor: + name: 'Reactor nuclear' lore: - 'Este objeto es un suproducto generado' - 'al correr un Nuclear Reactor' oil_pump: + name: 'Bomba Petrolera' lore: - 'Este objeto puede ser recogido' - 'usando una Oil Pump' pickaxe_of_containment: + name: 'Pica-Spawners' lore: - 'Este bloque puede ser obtenido' - 'al minar un Generador con' - 'el Pickaxe of Containment' refinery: + name: 'Refinería' lore: - 'Haz este objeto tal como se muestra' - 'usando una Refinery' barter_drop: + name: 'Trueque de Piglin' lore: - 'Tradea con Piglins usando' - 'Lingotes de Oro para obtener este objeto' @@ -139,6 +162,7 @@ minecraft: - 'Haz este objeto tal como se muestra' - 'usando un Cortapiedras' smithing: + name: 'Receta de Mesa de Herrerías' lore: - 'Haz este objeto como se muestra' - 'usando una Smithing Table' diff --git a/src/main/resources/languages/es/researches.yml b/src/main/resources/languages/es/researches.yml index 5aff5810f9..1cbba4cfa4 100644 --- a/src/main/resources/languages/es/researches.yml +++ b/src/main/resources/languages/es/researches.yml @@ -25,6 +25,7 @@ slimefun: steel_thruster: Propulsor de Acero parachute: Paracaídas grappling_hook: Gancho + jetpacks: Jetpack multitools: Multi Herramientas solar_panel_and_helmet: Energía solar elemental_staff: Bastónes Elementales @@ -50,6 +51,7 @@ slimefun: reinforced_armor: Armadura Reforzada ore_washer: Tamizador gold_carats: Oro Puro + silicon: Silicon Valley fire_staff: Vara de Fuego smelters_pickaxe: Pico Fundidor common_talisman: Talismán Común @@ -60,6 +62,7 @@ slimefun: water_talisman: Talismán del Pez angel_talisman: Talismán del Ángel fire_talisman: Talismán del Bombero + caveman_talisman: Talismán del Cavernícola wise_talisman: Talismán del Sabio lava_crystal: Situación Ardiente magician_talisman: Talismán del Mago @@ -122,6 +125,7 @@ slimefun: electric_motor: Calentando Motores block_placer: Colocador de Bloques scroll_of_dimensional_teleposition: Volteando cosas por aquí + special_bows: Robin Hood tome_of_knowledge_sharing: Compartiendo con amigos flask_of_knowledge: Almacenamiento de EXP hardened_glass: Resistiendo Explosiones @@ -185,6 +189,7 @@ slimefun: cargo_basics: Fundamentos de Cargas cargo_nodes: Configuración de Carga electric_ingot_machines: Fabricación Eléctrica de Lingotes + medium_tier_electric_ingot_machines: Fabricación Eléctrica de Lingotes high_tier_electric_ingot_machines: Lingotes Super Rápidos automated_crafting_chamber: Crafteo Automatizado better_food_fabricator: Fabricación de Alimentos Mejorado @@ -204,7 +209,9 @@ slimefun: high_tier_carbon_press: Carbón Prensado Definitivo wither_assembler: Mata Withers Automatizado better_heated_pressure_chamber: Maquina de Presión Caliente Mejorada + elytra: Élitros special_elytras: Elytras Especiales + trident: Tridente electric_crucible: Crisól Electrificado better_electric_crucibles: Crisoles Calientes advanced_electric_smeltery: Fundición Eléctrica Avanzada @@ -235,6 +242,7 @@ slimefun: advanced_industrial_miner: Minería Mejorada magical_zombie_pills: De-Zombificación auto_brewer: Alquimia Industrial + climbing_pick: Incursor de Bloques shulker_shell: Shulkers Sintéticos enchantment_rune: Encantamiento Antiguo lead_clothing: Ropa de Plomo @@ -243,3 +251,11 @@ slimefun: villager_rune: Restablece los Intercambios de los Aldeanos elytra_cap: Equipo de choque bee_armor: Armadura de Abeja + book_binder: Atadura de Libros de Encantamiento + auto_crafting: Crafteo Automatizado + produce_collector: Ordeño Automático + improved_generators: Generadores Improvisados + ingredients_and_cheese: Cocina de Slimefun + medium_tier_auto_enchanting: Mejorar Encantar y Desencantar Automático + portable_teleporter: Teletransporte en tu bolsillo + farmer_talisman: Talisman del Granjero diff --git a/src/main/resources/languages/he/messages.yml b/src/main/resources/languages/he/messages.yml index d8eb04c772..f265c16ce7 100644 --- a/src/main/resources/languages/he/messages.yml +++ b/src/main/resources/languages/he/messages.yml @@ -140,6 +140,21 @@ messages: multi-tool: mode-change: '&b%device% &9: המצב השתנה ל: %mode%' not-shears: '&c מולטי טול לא יכול לשמש כמזמרה!' + auto-crafting: + select: 'בחר מתכון זה' + temporarily-disabled: '&eיוצר אוטומטי זה מושבת זמנית אתה יכול להפעילו שוב בכל זמן!' + re-enabled: '&aיוצר אוטומטי זה הופעל שוב!' + tooltips: + enabled: + - '&aמתכון זה כרגע פעיל' + - '' + - '&e לחץ על מקש שמאלי &7 על מנת להשבית מתכון זה זמנית' + - '&eהקש על מקש ימני &7 על מנת למחוק מתכון זה' + disabled: + - '&cמתכון זה כרגע מושבת' + - '' + - '&eלחץ על מקש שמאלי &7 על מנת לאפשר שוב מתכון זה' + - '&eלחץ על מקש ימני &7 על מנת למחוק מתכון זה' talisman: anvil: '&a&o הקמע שלך הציל את הכלי שלך מלהישבר' miner: '&a&o הקמע שלך בכפיל את הפריטים הנופלים' @@ -198,6 +213,9 @@ messages: - '&7תמיד תסתכל על הצד הטוב שבחיים' - '&7זה היה למעשה ביסקוויט ולא עוגיה' - '&7שלטי הניאון דולקים' + above-limit-level: '&c לא מצליח לכשף/להוריד כישוף עם רמה גבוהה יותר מהרמה (%level%)!' + pickaxe-of-the-seeker: + no-ores: '&c לא מצליח למצוא עופרות בקרבת מקום!' machines: pattern-not-found: "&e סליחה לא יכולתי \n .לזהות את המתכון \nאנא הכנס את \nהפריטים בדפוס הנכון לתוך המתקן " unknown-material: '&e סליחה, לא יכולתי לזהות את הפריט במתקן שלי. אנא הכנס משהו שאני יודע.' @@ -205,6 +223,7 @@ machines: full-inventory: '&e סליחה המלאי שלי יותר מדיי מלא!' in-use: '&c המלאי של בלוק זה נפתח כרגע על ידי שחקן אחר.' ignition-chamber-no-flint: '&c תא הצתה חסר צור ופלדה.' + inventory-empty: '&6 הקמת בהצלחה את ה מולטיבלוק הזה. המשך על ידי הנחת פריטים בתוך המתקן ולחץ עלי שוב כדי ליצור את הפריט הרצוי!' ANCIENT_ALTAR: not-enough-pedestals: "&4 המזבח אני מוקף בכמות המתאימה של כינים &c(%pedestals% /\n8( " unknown-catalyst: '&4 זרז לא ידוע! &c השתמש במתכון הנכון במקום זאת!' diff --git a/src/main/resources/languages/he/recipes.yml b/src/main/resources/languages/he/recipes.yml index ed97d539c0..074bd89a84 100644 --- a/src/main/resources/languages/he/recipes.yml +++ b/src/main/resources/languages/he/recipes.yml @@ -1 +1,91 @@ --- +slimefun: + multiblock: + name: 'מולטיבלוק' + lore: + - 'בנה את הסרטוט המוצג' + - 'כמו שנראה, זה לא נוצר.' + enhanced_crafting_table: + name: 'שולחן יצירה מכושף' + lore: + - 'צור פריט זה, כמו בסרטוט' + - 'בתוך שולחן יצירה מכושף.' + - 'שולחן יצירה רגיל לא יספיק!' + armor_forge: + lore: + - 'צור פריט זה, כמו בסרטוט' + - 'using an Armor Forge' + grind_stone: + name: 'אבן השחזה' + smeltery: + name: 'תנור התכה' + ore_crusher: + lore: + - 'צור פריט זה, כמו בסרטוט' + - 'using an Ore Crusher' + juicer: + name: 'מסחטה' + magic_workbench: + name: 'שולחן מלאכה קסום' + lore: + - 'Craft this Item as shown' + - 'משתמש בשולחן מלאכה קסום' + ancient_altar: + name: 'מזבח עתיק' + lore: + - 'Craft this Item as shown' + - 'משתמש במזבח עתיק.' + - 'חקור את המזבח העתיק בשביל עוד מידע' + heated_pressure_chamber: + name: 'תא לחץ מחומם' + lore: + - 'צור פריט זה, כמו בסרטוט' + - 'using a Heated Pressure Chamber' + food_fabricator: + name: 'מעבד מזון' + lore: + - 'Craft this Item as shown' + - 'משתמש במעבד מזון' + barter_drop: + name: 'טיפת חליפין של חזיר' + lore: + - 'סחר חליפין עם חזירים באמצעות' + - 'Gold Ingots to obtain this Item' +minecraft: + shaped: + name: 'מתכון יצירה מעוצב' + lore: + - 'צור פריט זה, כמו בסרטוט' + - 'בתוך שולחן יצירה רגיל.' + - 'הצורה חשובה.' + shapeless: + name: 'מתכון יצירה ללא צורה' + lore: + - 'צור פריט זה, כמו בסרטוט' + - 'בתוך שולחן יצירה רגיל.' + - 'פריט זה הוא חסר צורה.' + furnace: + lore: + - 'התך פריט זה בתוך תנור' + - 'ליצור את הפריט הרצוי' + blasting: + name: 'מתכון של תנור מתכות' + lore: + - 'התך פריט זה בתוך תנור מתכות' + - 'ליצור את הפריט הרצוי' + smoking: + lore: + - 'התך פריט זה בתוך מעשנה' + - 'ליצור את הפריט הרצוי' + campfire: + lore: + - 'התך פריט זה מעל מדורה' + - 'ליצור את הפריט הרצוי' + stonecutting: + lore: + - 'צור פריט זה, כמו בסרטוט' + - 'using a Stonecutter' + smithing: + lore: + - 'צור פריט זה, כמו בסרטוט' + - 'using a Smithing Table' From d78110b5273cc485320677e26212720c8cfd8fba Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Mar 2022 13:37:33 +0100 Subject: [PATCH 45/56] [CI skip] Added test to catch faulty color codes --- .../AbstractLocaleRegexChecker.java | 99 +++++++++++++++++++ .../services/localization/TestColorCodes.java | 52 ++++++++++ .../localization/TestSlimefunSpelling.java | 74 ++------------ 3 files changed, 159 insertions(+), 66 deletions(-) create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java new file mode 100644 index 0000000000..c54250acfa --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java @@ -0,0 +1,99 @@ +package io.github.thebusybiscuit.slimefun4.core.services.localization; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Stream; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.apache.commons.lang.Validate; +import org.bukkit.configuration.file.FileConfiguration; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.provider.Arguments; + +import be.seeseemelk.mockbukkit.MockBukkit; + +class AbstractLocaleRegexChecker { + + private final Pattern pattern; + + AbstractLocaleRegexChecker(@Nonnull Pattern pattern) { + Validate.notNull(pattern, "The pattern cannot be null."); + + this.pattern = pattern; + } + + @BeforeAll + public static void load() { + MockBukkit.mock(); + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + public @Nonnull Pattern getPattern() { + return this.pattern; + } + + @ParametersAreNonnullByDefault + @Nullable + BufferedReader readLanguageFile(LanguagePreset lang, LanguageFile file) { + String path = file.getFilePath(lang.getLanguageCode()); + InputStream inputStream = getClass().getResourceAsStream(path); + + if (inputStream == null) { + // This file does not exist, we consider it "passed". + return null; + } + + return new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); + } + + @ParametersAreNonnullByDefault + void assertNoRegexMatchesForAllEntries(LanguagePreset lang, LanguageFile file, FileConfiguration config) { + for (Map.Entry entry : config.getValues(true).entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + + if (value instanceof String) { + assertNoRegexMatch(lang, file, key, (String) value); + } else if (value instanceof List) { + for (Object element : (List) value) { + if (element instanceof String) { + assertNoRegexMatch(lang, file, key, (String) element); + } + } + } + } + } + + @ParametersAreNonnullByDefault + void assertNoRegexMatch(LanguagePreset lang, LanguageFile file, String key, String value) { + Matcher matcher = getPattern().matcher(value); + boolean hasIncorrectSpelling = matcher.find(); + + if (hasIncorrectSpelling) { + String location = lang.getLanguageCode() + '/' + file.name() + ": " + key; + Assertions.fail("Mistake in file \"" + location + "\" - \"" + matcher.group() + "\"!"); + } + } + + static @Nonnull Stream getAllLanguageFiles() { + Stream stream = Arrays.stream(LanguagePreset.values()); + return stream.flatMap(a -> Arrays.stream(LanguageFile.values()).map(b -> Arguments.of(a, b))); + } + +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java new file mode 100644 index 0000000000..0691a250c0 --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java @@ -0,0 +1,52 @@ +package io.github.thebusybiscuit.slimefun4.core.services.localization; + +import java.io.BufferedReader; +import java.io.IOException; +import java.util.regex.Pattern; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +/** + * We need to make sure that color codes are still working properly. + *

+ * Sometimes, the color code can be accidentally removed as people see + * it as part of the word on first look. This test is designed to catch + * these cases. + *

+ * The test checks for color chars (ampersands) that have no follow-up + * chatcolor key but rather a preceeding one. + *

+ * The test will catch occurences like "a& ", "b&Hello" or "7&". + * The test will however ignore valid color codes such as "a&a". + * + * @author TheBusyBiscuit + * + */ +class TestColorCodes extends AbstractLocaleRegexChecker { + + TestColorCodes() { + super(Pattern.compile("[a-f0-9klmno]&[^a-f0-9klmno]")); + } + + @ParameterizedTest + @ParametersAreNonnullByDefault + @MethodSource("getAllLanguageFiles") + @DisplayName("Test for mistakes in color codes for Slimefun locale files") + void testSpelling(LanguagePreset lang, LanguageFile file) throws IOException { + try (BufferedReader reader = readLanguageFile(lang, file)) { + if (reader == null) { + return; + } + + FileConfiguration config = YamlConfiguration.loadConfiguration(reader); + assertNoRegexMatchesForAllEntries(lang, file, config); + } + } + +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestSlimefunSpelling.java b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestSlimefunSpelling.java index 530d982bce..c33bb4c11d 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestSlimefunSpelling.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestSlimefunSpelling.java @@ -2,31 +2,16 @@ import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Stream; -import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import be.seeseemelk.mockbukkit.MockBukkit; - /** * Your friendly neighbourhood spellcheck. * Brought to you by our Discord bot "@WalshBot". @@ -35,18 +20,10 @@ * @author TheBusyBiscuit * */ -class TestSlimefunSpelling { - - private final Pattern incorrectSpelling = Pattern.compile("[Ss]lime(?:F|( [Ff]))un"); +class TestSlimefunSpelling extends AbstractLocaleRegexChecker { - @BeforeAll - public static void load() { - MockBukkit.mock(); - } - - @AfterAll - public static void unload() { - MockBukkit.unmock(); + TestSlimefunSpelling() { + super(Pattern.compile("[Ss]lime(?:F|( [Ff]))un")); } @ParameterizedTest @@ -54,49 +31,14 @@ public static void unload() { @MethodSource("getAllLanguageFiles") @DisplayName("Test correct spelling of Slimefun in language files") void testSpelling(LanguagePreset lang, LanguageFile file) throws IOException { - String path = file.getFilePath(lang.getLanguageCode()); - InputStream inputStream = getClass().getResourceAsStream(path); - - if (inputStream == null) { - // This file does not exist, we consider it "passed". - return; - } - - // Read the language file as yaml - try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { - FileConfiguration config = YamlConfiguration.loadConfiguration(reader); - - for (Map.Entry entry : config.getValues(true).entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - - if (value instanceof String) { - assertCorrectSpelling(lang, file, key, (String) value); - } else if (value instanceof List) { - for (Object element : (List) value) { - if (element instanceof String) { - assertCorrectSpelling(lang, file, key, (String) element); - } - } - } + try (BufferedReader reader = readLanguageFile(lang, file)) { + if (reader == null) { + return; } - } - } - - @ParametersAreNonnullByDefault - private void assertCorrectSpelling(LanguagePreset lang, LanguageFile file, String key, String value) { - Matcher matcher = incorrectSpelling.matcher(value); - boolean hasIncorrectSpelling = matcher.find(); - if (hasIncorrectSpelling) { - String location = lang.getLanguageCode() + '/' + file.name() + ": " + key; - Assertions.fail("Mistake in file \"" + location + "\" - It's \"Slimefun\", not \"" + matcher.group() + "\"!"); + FileConfiguration config = YamlConfiguration.loadConfiguration(reader); + assertNoRegexMatchesForAllEntries(lang, file, config); } } - private static @Nonnull Stream getAllLanguageFiles() { - Stream stream = Arrays.stream(LanguagePreset.values()); - return stream.flatMap(a -> Arrays.stream(LanguageFile.values()).map(b -> Arguments.of(a, b))); - } - } From 5adafcda645488b319c0242acd2f3ad68676f14d Mon Sep 17 00:00:00 2001 From: The Busy Bot Date: Wed, 9 Mar 2022 14:12:24 +0100 Subject: [PATCH 46/56] [CI skip] New locale updates from Crowdin --- src/main/resources/languages/es/messages.yml | 2 +- src/main/resources/languages/he/messages.yml | 9 +++++---- src/main/resources/languages/it/messages.yml | 2 +- src/main/resources/languages/tr/messages.yml | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/resources/languages/es/messages.yml b/src/main/resources/languages/es/messages.yml index f7cb875f05..f88a777744 100644 --- a/src/main/resources/languages/es/messages.yml +++ b/src/main/resources/languages/es/messages.yml @@ -175,7 +175,7 @@ messages: talisman: anvil: '&a&oEl talismán salvó tu herramienta de ser destruida.' miner: '&a&oTu talismán ha duplicado los minerales.' - farmer: '&a&Tu Talismán acaba de duplicar tus objetos' + farmer: '&a&oTu Talismán acaba de duplicar tus objetos' hunter: '&a&oTu talismán ha duplicado el botín' lava: '&a&oTu talismán ha evitado que te quemes en lava.' water: '&a&oTu talismán ha evitado que mueras ahogado.' diff --git a/src/main/resources/languages/he/messages.yml b/src/main/resources/languages/he/messages.yml index f265c16ce7..abe377b16e 100644 --- a/src/main/resources/languages/he/messages.yml +++ b/src/main/resources/languages/he/messages.yml @@ -82,16 +82,17 @@ guide: - '&aאנימציית למידה: &aכן' - '' - '&7עכשיו אתה יכול לעבור בין אם אתה' - - '&7will see information about your pondering in chat' + - '&7יראה מידע על התלבטויותיך בתיבת הדיבור' - '&7 עם חקר פריט.' click: '&e לחץ על מנת לבטל את אנימציית הלמידה שלך' disabled: text: - - '&bLearning Animation: &4No' + - '&bאנימציית למידה: &aלא' - '' - '&7עכשיו אתה יכול לעבור בין אם אתה' - - '&7will see information about your pondering in chat' - - '7& עם חקר פריט.' + - '&7יראה מידע על התלבטויותיך בתיבת הדיבור' + - '&7 עם חקר פריט.' + click: '&e לחץ על מנת לאפשר את אנימציית הלמידה שלך' title: main: 'סליים פאן מדריך' settings: 'הגדרות & מידע ' diff --git a/src/main/resources/languages/it/messages.yml b/src/main/resources/languages/it/messages.yml index c45c1855ac..28241dbd65 100644 --- a/src/main/resources/languages/it/messages.yml +++ b/src/main/resources/languages/it/messages.yml @@ -121,7 +121,7 @@ messages: give-research: '&bHai dato a %player% la ricerca &7 "%research% &7"' hungry: '&cSei troppo affamato per farlo!' disabled-in-world: '&4&lQuesto oggetto è stato disattivato in questo mondo!' - disabled-item: '&4& lQuesto oggetto è stato disabilitato! Come l''hai ottenuto?' + disabled-item: '&4&lQuesto oggetto è stato disabilitato! Come l''hai ottenuto?' no-tome-yourself: '&cNon puoi utilizzare il &4Tomo della conoscienza &c su te stesso ...' multimeter: '&bEnergia salvata: &3%stored% &b/&3%capacity%' piglin-barter: '&4Non puoi barattare con i Piglins usando gli oggetti di Slimefun' diff --git a/src/main/resources/languages/tr/messages.yml b/src/main/resources/languages/tr/messages.yml index 2ee7612cd8..ac4c9af471 100644 --- a/src/main/resources/languages/tr/messages.yml +++ b/src/main/resources/languages/tr/messages.yml @@ -24,7 +24,12 @@ commands: charge-success: Eşyanız şarz edildi! not-rechargeable: Bu eşya şarz edilemez! timings: + description: Slimefun ve Eklentileri için zamanlamalar please-wait: '&eLütfen bir saniye bekleyin... Sonuçlar geliyor!' + verbose-player: '&4Ayrıntılı bayrak bir oyuncu tarafından kullanılamaz!' + debug: + description: 'Developerlar için hata ayıklamayı başlat' + disabled: '&7Hata ayıklama kapalı.' placeholderapi: profile-loading: 'Yükleniyor...' guide: @@ -119,6 +124,14 @@ messages: multi-tool: mode-change: '&b%device% modül değiştirildi: &9%mode%' not-shears: '&cBir Multi Tool makas olarak kullanılamaz!' + auto-crafting: + select: 'Bu tarifi seçin' + tooltips: + enabled: + - '&aBu tarif şu anda etkin' + - '' + - '&eLeft Click &7to temporarily disable the recipe' + - '&eRight Click &7to remove this recipe' talisman: anvil: '&a&oTılsım aletinizi kırılmadan kurtardı' miner: '&a&oTılsımın madenini ikiye katladı' @@ -176,6 +189,8 @@ messages: - '&7Daima hayatın parlak tarafından bak!' - '&7Bu aslında bir Bisküvi idi, Kurabiye değil.' - '&7Neon levhalar ışık yayar!' + pickaxe-of-the-seeker: + no-ores: '&cYakındaki cevherleri bulamıyorum!' machines: pattern-not-found: '&eÜzgünüm, bu tarifi tanıyamadım. Lütfen Eşyaları Dağıtıcıya doğru şekilde yerleştirin.' unknown-material: '&eÜzgünüm, fırlatıcıdaki Eşyayı tanıyamadım. Lütfen bildiğim bir şey koy.' @@ -257,6 +272,7 @@ android: scripts: already-uploaded: '&4Bu senaryo zaten yüklendi.' editor: 'Senaryo Editörü' + too-long: '&cSenaryo düzenlemek için çok uzun!' instructions: START: '&2Senaryoyu başlat' REPEAT: '&9Senaryoyu Tekrar Et' From bd3640c7a8369f09e8078662022de8f595cf3996 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Mar 2022 14:13:03 +0100 Subject: [PATCH 47/56] [CI skip] Improved color codes test --- .../core/services/localization/Language.java | 15 ++-- .../services/localization/LanguagePreset.java | 80 ++++++++++++------- .../services/localization/TextDirection.java | 25 ++++++ .../AbstractLocaleRegexChecker.java | 18 +++-- .../services/localization/TestColorCodes.java | 4 +- 5 files changed, 99 insertions(+), 43 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TextDirection.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java index eeaad65c76..0db0125e2e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java @@ -59,8 +59,7 @@ public Language(@Nonnull String id, @Nonnull String hash) { * * @return The identifier of this {@link Language} */ - @Nonnull - public String getId() { + public @Nonnull String getId() { return id; } @@ -101,8 +100,7 @@ public void setFile(@Nonnull LanguageFile file, @Nonnull FileConfiguration confi * * @return The {@link ItemStack} used to display this {@link Language} */ - @Nonnull - public ItemStack getItem() { + public @Nonnull ItemStack getItem() { return item; } @@ -114,8 +112,7 @@ public ItemStack getItem() { * The {@link Player} to localize the name for * @return The localized name of this {@link Language} */ - @Nonnull - public String getName(@Nonnull Player p) { + public @Nonnull String getName(@Nonnull Player p) { return Slimefun.getLocalization().getMessage(p, "languages." + id); } @@ -136,7 +133,11 @@ public String toString() { @Nonnull FileConfiguration[] getFiles() { - return Arrays.stream(LanguageFile.valuesCached).map(this::getFile).toArray(FileConfiguration[]::new); + // @formatter:off + return Arrays.stream(LanguageFile.valuesCached) + .map(this::getFile) + .toArray(FileConfiguration[]::new); + // @formatter:on } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java index 56b969fb7a..bc692be6e6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java @@ -17,56 +17,73 @@ */ public enum LanguagePreset { - ENGLISH("en", true, "a1701f21835a898b20759fb30a583a38b994abf60d3912ab4ce9f2311e74f72"), - GERMAN("de", true, "5e7899b4806858697e283f084d9173fe487886453774626b24bd8cfecc77b3f"), - FRENCH("fr", true, "51269a067ee37e63635ca1e723b676f139dc2dbddff96bbfef99d8b35c996bc"), - ITALIAN("it", true, "85ce89223fa42fe06ad65d8d44ca412ae899c831309d68924dfe0d142fdbeea4"), - SPANISH("es", true, "32bd4521983309e0ad76c1ee29874287957ec3d96f8d889324da8c887e485ea8"), - RUSSIAN("ru", true, "16eafef980d6117dabe8982ac4b4509887e2c4621f6a8fe5c9b735a83d775ad"), + ENGLISH("en", "a1701f21835a898b20759fb30a583a38b994abf60d3912ab4ce9f2311e74f72"), + GERMAN("de", "5e7899b4806858697e283f084d9173fe487886453774626b24bd8cfecc77b3f"), + FRENCH("fr", "51269a067ee37e63635ca1e723b676f139dc2dbddff96bbfef99d8b35c996bc"), + ITALIAN("it", "85ce89223fa42fe06ad65d8d44ca412ae899c831309d68924dfe0d142fdbeea4"), + SPANISH("es", "32bd4521983309e0ad76c1ee29874287957ec3d96f8d889324da8c887e485ea8"), + RUSSIAN("ru", "16eafef980d6117dabe8982ac4b4509887e2c4621f6a8fe5c9b735a83d775ad"), POLISH("pl", false, "921b2af8d2322282fce4a1aa4f257a52b68e27eb334f4a181fd976bae6d8eb"), - UKRAINIAN("uk", true, "28b9f52e36aa5c7caaa1e7f26ea97e28f635e8eac9aef74cec97f465f5a6b51"), + UKRAINIAN("uk", "28b9f52e36aa5c7caaa1e7f26ea97e28f635e8eac9aef74cec97f465f5a6b51"), BELARUSIAN("be", false, "8c12eaf0d83e97e2bace652d0d23e74908ee766894361271f00c22ea82d25b02"), - SWEDISH("sv", true, "e910904bff9c86f6ed47688e9429c26e8d9c5d5743bd3ebb8e6f5040be192998"), + SWEDISH("sv", "e910904bff9c86f6ed47688e9429c26e8d9c5d5743bd3ebb8e6f5040be192998"), DUTCH("nl", false, "c23cf210edea396f2f5dfbced69848434f93404eefeabf54b23c073b090adf"), DANISH("da", false, "10c23055c392606f7e531daa2676ebe2e348988810c15f15dc5b3733998232"), FINNISH("fi", false, "59f2349729a7ec8d4b1478adfe5ca8af96479e983fbad238ccbd81409b4ed"), NORWEGIAN("no", false, "e0596e165ec3f389b59cfdda93dd6e363e97d9c6456e7c2e123973fa6c5fda"), - CZECH("cs", true, "48152b7334d7ecf335e47a4f35defbd2eb6957fc7bfe94212642d62f46e61e"), + CZECH("cs", "48152b7334d7ecf335e47a4f35defbd2eb6957fc7bfe94212642d62f46e61e"), ROMANIAN("ro", false, "dceb1708d5404ef326103e7b60559c9178f3dce729007ac9a0b498bdebe46107"), - BULGARIAN("bg", true, "19039e1fd88c78d9d7adc5aad5ab16e356be13464934ed9e2b0cef2051c5b534"), + BULGARIAN("bg", "19039e1fd88c78d9d7adc5aad5ab16e356be13464934ed9e2b0cef2051c5b534"), PORTUGUESE_PORTUGAL("pt", false, "ebd51f4693af174e6fe1979233d23a40bb987398e3891665fafd2ba567b5a53a"), - PORTUGUESE_BRAZIL("pt-BR", true, "9a46475d5dcc815f6c5f2859edbb10611f3e861c0eb14f088161b3c0ccb2b0d9"), - HUNGARIAN("hu", true, "4a9c3c4b6c5031332dd2bfece5e31e999f8deff55474065cc86993d7bdcdbd0"), + PORTUGUESE_BRAZIL("pt-BR", "9a46475d5dcc815f6c5f2859edbb10611f3e861c0eb14f088161b3c0ccb2b0d9"), + HUNGARIAN("hu", "4a9c3c4b6c5031332dd2bfece5e31e999f8deff55474065cc86993d7bdcdbd0"), CROATIAN("hr", false, "b050c04ec8cabce71d7103f3e9ef4bb8819f9f365eb335a9139912bc07ed445"), LATVIAN("lv", false, "f62a4938b59447f996b5ed94101df07429d1ad34776d591ffc6fd75b79473c"), GREEK("el", false, "1514de6dd2b7682b1d3ebcd10291ae1f021e3012b5c8beffeb75b1819eb4259d"), - SLOVAK("sk", true, "6c72a8c115a1fb669a25715c4d15f22136ac4c2452784e4894b3d56bc5b0b9"), - VIETNAMESE("vi", true, "8a57b9d7dd04169478cfdb8d0b6fd0b8c82b6566bb28371ee9a7c7c1671ad0bb"), - INDONESIAN("id", true, "5db2678ccaba7934412cb97ee16d416463a392574c5906352f18dea42895ee"), - CHINESE_CHINA("zh-CN", true, "7f9bc035cdc80f1ab5e1198f29f3ad3fdd2b42d9a69aeb64de990681800b98dc"), - CHINESE_TAIWAN("zh-TW", true, "702a4afb2e1e2e3a1894a8b74272f95cfa994ce53907f9ac140bd3c932f9f"), - JAPANESE("ja", true, "d640ae466162a47d3ee33c4076df1cab96f11860f07edb1f0832c525a9e33323"), - KOREAN("ko", true, "fc1be5f12f45e413eda56f3de94e08d90ede8e339c7b1e8f32797390e9a5f"), - HEBREW("he", true, "1ba086a2cc7272cf5ba49c80248546c22e5ef1bab54120e8a8e5d9e75b6a"), - ARABIC("ar", true, "a4be759a9cf7f0a19a7e8e62f23789ad1d21cebae38af9d9541676a3db001572"), - TURKISH("tr", true, "9852b9aba3482348514c1034d0affe73545c9de679ae4647f99562b5e5f47d09"), + SLOVAK("sk", "6c72a8c115a1fb669a25715c4d15f22136ac4c2452784e4894b3d56bc5b0b9"), + VIETNAMESE("vi", "8a57b9d7dd04169478cfdb8d0b6fd0b8c82b6566bb28371ee9a7c7c1671ad0bb"), + INDONESIAN("id", "5db2678ccaba7934412cb97ee16d416463a392574c5906352f18dea42895ee"), + CHINESE_CHINA("zh-CN", "7f9bc035cdc80f1ab5e1198f29f3ad3fdd2b42d9a69aeb64de990681800b98dc"), + CHINESE_TAIWAN("zh-TW", "702a4afb2e1e2e3a1894a8b74272f95cfa994ce53907f9ac140bd3c932f9f"), + JAPANESE("ja", "d640ae466162a47d3ee33c4076df1cab96f11860f07edb1f0832c525a9e33323"), + KOREAN("ko", "fc1be5f12f45e413eda56f3de94e08d90ede8e339c7b1e8f32797390e9a5f"), + HEBREW("he", TextDirection.RIGHT_TO_LEFT, "1ba086a2cc7272cf5ba49c80248546c22e5ef1bab54120e8a8e5d9e75b6a"), + ARABIC("ar", TextDirection.RIGHT_TO_LEFT, "a4be759a9cf7f0a19a7e8e62f23789ad1d21cebae38af9d9541676a3db001572"), + TURKISH("tr", "9852b9aba3482348514c1034d0affe73545c9de679ae4647f99562b5e5f47d09"), PERSIAN("fa", false, "5cd9badf1972583b663b44b1e027255de8f275aa1e89defcf77782ba6fcc652"), SERBIAN("sr", false, "5b0483a4f0ddf4fbbc977b127b3d294d7a869f995366e3f50f6b05a70f522510"), AFRIKAANS("af", false, "961a1eacc10524d1f45f23b0e487bb2fc33948d9676b418b19a3da0b109d0e3c"), MALAY("ms", false, "754b9041dea6db6db44750f1385a743adf653767b4b8802cad4c585dd3f5be46"), - THAI("th", true, "2a7916e4a852f7e6f3f3de19c7fb57686a37bce834bd54684a7dbef8d53fb"), - MACEDONIAN("mk", false, "a0e0b0b5d87a855466980a101a757bcdb5f77d9f7287889f3efa998ee0472fc0"), - TAGALOG("tl", true, "9306c0c1ce6a9c61bb42a572c49e6d0ed20e0e6b3d122cc64c339cbf78e9e937"); + THAI("th", "2a7916e4a852f7e6f3f3de19c7fb57686a37bce834bd54684a7dbef8d53fb"), + MACEDONIAN("mk", "a0e0b0b5d87a855466980a101a757bcdb5f77d9f7287889f3efa998ee0472fc0"), + TAGALOG("tl", "9306c0c1ce6a9c61bb42a572c49e6d0ed20e0e6b3d122cc64c339cbf78e9e937"); private final String id; private final boolean releaseReady; private final String textureHash; + private final TextDirection textDirection; @ParametersAreNonnullByDefault - LanguagePreset(String id, boolean releaseReady, String textureHash) { + LanguagePreset(String id, boolean releaseReady, TextDirection direction, String textureHash) { this.id = id; this.releaseReady = releaseReady; this.textureHash = textureHash; + this.textDirection = direction; + } + + @ParametersAreNonnullByDefault + LanguagePreset(String id, boolean releaseReady, String textureHash) { + this(id, releaseReady, TextDirection.LEFT_TO_RIGHT, textureHash); + } + + @ParametersAreNonnullByDefault + LanguagePreset(String id, TextDirection direction, String textureHash) { + this(id, true, direction, textureHash); + } + + @ParametersAreNonnullByDefault + LanguagePreset(String id, String textureHash) { + this(id, true, textureHash); } /** @@ -96,8 +113,17 @@ boolean isReadyForRelease() { * * @return The texture hash of this language */ - public @Nonnull String getTexture() { return textureHash; } + + /** + * This returns the direction of text for + * this language. + * + * @return The direction of text for this language + */ + public @Nonnull TextDirection getTextDirection() { + return textDirection; + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TextDirection.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TextDirection.java new file mode 100644 index 0000000000..1c1d57bb11 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TextDirection.java @@ -0,0 +1,25 @@ +package io.github.thebusybiscuit.slimefun4.core.services.localization; + +/** + * A simple enum to define the direction of text for a given {@link LanguagePreset} + * + * @author TheBusyBiscuit + * + */ +public enum TextDirection { + + /** + * The text flows from left to right. + * This is true for most western languages, + * such as English, Spanish, German, French and more. + */ + LEFT_TO_RIGHT, + + /** + * The text flows from right to left. + * Most common languages that use this direction + * of text are Hebrew and Arabic. + */ + RIGHT_TO_LEFT + +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java index c54250acfa..63eef282b4 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java @@ -69,25 +69,29 @@ void assertNoRegexMatchesForAllEntries(LanguagePreset lang, LanguageFile file, F Object value = entry.getValue(); if (value instanceof String) { - assertNoRegexMatch(lang, file, key, (String) value); + String location = lang.getLanguageCode() + '/' + file.name() + ": " + key; + assertNoRegexMatch(location, (String) value); } else if (value instanceof List) { + int index = 0; for (Object element : (List) value) { if (element instanceof String) { - assertNoRegexMatch(lang, file, key, (String) element); + String location = lang.getLanguageCode() + '/' + file.name() + ": " + key + "[" + index + "]"; + assertNoRegexMatch(location, (String) element); } + + index++; } } } } @ParametersAreNonnullByDefault - void assertNoRegexMatch(LanguagePreset lang, LanguageFile file, String key, String value) { + void assertNoRegexMatch(String location, String value) { Matcher matcher = getPattern().matcher(value); - boolean hasIncorrectSpelling = matcher.find(); + boolean hasMatch = matcher.find(); - if (hasIncorrectSpelling) { - String location = lang.getLanguageCode() + '/' + file.name() + ": " + key; - Assertions.fail("Mistake in file \"" + location + "\" - \"" + matcher.group() + "\"!"); + if (hasMatch) { + Assertions.fail("Mistake found @ \"" + location + "\" - \"" + matcher.group() + "\"!"); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java index 0691a250c0..9be3d2710b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java @@ -17,12 +17,12 @@ *

* Sometimes, the color code can be accidentally removed as people see * it as part of the word on first look. This test is designed to catch - * these cases. + * these cases. It is not perfect but it does catch a few instances. *

* The test checks for color chars (ampersands) that have no follow-up * chatcolor key but rather a preceeding one. *

- * The test will catch occurences like "a& ", "b&Hello" or "7&". + * The test will catch occurences like "a& ", "b&Hello" or "7&", "5& a". * The test will however ignore valid color codes such as "a&a". * * @author TheBusyBiscuit From ef1b6ae9a9aadf35136ce9fe3980a37fcd998de9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Mar 2022 14:14:05 +0100 Subject: [PATCH 48/56] Added support for Minecraft 1.18.2 Happy build DEV-1000 :tada: --- CHANGELOG.md | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6276538b00..927cda779b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ * Added a new item setting for Freezers to allow them to use a 9:1 "vanilla" ratio instead of 1:1 (1:1 by default, like before) * (API) Added `PlayerProfile#hasUnlockedEverything()` to check if a player has unlocked all researches * Added support for the plugin "HuskTowns" +* Added support for Minecraft 1.18.2 #### Changes * (API) `BiomeMapParser` is now `public` diff --git a/pom.xml b/pom.xml index 17735027c3..7c2842ba3c 100644 --- a/pom.xml +++ b/pom.xml @@ -350,7 +350,7 @@ io.github.baked-libs dough-api - 1.1.2 + 1.1.3 compile From c5045c839348bff0b745925da0f49e39bcbca9e2 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Mar 2022 14:28:54 +0100 Subject: [PATCH 49/56] [CI skip] Updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 927cda779b..bcc4a6f389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,8 +43,10 @@ * Added Spore Blossom as a fuel type for the Bio-Generator * Added a new item setting for Freezers to allow them to use a 9:1 "vanilla" ratio instead of 1:1 (1:1 by default, like before) * (API) Added `PlayerProfile#hasUnlockedEverything()` to check if a player has unlocked all researches +* (API) Added `Research#getUnlocalizedName()` * Added support for the plugin "HuskTowns" * Added support for Minecraft 1.18.2 +* You can now pick up Slimefun blocks in creative mode using the middle mouse button #### Changes * (API) `BiomeMapParser` is now `public` From 92979d4fb67409bff79e683f35ae6d15c30504cd Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Mar 2022 15:57:37 +0100 Subject: [PATCH 50/56] [CI skip] Updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcc4a6f389..dc27b7d47e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,8 @@ * Added support for the plugin "HuskTowns" * Added support for Minecraft 1.18.2 * You can now pick up Slimefun blocks in creative mode using the middle mouse button +* `/sf search` no longer shows items in hidden item groups (can be overidden by a config setting) +* Fluid Pumps can now fill bottles with water #### Changes * (API) `BiomeMapParser` is now `public` From 280440857bac949c33d48555d1090d96036a3ece Mon Sep 17 00:00:00 2001 From: Jeffrey Kosse Date: Wed, 9 Mar 2022 21:22:08 +0100 Subject: [PATCH 51/56] fixes #3483 --- .../implementation/listeners/MiddleClickListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java index e30697a76f..343c90ab33 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -46,7 +46,8 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { // get the block the player is looking at for later Block b = player.getTargetBlockExact(5); - if (!isActualMiddleClick(e, b)) { + // Fixes: #3483 + if (b == null || !isActualMiddleClick(e, b)) { return; } From 52aa81419f2f5206206a0fe25ec8ab05b1af1a68 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 10 Mar 2022 00:16:41 +0100 Subject: [PATCH 52/56] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc27b7d47e..d5e7bd87ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ * Fixed "LogBlock" integration * Fixed "Lands" integration * Fixed #3133 +* Fixed #3483 ## Release Candidate 30 (31 Dec 2021) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#30 From 9387f28446f9f3aeabee2f3ff3f107bacf40f7b5 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 10 Mar 2022 20:40:47 +0100 Subject: [PATCH 53/56] [CI skip] Updated auto-squash workflow --- .github/workflows/auto-squash.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-squash.yml b/.github/workflows/auto-squash.yml index a310b8930d..6823ab0790 100644 --- a/.github/workflows/auto-squash.yml +++ b/.github/workflows/auto-squash.yml @@ -12,9 +12,9 @@ on: status: {} jobs: - autosquash: + autosquash-crowdin: - name: Auto squash + name: Auto squash (Crowdin) runs-on: ubuntu-latest ## Only run this on the main repo @@ -31,3 +31,23 @@ jobs: MERGE_DELETE_BRANCH: true MERGE_LABELS: '📄 Translations Update' MERGE_COMMIT_MESSAGE: '[CI skip] New locale updates from Crowdin' + + autosquash-renovate: + + name: Auto squash (Renovate) + runs-on: ubuntu-latest + + ## Only run this on the main repo + if: github.event.pull_request.head.repo.full_name == 'Slimefun/Slimefun4' + + steps: + - name: Auto squash + uses: pascalgn/automerge-action@v0.14.3 + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + UPDATE_RETRIES: 0 + MERGE_METHOD: squash + MERGE_FORKS: false + MERGE_DELETE_BRANCH: true + MERGE_LABELS: '🚨 Dependency Update' + MERGE_COMMIT_MESSAGE: '[CI skip] ${{ github.event.pull_request.title }}' From 32054f328de03138599d949830171b3fd0c42460 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 10 Mar 2022 20:44:05 +0100 Subject: [PATCH 54/56] [CI skip] Update dependency net.imprex:orebfuscator-api to v5.2.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c2842ba3c..30e05be735 100644 --- a/pom.xml +++ b/pom.xml @@ -491,7 +491,7 @@ net.imprex orebfuscator-api - 5.2.4 + 5.2.6 provided From f4ded6b09bb0b9f9a817dea4475bc3eaded08dcb Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 10 Mar 2022 20:45:06 +0100 Subject: [PATCH 55/56] [CI skip] Properly name this workflow --- .github/workflows/auto-squash.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-squash.yml b/.github/workflows/auto-squash.yml index 6823ab0790..c52e88947c 100644 --- a/.github/workflows/auto-squash.yml +++ b/.github/workflows/auto-squash.yml @@ -1,4 +1,4 @@ -name: Auto squash Crowdin updates +name: Auto squash pull requests on: pull_request_review: From cea7204994359822ce7c50cad63100c55396f872 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 10 Mar 2022 21:00:28 +0100 Subject: [PATCH 56/56] Fixed #3487 --- CHANGELOG.md | 3 +++ .../slimefun4/api/items/SlimefunItem.java | 12 +++++++---- .../guide/SurvivalSlimefunGuide.java | 21 ++++++++++++++++--- .../listeners/AncientAltarListener.java | 4 ++-- .../listeners/MiddleClickListener.java | 14 ++++++------- 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5e7bd87ac..8fd5d80239 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,9 @@ * Fixed "Lands" integration * Fixed #3133 * Fixed #3483 +* Fixed #3469 +* Fixed #3476 +* Fixed #3487 ## Release Candidate 30 (31 Dec 2021) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#30 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java index ec07e61430..9de3953092 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java @@ -663,7 +663,8 @@ public void setResearch(@Nullable Research research) { /** * Sets the recipe for this {@link SlimefunItem}. * - * @param recipe The recipe for this {@link ItemStack} + * @param recipe + * The recipe for this {@link ItemStack} */ public void setRecipe(@Nonnull ItemStack[] recipe) { if (recipe == null || recipe.length != 9) { @@ -676,7 +677,8 @@ public void setRecipe(@Nonnull ItemStack[] recipe) { /** * Sets the {@link RecipeType} for this {@link SlimefunItem}. * - * @param type The {@link RecipeType} for this {@link SlimefunItem} + * @param type + * The {@link RecipeType} for this {@link SlimefunItem} */ public void setRecipeType(@Nonnull RecipeType type) { Validate.notNull(type, "The RecipeType is not allowed to be null!"); @@ -1135,7 +1137,8 @@ public final int hashCode() { /** * Retrieve a {@link SlimefunItem} by its id. * - * @param id The id of the {@link SlimefunItem} + * @param id + * The id of the {@link SlimefunItem} * @return The {@link SlimefunItem} associated with that id. Null if non-existent */ public static @Nullable SlimefunItem getById(@Nonnull String id) { @@ -1145,7 +1148,8 @@ public final int hashCode() { /** * Retrieve a {@link SlimefunItem} from an {@link ItemStack}. * - * @param item The {@link ItemStack} to check + * @param item + * The {@link ItemStack} to check * @return The {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise null */ public static @Nullable SlimefunItem getByItem(@Nullable ItemStack item) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index 3ff27e6192..047a696a6b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -33,6 +33,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.groups.SubItemGroup; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.api.researches.Research; @@ -360,9 +361,7 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory break; } - boolean isItemGroupHidden = showHiddenItemGroupsInSearch || !slimefunItem.getItemGroup().isHidden(p); - - if (!slimefunItem.isHidden() && isItemGroupHidden && isSearchFilterApplicable(slimefunItem, searchTerm)) { + if (!slimefunItem.isHidden() && !isItemGroupHidden(p, slimefunItem) && isSearchFilterApplicable(slimefunItem, searchTerm)) { ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); @@ -391,6 +390,22 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory menu.open(p); } + @ParametersAreNonnullByDefault + private boolean isItemGroupHidden(Player p, SlimefunItem slimefunItem) { + if (showHiddenItemGroupsInSearch) { + return false; + } + + ItemGroup itemGroup = slimefunItem.getItemGroup(); + + // Fixes #3487 - SubItemGroups are "pseudo-hidden" + if (itemGroup instanceof SubItemGroup) { + return false; + } else { + return itemGroup.isHidden(p); + } + } + @ParametersAreNonnullByDefault private boolean isSearchFilterApplicable(SlimefunItem slimefunItem, String searchTerm) { String itemName = ChatColor.stripColor(slimefunItem.getItemName()).toLowerCase(Locale.ROOT); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 4187d19b68..30071db6f7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -164,8 +164,8 @@ private void usePedestal(@Nonnull Block pedestal, @Nonnull Player p) { * Drop the item instead if the player's inventory is full and * no stack space left else add remaining items from the returned map value */ - Map remainingItemMap = p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); - + Map remainingItemMap = p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); + for (ItemStack item : remainingItemMap.values()) { p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), item.clone()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java index 343c90ab33..b35d48292b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java @@ -1,7 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; -import java.util.Optional; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -16,10 +14,12 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; + import me.mrCookieSlime.Slimefun.api.BlockStorage; /** - * The {@link MiddleClickListener} is responsible for listening to the {@link InventoryCreativeEvent}. + * The {@link MiddleClickListener} is responsible for listening to + * the {@link InventoryCreativeEvent}. * * @author svr333 * @@ -30,7 +30,7 @@ public MiddleClickListener(@Nonnull Slimefun plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); } - /* + /* * General Discloser: this event has really really really weird behavior on middle click. * Has been tested thoroughly to make sure it doesnt break anything else. */ @@ -58,8 +58,8 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { if (sfItem == null) { return; } - - /* + + /* * Before giving the item to the user, check if you can swap * to the item instead (user already has item in hotbar). * This is sometimes bypassed by the client itself (not fixable though). @@ -85,7 +85,7 @@ private boolean isActualMiddleClick(InventoryCreativeEvent e, Block b) { * to the actual block that is middle clicked, while currentItem will be AIR. * * This check is really weird due to the weird nature of this event's behaviour. - * It checks if the block the player is looking at is of the same type as the cursor; + * It checks if the block the player is looking at is of the same type as the cursor, * after this we can make sure that it is a middle click outside of the inventory * currentItem should also be air, otherwise it is not outside of the inventory */