From c0d6208d12810912e63722bc979b8cddd685ada8 Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Mon, 5 Jul 2021 23:22:09 +0100 Subject: [PATCH 1/2] Hoe Fixes --- .../sensibletoolbox/items/CombineHoe.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/sensibletoolbox/items/CombineHoe.java b/src/main/java/io/github/thebusybiscuit/sensibletoolbox/items/CombineHoe.java index a51ff4eb..7f9c4001 100644 --- a/src/main/java/io/github/thebusybiscuit/sensibletoolbox/items/CombineHoe.java +++ b/src/main/java/io/github/thebusybiscuit/sensibletoolbox/items/CombineHoe.java @@ -5,6 +5,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import me.desht.dhutils.text.LogUtils; import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Material; @@ -41,6 +42,7 @@ public abstract class CombineHoe extends BaseSTBItem { private Material seedType; private int seedAmount; private InventoryGUI gui; + private EquipmentSlot equipmentSlot; @Nonnull public static String getInventoryTitle() { @@ -83,6 +85,14 @@ public void setSeedAmount(int seedAmount) { this.seedAmount = seedAmount; } + public EquipmentSlot getEquipmentSlot() { + return equipmentSlot; + } + + public void setEquipmentSlot(EquipmentSlot equipmentSlot) { + this.equipmentSlot = equipmentSlot; + } + @Override public boolean isEnchantable() { return false; @@ -92,7 +102,7 @@ public boolean isEnchantable() { public String[] getLore() { int n = getWorkRadius() * 2 + 1; String s = n + "x" + n; - return new String[] { "Right-click dirt/grass:" + ChatColor.WHITE + " till 3x3 area", "Right-click soil:" + ChatColor.WHITE + " sow 3x3 area", "Right-click other:" + ChatColor.WHITE + " open seed bag", "Left-click plants:" + ChatColor.WHITE + " harvest " + s + " area", "Left-click leaves:" + ChatColor.WHITE + " break 3x3x3 area", }; + return new String[] { "Right-click dirt/grass:" + ChatColor.WHITE + " till 3x3 area", "Right-click soil:" + ChatColor.WHITE + " sow 3x3 area", "Right-click air:" + ChatColor.WHITE + " open seed bag", "Left-click plants:" + ChatColor.WHITE + " harvest " + s + " area", "Left-click leaves:" + ChatColor.WHITE + " break 3x3x3 area", }; } @Override @@ -113,20 +123,21 @@ public boolean hasGlow() { @Override public void onInteractItem(PlayerInteractEvent event) { Block b = event.getClickedBlock(); + setEquipmentSlot(event.getHand()); if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (b.getType() == Material.FARMLAND) { plantSeeds(event.getPlayer(), b); event.setCancelled(true); return; - } else if (b.getType() == Material.DIRT || b.getType() == Material.GRASS) { + } else if (b.getType() == Material.DIRT || b.getType() == Material.GRASS_BLOCK) { tillSoil(event.getPlayer(), event.getItem(), event.getHand(), b); event.setCancelled(true); return; } } - if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { + if (event.getAction() == Action.RIGHT_CLICK_AIR) { if (event.getClickedBlock() == null || !event.getClickedBlock().getType().isInteractable()) { gui = GUIUtil.createGUI(event.getPlayer(), this, 9, getInventoryTitle()); @@ -241,6 +252,7 @@ public void onGUIClosed(HumanEntity player) { setSeedAmount(count); setSeedType(seeds); + updateHeldItemStack((Player) player, getEquipmentSlot()); } private void populateSeedBag(InventoryGUI gui) { @@ -286,6 +298,7 @@ private void plantSeeds(Player player, Block b) { if (amountLeft < getSeedAmount()) { setSeedAmount(amountLeft); + updateHeldItemStack(player, getEquipmentSlot()); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.0F); } } @@ -297,7 +310,7 @@ private void harvestLayer(Player player, Block b) { for (Block block : cuboid) { if (!block.equals(b) && (STBUtil.isPlant(block.getType()) || Tag.LEAVES.isTagged(block.getType()))) { - if (!SensibleToolbox.getProtectionManager().hasPermission(player, b, ProtectableAction.BREAK_BLOCK)) { + if (SensibleToolbox.getProtectionManager().hasPermission(player, b, ProtectableAction.BREAK_BLOCK)) { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); block.breakNaturally(); } From fb001d556ece63548035aca80ef3bdeda13aaffd Mon Sep 17 00:00:00 2001 From: Sefiraat Date: Mon, 5 Jul 2021 23:24:38 +0100 Subject: [PATCH 2/2] Remove import --- .../github/thebusybiscuit/sensibletoolbox/items/CombineHoe.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/sensibletoolbox/items/CombineHoe.java b/src/main/java/io/github/thebusybiscuit/sensibletoolbox/items/CombineHoe.java index 7f9c4001..17b58223 100644 --- a/src/main/java/io/github/thebusybiscuit/sensibletoolbox/items/CombineHoe.java +++ b/src/main/java/io/github/thebusybiscuit/sensibletoolbox/items/CombineHoe.java @@ -5,7 +5,6 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import me.desht.dhutils.text.LogUtils; import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Material;