From 4d173e0623c613e381697c03742ed45373b98a23 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Sun, 14 Jun 2020 13:28:41 +0200 Subject: [PATCH] Add ability to prevent crop resize payment when we places more cactus --- .../com/gamingmesh/jobs/config/GeneralConfigManager.java | 5 +++++ .../gamingmesh/jobs/listeners/JobsPaymentListener.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index f61f56b5..ed640d5c 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -67,6 +67,7 @@ public class GeneralConfigManager { public boolean disablePaymentIfRiding; protected boolean addXpPlayer; public boolean boostedItemsInOffHand; + public boolean preventCropResizePayment; public boolean payItemDurabilityLoss; protected boolean hideJobsWithoutPermission; protected int maxJobs; @@ -583,6 +584,10 @@ public class GeneralConfigManager { boostedItemsInOffHand = c.get("enable-boosted-items-in-offhand", true); } + c.addComment("enable-payment-for-planting-blocks", "Do you want to prevent crop resizing payment when placing more cactus?", + "This option is only related to: sugar_cane, cactus, kelp, bamboo"); + preventCropResizePayment = c.get("prevent-crop-resize-payment", false); + c.addComment("allow-pay-for-durability-loss", "Allows, when losing maximum durability of item then it does not pay the player until it is repaired.", "E.g. the player wants to enchant a item with enchanting table and the item has durability loss then not paying."); c.addComment("allow-pay-for-durability-loss.Use", "Do not disable this if you don't know what mean this option."); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 6bddb42f..192b11c6 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -37,6 +37,7 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.block.BrewingStand; import org.bukkit.block.Furnace; import org.bukkit.block.data.Ageable; @@ -452,6 +453,14 @@ public class JobsPaymentListener implements Listener { if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) return; + // Prevent money duplication when placing plant blocks + Material placedBlock = event.getBlockPlaced().getRelative(BlockFace.DOWN).getType(); + if (Jobs.getGCManager().preventCropResizePayment && (placedBlock == CMIMaterial.SUGAR_CANE.getMaterial() + || placedBlock == CMIMaterial.KELP.getMaterial() + || placedBlock == CMIMaterial.CACTUS.getMaterial() || placedBlock == CMIMaterial.BAMBOO.getMaterial())) { + return; + } + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return;