diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 06e4924d..294d8dee 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -96,6 +96,7 @@ import com.gamingmesh.jobs.i18n.Language; import com.gamingmesh.jobs.listeners.JobsListener; import com.gamingmesh.jobs.listeners.JobsPayment1_14Listener; import com.gamingmesh.jobs.listeners.JobsPayment1_16Listener; +import com.gamingmesh.jobs.listeners.JobsPayment1_9Listener; import com.gamingmesh.jobs.listeners.JobsPaymentListener; import com.gamingmesh.jobs.listeners.PistonProtectionListener; import com.gamingmesh.jobs.listeners.PlayerSignEdit1_20Listeners; @@ -797,26 +798,24 @@ public final class Jobs extends JavaPlugin { private static void registerListeners() { - org.bukkit.plugin.PluginManager pm = getInstance().getServer().getPluginManager(); + CMIMessages.consoleMessage("&eRegistering listeners..."); - if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) { - pm.registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), getInstance()); - } + org.bukkit.plugin.PluginManager pm = getInstance().getServer().getPluginManager(); pm.registerEvents(new JobsListener(getInstance()), getInstance()); pm.registerEvents(new JobsPaymentListener(getInstance()), getInstance()); - if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) { + if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) + pm.registerEvents(new JobsPayment1_9Listener(), getInstance()); + + if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) pm.registerEvents(new JobsPayment1_14Listener(), getInstance()); - } - if (Version.isCurrentEqualOrHigher(Version.v1_16_R3)) { + if (Version.isCurrentEqualOrHigher(Version.v1_16_R3)) pm.registerEvents(new JobsPayment1_16Listener(), getInstance()); - } - if (Version.isCurrentEqualOrHigher(Version.v1_20_R1)) { + if (Version.isCurrentEqualOrHigher(Version.v1_20_R1)) pm.registerEvents(new PlayerSignEdit1_20Listeners(), getInstance()); - } if (getGCManager().useBlockProtection) { pm.registerEvents(new PistonProtectionListener(), getInstance()); @@ -830,6 +829,7 @@ public final class Jobs extends JavaPlugin { if (HookManager.checkMythicMobs()) { HookManager.getMythicManager().registerListener(); } + CMIMessages.consoleMessage("&eListeners registered successfully"); } public static void reload() { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment1_9Listener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment1_9Listener.java new file mode 100644 index 00000000..c4e33c21 --- /dev/null +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment1_9Listener.java @@ -0,0 +1,34 @@ +package com.gamingmesh.jobs.listeners; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.PrepareAnvilEvent; +import org.bukkit.event.player.PlayerSwapHandItemsEvent; + +import com.gamingmesh.jobs.ItemBoostManager; +import com.gamingmesh.jobs.Jobs; + +import net.Zrips.CMILib.Items.CMIMaterial; + +public final class JobsPayment1_9Listener implements Listener { + + @EventHandler(priority = EventPriority.NORMAL) + public void PrepareAnvilEvent(final PrepareAnvilEvent event) { + if (!Jobs.getGCManager().preventShopItemEnchanting) + return; + + if (!ItemBoostManager.containsItemBoostByNBT(event.getInventory().getContents()[0])) + return; + + if (!CMIMaterial.get(event.getInventory().getContents()[1]).equals(CMIMaterial.ENCHANTED_BOOK)) + return; + + event.setResult(null); + } + + @EventHandler + public void onPlayerHandSwap(PlayerSwapHandItemsEvent event) { + Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId()); + } +} diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 9caedfb2..dfbdbdac 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -71,7 +71,6 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType.SlotType; -import org.bukkit.event.inventory.PrepareAnvilEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -418,13 +417,20 @@ public final class JobsPaymentListener implements Listener { } } + @EventHandler(priority = EventPriority.NORMAL) + public void breakTest(BlockBreakEvent event) { + + CMIMessages.consoleMessage("break" + 1); + } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { - + CMIMessages.consoleMessage("" + 1); final Block block = event.getBlock(); if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld())) return; + CMIMessages.consoleMessage("" + 2); Player player = event.getPlayer(); @@ -434,14 +440,17 @@ public final class JobsPaymentListener implements Listener { // check if player is riding if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) return; + CMIMessages.consoleMessage("" + 3); // check if in creative if (!payIfCreative(player)) return; + CMIMessages.consoleMessage("" + 4); if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; + CMIMessages.consoleMessage("" + 5); BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.BREAK); FastPayment fp = Jobs.FASTPAYMENT.get(player.getUniqueId()); @@ -454,9 +463,11 @@ public final class JobsPaymentListener implements Listener { Jobs.FASTPAYMENT.remove(player.getUniqueId()); } + CMIMessages.consoleMessage("" + 6); if (!payForItemDurabilityLoss(player)) return; + CMIMessages.consoleMessage("" + 7); // Protection for block break with silktouch if (Jobs.getGCManager().useSilkTouchProtection) { ItemStack item = CMIItemStack.getItemInMainHand(player); @@ -469,6 +480,7 @@ public final class JobsPaymentListener implements Listener { } } } + CMIMessages.consoleMessage("" + 8); // Better implementation? // Prevent money duplication when breaking plant blocks @@ -1079,19 +1091,6 @@ public final class JobsPaymentListener implements Listener { Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT)); } - @EventHandler(priority = EventPriority.NORMAL) - public void PrepareAnvilEvent(final PrepareAnvilEvent event) { - if (!Jobs.getGCManager().preventShopItemEnchanting) - return; - - if (!ItemBoostManager.containsItemBoostByNBT(event.getInventory().getContents()[0])) - return; - - if (!CMIMaterial.get(event.getInventory().getContents()[1]).equals(CMIMaterial.ENCHANTED_BOOK)) - return; - - event.setResult(null); - } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/Listener1_9.java b/src/main/java/com/gamingmesh/jobs/listeners/Listener1_9.java deleted file mode 100644 index 6e38fe7f..00000000 --- a/src/main/java/com/gamingmesh/jobs/listeners/Listener1_9.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gamingmesh.jobs.listeners; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerSwapHandItemsEvent; - -import com.gamingmesh.jobs.Jobs; - -public class Listener1_9 implements Listener { - - @EventHandler - public void onPlayerHandSwap(PlayerSwapHandItemsEvent event) { - Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId()); - } -}