From d70d2e79187891b5ffe8abd68b2575503158ffb9 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Mon, 16 Nov 2020 18:12:57 +0100 Subject: [PATCH] Now you can craft items in the smithing table to get income Closes #1002 --- .../gamingmesh/jobs/listeners/JobsListener.java | 14 +++++--------- .../jobs/listeners/JobsPaymentListener.java | 10 +++++++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index 94f14d4f..ff0165f9 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -310,9 +310,9 @@ public class JobsListener implements Listener { special = true; } - int Number = 0; + int number = 0; try { - Number = Integer.parseInt(numberString); + number = Integer.parseInt(numberString); } catch (NumberFormatException e) { player.sendMessage(Jobs.getLanguage().getMessage("general.error.notNumber")); return; @@ -322,7 +322,7 @@ public class JobsListener implements Listener { Location loc = sign.getLocation(); signInfo.setLoc(loc); - signInfo.setNumber(Number); + signInfo.setNumber(number); if (job != null) signInfo.setJobName(job.getName()); signInfo.setType(type); @@ -356,7 +356,6 @@ public class JobsListener implements Listener { } String command = CMIChatColor.stripColor(event.getLine(1)).toLowerCase(); - for (String key : Jobs.getGCManager().keys) { if (command.equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.secondline." + key)))) { event.setLine(1, Convert(Jobs.getLanguage().getMessage("signs.secondline." + key))); @@ -481,9 +480,7 @@ public class JobsListener implements Listener { mein: for (JobProgression one : JPlayer.getJobProgression()) { for (JobLimitedItems oneItem : one.getJob().getLimitedItems().values()) { - if (one.getLevel() >= oneItem.getLevel()) - continue; - if (!isThisItem(oneItem, CMIMaterial.get(iih), name, lore, enchants)) + if (one.getLevel() >= oneItem.getLevel() || !isThisItem(oneItem, CMIMaterial.get(iih), name, lore, enchants)) continue; meinOk = one.getJob().getName(); break mein; @@ -500,7 +497,7 @@ public class JobsListener implements Listener { if (oneItem.getType() != mat) return false; - if (oneItem.getName() != null && name != null && !CMIChatColor.translate(oneItem.getName()).equalsIgnoreCase(name)) { + if (oneItem.getName() != null && !CMIChatColor.translate(oneItem.getName()).equalsIgnoreCase(name)) { return false; } @@ -595,7 +592,6 @@ public class JobsListener implements Listener { event.setCancelled(true); } } - } else { ItemStack newArmorPiece = event.getCursor(); ItemStack oldArmorPiece = event.getCurrentItem(); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 9ac87ad6..977cd051 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -83,6 +83,7 @@ import org.bukkit.inventory.EnchantingInventory; import org.bukkit.inventory.GrindstoneInventory; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.SmithingInventory; import org.bukkit.inventory.StonecutterInventory; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.metadata.FixedMetadataValue; @@ -803,14 +804,16 @@ public class JobsPaymentListener implements Listener { Inventory inv = event.getInventory(); // must be anvil inventory if (!(inv instanceof AnvilInventory) && (Version.isCurrentEqualOrHigher(Version.v1_14_R1) - && !(inv instanceof GrindstoneInventory) && !(inv instanceof StonecutterInventory))) + && !(inv instanceof GrindstoneInventory) && !(inv instanceof StonecutterInventory) + && !(inv instanceof SmithingInventory))) return; int slot = event.getSlot(); if (event.getSlotType() != SlotType.RESULT || (slot != 2 && slot != 1)) return; - if ((Version.isCurrentEqualOrHigher(Version.v1_14_R1) && !(inv instanceof StonecutterInventory)) && slot == 1) + if ((Version.isCurrentEqualOrHigher(Version.v1_14_R1) + && !(inv instanceof StonecutterInventory) && !(inv instanceof SmithingInventory)) && slot == 1) return; if (!(event.getWhoClicked() instanceof Player)) @@ -880,7 +883,8 @@ public class JobsPaymentListener implements Listener { if (jPlayer == null) return; - if (Version.isCurrentEqualOrHigher(Version.v1_14_R1) && inv instanceof StonecutterInventory) { + if (Version.isCurrentEqualOrHigher(Version.v1_14_R1) && (inv instanceof StonecutterInventory + || inv instanceof SmithingInventory)) { if (event.getAction() != InventoryAction.DROP_ONE_SLOT) { Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT)); }