From 5c194bc8ca8860c1f43057b76f6d4a1111a5cbca Mon Sep 17 00:00:00 2001 From: Zrips Date: Mon, 10 Jun 2024 13:13:43 +0300 Subject: [PATCH] New permission node jobs.noownershiptakeover to not take over existing block ownership --- pom.xml | 8 ++++++++ .../com/gamingmesh/jobs/container/Job.java | 1 + .../blockOwnerShip/BlockOwnerShip.java | 4 ++++ .../jobs/listeners/JobsPaymentListener.java | 19 +++++++++++++++---- src/main/resources/plugin.yml | 3 +++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 38bd1c21..e42fd4da 100644 --- a/pom.xml +++ b/pom.xml @@ -248,6 +248,14 @@ 1.8 + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + D:\MC\Server 1.20.5\plugins\ + + \ No newline at end of file diff --git a/src/main/java/com/gamingmesh/jobs/container/Job.java b/src/main/java/com/gamingmesh/jobs/container/Job.java index 8b2c6c4b..e7ad8602 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Job.java +++ b/src/main/java/com/gamingmesh/jobs/container/Job.java @@ -211,6 +211,7 @@ public class Job { return totalPlayers; } + /** * * @param change the amount to change diff --git a/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java b/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java index 00fa2222..9dbad2d2 100644 --- a/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java +++ b/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java @@ -127,6 +127,10 @@ public class BlockOwnerShip { if (ownerUUID != null && !ownerUUID.equals(player.getUniqueId())) { if (Jobs.getGCManager().blockOwnershipTakeOver) { + + if (Jobs.getPermissionManager().hasPermission(jPlayer, "jobs.noownershiptakeover")) + return ownershipFeedback.invalid; + // Removing ownership to record new player this.remove(ownerUUID, CMILocation.toString(block.getLocation(), ":", true, true)); block.removeMetadata(metadataName, plugin); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 1295adff..ae224e21 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -26,8 +26,6 @@ import java.util.Map.Entry; import java.util.UUID; import java.util.concurrent.TimeUnit; -import com.gamingmesh.jobs.actions.*; -import com.gamingmesh.jobs.hooks.pyroFishingPro.PyroFishingProManager; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -94,6 +92,16 @@ import org.bukkit.permissions.PermissionAttachmentInfo; import com.bgsoftware.wildstacker.api.enums.StackSplit; import com.gamingmesh.jobs.ItemBoostManager; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.actions.BlockActionInfo; +import com.gamingmesh.jobs.actions.BlockCollectInfo; +import com.gamingmesh.jobs.actions.CustomKillInfo; +import com.gamingmesh.jobs.actions.EnchantActionInfo; +import com.gamingmesh.jobs.actions.EntityActionInfo; +import com.gamingmesh.jobs.actions.ExploreActionInfo; +import com.gamingmesh.jobs.actions.ItemActionInfo; +import com.gamingmesh.jobs.actions.ItemNameActionInfo; +import com.gamingmesh.jobs.actions.PotionItemActionInfo; +import com.gamingmesh.jobs.actions.PyroFishingProInfo; import com.gamingmesh.jobs.api.JobsChunkChangeEvent; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.ExploreRespond; @@ -105,6 +113,7 @@ import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip; import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip.ownershipFeedback; import com.gamingmesh.jobs.hooks.HookManager; import com.gamingmesh.jobs.hooks.JobsHook; +import com.gamingmesh.jobs.hooks.pyroFishingPro.PyroFishingProManager; import com.gamingmesh.jobs.stuff.Util; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; @@ -124,7 +133,6 @@ import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMC; import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Schedulers.CMIScheduler; @@ -1776,7 +1784,8 @@ public final class JobsPaymentListener implements Listener { boolean isBrewingStand = cmat == CMIMaterial.BREWING_STAND || cmat == CMIMaterial.LEGACY_BREWING_STAND; boolean isFurnace = cmat == CMIMaterial.FURNACE || cmat == CMIMaterial.LEGACY_BURNING_FURNACE; - if (isFurnace || cmat == CMIMaterial.SMOKER || cmat == CMIMaterial.BLAST_FURNACE || isBrewingStand) { + if ((isFurnace || cmat == CMIMaterial.SMOKER || cmat == CMIMaterial.BLAST_FURNACE || isBrewingStand)) { + BlockOwnerShip blockOwner = plugin.getBlockOwnerShip(cmat).orElse(null); if (blockOwner == null) { return; @@ -1806,9 +1815,11 @@ public final class JobsPaymentListener implements Listener { if (report) CMIActionBar.send(p, Jobs.getLanguage().getMessage("general.error.noRegistration", "[block]", name)); } else if (done == ownershipFeedback.newReg && jPlayer != null && jPlayer.getMaxOwnerShipAllowed(blockOwner.getType()) > 0) { + CMIActionBar.send(p, Jobs.getLanguage().getMessage("general.error.newRegistration", "[block]", name, "[current]", blockOwner.getTotal(jPlayer.getUniqueId()), "[max]", jPlayer.getMaxOwnerShipAllowed(blockOwner.getType()) == 0 ? "-" : jPlayer.getMaxOwnerShipAllowed(blockOwner.getType()))); + } else if (done == ownershipFeedback.reenabled && jPlayer != null) { CMIActionBar.send(p, Jobs.getLanguage().getMessage("general.error.reenabledBlock")); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index cbf880e0..749d8ef9 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -238,3 +238,6 @@ permissions: jobs.hidegtop: description: Prevent player to be shown in the global jobs top default: false + jobs.noownershiptakeover: + description: Will not take over existing block ownership + default: op