1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Potion consumption/crafting error catcher for 1.8 1.7 servers.

This will disable potion recognition in these servers
This commit is contained in:
Zrips 2024-04-16 12:48:49 +03:00
parent d9ef365b65
commit 2d01ec3cc7

View File

@ -417,20 +417,12 @@ 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) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
CMIMessages.consoleMessage("" + 1);
final Block block = event.getBlock(); final Block block = event.getBlock();
if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
return; return;
CMIMessages.consoleMessage("" + 2);
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -440,17 +432,14 @@ public final class JobsPaymentListener implements Listener {
// check if player is riding // check if player is riding
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
return; return;
CMIMessages.consoleMessage("" + 3);
// check if in creative // check if in creative
if (!payIfCreative(player)) if (!payIfCreative(player))
return; return;
CMIMessages.consoleMessage("" + 4);
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
return; return;
CMIMessages.consoleMessage("" + 5);
BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.BREAK); BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.BREAK);
FastPayment fp = Jobs.FASTPAYMENT.get(player.getUniqueId()); FastPayment fp = Jobs.FASTPAYMENT.get(player.getUniqueId());
@ -463,11 +452,10 @@ public final class JobsPaymentListener implements Listener {
Jobs.FASTPAYMENT.remove(player.getUniqueId()); Jobs.FASTPAYMENT.remove(player.getUniqueId());
} }
CMIMessages.consoleMessage("" + 6);
if (!payForItemDurabilityLoss(player)) if (!payForItemDurabilityLoss(player))
return; return;
CMIMessages.consoleMessage("" + 7);
// Protection for block break with silktouch // Protection for block break with silktouch
if (Jobs.getGCManager().useSilkTouchProtection) { if (Jobs.getGCManager().useSilkTouchProtection) {
ItemStack item = CMIItemStack.getItemInMainHand(player); ItemStack item = CMIItemStack.getItemInMainHand(player);
@ -480,8 +468,6 @@ public final class JobsPaymentListener implements Listener {
} }
} }
} }
CMIMessages.consoleMessage("" + 8);
// Better implementation? // Better implementation?
// Prevent money duplication when breaking plant blocks // Prevent money duplication when breaking plant blocks
/*Material brokenBlock = block.getRelative(BlockFace.DOWN).getType(); /*Material brokenBlock = block.getRelative(BlockFace.DOWN).getType();
@ -738,7 +724,8 @@ public final class JobsPaymentListener implements Listener {
// when we trying to craft tipped arrow effects // when we trying to craft tipped arrow effects
if (currentItem != null && currentItem.getItemMeta() instanceof PotionMeta) { if (currentItem != null && currentItem.getItemMeta() instanceof PotionMeta) {
PotionMeta potion = (PotionMeta) currentItem.getItemMeta(); PotionMeta potion = (PotionMeta) currentItem.getItemMeta();
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.CRAFT, potion.getBasePotionData().getType())); if (Version.isCurrentEqualOrHigher(Version.v1_9_R1))
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.CRAFT, potion.getBasePotionData().getType()));
} else if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) { } else if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(resultStack.getItemMeta().getDisplayName()), ActionType.CRAFT)); Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(resultStack.getItemMeta().getDisplayName()), ActionType.CRAFT));
} else if (currentItem != null) { } else if (currentItem != null) {
@ -808,7 +795,8 @@ public final class JobsPaymentListener implements Listener {
if (resultStack.getItemMeta() instanceof PotionMeta) { if (resultStack.getItemMeta() instanceof PotionMeta) {
PotionMeta potion = (PotionMeta) resultStack.getItemMeta(); PotionMeta potion = (PotionMeta) resultStack.getItemMeta();
Jobs.action(jPlayer, new PotionItemActionInfo(resultStack, type, potion.getBasePotionData().getType())); if (Version.isCurrentEqualOrHigher(Version.v1_9_R1))
Jobs.action(jPlayer, new PotionItemActionInfo(resultStack, type, potion.getBasePotionData().getType()));
} else if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) { } else if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(resultStack.getItemMeta().getDisplayName()), type)); Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(resultStack.getItemMeta().getDisplayName()), type));
} else { } else {
@ -1091,7 +1079,6 @@ public final class JobsPaymentListener implements Listener {
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT)); Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT));
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) { public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) {
if (!Jobs.getGCManager().PreventHopperFillUps || event.getItem().getType() == Material.AIR) if (!Jobs.getGCManager().PreventHopperFillUps || event.getItem().getType() == Material.AIR)
@ -1660,7 +1647,8 @@ public final class JobsPaymentListener implements Listener {
return; return;
if (currentItem.getItemMeta() instanceof PotionMeta) { if (currentItem.getItemMeta() instanceof PotionMeta) {
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.EAT, ((PotionMeta) currentItem.getItemMeta()).getBasePotionData().getType())); if (Version.isCurrentEqualOrHigher(Version.v1_9_R1))
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.EAT, ((PotionMeta) currentItem.getItemMeta()).getBasePotionData().getType()));
} else { } else {
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.EAT)); Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.EAT));
} }