From e887a59158bcedbac8c06cd5070c7abf1d4d64bf Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Thu, 12 Jan 2023 10:03:11 +0100 Subject: [PATCH 01/32] Officially deprecated BukkitPlayer#BukkitPlayer() (#3922) * Officially deprecated BukkitPlayer#BukkitPlayer() * Address review feedback --- .../plotsquared/bukkit/player/BukkitPlayer.java | 17 ++++++++++++++--- .../bukkit/player/BukkitPlayerManager.java | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index 1bcd3750f..268258ead 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -67,14 +67,15 @@ public class BukkitPlayer extends PlotPlayer { private String name; /** - *

Please do not use this method. Instead use - * BukkitUtil.getPlayer(Player), as it caches player objects.

- * * @param plotAreaManager PlotAreaManager instance * @param eventDispatcher EventDispatcher instance * @param player Bukkit player instance * @param permissionHandler PermissionHandler instance + * + * @deprecated Please do not use this method. Instead use {@link BukkitUtil#adapt(Player)}, as it caches player objects. + * This method will be made private in a future release. */ + @Deprecated(forRemoval = true, since = "TODO") public BukkitPlayer( final @NonNull PlotAreaManager plotAreaManager, final @NonNull EventDispatcher eventDispatcher, final @NonNull Player player, final @NonNull PermissionHandler permissionHandler @@ -82,6 +83,16 @@ public class BukkitPlayer extends PlotPlayer { this(plotAreaManager, eventDispatcher, player, false, permissionHandler); } + /** + * @param plotAreaManager PlotAreaManager instance + * @param eventDispatcher EventDispatcher instance + * @param player Bukkit player instance + * @param permissionHandler PermissionHandler instance + * + * @deprecated Please do not use this method. Instead use {@link BukkitUtil#adapt(Player)}, as it caches player objects. + * This method will be made private in a future release. + */ + @Deprecated(forRemoval = true, since = "TODO") public BukkitPlayer( final @NonNull PlotAreaManager plotAreaManager, final @NonNull EventDispatcher eventDispatcher, final @NonNull Player player, diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java index 35b550d2f..a1a675598 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java @@ -54,6 +54,7 @@ public class BukkitPlayerManager extends PlayerManager { @NonNull @Override + @SuppressWarnings("deprecation") public BukkitPlayer getPlayer(final @NonNull Player object) { if (object.getUniqueId().version() == 2) { // not a real player return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, object, false, this.permissionHandler); @@ -65,6 +66,7 @@ public class BukkitPlayerManager extends PlayerManager { } @Override + @SuppressWarnings("deprecation") public @NonNull BukkitPlayer createPlayer(final @NonNull UUID uuid) { final Player player = Bukkit.getPlayer(uuid); if (player == null || !player.isOnline()) { From 1d201b04baf8d608ccc365326398686d72791218 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Fri, 13 Jan 2023 17:48:13 +0100 Subject: [PATCH 02/32] chore: Update a few deprecations (#3913) --- .../src/main/java/com/plotsquared/bukkit/BukkitPlatform.java | 5 ----- .../plotsquared/bukkit/managers/MultiverseWorldManager.java | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 4355e9418..8055bd5cb 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -36,7 +36,6 @@ import com.plotsquared.bukkit.listener.ChunkListener; import com.plotsquared.bukkit.listener.EntityEventListener; import com.plotsquared.bukkit.listener.EntitySpawnListener; import com.plotsquared.bukkit.listener.PaperListener; -import com.plotsquared.bukkit.listener.PaperListener113; import com.plotsquared.bukkit.listener.PlayerEventListener; import com.plotsquared.bukkit.listener.ProjectileEventListener; import com.plotsquared.bukkit.listener.ServerListener; @@ -356,11 +355,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl getServer().getPluginManager().registerEvents(injector().getInstance(ServerListener.class), this); getServer().getPluginManager().registerEvents(injector().getInstance(EntitySpawnListener.class), this); if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) { - if (serverVersion()[1] == 13) { - getServer().getPluginManager().registerEvents(injector().getInstance(PaperListener113.class), this); - } else { getServer().getPluginManager().registerEvents(injector().getInstance(PaperListener.class), this); - } } else { getServer().getPluginManager().registerEvents(injector().getInstance(SpigotListener.class), this); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/MultiverseWorldManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/MultiverseWorldManager.java index 0a6ed594b..8f4439339 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/MultiverseWorldManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/MultiverseWorldManager.java @@ -30,8 +30,9 @@ import org.checkerframework.checker.nullness.qual.Nullable; * * @deprecated Deprecated and scheduled for removal without replacement * in favor of the build in setup wizard. + * However, this class will be kept around for a while, given it's not a maintenance burden. */ -@Deprecated(forRemoval = true, since = "6.0.0") +@Deprecated @Singleton public class MultiverseWorldManager extends BukkitWorldManager { From 6a34a1996f821f99617cb3ada67bc40ca93bb668 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 13 Jan 2023 22:28:58 +0100 Subject: [PATCH 03/32] Update dependency com.intellectualsites.bom:bom-1.18.x to v1.22 (#3918) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3a8abe758..d6d7bb50b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -64,7 +64,7 @@ subprojects { } dependencies { - implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.21")) + implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.22")) } dependencies { From 00722bc4633410ca7644b531f3a0a2172f000385 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sat, 14 Jan 2023 00:27:09 +0100 Subject: [PATCH 04/32] Reduce `/plot home` overhead (#3921) * Add JFR events * Replace global connected plots cache with local cache * Simplify isOwner check * Avoid extensive hashing of plots * Clear caches in more cases * Revert "Add JFR events" This reverts commit 78c107f1 --- .../java/com/plotsquared/core/plot/Plot.java | 41 ++++++++++--------- .../core/plot/PlotModificationManager.java | 6 ++- .../core/util/query/GlobalPlotProvider.java | 6 +-- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 098b95656..bab1a3d61 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -122,9 +122,6 @@ public class Plot { private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build(); private static final Cleaner CLEANER = Cleaner.create(); - static Set connected_cache; - static Set regions_cache; - static { FLAG_DECIMAL_FORMAT.setMaximumFractionDigits(340); } @@ -207,6 +204,8 @@ public class Plot { */ private Plot origin; + private Set connectedCache; + /** * Constructor for a new plot. * (Only changes after plot.create() will be properly set in the database) @@ -576,7 +575,14 @@ public class Plot { return false; } final Set connected = getConnectedPlots(); - return connected.stream().anyMatch(current -> uuid.equals(current.getOwner())); + for (Plot current : connected) { + // can skip ServerPlotFlag check in getOwner() + // as flags are synchronized between plots + if (uuid.equals(current.getOwnerAbs())) { + return true; + } + } + return false; } /** @@ -1294,6 +1300,7 @@ public class Plot { DBFunc.delete(current); current.setOwnerAbs(null); current.settings = null; + current.clearCache(); for (final PlotPlayer pp : players) { this.plotListener.plotEntry(pp, current); } @@ -1864,6 +1871,7 @@ public class Plot { this.area.removePlot(this.id); this.id = plot.getId(); this.area.addPlotAbs(this); + clearCache(); DBFunc.movePlot(this, plot); TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L)); return true; @@ -2128,17 +2136,16 @@ public class Plot { this.origin.origin = base; other.origin = base; this.origin = base; - connected_cache = null; + this.connectedCache = null; } } else { if (this.origin != null) { this.origin.origin = null; this.origin = null; } - connected_cache = null; + this.connectedCache = null; } DBFunc.setMerged(this, this.getSettings().getMerged()); - regions_cache = null; } } @@ -2173,8 +2180,7 @@ public class Plot { } public void clearCache() { - connected_cache = null; - regions_cache = null; + this.connectedCache = null; if (this.origin != null) { this.origin.origin = null; this.origin = null; @@ -2301,10 +2307,9 @@ public class Plot { if (!this.isMerged()) { return Collections.singleton(this); } - if (connected_cache != null && connected_cache.contains(this)) { - return connected_cache; + if (this.connectedCache != null && this.connectedCache.contains(this)) { + return this.connectedCache; } - regions_cache = null; HashSet tmpSet = new HashSet<>(); tmpSet.add(this); @@ -2409,7 +2414,7 @@ public class Plot { } } } - connected_cache = tmpSet; + this.connectedCache = tmpSet; return tmpSet; } @@ -2421,19 +2426,15 @@ public class Plot { * @return all regions within the plot */ public @NonNull Set getRegions() { - if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) { - return regions_cache; - } if (!this.isMerged()) { Location pos1 = this.getBottomAbs().withY(getArea().getMinBuildHeight()); Location pos2 = this.getTopAbs().withY(getArea().getMaxBuildHeight()); - connected_cache = Sets.newHashSet(this); + this.connectedCache = Sets.newHashSet(this); CuboidRegion rg = new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()); - regions_cache = Collections.singleton(rg); - return regions_cache; + return Collections.singleton(rg); } Set plots = this.getConnectedPlots(); - Set regions = regions_cache = new HashSet<>(); + Set regions = new HashSet<>(); Set visited = new HashSet<>(); for (Plot current : plots) { if (visited.contains(current.getId())) { diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java index 61658391f..cfab430b8 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java @@ -263,6 +263,7 @@ public final class PlotModificationManager { return; } Plot current = queue.poll(); + current.clearCache(); if (plot.getArea().getTerrain() != PlotAreaTerrainType.NONE) { try { PlotSquared.platform().regionManager().regenerateRegion( @@ -327,6 +328,7 @@ public final class PlotModificationManager { ArrayList ids = new ArrayList<>(plots.size()); for (Plot current : plots) { current.setHome(null); + current.clearCache(); ids.add(current.getId()); } this.plot.clearRatings(); @@ -478,8 +480,7 @@ public final class PlotModificationManager { this.plot.updateWorldBorder(); } } - Plot.connected_cache = null; - Plot.regions_cache = null; + this.plot.clearCache(); this.plot.getTrusted().clear(); this.plot.getMembers().clear(); this.plot.getDenied().clear(); @@ -630,6 +631,7 @@ public final class PlotModificationManager { if (queue.size() > 0) { queue.enqueue(); } + visited.forEach(Plot::clearCache); return toReturn; } diff --git a/Core/src/main/java/com/plotsquared/core/util/query/GlobalPlotProvider.java b/Core/src/main/java/com/plotsquared/core/util/query/GlobalPlotProvider.java index 2e635101e..e02994e63 100644 --- a/Core/src/main/java/com/plotsquared/core/util/query/GlobalPlotProvider.java +++ b/Core/src/main/java/com/plotsquared/core/util/query/GlobalPlotProvider.java @@ -23,9 +23,9 @@ import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.world.PlotAreaManager; import org.checkerframework.checker.nullness.qual.NonNull; +import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.List; class GlobalPlotProvider implements PlotProvider { @@ -37,7 +37,7 @@ class GlobalPlotProvider implements PlotProvider { @Override public Collection getPlots() { - final Set plots = new HashSet<>(); + final List plots = new ArrayList<>(); for (final PlotArea plotArea : this.plotAreaManager.getAllPlotAreas()) { plots.addAll(plotArea.getPlots()); } From 86919b88415cadb0dbb15bca257c1e183f9f1343 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 15 Jan 2023 10:28:43 +0100 Subject: [PATCH 05/32] Update dependency com.diffplug.spotless to v6.13.0 (#3929) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 16bd6bc7b..3fb14d96b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ http4j = "1.3" # Gradle plugins shadow = "7.1.2" grgit = "4.1.1" -spotless = "6.12.1" +spotless = "6.13.0" nexus = "1.1.0" [libraries] From 39d2f1a72c6f69c00319600ebc2c81feef7ecdf8 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 15 Jan 2023 13:08:59 +0000 Subject: [PATCH 06/32] chore: remove uses of deprecated Permissions class and add javadoc notes (#3930) - Closes #3907 --- .../bukkit/listener/BlockEventListener.java | 47 ++++------ .../bukkit/listener/EntityEventListener.java | 6 +- .../bukkit/listener/ForceFieldListener.java | 7 +- .../bukkit/listener/PaperListener.java | 8 +- .../bukkit/listener/PlayerEventListener.java | 93 +++++++++---------- .../listener/ProjectileEventListener.java | 15 ++- .../bukkit/player/BukkitOfflinePlayer.java | 5 + .../bukkit/util/BukkitEntityUtil.java | 21 ++--- .../com/plotsquared/core/command/Add.java | 18 ++-- .../com/plotsquared/core/command/Alias.java | 3 +- .../com/plotsquared/core/command/Area.java | 25 +++-- .../com/plotsquared/core/command/Auto.java | 9 +- .../com/plotsquared/core/command/Backup.java | 10 +- .../com/plotsquared/core/command/Caps.java | 4 +- .../com/plotsquared/core/command/Claim.java | 8 +- .../com/plotsquared/core/command/Clear.java | 10 +- .../com/plotsquared/core/command/Cluster.java | 84 ++++++++--------- .../com/plotsquared/core/command/Command.java | 3 +- .../plotsquared/core/command/Continue.java | 4 +- .../com/plotsquared/core/command/Copy.java | 4 +- .../com/plotsquared/core/command/Delete.java | 4 +- .../com/plotsquared/core/command/Deny.java | 9 +- .../com/plotsquared/core/command/Dislike.java | 5 +- .../com/plotsquared/core/command/Done.java | 4 +- .../plotsquared/core/command/Download.java | 15 ++- .../plotsquared/core/command/FlagCommand.java | 12 +-- .../com/plotsquared/core/command/Grant.java | 9 +- .../plotsquared/core/command/HomeCommand.java | 4 +- .../com/plotsquared/core/command/Inbox.java | 9 +- .../com/plotsquared/core/command/Info.java | 5 +- .../com/plotsquared/core/command/Kick.java | 9 +- .../com/plotsquared/core/command/Like.java | 8 +- .../com/plotsquared/core/command/ListCmd.java | 77 ++++++++------- .../com/plotsquared/core/command/Load.java | 4 +- .../plotsquared/core/command/MainCommand.java | 5 +- .../com/plotsquared/core/command/Merge.java | 23 +++-- .../com/plotsquared/core/command/Move.java | 7 +- .../com/plotsquared/core/command/Music.java | 4 +- .../com/plotsquared/core/command/Owner.java | 12 +-- .../com/plotsquared/core/command/Rate.java | 10 +- .../com/plotsquared/core/command/Remove.java | 4 +- .../com/plotsquared/core/command/Save.java | 4 +- .../core/command/SchematicCmd.java | 21 ++--- .../com/plotsquared/core/command/Set.java | 33 ++++--- .../plotsquared/core/command/SetCommand.java | 5 +- .../com/plotsquared/core/command/Swap.java | 4 +- .../plotsquared/core/command/Template.java | 7 +- .../com/plotsquared/core/command/Trust.java | 9 +- .../com/plotsquared/core/command/Unlink.java | 4 +- .../com/plotsquared/core/command/Visit.java | 14 ++- .../components/ComponentPresetManager.java | 8 +- .../core/listener/PlotListener.java | 19 ++-- .../core/listener/WESubscriber.java | 3 +- .../core/permissions/PermissionHolder.java | 47 ++++++++++ .../plotsquared/core/player/PlotPlayer.java | 17 +++- .../java/com/plotsquared/core/plot/Plot.java | 8 +- .../com/plotsquared/core/plot/PlotArea.java | 3 +- .../core/plot/comment/CommentInbox.java | 18 ++-- .../core/util/EventDispatcher.java | 49 +++++----- .../plotsquared/core/util/Permissions.java | 16 ++-- 60 files changed, 428 insertions(+), 484 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index dded70e62..343acce06 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -55,7 +55,6 @@ import com.plotsquared.core.plot.flag.implementations.VineGrowFlag; import com.plotsquared.core.plot.flag.types.BlockTypeWrapper; import com.plotsquared.core.plot.flag.types.BooleanFlag; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotFlagUtil; import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskTime; @@ -278,7 +277,7 @@ public class BlockEventListener implements Listener { return; } if (!plot.hasOwner()) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) @@ -295,7 +294,7 @@ public class BlockEventListener implements Listener { return; } } - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) @@ -306,7 +305,7 @@ public class BlockEventListener implements Listener { return; } } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { pp.sendMessage( TranslatableCaption.of("done.building_restricted") ); @@ -322,7 +321,7 @@ public class BlockEventListener implements Listener { + " did not fall because of disable-physics = true"); } } - } else if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) { + } else if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_ROAD)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD)) @@ -344,8 +343,7 @@ public class BlockEventListener implements Listener { BukkitPlayer plotPlayer = BukkitUtil.adapt(player); // == rather than <= as we only care about the "ground level" not being destroyed if (event.getBlock().getY() == area.getMinGenHeight()) { - if (!Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) @@ -358,8 +356,7 @@ public class BlockEventListener implements Listener { return; } if (!plot.hasOwner()) { - if (!Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED, true)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED, true)) { event.setCancelled(true); } return; @@ -373,8 +370,7 @@ public class BlockEventListener implements Listener { return; } } - if (Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { return; } plotPlayer.sendMessage( @@ -383,7 +379,7 @@ public class BlockEventListener implements Listener { ); event.setCancelled(true); } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { plotPlayer.sendMessage( TranslatableCaption.of("done.building_restricted") ); @@ -394,7 +390,7 @@ public class BlockEventListener implements Listener { return; } BukkitPlayer pp = BukkitUtil.adapt(player); - if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_ROAD)) { + if (pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_ROAD)) { return; } if (this.worldEdit != null && pp.getAttribute("worldedit")) { @@ -479,18 +475,18 @@ public class BlockEventListener implements Listener { BukkitPlayer plotPlayer = BukkitUtil.adapt(player); if (plot != null) { if (!plot.hasOwner()) { - if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) { return; } } else if (!plot.isAdded(plotPlayer.getUUID())) { - if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { return; } } else { return; } } else { - if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) { return; } if (this.worldEdit != null && plotPlayer.getAttribute("worldedit")) { @@ -635,8 +631,7 @@ public class BlockEventListener implements Listener { } if (!plot.hasOwner()) { BukkitPlayer plotPlayer = BukkitUtil.adapt(player); - if (Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) { return; } event.setCancelled(true); @@ -648,8 +643,7 @@ public class BlockEventListener implements Listener { Block block = event.getBlock(); if (destroy .contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType()))) - || Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { + || plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { return; } plot.debug(player.getName() + " could not break " + block.getType() @@ -660,7 +654,7 @@ public class BlockEventListener implements Listener { return; } BukkitPlayer plotPlayer = BukkitUtil.adapt(player); - if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_ROAD)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_ROAD)) { return; } event.setCancelled(true); @@ -1088,8 +1082,7 @@ public class BlockEventListener implements Listener { return; } if (plot == null) { - if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !Permissions.hasPermission( - pp, + if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !pp.hasPermission( Permission.PERMISSION_ADMIN_BUILD_ROAD )) { pp.sendMessage( @@ -1099,8 +1092,7 @@ public class BlockEventListener implements Listener { event.setCancelled(true); } } else if (!plot.hasOwner()) { - if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !Permissions.hasPermission( - pp, + if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !pp.hasPermission( Permission.PERMISSION_ADMIN_BUILD_UNOWNED )) { pp.sendMessage( @@ -1110,7 +1102,7 @@ public class BlockEventListener implements Listener { event.setCancelled(true); } } else if (!plot.isAdded(pp.getUUID())) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) @@ -1234,8 +1226,7 @@ public class BlockEventListener implements Listener { for (final BlockState state : event.getReplacedBlockStates()) { Location currentLocation = BukkitUtil.adapt(state.getLocation()); - if (!Permissions.hasPermission( - pp, + if (!pp.hasPermission( Permission.PERMISSION_ADMIN_BUILD_ROAD ) && !(Objects.equals(currentLocation.getPlot(), plot))) { pp.sendMessage( diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java index 3e32a9816..68f658a20 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java @@ -37,7 +37,6 @@ import com.plotsquared.core.plot.flag.implementations.ExplosionFlag; import com.plotsquared.core.plot.flag.implementations.InvincibleFlag; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotFlagUtil; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.block.BlockType; @@ -371,14 +370,13 @@ public class EntityEventListener implements Listener { if (shooter instanceof Player) { PlotPlayer pp = BukkitUtil.adapt((Player) shooter); if (plot == null) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { entity.remove(); event.setCancelled(true); } return; } - if (plot.isAdded(pp.getUUID()) || Permissions - .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { + if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { return; } entity.remove(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java index 8c4b5b9b6..d14a259b3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java @@ -25,7 +25,6 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.implementations.ForcefieldFlag; -import com.plotsquared.core.util.Permissions; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -109,8 +108,7 @@ public class ForceFieldListener { if (plot.isAdded(uuid)) { Set> players = getNearbyPlayers(player, plot); for (PlotPlayer oPlayer : players) { - if (!Permissions - .hasPermission(oPlayer, Permission.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) { + if (!oPlayer.hasPermission(Permission.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) { ((BukkitPlayer) oPlayer).player .setVelocity(calculateVelocity(plotPlayer, oPlayer)); } @@ -120,8 +118,7 @@ public class ForceFieldListener { if (oPlayer == null) { return; } - if (!Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) { player.setVelocity(calculateVelocity(oPlayer, plotPlayer)); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index 3ad3a6227..dee073885 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -43,7 +43,6 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag; import com.plotsquared.core.plot.flag.types.BooleanFlag; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotFlagUtil; import net.kyori.adventure.text.minimessage.Template; import org.bukkit.Chunk; @@ -335,8 +334,7 @@ public class PaperListener implements Listener { Plot plot = location.getOwnedPlot(); if (plot == null) { - if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !Permissions.hasPermission( - pp, + if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !pp.hasPermission( Permission.PERMISSION_ADMIN_PROJECTILE_ROAD )) { pp.sendMessage( @@ -347,7 +345,7 @@ public class PaperListener implements Listener { event.setCancelled(true); } } else if (!plot.hasOwner()) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) @@ -357,7 +355,7 @@ public class PaperListener implements Listener { } } else if (!plot.isAdded(pp.getUUID())) { if (!plot.getFlag(ProjectilesFlag.class)) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index fbe26e676..6602cb8be 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -67,7 +67,6 @@ import com.plotsquared.core.plot.flag.implementations.VillagerInteractFlag; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotFlagUtil; import com.plotsquared.core.util.PremiumVerification; import com.plotsquared.core.util.entity.EntityCategories; @@ -275,8 +274,10 @@ public class PlayerEventListener implements Listener { switch (parts[0]) { case "up": case "worldedit:up": - if (plot == null || (!plot.isAdded(plotPlayer.getUUID()) && !Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER, true))) { + if (plot == null || (!plot.isAdded(plotPlayer.getUUID()) && !plotPlayer.hasPermission( + Permission.PERMISSION_ADMIN_BUILD_OTHER, + true + ))) { event.setCancelled(true); return; } @@ -291,7 +292,7 @@ public class PlayerEventListener implements Listener { if (blockedCommands.isEmpty()) { return; } - if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) { return; } // When using namespaced commands, we're not interested in the namespace @@ -310,7 +311,7 @@ public class PlayerEventListener implements Listener { } else { perm = "plots.admin.command.blocked-cmds.road"; } - if (!Permissions.hasPermission(plotPlayer, perm)) { + if (!plotPlayer.hasPermission(perm)) { plotPlayer.sendMessage(TranslatableCaption.of("blockedcmds.command_blocked")); event.setCancelled(true); } @@ -600,7 +601,7 @@ public class PlayerEventListener implements Listener { int border = area.getBorder(); int x1; if (x2 > border && this.tmpTeleport) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { to.setX(border - 1); this.tmpTeleport = false; player.teleport(event.getTo()); @@ -610,7 +611,7 @@ public class PlayerEventListener implements Listener { pp.sendMessage(TranslatableCaption.of("border.bypass.exited")); } } else if (x2 < -border && this.tmpTeleport) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { to.setX(-border + 1); this.tmpTeleport = false; player.teleport(event.getTo()); @@ -620,7 +621,7 @@ public class PlayerEventListener implements Listener { pp.sendMessage(TranslatableCaption.of("border.bypass.exited")); } } else if (((x1 = MathMan.roundInt(from.getX())) >= border && x2 <= border) || (x1 <= -border && x2 >= -border)) { - if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { + if (pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { pp.sendMessage(TranslatableCaption.of("border.bypass.entered")); } } @@ -691,7 +692,7 @@ public class PlayerEventListener implements Listener { int border = area.getBorder(); int z1; if (z2 > border && this.tmpTeleport) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { to.setZ(border - 1); this.tmpTeleport = false; player.teleport(event.getTo()); @@ -701,7 +702,7 @@ public class PlayerEventListener implements Listener { pp.sendMessage(TranslatableCaption.of("border.bypass.exited")); } } else if (z2 < -border && this.tmpTeleport) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { to.setZ(-border + 1); this.tmpTeleport = false; player.teleport(event.getTo()); @@ -711,7 +712,7 @@ public class PlayerEventListener implements Listener { pp.sendMessage(TranslatableCaption.of("border.bypass.exited")); } } else if (((z1 = MathMan.roundInt(from.getZ())) >= border && z2 <= border) || (z1 <= -border && z2 >= -border)) { - if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { + if (pp.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { pp.sendMessage(TranslatableCaption.of("border.bypass.entered")); } } @@ -738,8 +739,7 @@ public class PlayerEventListener implements Listener { || area.isForcingPlotChat())) { return; } - if (plot.isDenied(plotPlayer.getUUID()) && !Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_CHAT_BYPASS)) { + if (plot.isDenied(plotPlayer.getUUID()) && !plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_CHAT_BYPASS)) { return; } event.setCancelled(true); @@ -824,7 +824,7 @@ public class PlayerEventListener implements Listener { plotListener.plotExit(pp, plot); } if (this.worldEdit != null) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_WORLDEDIT_BYPASS)) { + if (!pp.hasPermission(Permission.PERMISSION_WORLDEDIT_BYPASS)) { if (pp.getAttribute("worldedit")) { pp.removeAttribute("worldedit"); } @@ -880,8 +880,7 @@ public class PlayerEventListener implements Listener { final Plot plot = pp.getCurrentPlot(); if (plot != null) { if (plot.getFlag(PreventCreativeCopyFlag.class) && !plot - .isAdded(player.getUniqueId()) && !Permissions - .hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { + .isAdded(player.getUniqueId()) && !pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { final ItemStack newStack = new ItemStack(newItem.getType(), newItem.getAmount()); event.setCursor(newStack); @@ -943,7 +942,7 @@ public class PlayerEventListener implements Listener { Plot plot = area.getPlotAbs(location); boolean cancelled = false; if (plot == null) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) @@ -951,7 +950,7 @@ public class PlayerEventListener implements Listener { cancelled = true; } } else if (!plot.hasOwner()) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) @@ -961,7 +960,7 @@ public class PlayerEventListener implements Listener { } else { UUID uuid = pp.getUUID(); if (!plot.isAdded(uuid)) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) @@ -998,8 +997,7 @@ public class PlayerEventListener implements Listener { Plot plot = location.getPlotAbs(); BukkitPlayer pp = BukkitUtil.adapt(e.getPlayer()); if (plot == null) { - if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, MiscInteractFlag.class, true) && !Permissions.hasPermission( - pp, + if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, MiscInteractFlag.class, true) && !pp.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_ROAD )) { pp.sendMessage( @@ -1010,14 +1008,14 @@ public class PlayerEventListener implements Listener { } } else { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { pp.sendMessage(TranslatableCaption.of("done.building_restricted")); e.setCancelled(true); return; } } if (!plot.hasOwner()) { - if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { + if (!pp.hasPermission("plots.admin.interact.unowned")) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) @@ -1032,7 +1030,7 @@ public class PlayerEventListener implements Listener { if (plot.getFlag(MiscInteractFlag.class)) { return; } - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) @@ -1257,7 +1255,7 @@ public class PlayerEventListener implements Listener { BukkitPlayer pp = BukkitUtil.adapt(event.getPlayer()); Plot plot = area.getPlot(location); if (plot == null) { - if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) { + if (pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_ROAD)) { return; } pp.sendMessage( @@ -1266,7 +1264,7 @@ public class PlayerEventListener implements Listener { ); event.setCancelled(true); } else if (!plot.hasOwner()) { - if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { + if (pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { return; } pp.sendMessage( @@ -1275,7 +1273,7 @@ public class PlayerEventListener implements Listener { ); event.setCancelled(true); } else if (!plot.isAdded(pp.getUUID())) { - if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { return; } pp.sendMessage( @@ -1284,7 +1282,7 @@ public class PlayerEventListener implements Listener { ); event.setCancelled(true); } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { pp.sendMessage( TranslatableCaption.of("done.building_restricted") ); @@ -1322,7 +1320,7 @@ public class PlayerEventListener implements Listener { BukkitPlayer plotPlayer = BukkitUtil.adapt(player); Plot plot = area.getPlot(location); if (plot == null) { - if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_ROAD)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_ROAD)) { return; } plotPlayer.sendMessage( @@ -1331,7 +1329,7 @@ public class PlayerEventListener implements Listener { ); event.setCancelled(true); } else if (!plot.hasOwner()) { - if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { return; } plotPlayer.sendMessage( @@ -1340,7 +1338,7 @@ public class PlayerEventListener implements Listener { ); event.setCancelled(true); } else if (!plot.isAdded(plotPlayer.getUUID())) { - if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { return; } plotPlayer.sendMessage( @@ -1349,7 +1347,7 @@ public class PlayerEventListener implements Listener { ); event.setCancelled(true); } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { plotPlayer.sendMessage( TranslatableCaption.of("done.building_restricted") ); @@ -1374,7 +1372,7 @@ public class PlayerEventListener implements Listener { BukkitPlayer pp = BukkitUtil.adapt(p); Plot plot = area.getPlot(location); if (plot == null) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_ROAD)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD)) @@ -1383,7 +1381,7 @@ public class PlayerEventListener implements Listener { } } else { if (!plot.hasOwner()) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) @@ -1394,7 +1392,7 @@ public class PlayerEventListener implements Listener { } if (!plot.isAdded(pp.getUUID())) { if (!plot.getFlag(HangingPlaceFlag.class)) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) @@ -1423,7 +1421,7 @@ public class PlayerEventListener implements Listener { BukkitPlayer pp = BukkitUtil.adapt(p); Plot plot = area.getPlot(location); if (plot == null) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_ROAD)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_ROAD)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD)) @@ -1431,7 +1429,7 @@ public class PlayerEventListener implements Listener { event.setCancelled(true); } } else if (!plot.hasOwner()) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) @@ -1442,7 +1440,7 @@ public class PlayerEventListener implements Listener { if (plot.getFlag(HangingBreakFlag.class)) { return; } - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) @@ -1463,8 +1461,7 @@ public class PlayerEventListener implements Listener { Plot plot = area.getPlot(BukkitUtil.adapt(event.getEntity().getLocation())); if (plot != null) { if (!plot.hasOwner()) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) { + if (!player.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) { player.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) @@ -1473,8 +1470,7 @@ public class PlayerEventListener implements Listener { } } else if (!plot.isAdded(player.getUUID())) { if (!plot.getFlag(HangingBreakFlag.class)) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { + if (!player.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) @@ -1506,7 +1502,7 @@ public class PlayerEventListener implements Listener { BukkitPlayer pp = BukkitUtil.adapt(p); Plot plot = area.getPlot(location); if (plot == null && !area.isRoadFlags()) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) @@ -1514,7 +1510,7 @@ public class PlayerEventListener implements Listener { event.setCancelled(true); } } else if (plot != null && !plot.hasOwner()) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) @@ -1572,7 +1568,7 @@ public class PlayerEventListener implements Listener { return; } - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) @@ -1594,8 +1590,7 @@ public class PlayerEventListener implements Listener { BukkitPlayer pp = BukkitUtil.adapt(p); Plot plot = area.getPlot(location); if (plot == null) { - if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, VehicleBreakFlag.class, true) && !Permissions.hasPermission( - pp, + if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, VehicleBreakFlag.class, true) && !pp.hasPermission( Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD )) { pp.sendMessage( @@ -1606,7 +1601,7 @@ public class PlayerEventListener implements Listener { } } else { if (!plot.hasOwner()) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED)) @@ -1620,7 +1615,7 @@ public class PlayerEventListener implements Listener { if (plot.getFlag(VehicleBreakFlag.class)) { return; } - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER)) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java index 2703c8cd9..32773d0ba 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java @@ -30,7 +30,6 @@ import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotHandler; import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotFlagUtil; import net.kyori.adventure.text.minimessage.Template; import org.bukkit.entity.Entity; @@ -106,8 +105,7 @@ public class ProjectileEventListener implements Listener { Plot plot = location.getOwnedPlot(); if (plot == null) { - if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !Permissions.hasPermission( - pp, + if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !pp.hasPermission( Permission.PERMISSION_ADMIN_PROJECTILE_ROAD )) { pp.sendMessage( @@ -118,7 +116,7 @@ public class ProjectileEventListener implements Listener { event.setCancelled(true); } } else if (!plot.hasOwner()) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) @@ -128,7 +126,7 @@ public class ProjectileEventListener implements Listener { } } else if (!plot.isAdded(pp.getUUID())) { if (!plot.getFlag(ProjectilesFlag.class)) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { + if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { pp.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) @@ -170,8 +168,7 @@ public class ProjectileEventListener implements Listener { PlotPlayer pp = BukkitUtil.adapt((Player) shooter); if (plot == null) { - if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !Permissions.hasPermission( - pp, + if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !pp.hasPermission( Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED )) { entity.remove(); @@ -179,8 +176,8 @@ public class ProjectileEventListener implements Listener { } return; } - if (plot.isAdded(pp.getUUID()) || Permissions - .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(ProjectilesFlag.class)) { + if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag( + ProjectilesFlag.class)) { return; } entity.remove(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java index 8d04b444e..928cbca7d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java @@ -87,4 +87,9 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer { ); } + @Override + public boolean hasPermission(@NonNull final String permission, final boolean notify) { + return hasPermission(permission); + } + } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java index 2661186a4..9c5e29b14 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java @@ -40,7 +40,6 @@ import com.plotsquared.core.plot.flag.implementations.PvpFlag; import com.plotsquared.core.plot.flag.implementations.TamedAttackFlag; import com.plotsquared.core.plot.flag.implementations.VehicleCapFlag; import com.plotsquared.core.util.EntityUtil; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.entity.EntityCategories; import com.sk89q.worldedit.bukkit.BukkitAdapter; import net.kyori.adventure.text.minimessage.Template; @@ -168,8 +167,7 @@ public class BukkitEntityUtil { if (plot != null && (plot.getFlag(HangingBreakFlag.class) || plot .isAdded(plotPlayer.getUUID()))) { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { - if (!Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_BUILD_OTHER)) { plotPlayer.sendMessage( TranslatableCaption.of("done.building_restricted") ); @@ -178,7 +176,7 @@ public class BukkitEntityUtil { } return true; } - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub) @@ -190,7 +188,7 @@ public class BukkitEntityUtil { .isAdded(plotPlayer.getUUID()))) { return true; } - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub) @@ -211,7 +209,7 @@ public class BukkitEntityUtil { .getFlag(PveFlag.class))) { return true; } - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVE + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) @@ -232,7 +230,7 @@ public class BukkitEntityUtil { .getFlag(PveFlag.class))) { return true; } - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVE + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) @@ -245,8 +243,7 @@ public class BukkitEntityUtil { } } else if (EntityCategories.PLAYER.contains(entityType)) { if (isPlot) { - if (!plot.getFlag(PvpFlag.class) && !Permissions - .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) { + if (!plot.getFlag(PvpFlag.class) && !plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVP + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub) @@ -260,7 +257,7 @@ public class BukkitEntityUtil { } else if (roadFlags && area.getRoadFlag(PvpFlag.class)) { return true; } - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVP + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub) @@ -277,7 +274,7 @@ public class BukkitEntityUtil { .getFlag(PveFlag.class))) { return true; } - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVE + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) @@ -299,7 +296,7 @@ public class BukkitEntityUtil { } else if (roadFlags && area.getRoadFlag(PveFlag.class)) { return true; } - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { + if (!plotPlayer.hasPermission(Permission.PERMISSION_ADMIN_PVE + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) diff --git a/Core/src/main/java/com/plotsquared/core/command/Add.java b/Core/src/main/java/com/plotsquared/core/command/Add.java index a457b6c50..04d36f285 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Add.java +++ b/Core/src/main/java/com/plotsquared/core/command/Add.java @@ -26,7 +26,6 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.task.RunnableVal2; @@ -58,18 +57,20 @@ public class Add extends Command { @Override public CompletableFuture execute( - final PlotPlayer player, String[] args, + final PlotPlayer player, + String[] args, RunnableVal3 confirm, RunnableVal2 whenDone ) throws CommandException { final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned")); checkTrue( - plot.isOwner(player.getUUID()) || Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST), + plot.isOwner(player.getUUID()) || player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_TRUST), TranslatableCaption.of("permission.no_plot_perms") ); - checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"), + checkTrue( + args.length == 1, + TranslatableCaption.of("commandconfig.command_syntax"), Template.of("value", "/plot add ") ); final CompletableFuture future = new CompletableFuture<>(); @@ -94,9 +95,8 @@ public class Add extends Command { int size = plot.getTrusted().size() + plot.getMembers().size(); while (iterator.hasNext()) { UUID uuid = iterator.next(); - if (uuid == DBFunc.EVERYONE && !( - Permissions.hasPermission(player, Permission.PERMISSION_TRUST_EVERYONE) || Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) { + if (uuid == DBFunc.EVERYONE && !(player.hasPermission(Permission.PERMISSION_TRUST_EVERYONE) || player.hasPermission( + Permission.PERMISSION_ADMIN_COMMAND_TRUST))) { player.sendMessage( TranslatableCaption.of("errors.invalid_player"), Template.of("value", PlayerManager.resolveName(uuid).getComponent(player)) @@ -124,7 +124,7 @@ public class Add extends Command { } checkTrue(!uuids.isEmpty(), null); int localAddSize = plot.getMembers().size(); - int maxAddSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_ADD, Settings.Limit.MAX_PLOTS); + int maxAddSize = player.hasPermissionRange(Permission.PERMISSION_ADD, Settings.Limit.MAX_PLOTS); if (localAddSize >= maxAddSize) { player.sendMessage( TranslatableCaption.of("members.plot_max_members_added"), diff --git a/Core/src/main/java/com/plotsquared/core/command/Alias.java b/Core/src/main/java/com/plotsquared/core/command/Alias.java index 9063ede69..11439a6e8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Alias.java +++ b/Core/src/main/java/com/plotsquared/core/command/Alias.java @@ -26,7 +26,6 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.query.PlotQuery; import net.kyori.adventure.text.minimessage.Template; @@ -194,7 +193,7 @@ public class Alias extends SubCommand { } private boolean isPermitted(PlotPlayer player, Permission permission) { - return Permissions.hasPermission(player, permission); + return player.hasPermission(permission); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Area.java b/Core/src/main/java/com/plotsquared/core/command/Area.java index 4931d2cac..093ca744d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Area.java +++ b/Core/src/main/java/com/plotsquared/core/command/Area.java @@ -48,7 +48,6 @@ import com.plotsquared.core.queue.QueueCoordinator; import com.plotsquared.core.setup.PlotAreaBuilder; import com.plotsquared.core.util.FileUtils; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.RegionUtil; import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SetupUtils; @@ -138,7 +137,7 @@ public class Area extends SubCommand { player.sendMessage(RequiredType.CONSOLE.getErrorMessage()); return false; } - if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) { + if (!player.hasPermission(Permission.PERMISSION_AREA_CREATE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_AREA_CREATE)) @@ -288,7 +287,7 @@ public class Area extends SubCommand { return true; } case "c", "setup", "create" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) { + if (!player.hasPermission(Permission.PERMISSION_AREA_CREATE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_AREA_CREATE)) @@ -575,7 +574,7 @@ public class Area extends SubCommand { return true; } case "i", "info" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO)) { + if (!player.hasPermission(Permission.PERMISSION_AREA_INFO)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_AREA_INFO)) @@ -653,7 +652,7 @@ public class Area extends SubCommand { return true; } case "l", "list" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_LIST)) { + if (!player.hasPermission(Permission.PERMISSION_AREA_LIST)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_AREA_LIST)) @@ -736,7 +735,7 @@ public class Area extends SubCommand { return true; } case "regen", "clear", "reset", "regenerate" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_REGEN)) { + if (!player.hasPermission(Permission.PERMISSION_AREA_REGEN)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_AREA_REGEN)) @@ -769,7 +768,7 @@ public class Area extends SubCommand { return true; } case "goto", "v", "teleport", "visit", "tp" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_TP)) { + if (!player.hasPermission(Permission.PERMISSION_AREA_TP)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_AREA_TP)) @@ -825,19 +824,19 @@ public class Area extends SubCommand { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) { + if (player.hasPermission(Permission.PERMISSION_AREA_CREATE)) { completions.add("create"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) { + if (player.hasPermission(Permission.PERMISSION_AREA_CREATE)) { completions.add("single"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_LIST)) { + if (player.hasPermission(Permission.PERMISSION_AREA_LIST)) { completions.add("list"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO)) { + if (player.hasPermission(Permission.PERMISSION_AREA_INFO)) { completions.add("info"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_TP)) { + if (player.hasPermission(Permission.PERMISSION_AREA_TP)) { completions.add("tp"); } final List commands = completions.stream().filter(completion -> completion @@ -852,7 +851,7 @@ public class Area extends SubCommand { CommandCategory.ADMINISTRATION ) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_AREA) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_AREA) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/Auto.java b/Core/src/main/java/com/plotsquared/core/command/Auto.java index 60ed4bfea..1f78c6af3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -38,7 +38,6 @@ import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.services.plots.AutoService; import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.task.AutoClaimFinishTask; import com.plotsquared.core.util.task.RunnableVal; @@ -246,7 +245,7 @@ public class Auto extends SubCommand { sizeX = event.getSizeX(); sizeZ = event.getSizeZ(); schematic = event.getSchematic(); - if (!force && mega && !Permissions.hasPermission(player, Permission.PERMISSION_AUTO_MEGA)) { + if (!force && mega && !player.hasPermission(Permission.PERMISSION_AUTO_MEGA)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_AUTO_MEGA)) @@ -279,11 +278,9 @@ public class Auto extends SubCommand { ); return true; } - if (!force && !Permissions.hasPermission( - player, + if (!force && !player.hasPermission( Permission.PERMISSION_CLAIM_SCHEMATIC.format(schematic) - ) && !Permissions - .hasPermission(player, "plots.admin.command.schematic")) { + ) && !player.hasPermission("plots.admin.command.schematic")) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", "plots.claim.%s0") diff --git a/Core/src/main/java/com/plotsquared/core/command/Backup.java b/Core/src/main/java/com/plotsquared/core/command/Backup.java index adb832c61..a0030ab1a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Backup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java @@ -27,7 +27,6 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal3; import net.kyori.adventure.text.minimessage.Template; @@ -144,8 +143,7 @@ public final class Backup extends Command { TranslatableCaption.of("backups.backup_impossible"), Template.of("plot", TranslatableCaption.of("generic.generic_merged").getComponent(player)) ); - } else if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { + } else if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER)) @@ -198,8 +196,7 @@ public final class Backup extends Command { ); } else if (plot.getVolume() > Integer.MAX_VALUE) { player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); - } else if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { + } else if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER)) @@ -269,8 +266,7 @@ public final class Backup extends Command { ); } else if (plot.getVolume() > Integer.MAX_VALUE) { player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); - } else if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { + } else if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER)) diff --git a/Core/src/main/java/com/plotsquared/core/command/Caps.java b/Core/src/main/java/com/plotsquared/core/command/Caps.java index da99bcfb2..4093ce77e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Caps.java +++ b/Core/src/main/java/com/plotsquared/core/command/Caps.java @@ -29,7 +29,6 @@ import com.plotsquared.core.plot.flag.implementations.HostileCapFlag; import com.plotsquared.core.plot.flag.implementations.MiscCapFlag; import com.plotsquared.core.plot.flag.implementations.MobCapFlag; import com.plotsquared.core.plot.flag.implementations.VehicleCapFlag; -import com.plotsquared.core.util.Permissions; import net.kyori.adventure.text.minimessage.Template; import static com.plotsquared.core.util.entity.EntityCategories.CAP_ANIMAL; @@ -51,8 +50,7 @@ public class Caps extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } - if (!plot.isAdded(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_CAPS_OTHER)) { + if (!plot.isAdded(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_CAPS_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_CAPS_OTHER)) diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java index 821ade23d..0f17c7fbb 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -35,7 +35,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.task.TaskManager; import net.kyori.adventure.text.minimessage.Template; @@ -127,9 +126,8 @@ public class Claim extends SubCommand { Template.of("reason", "non-existent") ); } - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLAIM_SCHEMATIC - .format(schematic)) && !Permissions.hasPermission( - player, + if (!player.hasPermission(Permission.PERMISSION_CLAIM_SCHEMATIC + .format(schematic)) && !player.hasPermission( "plots.admin.command.schematic" ) && !force) { player.sendMessage( @@ -176,7 +174,7 @@ public class Claim extends SubCommand { ); } } - if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { + if (!player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_BORDER)) { int border = area.getBorder(); if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) { player.sendMessage(TranslatableCaption.of("border.denied")); diff --git a/Core/src/main/java/com/plotsquared/core/command/Clear.java b/Core/src/main/java/com/plotsquared/core/command/Clear.java index a8d50e223..83a612951 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Clear.java +++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java @@ -32,7 +32,6 @@ import com.plotsquared.core.plot.flag.implementations.AnalysisFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.TaskManager; @@ -89,13 +88,14 @@ public class Clear extends Command { } boolean force = eventResult == Result.FORCE; checkTrue( - force || plot.isOwner(player.getUUID()) || Permissions - .hasPermission(player, "plots.admin.command.clear"), + force || plot.isOwner(player.getUUID()) || player.hasPermission("plots.admin.command.clear"), TranslatableCaption.of("permission.no_plot_perms") ); checkTrue(plot.getRunning() == 0, TranslatableCaption.of("errors.wait_for_timer")); - checkTrue(force || !Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions - .hasPermission(player, "plots.continue"), TranslatableCaption.of("done.done_already_done")); + checkTrue( + force || !Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || player.hasPermission("plots.continue"), + TranslatableCaption.of("done.done_already_done") + ); confirm.run(this, () -> { if (Settings.Teleport.ON_CLEAR) { plot.getPlayersInPlot().forEach(playerInPlot -> plot.teleportPlayer(playerInPlot, TeleportCause.COMMAND_CLEAR, diff --git a/Core/src/main/java/com/plotsquared/core/command/Cluster.java b/Core/src/main/java/com/plotsquared/core/command/Cluster.java index 74d38407d..2821803a4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Cluster.java +++ b/Core/src/main/java/com/plotsquared/core/command/Cluster.java @@ -32,7 +32,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotCluster; import com.plotsquared.core.plot.PlotId; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.query.PlotQuery; import net.kyori.adventure.text.minimessage.Template; @@ -73,7 +72,7 @@ public class Cluster extends SubCommand { switch (sub) { case "l": case "list": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_LIST)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_LIST)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_LIST)) @@ -126,7 +125,7 @@ public class Cluster extends SubCommand { } case "c": case "create": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_CREATE)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_CREATE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_CREATE)) @@ -197,8 +196,7 @@ public class Cluster extends SubCommand { } Set plots = area.getPlotSelectionOwned(pos1, pos2); if (!plots.isEmpty()) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_CLUSTER_CREATE_OTHER)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_CREATE_OTHER)) { UUID uuid = player.getUUID(); for (Plot plot : plots) { if (!plot.isOwner(uuid)) { @@ -219,10 +217,10 @@ public class Cluster extends SubCommand { } else { current = player.getPlayerClusterCount(player.getLocation().getWorldName()); } - int allowed = Permissions - .hasPermissionRange(player, Permission.PERMISSION_CLUSTER_SIZE, - Settings.Limit.MAX_PLOTS - ); + int allowed = player.hasPermissionRange( + Permission.PERMISSION_CLUSTER_SIZE, + Settings.Limit.MAX_PLOTS + ); if (current + cluster.getArea() > allowed) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), @@ -252,7 +250,7 @@ public class Cluster extends SubCommand { case "disband": case "del": case "delete": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_DELETE)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_DELETE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE)) @@ -289,8 +287,7 @@ public class Cluster extends SubCommand { } } if (!cluster.owner.equals(player.getUUID())) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_CLUSTER_DELETE_OTHER)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_DELETE_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE_OTHER)) @@ -307,7 +304,7 @@ public class Cluster extends SubCommand { } case "res": case "resize": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_RESIZE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE)) @@ -347,8 +344,7 @@ public class Cluster extends SubCommand { return false; } if (!cluster.hasHelperRights(player.getUUID())) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_OTHER)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_RESIZE_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_OTHER)) @@ -373,8 +369,7 @@ public class Cluster extends SubCommand { removed.removeAll(newPlots); // Check expand / shrink if (!removed.isEmpty()) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_SHRINK)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_RESIZE_SHRINK)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_SHRINK)) @@ -384,8 +379,7 @@ public class Cluster extends SubCommand { } newPlots.removeAll(existing); if (!newPlots.isEmpty()) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_EXPAND)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_RESIZE_EXPAND)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_EXPAND)) @@ -401,7 +395,8 @@ public class Cluster extends SubCommand { current = player.getPlayerClusterCount(player.getLocation().getWorldName()); } current -= cluster.getArea() + (1 + pos2.getX() - pos1.getX()) * (1 + pos2.getY() - pos1.getY()); - int allowed = Permissions.hasPermissionRange(player, Permission.PERMISSION_CLUSTER, + int allowed = player.hasPermissionRange( + Permission.PERMISSION_CLUSTER, Settings.Limit.MAX_PLOTS ); if (current + cluster.getArea() > allowed) { @@ -419,7 +414,7 @@ public class Cluster extends SubCommand { case "add": case "inv": case "invite": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INVITE)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_INVITE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_INVITE)) @@ -444,8 +439,7 @@ public class Cluster extends SubCommand { return false; } if (!cluster.hasHelperRights(player.getUUID())) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_CLUSTER_INVITE_OTHER)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_INVITE_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_INVITE_OTHER.toString()) @@ -485,7 +479,7 @@ public class Cluster extends SubCommand { case "k": case "remove": case "kick": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_KICK)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_KICK)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_KICK.toString()) @@ -509,8 +503,7 @@ public class Cluster extends SubCommand { return false; } if (!cluster.hasHelperRights(player.getUUID())) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_CLUSTER_KICK_OTHER)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_KICK_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_KICK_OTHER.toString()) @@ -561,7 +554,7 @@ public class Cluster extends SubCommand { } case "quit": case "leave": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_LEAVE)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_LEAVE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_LEAVE.toString()) @@ -619,7 +612,7 @@ public class Cluster extends SubCommand { return true; } case "members": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_HELPERS)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_HELPERS)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_HELPERS.toString()) @@ -674,7 +667,7 @@ public class Cluster extends SubCommand { case "spawn": case "home": case "tp": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_TP)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_TP)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_TP.toString()) @@ -703,7 +696,7 @@ public class Cluster extends SubCommand { } UUID uuid = player.getUUID(); if (!cluster.isAdded(uuid)) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_TP_OTHER)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_TP_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_TP_OTHER.toString()) @@ -719,7 +712,7 @@ public class Cluster extends SubCommand { case "info": case "show": case "information": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INFO)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_INFO)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_TP.toString()) @@ -792,7 +785,7 @@ public class Cluster extends SubCommand { case "sh": case "setspawn": case "sethome": { - if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_SETHOME)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_SETHOME)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_SETHOME.toString()) @@ -816,8 +809,7 @@ public class Cluster extends SubCommand { return false; } if (!cluster.hasHelperRights(player.getUUID())) { - if (!Permissions - .hasPermission(player, Permission.PERMISSION_CLUSTER_SETHOME_OTHER)) { + if (!player.hasPermission(Permission.PERMISSION_CLUSTER_SETHOME_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_CLUSTER_SETHOME_OTHER.toString()) @@ -869,37 +861,37 @@ public class Cluster extends SubCommand { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_LIST)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_LIST)) { completions.add("list"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_CREATE)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_CREATE)) { completions.add("create"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_DELETE)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_DELETE)) { completions.add("delete"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_RESIZE)) { completions.add("resize"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INVITE)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_INVITE)) { completions.add("invite"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_KICK)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_KICK)) { completions.add("kick"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_KICK)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_KICK)) { completions.add("leave"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_HELPERS)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_HELPERS)) { completions.add("members"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INFO)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_INFO)) { completions.add("info"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_TP)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_TP)) { completions.add("tp"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_SETHOME)) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER_SETHOME)) { completions.add("sethome"); } final List commands = completions.stream().filter(completion -> completion @@ -914,7 +906,7 @@ public class Cluster extends SubCommand { CommandCategory.ADMINISTRATION ) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_CLUSTER) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/Command.java b/Core/src/main/java/com/plotsquared/core/command/Command.java index c3cd5ce36..7e7e090db 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Command.java +++ b/Core/src/main/java/com/plotsquared/core/command/Command.java @@ -25,7 +25,6 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.permissions.PermissionHolder; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.StringComparison; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.task.RunnableVal2; @@ -466,7 +465,7 @@ public abstract class Command { if (message) { player.sendMessage(this.required.getErrorMessage()); } - } else if (!Permissions.hasPermission(player, getPermission())) { + } else if (!player.hasPermission(getPermission())) { if (message) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), diff --git a/Core/src/main/java/com/plotsquared/core/command/Continue.java b/Core/src/main/java/com/plotsquared/core/command/Continue.java index 9db740575..5d064c7a8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Continue.java +++ b/Core/src/main/java/com/plotsquared/core/command/Continue.java @@ -29,7 +29,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import net.kyori.adventure.text.minimessage.Template; import org.checkerframework.checker.nullness.qual.NonNull; @@ -53,8 +52,7 @@ public class Continue extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } - if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_CONTINUE)) { + if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_CONTINUE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", TranslatableCaption.of("permission.no_plot_perms").getComponent(player)) diff --git a/Core/src/main/java/com/plotsquared/core/command/Copy.java b/Core/src/main/java/com/plotsquared/core/command/Copy.java index 82afe0457..41870eb37 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Copy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Copy.java @@ -23,7 +23,6 @@ import com.plotsquared.core.location.Location; import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; -import com.plotsquared.core.util.Permissions; import net.kyori.adventure.text.minimessage.Template; @CommandDeclaration(command = "copy", @@ -42,8 +41,7 @@ public class Copy extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } - if (!plot1.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN.toString())) { + if (!plot1.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN.toString())) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Delete.java b/Core/src/main/java/com/plotsquared/core/command/Delete.java index ba323673f..36ec56e31 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Delete.java +++ b/Core/src/main/java/com/plotsquared/core/command/Delete.java @@ -30,7 +30,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.task.TaskManager; import net.kyori.adventure.text.minimessage.Template; @@ -83,8 +82,7 @@ public class Delete extends SubCommand { return true; } boolean force = eventResult == Result.FORCE; - if (!force && !plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DELETE)) { + if (!force && !plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_DELETE)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Deny.java b/Core/src/main/java/com/plotsquared/core/command/Deny.java index 70cdb6e2d..585f25314 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Deny.java +++ b/Core/src/main/java/com/plotsquared/core/command/Deny.java @@ -30,7 +30,6 @@ import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.WorldUtil; @@ -79,13 +78,12 @@ public class Deny extends SubCommand { player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } - if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DENY)) { + if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_DENY)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return true; } - int maxDenySize = Permissions.hasPermissionRange(player, Permission.PERMISSION_DENY, Settings.Limit.MAX_PLOTS); + int maxDenySize = player.hasPermissionRange(Permission.PERMISSION_DENY, Settings.Limit.MAX_PLOTS); int size = plot.getDenied().size(); if (size >= maxDenySize) { player.sendMessage( @@ -106,8 +104,7 @@ public class Deny extends SubCommand { } else { for (UUID uuid : uuids) { if (uuid == DBFunc.EVERYONE && !( - Permissions.hasPermission(player, Permission.PERMISSION_DENY_EVERYONE) || Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DENY))) { + player.hasPermission(Permission.PERMISSION_DENY_EVERYONE) || player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_DENY))) { player.sendMessage( TranslatableCaption.of("errors.invalid_player"), Template.of("value", args[0]) diff --git a/Core/src/main/java/com/plotsquared/core/command/Dislike.java b/Core/src/main/java/com/plotsquared/core/command/Dislike.java index d11afa828..e2cd89e8f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Dislike.java +++ b/Core/src/main/java/com/plotsquared/core/command/Dislike.java @@ -21,7 +21,6 @@ package com.plotsquared.core.command; import com.google.inject.Inject; import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.TabCompletions; import org.checkerframework.checker.nullness.qual.NonNull; @@ -54,7 +53,7 @@ public class Dislike extends SubCommand { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS)) { + if (player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS)) { completions.add("purge"); } final List commands = completions.stream().filter(completion -> completion @@ -62,7 +61,7 @@ public class Dislike extends SubCommand { .startsWith(args[0].toLowerCase())) .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_RATE) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/Done.java b/Core/src/main/java/com/plotsquared/core/command/Done.java index c50bdfce9..68c90b948 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Done.java +++ b/Core/src/main/java/com/plotsquared/core/command/Done.java @@ -34,7 +34,6 @@ import com.plotsquared.core.plot.expiration.PlotAnalysis; import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.RunnableVal; import net.kyori.adventure.text.minimessage.Template; import org.checkerframework.checker.nullness.qual.NonNull; @@ -75,8 +74,7 @@ public class Done extends SubCommand { return true; } boolean force = event.getEventResult() == Result.FORCE; - if (!force && !plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DONE)) { + if (!force && !plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_DONE)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Download.java b/Core/src/main/java/com/plotsquared/core/command/Download.java index 15cf82851..9f3d2112b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Download.java +++ b/Core/src/main/java/com/plotsquared/core/command/Download.java @@ -27,7 +27,6 @@ import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotUploader; import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.StringMan; @@ -87,13 +86,11 @@ public class Download extends SubCommand { player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } - if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && !DoneFlag.isDone(plot)) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) { + if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && !DoneFlag.isDone(plot)) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) { player.sendMessage(TranslatableCaption.of("done.done_not_done")); return false; } - if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN.toString())) { + if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN.toString())) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } @@ -111,7 +108,7 @@ public class Download extends SubCommand { upload(player, plot); } else if (args.length == 1 && StringMan .isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_DOWNLOAD_WORLD)) { + if (!player.hasPermission(Permission.PERMISSION_DOWNLOAD_WORLD)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_DOWNLOAD_WORLD.toString()) @@ -147,10 +144,10 @@ public class Download extends SubCommand { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_DOWNLOAD)) { + if (player.hasPermission(Permission.PERMISSION_DOWNLOAD)) { completions.add("schem"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_DOWNLOAD_WORLD)) { + if (player.hasPermission(Permission.PERMISSION_DOWNLOAD_WORLD)) { completions.add("world"); } final List commands = completions.stream().filter(completion -> completion @@ -165,7 +162,7 @@ public class Download extends SubCommand { CommandCategory.ADMINISTRATION ) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_DOWNLOAD) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_DOWNLOAD) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java index 16d28c38a..fd14d650c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java @@ -40,7 +40,6 @@ import com.plotsquared.core.plot.flag.types.IntegerFlag; import com.plotsquared.core.plot.flag.types.ListFlag; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.StringComparison; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.helpmenu.HelpMenu; @@ -128,7 +127,7 @@ public final class FlagCommand extends Command { key.toLowerCase(), entry.toString().toLowerCase() ); - final boolean result = Permissions.hasPermission(player, permission); + final boolean result = player.hasPermission(permission); if (!result) { player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", permission)); return false; @@ -150,9 +149,9 @@ public final class FlagCommand extends Command { boolean result; String basePerm = Permission.PERMISSION_SET_FLAG_KEY.format(key.toLowerCase()); if (flag.isValuedPermission()) { - result = Permissions.hasKeyedPermission(player, basePerm, value); + result = player.hasKeyedPermission(basePerm, value); } else { - result = Permissions.hasPermission(player, basePerm); + result = player.hasPermission(basePerm); perm = basePerm; } if (!result) { @@ -177,8 +176,7 @@ public final class FlagCommand extends Command { player.sendMessage(TranslatableCaption.of("working.plot_not_claimed")); return false; } - if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_SET_FLAG_OTHER)) { + if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_SET_FLAG_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_SET_FLAG_OTHER)) @@ -473,7 +471,7 @@ public final class FlagCommand extends Command { } boolean force = event.getEventResult() == Result.FORCE; flag = event.getFlag(); - if (!force && !Permissions.hasPermission(player, Permission.PERMISSION_SET_FLAG_KEY.format(args[0].toLowerCase()))) { + if (!force && !player.hasPermission(Permission.PERMISSION_SET_FLAG_KEY.format(args[0].toLowerCase()))) { if (args.length != 2) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), diff --git a/Core/src/main/java/com/plotsquared/core/command/Grant.java b/Core/src/main/java/com/plotsquared/core/command/Grant.java index 841098515..48b3fdba7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Grant.java +++ b/Core/src/main/java/com/plotsquared/core/command/Grant.java @@ -26,7 +26,6 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.MetaDataAccess; import com.plotsquared.core.player.PlayerMetaDataKeys; import com.plotsquared.core.player.PlotPlayer; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.task.RunnableVal; @@ -69,7 +68,7 @@ public class Grant extends Command { final String arg0 = args[0].toLowerCase(); switch (arg0) { case "add", "check" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_GRANT.format(arg0))) { + if (!player.hasPermission(Permission.PERMISSION_GRANT.format(arg0))) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_GRANT.format(arg0)) @@ -150,10 +149,10 @@ public class Grant extends Command { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_GRANT_ADD)) { + if (player.hasPermission(Permission.PERMISSION_GRANT_ADD)) { completions.add("add"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_GRANT_CHECK)) { + if (player.hasPermission(Permission.PERMISSION_GRANT_CHECK)) { completions.add("check"); } final List commands = completions.stream().filter(completion -> completion @@ -168,7 +167,7 @@ public class Grant extends Command { CommandCategory.ADMINISTRATION ) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_GRANT_SINGLE) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_GRANT_SINGLE) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java index 2218ba44e..afc940012 100644 --- a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java @@ -29,7 +29,6 @@ import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.SortingStrategy; @@ -104,8 +103,7 @@ public class HomeCommand extends Command { // /plot home <[area;]x;y> // /plot home // /plot home - if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_OWNED) && !Permissions - .hasPermission(player, Permission.PERMISSION_HOME)) { + if (!player.hasPermission(Permission.PERMISSION_VISIT_OWNED) && !player.hasPermission(Permission.PERMISSION_HOME)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_VISIT_OWNED.toString()) diff --git a/Core/src/main/java/com/plotsquared/core/command/Inbox.java b/Core/src/main/java/com/plotsquared/core/command/Inbox.java index 8bdc4df41..928cd84a7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Inbox.java +++ b/Core/src/main/java/com/plotsquared/core/command/Inbox.java @@ -30,7 +30,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.comment.CommentInbox; import com.plotsquared.core.plot.comment.CommentManager; import com.plotsquared.core.plot.comment.PlotComment; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.task.RunnableVal; @@ -285,13 +284,13 @@ public class Inbox extends SubCommand { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_INBOX_READ_OWNER)) { + if (player.hasPermission(Permission.PERMISSION_INBOX_READ_OWNER)) { completions.add("owner"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_INBOX_READ_PUBLIC)) { + if (player.hasPermission(Permission.PERMISSION_INBOX_READ_PUBLIC)) { completions.add("public"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_INBOX_READ_REPORT)) { + if (player.hasPermission(Permission.PERMISSION_INBOX_READ_REPORT)) { completions.add("report"); } final List commands = completions.stream().filter(completion -> completion @@ -299,7 +298,7 @@ public class Inbox extends SubCommand { .startsWith(args[0].toLowerCase())) .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.CHAT) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_INBOX) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_INBOX) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/Info.java b/Core/src/main/java/com/plotsquared/core/command/Info.java index 6f4c085ad..613fd5cdf 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Info.java +++ b/Core/src/main/java/com/plotsquared/core/command/Info.java @@ -27,7 +27,6 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.implementations.HideInfoFlag; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.TabCompletions; import net.kyori.adventure.text.minimessage.Template; @@ -144,7 +143,7 @@ public class Info extends SubCommand { @Override public Collection tab(PlotPlayer player, String[] args, boolean space) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO_FORCE)) { + if (player.hasPermission(Permission.PERMISSION_AREA_INFO_FORCE)) { completions.add("-f"); } @@ -154,7 +153,7 @@ public class Info extends SubCommand { .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO_FORCE) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_AREA_INFO_FORCE) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Kick.java b/Core/src/main/java/com/plotsquared/core/command/Kick.java index 111a29026..c1357f09e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Kick.java +++ b/Core/src/main/java/com/plotsquared/core/command/Kick.java @@ -27,7 +27,6 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.WorldUtil; @@ -70,8 +69,7 @@ public class Kick extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } - if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_KICK)) { + if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_KICK)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } @@ -89,8 +87,7 @@ public class Kick extends SubCommand { for (UUID uuid : uuids) { if (uuid == DBFunc.EVERYONE) { for (PlotPlayer pp : plot.getPlayersInPlot()) { - if (pp == player || Permissions - .hasPermission(pp, Permission.PERMISSION_ADMIN_ENTRY_DENIED)) { + if (pp == player || pp.hasPermission(Permission.PERMISSION_ADMIN_ENTRY_DENIED)) { continue; } players.add(pp); @@ -118,7 +115,7 @@ public class Kick extends SubCommand { ); return; } - if (Permissions.hasPermission(player2, Permission.PERMISSION_ADMIN_ENTRY_DENIED)) { + if (player2.hasPermission(Permission.PERMISSION_ADMIN_ENTRY_DENIED)) { player.sendMessage( TranslatableCaption.of("cluster.cannot_kick_player"), Template.of("name", player2.getName()) diff --git a/Core/src/main/java/com/plotsquared/core/command/Like.java b/Core/src/main/java/com/plotsquared/core/command/Like.java index 9f93efe57..78f2023ea 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Like.java +++ b/Core/src/main/java/com/plotsquared/core/command/Like.java @@ -30,7 +30,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Rating; import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.task.TaskManager; @@ -121,8 +120,7 @@ public class Like extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } - if (!Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS, true)) { + if (!player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS, true)) { return false; } plot.clearRatings(); @@ -204,7 +202,7 @@ public class Like extends SubCommand { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS)) { + if (player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS)) { completions.add("purge"); } final List commands = completions.stream().filter(completion -> completion @@ -212,7 +210,7 @@ public class Like extends SubCommand { .startsWith(args[0].toLowerCase())) .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_RATE) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java index fcb161926..63cf73b05 100644 --- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java @@ -36,7 +36,6 @@ import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.StringComparison; import com.plotsquared.core.util.StringMan; @@ -82,40 +81,40 @@ public class ListCmd extends SubCommand { private String[] getArgumentList(PlotPlayer player) { List args = new ArrayList<>(); - if (this.econHandler != null && Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) { + if (this.econHandler != null && player.hasPermission(Permission.PERMISSION_LIST_FOR_SALE)) { args.add("forsale"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) { + if (player.hasPermission(Permission.PERMISSION_LIST_MINE)) { args.add("mine"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) { + if (player.hasPermission(Permission.PERMISSION_LIST_SHARED)) { args.add("shared"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) { + if (player.hasPermission(Permission.PERMISSION_LIST_WORLD)) { args.add("world"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) { + if (player.hasPermission(Permission.PERMISSION_LIST_TOP)) { args.add("top"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) { + if (player.hasPermission(Permission.PERMISSION_LIST_ALL)) { args.add("all"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) { + if (player.hasPermission(Permission.PERMISSION_LIST_UNOWNED)) { args.add("unowned"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_PLAYER)) { + if (player.hasPermission(Permission.PERMISSION_LIST_PLAYER)) { args.add(""); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) { + if (player.hasPermission(Permission.PERMISSION_LIST_WORLD)) { args.add(""); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) { + if (player.hasPermission(Permission.PERMISSION_LIST_DONE)) { args.add("done"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) { + if (player.hasPermission(Permission.PERMISSION_LIST_EXPIRED)) { args.add("expired"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_FUZZY)) { + if (player.hasPermission(Permission.PERMISSION_LIST_FUZZY)) { args.add("fuzzy "); } return args.toArray(new String[args.size()]); @@ -187,7 +186,7 @@ public class ListCmd extends SubCommand { switch (arg) { case "mine" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_MINE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.mine") @@ -202,7 +201,7 @@ public class ListCmd extends SubCommand { .withSortingStrategy(SortingStrategy.SORT_BY_TEMP)); } case "shared" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_SHARED)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.shared") @@ -215,14 +214,14 @@ public class ListCmd extends SubCommand { .thatPasses(plot -> !plot.isOwnerAbs(player.getUUID()))); } case "world" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_WORLD)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world") ); return false; } - if (!Permissions.hasPermission(player, "plots.list.world." + world)) { + if (!player.hasPermission("plots.list.world." + world)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world." + world) @@ -232,7 +231,7 @@ public class ListCmd extends SubCommand { plotConsumer.accept(PlotQuery.newQuery().inWorld(world)); } case "expired" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_EXPIRED)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.expired") @@ -246,14 +245,14 @@ public class ListCmd extends SubCommand { } } case "area" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_AREA)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_AREA)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.area") ); return false; } - if (!Permissions.hasPermission(player, "plots.list.world." + world)) { + if (!player.hasPermission("plots.list.world." + world)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world." + world) @@ -267,7 +266,7 @@ public class ListCmd extends SubCommand { } } case "all" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_ALL)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.all") @@ -277,7 +276,7 @@ public class ListCmd extends SubCommand { plotConsumer.accept(PlotQuery.newQuery().allPlots()); } case "done" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_DONE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.done") @@ -292,7 +291,7 @@ public class ListCmd extends SubCommand { .withSortingStrategy(SortingStrategy.SORT_BY_DONE)); } case "top" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_TOP)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.top") @@ -303,7 +302,7 @@ public class ListCmd extends SubCommand { plotConsumer.accept(PlotQuery.newQuery().allPlots().withSortingStrategy(SortingStrategy.SORT_BY_RATING)); } case "forsale" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_FOR_SALE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.forsale") @@ -316,7 +315,7 @@ public class ListCmd extends SubCommand { plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getFlag(PriceFlag.class) > 0)); } case "unowned" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_UNOWNED)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.unowned") @@ -326,7 +325,7 @@ public class ListCmd extends SubCommand { plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getOwner() == null)); } case "fuzzy" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FUZZY)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_FUZZY)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.fuzzy") @@ -351,14 +350,14 @@ public class ListCmd extends SubCommand { } default -> { if (this.plotAreaManager.hasPlotArea(args[0])) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_WORLD)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world") ); return false; } - if (!Permissions.hasPermission(player, "plots.list.world." + args[0])) { + if (!player.hasPermission("plots.list.world." + args[0])) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world." + args[0]) @@ -382,7 +381,7 @@ public class ListCmd extends SubCommand { if (uuid == null) { player.sendMessage(TranslatableCaption.of("errors.invalid_player"), Templates.of("value", args[0])); } else { - if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_PLAYER)) { + if (!player.hasPermission(Permission.PERMISSION_LIST_PLAYER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.player") @@ -515,31 +514,31 @@ public class ListCmd extends SubCommand { @Override public Collection tab(PlotPlayer player, String[] args, boolean space) { final List completions = new LinkedList<>(); - if (this.econHandler.isSupported() && Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) { + if (this.econHandler.isSupported() && player.hasPermission(Permission.PERMISSION_LIST_FOR_SALE)) { completions.add("forsale"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) { + if (player.hasPermission(Permission.PERMISSION_LIST_MINE)) { completions.add("mine"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) { + if (player.hasPermission(Permission.PERMISSION_LIST_SHARED)) { completions.add("shared"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) { + if (player.hasPermission(Permission.PERMISSION_LIST_WORLD)) { completions.addAll(PlotSquared.platform().worldManager().getWorlds()); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) { + if (player.hasPermission(Permission.PERMISSION_LIST_TOP)) { completions.add("top"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) { + if (player.hasPermission(Permission.PERMISSION_LIST_ALL)) { completions.add("all"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) { + if (player.hasPermission(Permission.PERMISSION_LIST_UNOWNED)) { completions.add("unowned"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) { + if (player.hasPermission(Permission.PERMISSION_LIST_DONE)) { completions.add("done"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) { + if (player.hasPermission(Permission.PERMISSION_LIST_EXPIRED)) { completions.add("expired"); } @@ -549,7 +548,7 @@ public class ListCmd extends SubCommand { .map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.TELEPORT) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_PLAYER) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_LIST_PLAYER) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Load.java b/Core/src/main/java/com/plotsquared/core/command/Load.java index f1b10ca73..933cc32c6 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Load.java +++ b/Core/src/main/java/com/plotsquared/core/command/Load.java @@ -31,7 +31,6 @@ import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.schematic.Schematic; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.TimeUtil; import com.plotsquared.core.util.task.RunnableVal; @@ -80,8 +79,7 @@ public class Load extends SubCommand { player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } - if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_LOAD)) { + if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_LOAD)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/MainCommand.java b/Core/src/main/java/com/plotsquared/core/command/MainCommand.java index 77ebe94c3..eb1583a51 100644 --- a/Core/src/main/java/com/plotsquared/core/command/MainCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/MainCommand.java @@ -32,7 +32,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.util.EconHandler; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal3; @@ -244,8 +243,8 @@ public class MainCommand extends Command { PlotArea area = player.getApplicablePlotArea(); Plot newPlot = Plot.fromString(area, args[0]); if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea() - .equals(area) || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN) - || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_AREA_SUDO)) + .equals(area) || player.hasPermission(Permission.PERMISSION_ADMIN) + || player.hasPermission(Permission.PERMISSION_ADMIN_AREA_SUDO)) && !newPlot.isDenied(player.getUUID())) { final Location newLoc; if (newPlot.getArea() instanceof SinglePlotArea) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Merge.java b/Core/src/main/java/com/plotsquared/core/command/Merge.java index 6da21063b..335d3728d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -32,7 +32,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.StringMan; import net.kyori.adventure.text.minimessage.Template; @@ -124,7 +123,7 @@ public class Merge extends SubCommand { return false; } final int size = plot.getConnectedPlots().size(); - int max = Permissions.hasPermissionRange(player, "plots.merge", Settings.Limit.MAX_PLOTS); + int max = player.hasPermissionRange("plots.merge", Settings.Limit.MAX_PLOTS); PlotMergeEvent event = this.eventDispatcher.callMerge(plot, direction, max, player); if (event.getEventResult() == Result.DENY) { @@ -152,7 +151,7 @@ public class Merge extends SubCommand { UUID uuid = player.getUUID(); if (!force && !plot.isOwner(uuid)) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_MERGE)) { + if (!player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_MERGE)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } else { @@ -164,8 +163,7 @@ public class Merge extends SubCommand { if (args.length == 2) { terrain = "true".equalsIgnoreCase(args[1]); } - if (!force && !terrain && !Permissions - .hasPermission(player, Permission.PERMISSION_MERGE_KEEP_ROAD)) { + if (!force && !terrain && !player.hasPermission(Permission.PERMISSION_MERGE_KEEP_ROAD)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD)) @@ -202,8 +200,7 @@ public class Merge extends SubCommand { } else { terrain = true; } - if (!force && !terrain && !Permissions - .hasPermission(player, Permission.PERMISSION_MERGE_KEEP_ROAD)) { + if (!force && !terrain && !player.hasPermission(Permission.PERMISSION_MERGE_KEEP_ROAD)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD)) @@ -228,7 +225,7 @@ public class Merge extends SubCommand { player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); return false; } - if (!force && !Permissions.hasPermission(player, Permission.PERMISSION_MERGE_OTHER)) { + if (!force && !player.hasPermission(Permission.PERMISSION_MERGE_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_MERGE_OTHER)) @@ -283,8 +280,14 @@ public class Merge extends SubCommand { } } if (force || !isOnline) { - if (force || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_MERGE_OTHER_OFFLINE)) { - if (plot.getPlotModificationManager().autoMerge(direction, maxSize - size, uuids.iterator().next(), player, terrain)) { + if (force || player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_MERGE_OTHER_OFFLINE)) { + if (plot.getPlotModificationManager().autoMerge( + direction, + maxSize - size, + uuids.iterator().next(), + player, + terrain + )) { if (this.econHandler.isEnabled(plotArea) && price > 0d) { if (!force && this.econHandler.getMoney(player) < price) { player.sendMessage( diff --git a/Core/src/main/java/com/plotsquared/core/command/Move.java b/Core/src/main/java/com/plotsquared/core/command/Move.java index 602e29c19..998420caa 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Move.java +++ b/Core/src/main/java/com/plotsquared/core/command/Move.java @@ -26,7 +26,6 @@ import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal3; import net.kyori.adventure.text.minimessage.Template; @@ -60,8 +59,7 @@ public class Move extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return CompletableFuture.completedFuture(false); } - if (!plot1.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN)) { + if (!plot1.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return CompletableFuture.completedFuture(false); } @@ -88,8 +86,7 @@ public class Move extends SubCommand { player.sendMessage(TranslatableCaption.of("invalid.origin_cant_be_target")); return CompletableFuture.completedFuture(false); } - if (!plot1.getArea().isCompatible(plot2.getArea()) && (!override || !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN))) { + if (!plot1.getArea().isCompatible(plot2.getArea()) && (!override || !player.hasPermission(Permission.PERMISSION_ADMIN))) { player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible")); return CompletableFuture.completedFuture(false); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Music.java b/Core/src/main/java/com/plotsquared/core/command/Music.java index f8a3af88d..1c760899a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Music.java +++ b/Core/src/main/java/com/plotsquared/core/command/Music.java @@ -33,7 +33,6 @@ import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.implementations.MusicFlag; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.InventoryUtil; -import com.plotsquared.core.util.Permissions; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import net.kyori.adventure.text.minimessage.Template; @@ -79,8 +78,7 @@ public class Music extends SubCommand { player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } - if (!plot.isAdded(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_MUSIC_OTHER)) { + if (!plot.isAdded(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_MUSIC_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_MUSIC_OTHER)) diff --git a/Core/src/main/java/com/plotsquared/core/command/Owner.java b/Core/src/main/java/com/plotsquared/core/command/Owner.java index bb44a4686..15e06497e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Owner.java +++ b/Core/src/main/java/com/plotsquared/core/command/Owner.java @@ -31,7 +31,6 @@ import com.plotsquared.core.player.PlayerMetaDataKeys; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.task.TaskManager; @@ -99,10 +98,10 @@ public class Owner extends SetCommand { uuid = event.getNewOwner(); boolean force = event.getEventResult() == Result.FORCE; if (uuid == null) { - if (!force && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SET_OWNER, - true - )) { + if (!force && !player.hasPermission( + Permission.PERMISSION_ADMIN_COMMAND_SET_OWNER, + true + )) { return; } PlotUnlinkEvent unlinkEvent = this.eventDispatcher.callUnlink( @@ -139,8 +138,7 @@ public class Owner extends SetCommand { ); return; } - if (!force && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SET_OWNER)) { + if (!force && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_SET_OWNER)) { if (other == null) { player.sendMessage( TranslatableCaption.of("errors.invalid_player_offline"), diff --git a/Core/src/main/java/com/plotsquared/core/command/Rate.java b/Core/src/main/java/com/plotsquared/core/command/Rate.java index 0c7a446d5..17869c44d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Rate.java +++ b/Core/src/main/java/com/plotsquared/core/command/Rate.java @@ -34,7 +34,6 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.InventoryUtil; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.task.TaskManager; @@ -114,8 +113,7 @@ public class Rate extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } - if (!Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS, true)) { + if (!player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS, true)) { return false; } plot.clearRatings(); @@ -273,10 +271,10 @@ public class Rate extends SubCommand { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_RATE)) { + if (player.hasPermission(Permission.PERMISSION_RATE)) { completions.add("1 - 10"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS)) { + if (player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS)) { completions.add("purge"); } final List commands = completions.stream().filter(completion -> completion @@ -284,7 +282,7 @@ public class Rate extends SubCommand { .startsWith(args[0].toLowerCase())) .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_RATE) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/Remove.java b/Core/src/main/java/com/plotsquared/core/command/Remove.java index 3a2e06a2d..ecfab4a88 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Remove.java +++ b/Core/src/main/java/com/plotsquared/core/command/Remove.java @@ -26,7 +26,6 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.TabCompletions; import net.kyori.adventure.text.minimessage.Template; @@ -65,8 +64,7 @@ public class Remove extends SubCommand { player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } - if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_REMOVE)) { + if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_REMOVE)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return true; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Save.java b/Core/src/main/java/com/plotsquared/core/command/Save.java index 1cfa55d1b..c15647fdc 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Save.java +++ b/Core/src/main/java/com/plotsquared/core/command/Save.java @@ -28,7 +28,6 @@ import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.TaskManager; @@ -82,8 +81,7 @@ public class Save extends SubCommand { player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); return false; } - if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SAVE)) { + if (!plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_SAVE)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java index 0a495e987..550a0cf93 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java @@ -30,7 +30,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.schematic.Schematic; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.TabCompletions; @@ -80,7 +79,7 @@ public class SchematicCmd extends SubCommand { String arg = args[0].toLowerCase(); switch (arg) { case "paste" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_PASTE)) { + if (!player.hasPermission(Permission.PERMISSION_SCHEMATIC_PASTE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_PASTE)) @@ -104,8 +103,7 @@ public class SchematicCmd extends SubCommand { player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } - if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, "plots.admin.command.schematic.paste")) { + if (!plot.isOwner(player.getUUID()) && !player.hasPermission("plots.admin.command.schematic.paste")) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } @@ -218,7 +216,7 @@ public class SchematicCmd extends SubCommand { } } case "export", "save" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_SAVE)) { + if (!player.hasPermission(Permission.PERMISSION_SCHEMATIC_SAVE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_SAVE)) @@ -243,8 +241,7 @@ public class SchematicCmd extends SubCommand { player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); return false; } - if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, "plots.admin.command.schematic.save")) { + if (!plot.isOwner(player.getUUID()) && !player.hasPermission("plots.admin.command.schematic.save")) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } @@ -261,7 +258,7 @@ public class SchematicCmd extends SubCommand { } } case "list" -> { - if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_LIST)) { + if (!player.hasPermission(Permission.PERMISSION_SCHEMATIC_LIST)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_LIST)) @@ -286,13 +283,13 @@ public class SchematicCmd extends SubCommand { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_SAVE)) { + if (player.hasPermission(Permission.PERMISSION_SCHEMATIC_SAVE)) { completions.add("save"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_LIST)) { + if (player.hasPermission(Permission.PERMISSION_SCHEMATIC_LIST)) { completions.add("list"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_PASTE)) { + if (player.hasPermission(Permission.PERMISSION_SCHEMATIC_PASTE)) { completions.add("paste"); } final List commands = completions.stream().filter(completion -> completion @@ -307,7 +304,7 @@ public class SchematicCmd extends SubCommand { CommandCategory.ADMINISTRATION ) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_SCHEMATIC) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/Set.java b/Core/src/main/java/com/plotsquared/core/command/Set.java index e12ab3505..84ec87eeb 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -32,7 +32,6 @@ import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.queue.QueueCoordinator; import com.plotsquared.core.util.PatternUtil; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.WorldUtil; @@ -96,7 +95,7 @@ public class Set extends SubCommand { BlockType::getName).toList()); } - if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_ALLOW_UNSAFE) && + if (!player.hasPermission(Permission.PERMISSION_ADMIN_ALLOW_UNSAFE) && !forbiddenTypes.isEmpty()) { for (String forbiddenType : forbiddenTypes) { forbiddenType = forbiddenType.toLowerCase(Locale.ENGLISH); @@ -132,7 +131,7 @@ public class Set extends SubCommand { for (String component : components) { if (component.equalsIgnoreCase(args[0])) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_SET_COMPONENT.format(component))) { + if (!player.hasPermission(Permission.PERMISSION_SET_COMPONENT.format(component))) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_SET_COMPONENT.format(component)) @@ -211,7 +210,7 @@ public class Set extends SubCommand { } Command cmd = MainCommand.getInstance().getCommand("set" + args[0]); if (cmd != null) { - if (!Permissions.hasPermission(player, cmd.getPermission(), true)) { + if (!player.hasPermission(cmd.getPermission(), true)) { return false; } cmd.execute(player, Arrays.copyOfRange(args, 1, args.length), null, null); @@ -241,37 +240,37 @@ public class Set extends SubCommand { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_BIOME)) { + if (player.hasPermission(Permission.PERMISSION_SET_BIOME)) { completions.add("biome"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_ALIAS)) { + if (player.hasPermission(Permission.PERMISSION_SET_ALIAS)) { completions.add("alias"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_HOME)) { + if (player.hasPermission(Permission.PERMISSION_SET_HOME)) { completions.add("home"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_MAIN)) { + if (player.hasPermission(Permission.PERMISSION_SET_MAIN)) { completions.add("main"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_FLOOR)) { + if (player.hasPermission(Permission.PERMISSION_SET_FLOOR)) { completions.add("floor"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_AIR)) { + if (player.hasPermission(Permission.PERMISSION_SET_AIR)) { completions.add("air"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_ALL)) { + if (player.hasPermission(Permission.PERMISSION_SET_ALL)) { completions.add("all"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_BORDER)) { + if (player.hasPermission(Permission.PERMISSION_SET_BORDER)) { completions.add("border"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_WALL)) { + if (player.hasPermission(Permission.PERMISSION_SET_WALL)) { completions.add("wall"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_OUTLINE)) { + if (player.hasPermission(Permission.PERMISSION_SET_OUTLINE)) { completions.add("outline"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_SET_MIDDLE)) { + if (player.hasPermission(Permission.PERMISSION_SET_MIDDLE)) { completions.add("middle"); } final List commands = completions.stream().filter(completion -> completion @@ -280,7 +279,7 @@ public class Set extends SubCommand { .map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.APPEARANCE) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_SET) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_SET) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; @@ -296,7 +295,7 @@ public class Set extends SubCommand { final Command cmd = MainCommand.getInstance().getCommand("set" + args[0]); if (cmd != null) { - if (!Permissions.hasPermission(player, cmd.getPermission(), true)) { + if (!player.hasPermission(cmd.getPermission(), true)) { return new ArrayList<>(); } return cmd.tab(player, newArgs, space); diff --git a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java index 1ff54853c..2189a0eae 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java @@ -23,7 +23,6 @@ import com.plotsquared.core.location.Location; import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.StringMan; import net.kyori.adventure.text.minimessage.Template; @@ -38,7 +37,7 @@ public abstract class SetCommand extends SubCommand { return false; } if (!plot.hasOwner()) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) { + if (!player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId())) @@ -48,7 +47,7 @@ public abstract class SetCommand extends SubCommand { } } if (!plot.isOwner(player.getUUID())) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) { + if (!player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId())) diff --git a/Core/src/main/java/com/plotsquared/core/command/Swap.java b/Core/src/main/java/com/plotsquared/core/command/Swap.java index 4c7864439..d97437d89 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Swap.java +++ b/Core/src/main/java/com/plotsquared/core/command/Swap.java @@ -23,7 +23,6 @@ import com.plotsquared.core.location.Location; import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal3; import net.kyori.adventure.text.minimessage.Template; @@ -49,8 +48,7 @@ public class Swap extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return CompletableFuture.completedFuture(false); } - if (!plot1.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN)) { + if (!plot1.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return CompletableFuture.completedFuture(false); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Template.java b/Core/src/main/java/com/plotsquared/core/command/Template.java index 02b95e71f..9f05d8aff 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Template.java +++ b/Core/src/main/java/com/plotsquared/core/command/Template.java @@ -39,7 +39,6 @@ import com.plotsquared.core.setup.PlotAreaBuilder; import com.plotsquared.core.setup.SettingsNodesWrapper; import com.plotsquared.core.util.FileBytes; import com.plotsquared.core.util.FileUtils; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.WorldUtil; @@ -279,10 +278,10 @@ public class Template extends SubCommand { public Collection tab(final PlotPlayer player, final String[] args, final boolean space) { if (args.length == 1) { final List completions = new LinkedList<>(); - if (Permissions.hasPermission(player, Permission.PERMISSION_TEMPLATE_EXPORT)) { + if (player.hasPermission(Permission.PERMISSION_TEMPLATE_EXPORT)) { completions.add("export"); } - if (Permissions.hasPermission(player, Permission.PERMISSION_TEMPLATE_IMPORT)) { + if (player.hasPermission(Permission.PERMISSION_TEMPLATE_IMPORT)) { completions.add("import"); } final List commands = completions.stream().filter(completion -> completion @@ -297,7 +296,7 @@ public class Template extends SubCommand { CommandCategory.ADMINISTRATION ) { }).collect(Collectors.toCollection(LinkedList::new)); - if (Permissions.hasPermission(player, Permission.PERMISSION_TEMPLATE) && args[0].length() > 0) { + if (player.hasPermission(Permission.PERMISSION_TEMPLATE) && args[0].length() > 0) { commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); } return commands; diff --git a/Core/src/main/java/com/plotsquared/core/command/Trust.java b/Core/src/main/java/com/plotsquared/core/command/Trust.java index 63c5e9a94..b44eec0e0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Trust.java +++ b/Core/src/main/java/com/plotsquared/core/command/Trust.java @@ -27,7 +27,6 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.task.RunnableVal2; @@ -69,8 +68,7 @@ public class Trust extends Command { } checkTrue(currentPlot.hasOwner(), TranslatableCaption.of("info.plot_unowned")); checkTrue( - currentPlot.isOwner(player.getUUID()) || Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST), + currentPlot.isOwner(player.getUUID()) || player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_TRUST), TranslatableCaption.of("permission.no_plot_perms") ); @@ -101,8 +99,7 @@ public class Trust extends Command { while (iterator.hasNext()) { UUID uuid = iterator.next(); if (uuid == DBFunc.EVERYONE && !( - Permissions.hasPermission(player, Permission.PERMISSION_TRUST_EVERYONE) || Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) { + player.hasPermission(Permission.PERMISSION_TRUST_EVERYONE) || player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_TRUST))) { player.sendMessage( TranslatableCaption.of("errors.invalid_player"), Template.of("value", PlayerManager.resolveName(uuid).getComponent(player)) @@ -130,7 +127,7 @@ public class Trust extends Command { } checkTrue(!uuids.isEmpty(), null); int localTrustSize = currentPlot.getTrusted().size(); - int maxTrustSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_TRUST, Settings.Limit.MAX_PLOTS); + int maxTrustSize = player.hasPermissionRange(Permission.PERMISSION_TRUST, Settings.Limit.MAX_PLOTS); if (localTrustSize >= maxTrustSize) { player.sendMessage( TranslatableCaption.of("members.plot_max_members_trusted"), diff --git a/Core/src/main/java/com/plotsquared/core/command/Unlink.java b/Core/src/main/java/com/plotsquared/core/command/Unlink.java index f0aec660d..45d49c6c3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Unlink.java +++ b/Core/src/main/java/com/plotsquared/core/command/Unlink.java @@ -27,7 +27,6 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.task.TaskManager; import net.kyori.adventure.text.minimessage.Template; @@ -91,8 +90,7 @@ public class Unlink extends SubCommand { return true; } boolean force = event.getEventResult() == Result.FORCE; - if (!force && !plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_UNLINK)) { + if (!force && !plot.isOwner(player.getUUID()) && !player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_UNLINK)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return true; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Visit.java b/Core/src/main/java/com/plotsquared/core/command/Visit.java index e287fa589..c20edeba8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Visit.java +++ b/Core/src/main/java/com/plotsquared/core/command/Visit.java @@ -31,7 +31,6 @@ import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.flag.implementations.UntrustedVisitFlag; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.query.PlotQuery; @@ -108,7 +107,7 @@ public class Visit extends Command { final Plot plot = plots.get(page - 1); if (!plot.hasOwner()) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_UNOWNED)) { + if (!player.hasPermission(Permission.PERMISSION_VISIT_UNOWNED)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.visit.unowned") @@ -116,8 +115,7 @@ public class Visit extends Command { return; } } else if (plot.isOwner(player.getUUID())) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_OWNED) && !Permissions - .hasPermission(player, Permission.PERMISSION_HOME)) { + if (!player.hasPermission(Permission.PERMISSION_VISIT_OWNED) && !player.hasPermission(Permission.PERMISSION_HOME)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.visit.owned") @@ -125,7 +123,7 @@ public class Visit extends Command { return; } } else if (plot.isAdded(player.getUUID())) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_SHARED)) { + if (!player.hasPermission(Permission.PERMISSION_SHARED)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.visit.shared") @@ -135,8 +133,8 @@ public class Visit extends Command { } else { // allow visit, if UntrustedVisit flag is set, or if the player has either the plot.visit.other or // plot.admin.visit.untrusted permission - if (!plot.getFlag(UntrustedVisitFlag.class) && !Permissions.hasPermission(player, Permission.PERMISSION_VISIT_OTHER) - && !Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_VISIT_UNTRUSTED)) { + if (!plot.getFlag(UntrustedVisitFlag.class) && !player.hasPermission(Permission.PERMISSION_VISIT_OTHER) + && !player.hasPermission(Permission.PERMISSION_ADMIN_VISIT_UNTRUSTED)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.visit.other") @@ -144,7 +142,7 @@ public class Visit extends Command { return; } if (plot.isDenied(player.getUUID())) { - if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_DENIED)) { + if (!player.hasPermission(Permission.PERMISSION_VISIT_DENIED)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), Template.of("node", String.valueOf(Permission.PERMISSION_VISIT_DENIED)) diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java index 710b6c283..88dc48672 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java @@ -35,7 +35,6 @@ import com.plotsquared.core.queue.QueueCoordinator; import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.InventoryUtil; import com.plotsquared.core.util.PatternUtil; -import com.plotsquared.core.util.Permissions; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.world.item.ItemTypes; import net.kyori.adventure.text.minimessage.MiniMessage; @@ -51,7 +50,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -153,8 +151,7 @@ public class ComponentPresetManager { } else if (!plot.hasOwner()) { player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return null; - } else if (!plot.isOwner(player.getUUID()) && !plot.getTrusted().contains(player.getUUID()) && !Permissions.hasPermission( - player, + } else if (!plot.isOwner(player.getUUID()) && !plot.getTrusted().contains(player.getUUID()) && !player.hasPermission( Permission.PERMISSION_ADMIN_COMPONENTS_OTHER )) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); @@ -166,8 +163,7 @@ public class ComponentPresetManager { final List allowedPresets = new ArrayList<>(this.presets.size()); for (final ComponentPreset componentPreset : this.presets) { - if (!componentPreset.getPermission().isEmpty() && !Permissions.hasPermission( - player, + if (!componentPreset.getPermission().isEmpty() && !player.hasPermission( componentPreset.getPermission() )) { continue; diff --git a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java index 0550d65eb..59f1b0d24 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java @@ -56,7 +56,6 @@ import com.plotsquared.core.plot.flag.implementations.TitlesFlag; import com.plotsquared.core.plot.flag.implementations.WeatherFlag; import com.plotsquared.core.plot.flag.types.TimedFlag; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskTime; @@ -149,8 +148,7 @@ public class PlotListener { } public boolean plotEntry(final PlotPlayer player, final Plot plot) { - if (plot.isDenied(player.getUUID()) && !Permissions - .hasPermission(player, "plots.admin.entry.denied")) { + if (plot.isDenied(player.getUUID()) && !player.hasPermission("plots.admin.entry.denied")) { player.sendMessage( TranslatableCaption.of("deny.no_enter"), Template.of("plot", plot.toString()) @@ -188,7 +186,7 @@ public class PlotListener { } if (plot.getFlag(NotifyEnterFlag.class)) { - if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) { + if (!player.hasPermission("plots.flag.notify-enter.bypass")) { for (UUID uuid : plot.getOwners()) { final PlotPlayer owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid); if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { @@ -200,7 +198,7 @@ public class PlotListener { } final FlyFlag.FlyStatus flyStatus = plot.getFlag(FlyFlag.class); - if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_FLIGHT)) { + if (!player.hasPermission(Permission.PERMISSION_ADMIN_FLIGHT)) { if (flyStatus != FlyFlag.FlyStatus.DEFAULT) { boolean flight = player.getFlight(); GameMode gamemode = player.getGameMode(); @@ -216,7 +214,7 @@ public class PlotListener { final GameMode gameMode = plot.getFlag(GamemodeFlag.class); if (!gameMode.equals(GamemodeFlag.DEFAULT)) { if (player.getGameMode() != gameMode) { - if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { + if (!player.hasPermission("plots.gamemode.bypass")) { player.setGameMode(gameMode); } else { player.sendMessage( @@ -231,7 +229,7 @@ public class PlotListener { final GameMode guestGameMode = plot.getFlag(GuestGamemodeFlag.class); if (!guestGameMode.equals(GamemodeFlag.DEFAULT)) { if (player.getGameMode() != guestGameMode && !plot.isAdded(player.getUUID())) { - if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { + if (!player.hasPermission("plots.gamemode.bypass")) { player.setGameMode(guestGameMode); } else { player.sendMessage( @@ -392,8 +390,7 @@ public class PlotListener { } try (final MetaDataAccess kickAccess = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) { - if (plot.getFlag(DenyExitFlag.class) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_EXIT_DENIED) && + if (plot.getFlag(DenyExitFlag.class) && !player.hasPermission(Permission.PERMISSION_ADMIN_EXIT_DENIED) && !kickAccess.get().orElse(false)) { if (previous != null) { lastPlot.set(previous); @@ -404,7 +401,7 @@ public class PlotListener { if (!plot.getFlag(GamemodeFlag.class).equals(GamemodeFlag.DEFAULT) || !plot .getFlag(GuestGamemodeFlag.class).equals(GamemodeFlag.DEFAULT)) { if (player.getGameMode() != pw.getGameMode()) { - if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { + if (!player.hasPermission("plots.gamemode.bypass")) { player.setGameMode(pw.getGameMode()); } else { player.sendMessage( @@ -426,7 +423,7 @@ public class PlotListener { } if (plot.getFlag(NotifyLeaveFlag.class)) { - if (!Permissions.hasPermission(player, "plots.flag.notify-leave.bypass")) { + if (!player.hasPermission("plots.flag.notify-leave.bypass")) { for (UUID uuid : plot.getOwners()) { final PlotPlayer owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid); if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { diff --git a/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java b/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java index 0ad71a737..493863a07 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java +++ b/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java @@ -25,7 +25,6 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.WEManager; import com.plotsquared.core.util.WorldUtil; import com.sk89q.worldedit.EditSession; @@ -92,7 +91,7 @@ public class WESubscriber { } else { mask = WEManager.getMask(plotPlayer); if (mask.isEmpty()) { - if (Permissions.hasPermission(plotPlayer, "plots.worldedit.bypass")) { + if (plotPlayer.hasPermission("plots.worldedit.bypass")) { plotPlayer.sendMessage( TranslatableCaption.of("worldedit.worldedit_bypass"), Template.of("command", "/plot toggle worldedit") diff --git a/Core/src/main/java/com/plotsquared/core/permissions/PermissionHolder.java b/Core/src/main/java/com/plotsquared/core/permissions/PermissionHolder.java index ed79cbdc9..3b483f45b 100644 --- a/Core/src/main/java/com/plotsquared/core/permissions/PermissionHolder.java +++ b/Core/src/main/java/com/plotsquared/core/permissions/PermissionHolder.java @@ -38,6 +38,16 @@ public interface PermissionHolder { return hasPermission(null, permission); } + /** + * Check if the owner of the profile has a given (global) permission + * + * @param permission Permission + * @return {@code true} if the owner has the given permission, else {@code false} + */ + default boolean hasPermission(final @NonNull Permission permission) { + return hasPermission(permission.toString()); + } + /** * Check if the owner of the profile has a given (global) keyed permission. Checks both {@code permission.key} * and {@code permission.*} @@ -54,6 +64,23 @@ public interface PermissionHolder { return hasKeyedPermission(null, permission, key); } + /** + * Check the highest permission a PlotPlayer has within a specified range.
+ * - Excessively high values will lag
+ * - The default range that is checked is {@link Settings.Limit#MAX_PLOTS}
+ * + * @param stub The permission stub to check e.g. for `plots.plot.#` the stub is `plots.plot` + * @param range The range to check + * @return The highest permission they have within that range + */ + @NonNegative + default int hasPermissionRange( + final @NonNull Permission stub, + @NonNegative final int range + ) { + return hasPermissionRange(stub.toString(), range); + } + /** * Check the highest permission a PlotPlayer has within a specified range.
* - Excessively high values will lag
@@ -92,6 +119,26 @@ public interface PermissionHolder { return 0; } + /** + * Checks if the owner of the profile has a permission, and optionally send the no permission message if applicable. + * + * @param permission Permission + * @param notify If to notify the permission holder + * @return {@code true} if the owner has the given permission, else {@code false} + */ + default boolean hasPermission(@NonNull Permission permission, boolean notify) { + return hasPermission(permission.toString(), notify); + } + + /** + * Checks if the owner of the profile has a permission, and optionally send the no permission message if applicable. + * + * @param permission Permission + * @param notify If to notify the permission holder + * @return {@code true} if the owner has the given permission, else {@code false} + */ + boolean hasPermission(@NonNull String permission, boolean notify); + /** * Check if the owner of the profile has a given permission * diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index f0d5cdfc3..29c487526 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -48,7 +48,6 @@ import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.plot.world.SinglePlotAreaManager; import com.plotsquared.core.synchronization.LockRepository; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.TaskManager; @@ -200,6 +199,20 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, return this.permissionProfile.hasKeyedPermission(world, permission, key); } + @Override + public final boolean hasPermission(@NonNull String permission, boolean notify) { + if (!hasPermission(permission)) { + if (notify) { + sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", permission) + ); + } + return false; + } + return true; + } + public abstract Actor toActor(); public abstract P getPlatformPlayer(); @@ -290,7 +303,7 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, * @return number of allowed plots within the scope (globally, or in the player's current world as defined in the settings.yml) */ public int getAllowedPlots() { - return Permissions.hasPermissionRange(this, "plots.plot", Settings.Limit.MAX_PLOTS); + return hasPermissionRange("plots.plot", Settings.Limit.MAX_PLOTS); } /** diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index bab1a3d61..5c90c2fad 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -54,7 +54,6 @@ import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.queue.QueueCoordinator; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.RegionManager; import com.plotsquared.core.util.RegionUtil; @@ -2207,7 +2206,7 @@ public class Plot { public boolean canClaim(@NonNull PlotPlayer player) { PlotCluster cluster = this.getCluster(); if (cluster != null) { - if (!cluster.isAdded(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.claim")) { + if (!cluster.isAdded(player.getUUID()) && !player.hasPermission("plots.admin.command.claim")) { return false; } } @@ -2598,7 +2597,7 @@ public class Plot { Template plotTemplate = Template.of("plot", this.toString()); Template messageTemplate = Template.of("message", message); for (final PlotPlayer player : players) { - if (isOwner(player.getUUID()) || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_DEBUG_OTHER)) { + if (isOwner(player.getUUID()) || player.hasPermission(Permission.PERMISSION_ADMIN_DEBUG_OTHER)) { player.sendMessage(caption, plotTemplate, messageTemplate); } } @@ -2635,8 +2634,7 @@ public class Plot { return; } final Consumer locationConsumer = location -> { - if (Settings.Teleport.DELAY == 0 || Permissions - .hasPermission(player, "plots.teleport.delay.bypass")) { + if (Settings.Teleport.DELAY == 0 || player.hasPermission("plots.teleport.delay.bypass")) { player.sendMessage(TranslatableCaption.of("teleport.teleported_to_plot")); player.teleport(location, cause); resultConsumer.accept(true); diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index 63f5577ba..b9b805f82 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -49,7 +49,6 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.queue.QueueCoordinator; import com.plotsquared.core.util.MathMan; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.RegionUtil; import com.plotsquared.core.util.StringMan; @@ -646,7 +645,7 @@ public abstract class PlotArea { * @since 6.9.1 */ public boolean notifyIfOutsideBuildArea(PlotPlayer player, int y) { - if (!buildRangeContainsY(y) && !Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { + if (!buildRangeContainsY(y) && !player.hasPermission(Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { player.sendMessage( TranslatableCaption.of("height.height_limit"), Template.of("minHeight", String.valueOf(minBuildHeight)), diff --git a/Core/src/main/java/com/plotsquared/core/plot/comment/CommentInbox.java b/Core/src/main/java/com/plotsquared/core/plot/comment/CommentInbox.java index ac9185bfe..1e0894538 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/comment/CommentInbox.java +++ b/Core/src/main/java/com/plotsquared/core/plot/comment/CommentInbox.java @@ -21,7 +21,6 @@ package com.plotsquared.core.plot.comment; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; -import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.RunnableVal; import java.util.List; @@ -37,9 +36,8 @@ public abstract class CommentInbox { * @return the inbox, otherwise {@code false} false */ public boolean canRead(Plot plot, PlotPlayer player) { - if (Permissions.hasPermission(player, "plots.inbox.read." + this, true)) { - return plot.isOwner(player.getUUID()) || Permissions - .hasPermission(player, "plots.inbox.read." + this + ".other", true); + if (player.hasPermission("plots.inbox.read." + this, true)) { + return plot.isOwner(player.getUUID()) || player.hasPermission("plots.inbox.read." + this + ".other", true); } return false; } @@ -51,11 +49,10 @@ public abstract class CommentInbox { */ public boolean canWrite(Plot plot, PlotPlayer player) { if (plot == null) { - return Permissions.hasPermission(player, "plots.inbox.write." + this, true); + return player.hasPermission("plots.inbox.write." + this, true); } - return Permissions.hasPermission(player, "plots.inbox.write." + this, true) && ( - plot.isOwner(player.getUUID()) || Permissions - .hasPermission(player, "plots.inbox.write." + this + ".other", true)); + return player.hasPermission("plots.inbox.write." + this, true) && ( + plot.isOwner(player.getUUID()) || player.hasPermission("plots.inbox.write." + this + ".other", true)); } /** @@ -65,9 +62,8 @@ public abstract class CommentInbox { */ @SuppressWarnings({"BooleanMethodIsAlwaysInverted"}) public boolean canModify(Plot plot, PlotPlayer player) { - if (Permissions.hasPermission(player, "plots.inbox.modify." + this, true)) { - return plot.isOwner(player.getUUID()) || Permissions - .hasPermission(player, "plots.inbox.modify." + this + ".other", true); + if (player.hasPermission("plots.inbox.modify." + this, true)) { + return plot.isOwner(player.getUUID()) || player.hasPermission("plots.inbox.modify." + this + ".other", true); } return false; } diff --git a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java index b2d858b4d..9318cccd0 100644 --- a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java +++ b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java @@ -332,8 +332,7 @@ public class EventDispatcher { ) { PlotArea area = location.getPlotArea(); assert area != null; - if (!area.buildRangeContainsY(location.getY()) && !Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { + if (!area.buildRangeContainsY(location.getY()) && !player.hasPermission(Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { player.sendMessage( TranslatableCaption.of("height.height_limit"), Template.of("minHeight", String.valueOf(area.getMinBuildHeight())), @@ -360,12 +359,12 @@ public class EventDispatcher { return true; } } - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms ); } if (!plot.hasOwner()) { - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms ); } @@ -376,7 +375,7 @@ public class EventDispatcher { return true; } } - if (Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), false)) { + if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), false)) { return true; } if (notifyPerms) { @@ -395,12 +394,12 @@ public class EventDispatcher { return true; } } - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), false ); } if (!plot.hasOwner()) { - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), false ); } @@ -414,19 +413,19 @@ public class EventDispatcher { return true; } } - return Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), - false - ); + return player.hasPermission( + Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), + false + ); } case SPAWN_MOB: { if (plot == null) { - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms ); } if (!plot.hasOwner()) { - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms ); } @@ -440,10 +439,10 @@ public class EventDispatcher { return true; } } - if (Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), - false - )) { + if (player.hasPermission( + Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), + false + )) { return true; } if (notifyPerms) { @@ -457,12 +456,12 @@ public class EventDispatcher { } case PLACE_MISC: { if (plot == null) { - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms ); } if (!plot.hasOwner()) { - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms ); } @@ -476,10 +475,10 @@ public class EventDispatcher { return true; } } - if (Permissions - .hasPermission(player, Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), - false - )) { + if (player.hasPermission( + Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), + false + )) { return true; } if (notifyPerms) { @@ -493,12 +492,12 @@ public class EventDispatcher { } case PLACE_VEHICLE: if (plot == null) { - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_ROAD.toString(), notifyPerms ); } if (!plot.hasOwner()) { - return Permissions.hasPermission(player, + return player.hasPermission( Permission.PERMISSION_ADMIN_INTERACT_UNOWNED.toString(), notifyPerms ); } diff --git a/Core/src/main/java/com/plotsquared/core/util/Permissions.java b/Core/src/main/java/com/plotsquared/core/util/Permissions.java index 06d0ddbee..972653a8b 100644 --- a/Core/src/main/java/com/plotsquared/core/util/Permissions.java +++ b/Core/src/main/java/com/plotsquared/core/util/Permissions.java @@ -32,14 +32,14 @@ import org.checkerframework.checker.nullness.qual.NonNull; * - Checking the PlotPlayer class directly will not take the above into account
* * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes + * classes */ @Deprecated(forRemoval = true, since = "6.9.3") public class Permissions { /** * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes + * classes. Use {@link PlotPlayer#hasPermission(String, boolean)} */ @Deprecated(forRemoval = true, since = "6.9.3") public static boolean hasPermission(PlotPlayer player, Permission permission, boolean notify) { @@ -53,7 +53,7 @@ public class Permissions { * @param permission Permission * @return {@code true} if the owner has the given permission, else {@code false} * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes + * classes. Use {@link PermissionHolder#hasPermission(Permission)} */ @Deprecated(forRemoval = true, since = "6.9.3") public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull Permission permission) { @@ -68,7 +68,7 @@ public class Permissions { * @param permission Permission * @return {@code true} if the owner has the given permission, else {@code false} * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes + * classes. Use {@link PermissionHolder#hasPermission(String)} */ @Deprecated(forRemoval = true, since = "6.9.3") public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull String permission) { @@ -85,7 +85,7 @@ public class Permissions { * @return {@code true} if the owner has the given permission, else {@code false} * @since 6.0.10 * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes + * classes. Use {@link PermissionHolder#hasKeyedPermission(String, String)} */ @Deprecated(forRemoval = true, since = "6.9.3") public static boolean hasKeyedPermission( @@ -103,7 +103,7 @@ public class Permissions { * @param notify if to notify the permission holder * @return if permission is had * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes + * classes. Use {@link PlotPlayer#hasPermission(String, boolean)} */ @Deprecated(forRemoval = true, since = "6.9.3") public static boolean hasPermission(PlotPlayer player, String permission, boolean notify) { @@ -121,7 +121,7 @@ public class Permissions { /** * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes + * classes. Use {@link PlotPlayer#hasPermissionRange(Permission, int)} */ @Deprecated(forRemoval = true, since = "6.9.3") public static int hasPermissionRange(PlotPlayer player, Permission Permission, int range) { @@ -138,7 +138,7 @@ public class Permissions { * @param range The range to check * @return The highest permission they have within that range * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes + * classes. Use {@link PlotPlayer#hasPermissionRange(String, int)} */ @Deprecated(forRemoval = true, since = "6.9.3") public static int hasPermissionRange(PlotPlayer player, String stub, int range) { From c978322036f670c4db31b7e4042db1c7cda11770 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 15 Jan 2023 14:10:41 +0100 Subject: [PATCH 07/32] Separate workflows between PRs and pushes (#3928) * Separate workflows between PRs and pushes * Fixup --- .github/workflows/build-pr.yml | 23 +++++++++++++++++++++++ .github/workflows/build.yml | 9 ++++++--- .github/workflows/codeql.yml | 2 -- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build-pr.yml diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml new file mode 100644 index 000000000..b1ffd45a4 --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,23 @@ +name: Build PR + +on: [ pull_request ] + +jobs: + build_pr: + if: github.repository_owner == 'IntellectualSites' + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + - name: Clean Build + run: ./gradlew clean build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bee920ea9..d7d6fa81c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,15 +1,18 @@ name: build -on: [ pull_request, push ] +on: + push: + branches: + - v6 jobs: build: - if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} + if: github.repository_owner == 'IntellectualSites' runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v3 - - name: Validate Gradle Wrapper" + - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@v1 - name: Setup Java uses: actions/setup-java@v3 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 42526cb92..625a76a13 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,8 +1,6 @@ name: "CodeQL" on: - push: - branches: [ v6 ] pull_request: # The branches below must be a subset of the branches above branches: [ v6 ] From abbac057ed1227d96b3ed62f41b7e2d367a8fdde Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 15 Jan 2023 17:54:52 +0100 Subject: [PATCH 08/32] Default to unix line endings (#3932) * Default to unix line endings * Respect preconfigured settings --- .gitattributes | 4 ++++ .../main/java/com/plotsquared/bukkit/util/BukkitWorld.java | 1 - .../plotsquared/bukkit/util/fawe/FaweSchematicHandler.java | 1 - .../src/main/java/com/plotsquared/core/command/DebugExec.java | 2 -- Core/src/main/java/com/plotsquared/core/plot/PlotWorld.java | 1 - .../main/java/com/plotsquared/core/plot/flag/PlotFlag.java | 1 - Core/src/main/java/com/plotsquared/core/util/RegionUtil.java | 1 - .../main/java/com/plotsquared/core/util/TabCompletions.java | 1 - .../core/util/net/AbstractDelegateOutputStream.java | 1 - .../com/plotsquared/core/util/query/OwnersIncludeFilter.java | 1 - .../java/com/plotsquared/core/util/task/PlotSquaredTask.java | 1 - .../java/com/plotsquared/core/database/AbstractDBTest.java | 1 - build.gradle.kts | 3 +++ 13 files changed, 7 insertions(+), 12 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..4c7cc4031 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +* text=auto + +*.java text +*.jar binary diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitWorld.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitWorld.java index 4f9e1db38..aa1111e9a 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitWorld.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitWorld.java @@ -24,7 +24,6 @@ import org.bukkit.Bukkit; import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Map; -import java.util.Objects; public class BukkitWorld implements World { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/fawe/FaweSchematicHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/fawe/FaweSchematicHandler.java index c1b2bbd7e..be2b3a21a 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/fawe/FaweSchematicHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/fawe/FaweSchematicHandler.java @@ -80,4 +80,3 @@ public class FaweSchematicHandler extends SchematicHandler { } } - diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java index 51e8ad8fe..d8e845591 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -28,7 +28,6 @@ import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; -import com.plotsquared.core.plot.expiration.ExpireManager; import com.plotsquared.core.plot.expiration.PlotAnalysis; import com.plotsquared.core.plot.flag.GlobalFlagContainer; import com.plotsquared.core.plot.flag.PlotFlag; @@ -42,7 +41,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotWorld.java b/Core/src/main/java/com/plotsquared/core/plot/PlotWorld.java index ca4024f7a..baeebeb5b 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotWorld.java @@ -24,7 +24,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Collection; -import java.util.Objects; /** * A world that contains plots diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java index 77b1a76c3..c38eb1b88 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java @@ -24,7 +24,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Collection; import java.util.Collections; -import java.util.Objects; /** * A plot flag is any property that can be assigned diff --git a/Core/src/main/java/com/plotsquared/core/util/RegionUtil.java b/Core/src/main/java/com/plotsquared/core/util/RegionUtil.java index a0aa27275..4ee917b84 100644 --- a/Core/src/main/java/com/plotsquared/core/util/RegionUtil.java +++ b/Core/src/main/java/com/plotsquared/core/util/RegionUtil.java @@ -19,7 +19,6 @@ package com.plotsquared.core.util; import com.plotsquared.core.location.Location; -import com.plotsquared.core.plot.Plot; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; diff --git a/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java b/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java index 13e951414..65d45dc16 100644 --- a/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java +++ b/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java @@ -31,7 +31,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.uuid.UUIDMapping; import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; import java.util.ArrayList; import java.util.Arrays; diff --git a/Core/src/main/java/com/plotsquared/core/util/net/AbstractDelegateOutputStream.java b/Core/src/main/java/com/plotsquared/core/util/net/AbstractDelegateOutputStream.java index 0af0d3fee..120ba15cc 100644 --- a/Core/src/main/java/com/plotsquared/core/util/net/AbstractDelegateOutputStream.java +++ b/Core/src/main/java/com/plotsquared/core/util/net/AbstractDelegateOutputStream.java @@ -55,4 +55,3 @@ public class AbstractDelegateOutputStream extends OutputStream { } } - diff --git a/Core/src/main/java/com/plotsquared/core/util/query/OwnersIncludeFilter.java b/Core/src/main/java/com/plotsquared/core/util/query/OwnersIncludeFilter.java index 702e4a640..8a9969b3e 100644 --- a/Core/src/main/java/com/plotsquared/core/util/query/OwnersIncludeFilter.java +++ b/Core/src/main/java/com/plotsquared/core/util/query/OwnersIncludeFilter.java @@ -21,7 +21,6 @@ package com.plotsquared.core.util.query; import com.plotsquared.core.plot.Plot; import org.checkerframework.checker.nullness.qual.NonNull; -import java.util.Objects; import java.util.UUID; class OwnersIncludeFilter implements PlotFilter { diff --git a/Core/src/main/java/com/plotsquared/core/util/task/PlotSquaredTask.java b/Core/src/main/java/com/plotsquared/core/util/task/PlotSquaredTask.java index b7337d45b..25a3b440c 100644 --- a/Core/src/main/java/com/plotsquared/core/util/task/PlotSquaredTask.java +++ b/Core/src/main/java/com/plotsquared/core/util/task/PlotSquaredTask.java @@ -83,4 +83,3 @@ public interface PlotSquaredTask extends Runnable { } } - diff --git a/Core/src/test/java/com/plotsquared/core/database/AbstractDBTest.java b/Core/src/test/java/com/plotsquared/core/database/AbstractDBTest.java index d4c8c7be8..18e0a5f41 100644 --- a/Core/src/test/java/com/plotsquared/core/database/AbstractDBTest.java +++ b/Core/src/test/java/com/plotsquared/core/database/AbstractDBTest.java @@ -276,4 +276,3 @@ public class AbstractDBTest implements AbstractDB { } } - diff --git a/build.gradle.kts b/build.gradle.kts index d6d7bb50b..05e70c4d1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -90,6 +90,9 @@ subprojects { java { licenseHeaderFile(rootProject.file("HEADER.txt")) target("**/*.java") + endWithNewline() + trimTrailingWhitespace() + removeUnusedImports() } } From 63a6bdc1d688791c577d125e74bd5126eda61dd1 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 16 Jan 2023 00:18:51 +0100 Subject: [PATCH 09/32] Terminate process if `.git` folder is not a repository (#3937) Terminate process if folder is not a repository --- build.gradle.kts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 05e70c4d1..0a8df0130 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,6 +20,16 @@ plugins { group = "com.plotsquared" version = "6.10.9-SNAPSHOT" +if (!File("$rootDir/.git").exists()) { + logger.lifecycle(""" + ************************************************************************************** + You need to fork and clone this repository! Don't download a .zip file. + If you need assistance, consult the GitHub docs: https://docs.github.com/get-started/quickstart/fork-a-repo + ************************************************************************************** + """.trimIndent() + ).also { kotlin.system.exitProcess(1) } +} + subprojects { group = rootProject.group version = rootProject.version From f6f00dfcda7a63c10cdba7559fa8aee55df87b73 Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 16 Jan 2023 17:14:20 +0000 Subject: [PATCH 10/32] fix: Remove chunk#isLoaded call in BukkitChunkCoordinator (#3934) --- .../plotsquared/bukkit/queue/BukkitChunkCoordinator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java index 7e787843b..fc3ce7370 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java @@ -239,9 +239,11 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator { * server's main thread. */ private void processChunk(final @NonNull Chunk chunk) { + /* Chunk#isLoaded does not necessarily return true shortly after PaperLib#getChunkAtAsync completes, but the chunk is + still loaded. if (!chunk.isLoaded()) { - throw new IllegalArgumentException(String.format("Chunk %d;%d is is not loaded", chunk.getX(), chunk.getZ())); - } + throw new IllegalArgumentException(String.format("Chunk %d;%d is is not loaded", chunk.getX(), chunk.getZ()); + }*/ if (finished) { return; } From 07e598e48ff862bc5916cb0be651069271108c5d Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 16 Jan 2023 21:15:35 +0000 Subject: [PATCH 11/32] fix: account for exclusivity of max build height where requires (#3935) --- .../com/plotsquared/core/generator/ClassicPlotManager.java | 6 +++--- Core/src/main/java/com/plotsquared/core/plot/Plot.java | 2 +- Core/src/main/java/com/plotsquared/core/util/WEManager.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java index f7037cc24..c9eeb4485 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java @@ -144,7 +144,7 @@ public class ClassicPlotManager extends SquarePlotManager { plot.getRegions(), blocks, classicPlotWorld.getMinBuildHeight(), - classicPlotWorld.getMaxBuildHeight(), + classicPlotWorld.getMaxBuildHeight() - 1, actor, queue ); @@ -175,7 +175,7 @@ public class ClassicPlotManager extends SquarePlotManager { plot.getRegions(), blocks, classicPlotWorld.PLOT_HEIGHT + 1, - classicPlotWorld.getMaxBuildHeight(), + classicPlotWorld.getMaxBuildHeight() - 1, actor, queue ); @@ -281,7 +281,7 @@ public class ClassicPlotManager extends SquarePlotManager { } } - int maxY = classicPlotWorld.getMaxBuildHeight(); + int maxY = classicPlotWorld.getMaxBuildHeight() - 1; if (!plot.isMerged(Direction.NORTH)) { int z = bottom.getZ(); for (int x = bottom.getX(); x <= top.getX(); x++) { diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 5c90c2fad..b1c7c1f6a 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -2506,7 +2506,7 @@ public class Plot { } } int minHeight = getArea().getMinBuildHeight(); - int maxHeight = getArea().getMaxBuildHeight(); + int maxHeight = getArea().getMaxBuildHeight() - 1; Location gtopabs = this.area.getPlotAbs(top).getTopAbs(); Location gbotabs = this.area.getPlotAbs(bot).getBottomAbs(); visited.addAll(Lists.newArrayList((Iterable) PlotId.PlotRangeIterator.range(bot, top))); diff --git a/Core/src/main/java/com/plotsquared/core/util/WEManager.java b/Core/src/main/java/com/plotsquared/core/util/WEManager.java index 78a3ff8ac..377160114 100644 --- a/Core/src/main/java/com/plotsquared/core/util/WEManager.java +++ b/Core/src/main/java/com/plotsquared/core/util/WEManager.java @@ -106,7 +106,7 @@ public class WEManager { .getTrusted().contains(uuid))) && !plot.getFlag(NoWorldeditFlag.class)) { for (CuboidRegion region : plot.getRegions()) { BlockVector3 pos1 = region.getMinimumPoint().withY(area.getMinBuildHeight()); - BlockVector3 pos2 = region.getMaximumPoint().withY(area.getMaxBuildHeight()); + BlockVector3 pos2 = region.getMaximumPoint().withY(area.getMaxBuildHeight() - 1); CuboidRegion copy = new CuboidRegion(pos1, pos2); regions.add(copy); } From b79537ebbce91fe18eff9bf10f34c4a826b2bf26 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 17 Jan 2023 12:59:16 +0000 Subject: [PATCH 12/32] Clean up merge --- Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index 0ff12ab4c..6bb9e1bad 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -57,6 +57,7 @@ import com.sk89q.worldedit.world.item.ItemType; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.tag.Tag; import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; import net.kyori.adventure.title.Title; import org.apache.logging.log4j.LogManager; @@ -205,7 +206,7 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, if (notify) { sendMessage( TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", permission) + TagResolver.resolver("node", Tag.inserting(Component.text(permission))) ); } return false; From 746028afbcda89e5441161d4cc54f1c769eb5bdb Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 17 Jan 2023 13:25:46 +0000 Subject: [PATCH 13/32] *Actually clean up --- .../com/plotsquared/bukkit/listener/BlockEventListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index 0d3ff90f1..d04b8db4c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -1288,7 +1288,7 @@ public class BlockEventListener implements Listener { event.setCancelled(true); break; } - if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { + if (pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { continue; } if (currentLocation.getY() >= area.getMaxBuildHeight() || currentLocation.getY() < area.getMinBuildHeight()) { From c45bbe3ec523121f9ed2717cd703a735214ef678 Mon Sep 17 00:00:00 2001 From: Jordan Date: Thu, 19 Jan 2023 08:01:06 +0000 Subject: [PATCH 14/32] fix: ensure plots are fully unlinked before the clear itself is run (#3933) * fix: ensure plots are fully unlinked before the clear itself is run * Update Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java Co-authored-by: Alexander Brandes --- .../core/plot/PlotModificationManager.java | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java index cfab430b8..c170dec7e 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java @@ -220,17 +220,6 @@ public final class PlotModificationManager { if (isDelete) { this.removeSign(); } - PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher() - .callUnlink( - this.plot.getArea(), - this.plot, - true, - !isDelete, - isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR - ); - if (event.getEventResult() != Result.DENY && this.unlinkPlot(event.isCreateRoad(), event.isCreateSign())) { - PlotSquared.get().getEventDispatcher().callPostUnlink(plot, event.getReason()); - } final PlotManager manager = this.plot.getArea().getPlotManager(); Runnable run = new Runnable() { @Override @@ -281,7 +270,21 @@ public final class PlotModificationManager { manager.clearPlot(current, this, actor, null); } }; - run.run(); + PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher() + .callUnlink( + this.plot.getArea(), + this.plot, + true, + !isDelete, + isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR + ); + if (event.getEventResult() != Result.DENY) { + if (this.unlinkPlot(event.isCreateRoad(), event.isCreateSign(), run)) { + PlotSquared.get().getEventDispatcher().callPostUnlink(plot, event.getReason()); + } + } else { + run.run(); + } return true; } @@ -321,7 +324,23 @@ public final class PlotModificationManager { * @return success/!cancelled */ public boolean unlinkPlot(final boolean createRoad, final boolean createSign) { + return unlinkPlot(createRoad, createSign, null); + } + + /** + * Unlink the plot and all connected plots. + * + * @param createRoad whether to recreate road + * @param createSign whether to recreate signs + * @param whenDone Task to run when unlink is complete + * @return success/!cancelled + * @since TODO + */ + public boolean unlinkPlot(final boolean createRoad, final boolean createSign, final Runnable whenDone) { if (!this.plot.isMerged()) { + if (whenDone != null) { + whenDone.run(); + } return false; } final Set plots = this.plot.getConnectedPlots(); @@ -366,14 +385,17 @@ public final class PlotModificationManager { current.getPlotModificationManager().setSign(PlayerManager.resolveName(current.getOwnerAbs()).getComponent( LocaleHolder.console())); } + if (whenDone != null) { + TaskManager.runTask(whenDone); + } })); + } else if (whenDone != null) { + queue.setCompleteTask(whenDone); } if (createRoad) { manager.finishPlotUnlink(ids, queue); } - if (queue != null) { - queue.enqueue(); - } + queue.enqueue(); return true; } From 5af8be4293293762fd580d5a66a6400d6612f44b Mon Sep 17 00:00:00 2001 From: Jordan Date: Sat, 21 Jan 2023 15:44:28 +0000 Subject: [PATCH 15/32] chore: Remove things marked as for removal (#3941) * chore: Remove things marked as for removal * Address feedback Co-authored-by: Alexander Brandes --- .../bukkit/generator/BlockStatePopulator.java | 12 -- .../bukkit/listener/PaperListener113.java | 93 ----------- .../bukkit/player/BukkitPlayer.java | 28 +--- .../bukkit/player/BukkitPlayerManager.java | 4 +- .../bukkit/schematic/StateWrapper.java | 30 ---- .../core/events/PlayerAutoPlotEvent.java | 32 ---- .../core/generator/HybridPlotWorld.java | 30 +--- .../com/plotsquared/core/plot/PlotId.java | 11 -- .../core/plot/expiration/ExpireManager.java | 6 - .../plotsquared/core/util/Permissions.java | 150 ------------------ 10 files changed, 7 insertions(+), 389 deletions(-) delete mode 100644 Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java delete mode 100644 Core/src/main/java/com/plotsquared/core/util/Permissions.java diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java index f2e0dfb5d..3280eedb9 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BlockStatePopulator.java @@ -24,7 +24,6 @@ import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.location.Location; import com.plotsquared.core.location.UncheckedWorldLocation; import com.plotsquared.core.plot.PlotArea; -import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator; import org.bukkit.generator.BlockPopulator; @@ -47,17 +46,6 @@ final class BlockStatePopulator extends BlockPopulator { this.plotGenerator = plotGenerator; } - /** - * @deprecated Use {@link BlockStatePopulator#BlockStatePopulator(IndependentPlotGenerator)} as plotAreManager is unused - */ - @Deprecated(forRemoval = true, since = "6.9.0") - public BlockStatePopulator( - final @NonNull IndependentPlotGenerator plotGenerator, - final @NonNull PlotAreaManager plotAreaManager - ) { - this.plotGenerator = plotGenerator; - } - @Override public void populate( @NonNull final WorldInfo worldInfo, diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java deleted file mode 100644 index 4542abb75..000000000 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * PlotSquared, a land and world management plugin for Minecraft. - * Copyright (C) IntellectualSites - * Copyright (C) IntellectualSites team and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.plotsquared.bukkit.listener; - -import com.google.inject.Inject; -import com.plotsquared.bukkit.util.BukkitUtil; -import com.plotsquared.core.configuration.Settings; -import com.plotsquared.core.configuration.caption.TranslatableCaption; -import com.plotsquared.core.location.Location; -import com.plotsquared.core.player.PlotPlayer; -import com.plotsquared.core.plot.PlotArea; -import com.plotsquared.core.plot.world.PlotAreaManager; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.minimessage.tag.Tag; -import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; -import org.bukkit.block.Banner; -import org.bukkit.block.Beacon; -import org.bukkit.block.BlockState; -import org.bukkit.block.CommandBlock; -import org.bukkit.block.Comparator; -import org.bukkit.block.Conduit; -import org.bukkit.block.Container; -import org.bukkit.block.CreatureSpawner; -import org.bukkit.block.DaylightDetector; -import org.bukkit.block.EnchantingTable; -import org.bukkit.block.EndGateway; -import org.bukkit.block.EnderChest; -import org.bukkit.block.Jukebox; -import org.bukkit.block.Sign; -import org.bukkit.block.Skull; -import org.bukkit.block.Structure; -import org.bukkit.block.data.type.Bed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockPlaceEvent; -import org.checkerframework.checker.nullness.qual.NonNull; - -/** - * @deprecated P2 effectively no longer supports 1.13 - */ -@Deprecated(forRemoval = true, since = "6.10.4") -public class PaperListener113 extends PaperListener { - - @Inject - public PaperListener113(@NonNull PlotAreaManager plotAreaManager) { - super(plotAreaManager); - } - - @EventHandler - public void onBlockPlace(BlockPlaceEvent event) { - if (!Settings.Paper_Components.TILE_ENTITY_CHECK || !Settings.Enabled_Components.CHUNK_PROCESSOR) { - return; - } - BlockState state = event.getBlock().getState(false); - if (!(state instanceof Banner || state instanceof Beacon || state instanceof Bed || state instanceof CommandBlock - || state instanceof Comparator || state instanceof Conduit || state instanceof Container || state instanceof CreatureSpawner - || state instanceof DaylightDetector || state instanceof EnchantingTable || state instanceof EnderChest || state instanceof EndGateway - || state instanceof Jukebox || state instanceof Sign || state instanceof Skull || state instanceof Structure)) { - return; - } - final Location location = BukkitUtil.adapt(event.getBlock().getLocation()); - final PlotArea plotArea = location.getPlotArea(); - if (plotArea == null) { - return; - } - final int tileEntityCount = event.getBlock().getChunk().getTileEntities(false).length; - if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) { - final PlotPlayer plotPlayer = BukkitUtil.adapt(event.getPlayer()); - plotPlayer.sendMessage( - TranslatableCaption.of("errors.tile_entity_cap_reached"), - TagResolver.resolver("amount", Tag.inserting(Component.text(Settings.Chunk_Processor.MAX_TILES))) - ); - event.setCancelled(true); - event.setBuild(false); - } - } - -} diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index 268258ead..04c41d701 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -71,31 +71,11 @@ public class BukkitPlayer extends PlotPlayer { * @param eventDispatcher EventDispatcher instance * @param player Bukkit player instance * @param permissionHandler PermissionHandler instance - * - * @deprecated Please do not use this method. Instead use {@link BukkitUtil#adapt(Player)}, as it caches player objects. - * This method will be made private in a future release. */ - @Deprecated(forRemoval = true, since = "TODO") - public BukkitPlayer( - final @NonNull PlotAreaManager plotAreaManager, final @NonNull EventDispatcher eventDispatcher, - final @NonNull Player player, final @NonNull PermissionHandler permissionHandler - ) { - this(plotAreaManager, eventDispatcher, player, false, permissionHandler); - } - - /** - * @param plotAreaManager PlotAreaManager instance - * @param eventDispatcher EventDispatcher instance - * @param player Bukkit player instance - * @param permissionHandler PermissionHandler instance - * - * @deprecated Please do not use this method. Instead use {@link BukkitUtil#adapt(Player)}, as it caches player objects. - * This method will be made private in a future release. - */ - @Deprecated(forRemoval = true, since = "TODO") - public BukkitPlayer( - final @NonNull PlotAreaManager plotAreaManager, final @NonNull - EventDispatcher eventDispatcher, final @NonNull Player player, + BukkitPlayer( + final @NonNull PlotAreaManager plotAreaManager, + final @NonNull EventDispatcher eventDispatcher, + final @NonNull Player player, final boolean realPlayer, final @NonNull PermissionHandler permissionHandler ) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java index a1a675598..cb598983c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java @@ -54,7 +54,6 @@ public class BukkitPlayerManager extends PlayerManager { @NonNull @Override - @SuppressWarnings("deprecation") public BukkitPlayer getPlayer(final @NonNull Player object) { if (object.getUniqueId().version() == 2) { // not a real player return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, object, false, this.permissionHandler); @@ -66,13 +65,12 @@ public class BukkitPlayerManager extends PlayerManager { } @Override - @SuppressWarnings("deprecation") public @NonNull BukkitPlayer createPlayer(final @NonNull UUID uuid) { final Player player = Bukkit.getPlayer(uuid); if (player == null || !player.isOnline()) { throw new NoSuchPlayerException(uuid); } - return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, player, this.permissionHandler); + return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, player, false, this.permissionHandler); } @Nullable diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java index c37e8e92d..b50208af8 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/schematic/StateWrapper.java @@ -37,7 +37,6 @@ import org.bukkit.block.Sign; import org.bukkit.block.Skull; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.checkerframework.checker.nullness.qual.NonNull; @@ -52,15 +51,6 @@ public class StateWrapper { public org.bukkit.block.BlockState state = null; public CompoundTag tag = null; - /** - * @deprecated in favour of using WE methods for obtaining NBT, specifically by obtaining a - * {@link com.sk89q.worldedit.world.block.BaseBlock} and then using {@link com.sk89q.worldedit.world.block.BaseBlock#getNbtData()} - */ - @Deprecated(forRemoval = true, since = "6.9.0") - public StateWrapper(org.bukkit.block.BlockState state) { - this.state = state; - } - public StateWrapper(CompoundTag tag) { this.tag = tag; } @@ -254,26 +244,6 @@ public class StateWrapper { return false; } - /** - * Get a CompoundTag of the contents of a block's inventory (chest, furnace, etc.). - * - * @deprecated in favour of using WorldEdit methods for obtaining NBT, specifically by obtaining a - * {@link com.sk89q.worldedit.world.block.BaseBlock} and then using {@link com.sk89q.worldedit.world.block.BaseBlock#getNbtData()} - */ - @Deprecated(forRemoval = true, since = "6.9.0") - public CompoundTag getTag() { - if (this.tag != null) { - return this.tag; - } - if (this.state instanceof InventoryHolder inv) { - ItemStack[] contents = inv.getInventory().getContents(); - Map values = new HashMap<>(); - values.put("Items", new ListTag(CompoundTag.class, serializeInventory(contents))); - return new CompoundTag(values); - } - return null; - } - public String getId() { String tileid = this.tag.getString("id").toLowerCase(); if (tileid.startsWith("minecraft:")) { diff --git a/Core/src/main/java/com/plotsquared/core/events/PlayerAutoPlotEvent.java b/Core/src/main/java/com/plotsquared/core/events/PlayerAutoPlotEvent.java index 03e9b10f9..97b4cd5fb 100644 --- a/Core/src/main/java/com/plotsquared/core/events/PlayerAutoPlotEvent.java +++ b/Core/src/main/java/com/plotsquared/core/events/PlayerAutoPlotEvent.java @@ -105,38 +105,6 @@ public class PlayerAutoPlotEvent extends PlotEvent implements CancellablePlotEve return this.plotArea; } - /** - * @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeX()} - */ - @Deprecated(forRemoval = true, since = "6.1.0") - public int getSize_x() { - return getSizeX(); - } - - /** - * @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeX(int)} - */ - @Deprecated(forRemoval = true, since = "6.1.0") - public void setSize_x(int sizeX) { - setSizeX(sizeX); - } - - /** - * @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeZ()} - */ - @Deprecated(forRemoval = true, since = "6.1.0") - public int getSize_z() { - return getSizeZ(); - } - - /** - * @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeZ(int)} - */ - @Deprecated(forRemoval = true, since = "6.1.0") - public void setSize_z(int sizeZ) { - setSizeZ(sizeZ); - } - /** * Get the x size of the auto-area * diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java index 532cc691a..efa145e54 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java @@ -68,8 +68,6 @@ public class HybridPlotWorld extends ClassicPlotWorld { private static final AffineTransform transform = new AffineTransform().rotateY(90); public boolean ROAD_SCHEMATIC_ENABLED; public boolean PLOT_SCHEMATIC = false; - @Deprecated(forRemoval = true, since = "6.9.0") - public int PLOT_SCHEMATIC_HEIGHT = -1; public short PATH_WIDTH_LOWER; public short PATH_WIDTH_UPPER; public HashMap G_SCH; @@ -104,22 +102,6 @@ public class HybridPlotWorld extends ClassicPlotWorld { PlotSquared.platform().injector().injectMembers(this); } - @Deprecated(forRemoval = true, since = "6.9.0") - public static byte wrap(byte data, int start) { - if ((data >= start) && (data < (start + 4))) { - data = (byte) ((((data - start) + 2) & 3) + start); - } - return data; - } - - @Deprecated(forRemoval = true, since = "6.9.0") - public static byte wrap2(byte data, int start) { - if ((data >= start) && (data < (start + 2))) { - data = (byte) ((((data - start) + 1) & 1) + start); - } - return data; - } - public static BaseBlock rotate(BaseBlock id) { CompoundTag tag = id.getNbtData(); @@ -486,11 +468,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { } } - /** - * @deprecated This method should not be available for public API usage and will be made private. - */ - @Deprecated(forRemoval = true, since = "6.10.2") - public void addOverlayBlock(short x, short y, short z, BaseBlock id, boolean rotate, int height) { + private void addOverlayBlock(short x, short y, short z, BaseBlock id, boolean rotate, int height) { if (z < 0) { z += this.SIZE; } else if (z >= this.SIZE) { @@ -521,11 +499,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { existing[y] = id; } - /** - * @deprecated This method should not be available for public API usage and will be made private. - */ - @Deprecated(forRemoval = true, since = "6.10.2") - public void addOverlayBiome(short x, short z, BiomeType id) { + private void addOverlayBiome(short x, short z, BiomeType id) { if (z < 0) { z += this.SIZE; } else if (z >= this.SIZE) { diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotId.java b/Core/src/main/java/com/plotsquared/core/plot/PlotId.java index 62077ccb9..b0ce3ffed 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotId.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotId.java @@ -106,17 +106,6 @@ public final class PlotId { return PlotId.of(hash >> 16, hash & 0xFFFF); } - /** - * Get a copy of the plot ID - * - * @return Plot ID copy - * @deprecated PlotId is immutable, copy is not required. - */ - @Deprecated(forRemoval = true, since = "6.10.2") - public @NonNull PlotId copy() { - return this; - } - /** * Get the ID X component * diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java index 388d58fc3..81b0555e1 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java @@ -19,7 +19,6 @@ package com.plotsquared.core.plot.expiration; import com.google.inject.Inject; -import com.plotsquared.core.PlotPlatform; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.caption.Caption; import com.plotsquared.core.configuration.caption.TranslatableCaption; @@ -63,11 +62,6 @@ import java.util.concurrent.ConcurrentLinkedDeque; public class ExpireManager { - /** - * @deprecated Use {@link PlotPlatform#expireManager()} instead - */ - @Deprecated(forRemoval = true, since = "6.10.2") - public static ExpireManager IMP; private final ConcurrentHashMap dates_cache; private final ConcurrentHashMap account_age_cache; private final EventDispatcher eventDispatcher; diff --git a/Core/src/main/java/com/plotsquared/core/util/Permissions.java b/Core/src/main/java/com/plotsquared/core/util/Permissions.java deleted file mode 100644 index 92b730320..000000000 --- a/Core/src/main/java/com/plotsquared/core/util/Permissions.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * PlotSquared, a land and world management plugin for Minecraft. - * Copyright (C) IntellectualSites - * Copyright (C) IntellectualSites team and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.plotsquared.core.util; - -import com.plotsquared.core.configuration.Settings; -import com.plotsquared.core.configuration.caption.TranslatableCaption; -import com.plotsquared.core.permissions.Permission; -import com.plotsquared.core.permissions.PermissionHolder; -import com.plotsquared.core.player.PlotPlayer; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.minimessage.tag.Tag; -import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; -import org.checkerframework.checker.nullness.qual.NonNull; - -/** - * The Permissions class handles checking user permissions.
- * - This will respect * nodes and plots.admin and can be used to check permission ranges (e.g. plots.plot.5)
- * - Checking the PlotPlayer class directly will not take the above into account
- * - * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes - */ -@Deprecated(forRemoval = true, since = "6.9.3") -public class Permissions { - - /** - * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes. Use {@link PlotPlayer#hasPermission(String, boolean)} - */ - @Deprecated(forRemoval = true, since = "6.9.3") - public static boolean hasPermission(PlotPlayer player, Permission permission, boolean notify) { - return hasPermission(player, permission.toString(), notify); - } - - /** - * Check if the owner of the profile has a given (global) permission - * - * @param caller permission holder - * @param permission Permission - * @return {@code true} if the owner has the given permission, else {@code false} - * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes. Use {@link PermissionHolder#hasPermission(Permission)} - */ - @Deprecated(forRemoval = true, since = "6.9.3") - public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull Permission permission) { - return caller.hasPermission(permission.toString()); - } - - /** - * Check if the owner of the profile has a given (global) permission. There is no guarantee that per-world permissions will - * be checked because unmaintained crap plugins like PEX exist. - * - * @param caller permission holder - * @param permission Permission - * @return {@code true} if the owner has the given permission, else {@code false} - * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes. Use {@link PermissionHolder#hasPermission(String)} - */ - @Deprecated(forRemoval = true, since = "6.9.3") - public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull String permission) { - return caller.hasPermission(permission); - } - - /** - * Check if the owner of the profile has a given (global) keyed permission. Checks both {@code permission.key} - * and {@code permission.*} - * - * @param caller permission holder - * @param permission Permission - * @param key Permission "key" - * @return {@code true} if the owner has the given permission, else {@code false} - * @since 6.0.10 - * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes. Use {@link PermissionHolder#hasKeyedPermission(String, String)} - */ - @Deprecated(forRemoval = true, since = "6.9.3") - public static boolean hasKeyedPermission( - final @NonNull PermissionHolder caller, final @NonNull String permission, - final @NonNull String key - ) { - return caller.hasKeyedPermission(permission, key); - } - - /** - * Checks if a PlotPlayer has a permission, and optionally send the no permission message if applicable. - * - * @param player permission holder - * @param permission permission - * @param notify if to notify the permission holder - * @return if permission is had - * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes. Use {@link PlotPlayer#hasPermission(String, boolean)} - */ - @Deprecated(forRemoval = true, since = "6.9.3") - public static boolean hasPermission(PlotPlayer player, String permission, boolean notify) { - if (!hasPermission(player, permission)) { - if (notify) { - player.sendMessage( - TranslatableCaption.of("permission.no_permission_event"), - TagResolver.resolver("node", Tag.inserting(Component.text(permission))) - ); - } - return false; - } - return true; - } - - /** - * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes. Use {@link PlotPlayer#hasPermissionRange(Permission, int)} - */ - @Deprecated(forRemoval = true, since = "6.9.3") - public static int hasPermissionRange(PlotPlayer player, Permission Permission, int range) { - return hasPermissionRange(player, Permission.toString(), range); - } - - /** - * Check the highest permission a PlotPlayer has within a specified range.
- * - Excessively high values will lag
- * - The default range that is checked is {@link Settings.Limit#MAX_PLOTS}
- * - * @param player Player to check for - * @param stub The permission stub to check e.g. for `plots.plot.#` the stub is `plots.plot` - * @param range The range to check - * @return The highest permission they have within that range - * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed - * classes. Use {@link PlotPlayer#hasPermissionRange(String, int)} - */ - @Deprecated(forRemoval = true, since = "6.9.3") - public static int hasPermissionRange(PlotPlayer player, String stub, int range) { - return player.hasPermissionRange(stub, range); - } - -} From 0558fcf5d5759867f70435a3038e78dff108726c Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sat, 21 Jan 2023 22:27:20 +0100 Subject: [PATCH 16/32] Provide full verbosity for invalid components --- .../java/com/plotsquared/core/components/ComponentPreset.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java index 5f6a37d44..cb1e989c4 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPreset.java @@ -62,7 +62,7 @@ public class ComponentPreset implements ConfigurationSerializable { public static ComponentPreset deserialize(final @NonNull Map map) { final ClassicPlotManagerComponent classicPlotManagerComponent = ClassicPlotManagerComponent .fromString(map.getOrDefault("component", "").toString()).orElseThrow(() -> - new IllegalArgumentException("The preset needs a valid target component")); + new IllegalArgumentException("The preset in components.yml needs a valid target component, got: " + map.get("component"))); final String pattern = map.getOrDefault("pattern", "").toString(); final double cost = Double.parseDouble(map.getOrDefault("cost", "0.0").toString()); final String permission = map.getOrDefault("permission", "").toString(); From 0dd8b1053cfac7b137dc04e254dbe0582d77a6d3 Mon Sep 17 00:00:00 2001 From: Matthew Kaulfers <42121989+mkaulfers@users.noreply.github.com> Date: Sat, 21 Jan 2023 17:02:15 -0600 Subject: [PATCH 17/32] PS-3908: Cleanup deprecated methods to improve code maturity. (#3944) https://github.com/IntellectualSites/PlotSquared/issues/3908 --- .../main/java/com/plotsquared/core/command/Area.java | 11 +++++++---- .../plotsquared/core/generator/HybridPlotWorld.java | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Area.java b/Core/src/main/java/com/plotsquared/core/command/Area.java index 093ca744d..5d9925f1a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Area.java +++ b/Core/src/main/java/com/plotsquared/core/command/Area.java @@ -56,6 +56,7 @@ import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.task.RunnableVal3; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.EditSessionBuilder; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; @@ -228,12 +229,14 @@ public class Area extends SubCommand { try (final ClipboardWriter clipboardWriter = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream( file))) { final BlockArrayClipboard clipboard = new BlockArrayClipboard(selectedRegion); - final EditSession editSession = WorldEdit - .getInstance() - .getEditSessionFactory() - .getEditSession(selectedRegion.getWorld(), -1); + + EditSessionBuilder editSessionBuilder = WorldEdit.getInstance().newEditSessionBuilder(); + editSessionBuilder.world(selectedRegion.getWorld()); + final EditSession editSession = editSessionBuilder.build(); + final ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, selectedRegion, clipboard, selectedRegion.getMinimumPoint()); + forwardExtentCopy.setCopyingBiomes(true); forwardExtentCopy.setCopyingEntities(true); Operations.complete(forwardExtentCopy); diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java index 532cc691a..37a56329e 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java @@ -204,7 +204,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { } Object value; try { - final boolean accessible = field.isAccessible(); + final boolean accessible = field.canAccess(field); field.setAccessible(true); value = field.get(this); field.setAccessible(accessible); From 83e274ff9f103156e47c0255c655f3ab0d38c877 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 22 Jan 2023 11:21:01 +0100 Subject: [PATCH 18/32] Revert "PS-3908: Cleanup deprecated methods to improve code maturity. (#3944)" This reverts commit 0dd8b1053cfac7b137dc04e254dbe0582d77a6d3. --- .../main/java/com/plotsquared/core/command/Area.java | 11 ++++------- .../plotsquared/core/generator/HybridPlotWorld.java | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Area.java b/Core/src/main/java/com/plotsquared/core/command/Area.java index 5d9925f1a..093ca744d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Area.java +++ b/Core/src/main/java/com/plotsquared/core/command/Area.java @@ -56,7 +56,6 @@ import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.task.RunnableVal3; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.EditSessionBuilder; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; @@ -229,14 +228,12 @@ public class Area extends SubCommand { try (final ClipboardWriter clipboardWriter = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream( file))) { final BlockArrayClipboard clipboard = new BlockArrayClipboard(selectedRegion); - - EditSessionBuilder editSessionBuilder = WorldEdit.getInstance().newEditSessionBuilder(); - editSessionBuilder.world(selectedRegion.getWorld()); - final EditSession editSession = editSessionBuilder.build(); - + final EditSession editSession = WorldEdit + .getInstance() + .getEditSessionFactory() + .getEditSession(selectedRegion.getWorld(), -1); final ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, selectedRegion, clipboard, selectedRegion.getMinimumPoint()); - forwardExtentCopy.setCopyingBiomes(true); forwardExtentCopy.setCopyingEntities(true); Operations.complete(forwardExtentCopy); diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java index 37a56329e..532cc691a 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java @@ -204,7 +204,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { } Object value; try { - final boolean accessible = field.canAccess(field); + final boolean accessible = field.isAccessible(); field.setAccessible(true); value = field.get(this); field.setAccessible(accessible); From 08800ec16daf1398c47fe191047a32764151a5f3 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 22 Jan 2023 11:26:07 +0100 Subject: [PATCH 19/32] Cleanup deperecated WorldEdit met Co-authored-by: Matthew Kaulfers <42121989+mkaulfers@users.noreply.github.com> --- Core/src/main/java/com/plotsquared/core/command/Area.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Area.java b/Core/src/main/java/com/plotsquared/core/command/Area.java index 093ca744d..32e6d7ea6 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Area.java +++ b/Core/src/main/java/com/plotsquared/core/command/Area.java @@ -56,6 +56,7 @@ import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.task.RunnableVal3; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.EditSessionBuilder; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; @@ -228,10 +229,9 @@ public class Area extends SubCommand { try (final ClipboardWriter clipboardWriter = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream( file))) { final BlockArrayClipboard clipboard = new BlockArrayClipboard(selectedRegion); - final EditSession editSession = WorldEdit - .getInstance() - .getEditSessionFactory() - .getEditSession(selectedRegion.getWorld(), -1); + EditSessionBuilder editSessionBuilder = WorldEdit.getInstance().newEditSessionBuilder(); + editSessionBuilder.world(selectedRegion.getWorld()); + final EditSession editSession = editSessionBuilder.build(); final ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(editSession, selectedRegion, clipboard, selectedRegion.getMinimumPoint()); forwardExtentCopy.setCopyingBiomes(true); From be8903128df2c1f5c8af7f37e579886c5cfb5084 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 23 Jan 2023 12:28:33 +0100 Subject: [PATCH 20/32] Release 6.10.9 --- .../main/java/com/plotsquared/bukkit/player/BukkitPlayer.java | 4 ++-- .../com/plotsquared/core/plot/PlotModificationManager.java | 2 +- build.gradle.kts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index 268258ead..75aeb647a 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -75,7 +75,7 @@ public class BukkitPlayer extends PlotPlayer { * @deprecated Please do not use this method. Instead use {@link BukkitUtil#adapt(Player)}, as it caches player objects. * This method will be made private in a future release. */ - @Deprecated(forRemoval = true, since = "TODO") + @Deprecated(forRemoval = true, since = "6.10.9") public BukkitPlayer( final @NonNull PlotAreaManager plotAreaManager, final @NonNull EventDispatcher eventDispatcher, final @NonNull Player player, final @NonNull PermissionHandler permissionHandler @@ -92,7 +92,7 @@ public class BukkitPlayer extends PlotPlayer { * @deprecated Please do not use this method. Instead use {@link BukkitUtil#adapt(Player)}, as it caches player objects. * This method will be made private in a future release. */ - @Deprecated(forRemoval = true, since = "TODO") + @Deprecated(forRemoval = true, since = "6.10.9") public BukkitPlayer( final @NonNull PlotAreaManager plotAreaManager, final @NonNull EventDispatcher eventDispatcher, final @NonNull Player player, diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java index c170dec7e..81a2f740b 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java @@ -334,7 +334,7 @@ public final class PlotModificationManager { * @param createSign whether to recreate signs * @param whenDone Task to run when unlink is complete * @return success/!cancelled - * @since TODO + * @since 6.10.9 */ public boolean unlinkPlot(final boolean createRoad, final boolean createSign, final Runnable whenDone) { if (!this.plot.isMerged()) { diff --git a/build.gradle.kts b/build.gradle.kts index 0a8df0130..bdfdc7923 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ plugins { } group = "com.plotsquared" -version = "6.10.9-SNAPSHOT" +version = "6.10.9" if (!File("$rootDir/.git").exists()) { logger.lifecycle(""" From b40383b5a4322cdb0b008c55aa98ee1c7100f238 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 23 Jan 2023 12:33:51 +0100 Subject: [PATCH 21/32] Back to snapshot for development --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index bdfdc7923..3ef77914f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ plugins { } group = "com.plotsquared" -version = "6.10.9" +version = "6.10.10-SNAPSHOT" if (!File("$rootDir/.git").exists()) { logger.lifecycle(""" From bed62edc02abe662ad97be48728c294c8ca8d9a4 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 23 Jan 2023 13:03:26 +0100 Subject: [PATCH 22/32] Resolved conflicts --- .../bukkit/player/BukkitPlayer.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index 48c9fed09..04c41d701 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -72,34 +72,10 @@ public class BukkitPlayer extends PlotPlayer { * @param player Bukkit player instance * @param permissionHandler PermissionHandler instance */ -<<<<<<< HEAD BukkitPlayer( final @NonNull PlotAreaManager plotAreaManager, final @NonNull EventDispatcher eventDispatcher, final @NonNull Player player, -======= - @Deprecated(forRemoval = true, since = "6.10.9") - public BukkitPlayer( - final @NonNull PlotAreaManager plotAreaManager, final @NonNull EventDispatcher eventDispatcher, - final @NonNull Player player, final @NonNull PermissionHandler permissionHandler - ) { - this(plotAreaManager, eventDispatcher, player, false, permissionHandler); - } - - /** - * @param plotAreaManager PlotAreaManager instance - * @param eventDispatcher EventDispatcher instance - * @param player Bukkit player instance - * @param permissionHandler PermissionHandler instance - * - * @deprecated Please do not use this method. Instead use {@link BukkitUtil#adapt(Player)}, as it caches player objects. - * This method will be made private in a future release. - */ - @Deprecated(forRemoval = true, since = "6.10.9") - public BukkitPlayer( - final @NonNull PlotAreaManager plotAreaManager, final @NonNull - EventDispatcher eventDispatcher, final @NonNull Player player, ->>>>>>> v6 final boolean realPlayer, final @NonNull PermissionHandler permissionHandler ) { From 57875885000338934b39dcbc6dafda7762121b16 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 23 Jan 2023 13:18:20 +0100 Subject: [PATCH 23/32] Move BukkitPlotGenerator#generateChunkData() deprecation from v7 to v6 --- .../plotsquared/bukkit/generator/BukkitPlotGenerator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index 38e29ef3b..a9f0c43b0 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -161,6 +161,12 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap world.setWaterAnimalSpawnLimit(limit); } + /** + * The entire method is deprecated, but kept for compatibility with <=1.16.2. + * The method will be removed in future versions, because WorldEdit and FastAsyncWorldEdit only support the latest point + * release. + */ + @Deprecated(forRemoval = true, since = "TODO") @Override public @NonNull ChunkData generateChunkData( @NonNull World world, @NonNull Random random, int x, int z, From 26692d6633b742b2e8af398c883b111887529fd9 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 23 Jan 2023 13:27:08 +0100 Subject: [PATCH 24/32] Cleanup deprecated methods --- .../core/configuration/Settings.java | 16 ---- .../core/generator/HybridPlotWorld.java | 8 -- .../core/util/SchematicHandler.java | 96 ------------------- 3 files changed, 120 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index 025c779ee..e3cb35bd1 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -433,22 +433,6 @@ public class Settings extends Config { } - - @Deprecated(forRemoval = true, since = "6.0.0") - @Comment("Schematic interface related settings") - public static class Web { - - @Comment({"The web interface for schematics", " - All schematics are anonymous and private", - " - Downloads can be deleted by the user", - " - Supports plot uploads, downloads and saves",}) - public static String URL = - "https://schem.intellectualsites.com/plots/"; - @Comment({"Whether or not the legacy web interface will be used for /plot download and /plot save", - "Note that this will be removed in future versions. Updating to Arkitektonika is highly suggested"}) - public static boolean LEGACY_WEBINTERFACE = false; - - } - @Comment("Schematic web interface related settings") public static class Arkitektonika { diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java index efa145e54..2a7e8b4da 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java @@ -544,14 +544,6 @@ public class HybridPlotWorld extends ClassicPlotWorld { return schem1PopulationNeeded || schem2PopulationNeeded || schem3PopulationNeeded; } - /** - * @deprecated in favour of {@link HybridPlotWorld#getSchematicRoot()} - */ - @Deprecated(forRemoval = true, since = "6.9.0") - public File getRoot() { - return this.root; - } - /** * Get the root folder for this world's generation schematics. May be null if schematics not initialised via * {@link HybridPlotWorld#setupSchematics()} diff --git a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java index f266a8114..d7822a280 100644 --- a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java +++ b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java @@ -120,84 +120,6 @@ public abstract class SchematicHandler { this.subscriberFactory = subscriberFactory; } - @Deprecated(forRemoval = true, since = "6.0.0") - public static void upload( - @Nullable UUID uuid, - final @Nullable String file, - final @NonNull String extension, - final @Nullable RunnableVal writeTask, - final @NonNull RunnableVal whenDone - ) { - if (writeTask == null) { - TaskManager.runTask(whenDone); - return; - } - final String filename; - final String website; - if (uuid == null) { - uuid = UUID.randomUUID(); - website = Settings.Web.URL + "upload.php?" + uuid; - filename = "plot." + extension; - } else { - website = Settings.Web.URL + "save.php?" + uuid; - filename = file + '.' + extension; - } - final URL url; - try { - url = new URL(Settings.Web.URL + "?key=" + uuid + "&type=" + extension); - } catch (MalformedURLException e) { - e.printStackTrace(); - whenDone.run(); - return; - } - TaskManager.runTaskAsync(() -> { - try { - String boundary = Long.toHexString(System.currentTimeMillis()); - URLConnection con = new URL(website).openConnection(); - con.setDoOutput(true); - con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); - try (OutputStream output = con.getOutputStream(); - PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true)) { - String CRLF = "\r\n"; - writer.append("--").append(boundary).append(CRLF); - writer.append("Content-Disposition: form-data; name=\"param\"").append(CRLF); - writer.append("Content-Type: text/plain; charset=").append(StandardCharsets.UTF_8.displayName()).append(CRLF); - String param = "value"; - writer.append(CRLF).append(param).append(CRLF).flush(); - writer.append("--").append(boundary).append(CRLF); - writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"").append(filename) - .append(String.valueOf('"')).append(CRLF); - writer.append("Content-Type: ").append(URLConnection.guessContentTypeFromName(filename)).append(CRLF); - writer.append("Content-Transfer-Encoding: binary").append(CRLF); - writer.append(CRLF).flush(); - writeTask.value = new AbstractDelegateOutputStream(output) { - @Override - public void close() { - } // Don't close - }; - writeTask.run(); - output.flush(); - writer.append(CRLF).flush(); - writer.append("--").append(boundary).append("--").append(CRLF).flush(); - } - String content; - try (Scanner scanner = new Scanner(con.getInputStream()).useDelimiter("\\A")) { - content = scanner.next().trim(); - } - if (!content.startsWith("<")) { - } - int responseCode = ((HttpURLConnection) con).getResponseCode(); - if (responseCode == 200) { - whenDone.value = url; - } - TaskManager.runTask(whenDone); - } catch (IOException e) { - e.printStackTrace(); - TaskManager.runTask(whenDone); - } - }); - } - public boolean exportAll( Collection collection, final File outputDir, @@ -514,24 +436,6 @@ public abstract class SchematicHandler { return null; } - @Deprecated(forRemoval = true, since = "6.0.0") - public void upload(final CompoundTag tag, UUID uuid, String file, RunnableVal whenDone) { - if (tag == null) { - TaskManager.runTask(whenDone); - return; - } - upload(uuid, file, "schem", new RunnableVal<>() { - @Override - public void run(OutputStream output) { - try (NBTOutputStream nos = new NBTOutputStream(new GZIPOutputStream(output, true))) { - nos.writeNamedTag("Schematic", tag); - } catch (IOException e1) { - e1.printStackTrace(); - } - } - }, whenDone); - } - /** * Saves a schematic to a file path. * From 6130c3dfa51117d22e8feea90041856b61a4b825 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 23 Jan 2023 13:28:05 +0100 Subject: [PATCH 25/32] Clarify 2D biome deprecation --- .../main/java/com/plotsquared/core/queue/QueueCoordinator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java index 12cafb5aa..df081ba0c 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java @@ -221,7 +221,7 @@ public abstract class QueueCoordinator { * @return success or not * @deprecated Biomes now take XYZ, see {@link #setBiome(int, int, int, BiomeType)} *
- * Scheduled for removal once we drop the support for versions not supporting 3D biomes. + * Scheduled for removal once we drop the support for versions not supporting 3D biomes, 1.18 and earlier. */ @Deprecated(forRemoval = true, since = "6.0.0") public abstract boolean setBiome(int x, int z, @NonNull BiomeType biome); From ab357deb48d593357c8f3e3b2bf7d75493a7c3f1 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 23 Jan 2023 13:40:35 +0100 Subject: [PATCH 26/32] Put more legacy web interface deprecations in place --- .../com/plotsquared/bukkit/generator/BukkitPlotGenerator.java | 2 +- .../main/java/com/plotsquared/core/util/SchematicHandler.java | 4 ++++ Core/src/main/java/com/plotsquared/core/util/WorldUtil.java | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index a9f0c43b0..fda56eaf3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -162,7 +162,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap } /** - * The entire method is deprecated, but kept for compatibility with <=1.16.2. + * The entire method is deprecated, but kept for compatibility with versions lower than or equal to 1.16.2. * The method will be removed in future versions, because WorldEdit and FastAsyncWorldEdit only support the latest point * release. */ diff --git a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java index f266a8114..7d2993ed2 100644 --- a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java +++ b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java @@ -491,6 +491,10 @@ public abstract class SchematicHandler { return null; } + /** + * The legacy web interface is deprecated for removal in favor of Arkitektonika. + */ + @Deprecated(forRemoval = true, since = "TODO") public List getSaves(UUID uuid) { String rawJSON; try { diff --git a/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java b/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java index 9b9267bf9..1861be25b 100644 --- a/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java +++ b/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java @@ -252,6 +252,10 @@ public abstract class WorldUtil { */ public abstract void refreshChunk(int x, int z, String world); + /** + * The legacy web interface is deprecated for removal in favor of Arkitektonika. + */ + @Deprecated(forRemoval = true, since = "TODO") public void upload( final @NonNull Plot plot, final @Nullable UUID uuid, From 70b6636f50e419dc45d388b284166b8456e7c1a7 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 23 Jan 2023 13:40:47 +0100 Subject: [PATCH 27/32] Revert "Cleanup deprecated methods" This reverts commit 26692d6633b742b2e8af398c883b111887529fd9. --- .../core/configuration/Settings.java | 16 ++++ .../core/generator/HybridPlotWorld.java | 8 ++ .../core/util/SchematicHandler.java | 96 +++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index e3cb35bd1..025c779ee 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -433,6 +433,22 @@ public class Settings extends Config { } + + @Deprecated(forRemoval = true, since = "6.0.0") + @Comment("Schematic interface related settings") + public static class Web { + + @Comment({"The web interface for schematics", " - All schematics are anonymous and private", + " - Downloads can be deleted by the user", + " - Supports plot uploads, downloads and saves",}) + public static String URL = + "https://schem.intellectualsites.com/plots/"; + @Comment({"Whether or not the legacy web interface will be used for /plot download and /plot save", + "Note that this will be removed in future versions. Updating to Arkitektonika is highly suggested"}) + public static boolean LEGACY_WEBINTERFACE = false; + + } + @Comment("Schematic web interface related settings") public static class Arkitektonika { diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java index 2a7e8b4da..efa145e54 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java @@ -544,6 +544,14 @@ public class HybridPlotWorld extends ClassicPlotWorld { return schem1PopulationNeeded || schem2PopulationNeeded || schem3PopulationNeeded; } + /** + * @deprecated in favour of {@link HybridPlotWorld#getSchematicRoot()} + */ + @Deprecated(forRemoval = true, since = "6.9.0") + public File getRoot() { + return this.root; + } + /** * Get the root folder for this world's generation schematics. May be null if schematics not initialised via * {@link HybridPlotWorld#setupSchematics()} diff --git a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java index d7822a280..f266a8114 100644 --- a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java +++ b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java @@ -120,6 +120,84 @@ public abstract class SchematicHandler { this.subscriberFactory = subscriberFactory; } + @Deprecated(forRemoval = true, since = "6.0.0") + public static void upload( + @Nullable UUID uuid, + final @Nullable String file, + final @NonNull String extension, + final @Nullable RunnableVal writeTask, + final @NonNull RunnableVal whenDone + ) { + if (writeTask == null) { + TaskManager.runTask(whenDone); + return; + } + final String filename; + final String website; + if (uuid == null) { + uuid = UUID.randomUUID(); + website = Settings.Web.URL + "upload.php?" + uuid; + filename = "plot." + extension; + } else { + website = Settings.Web.URL + "save.php?" + uuid; + filename = file + '.' + extension; + } + final URL url; + try { + url = new URL(Settings.Web.URL + "?key=" + uuid + "&type=" + extension); + } catch (MalformedURLException e) { + e.printStackTrace(); + whenDone.run(); + return; + } + TaskManager.runTaskAsync(() -> { + try { + String boundary = Long.toHexString(System.currentTimeMillis()); + URLConnection con = new URL(website).openConnection(); + con.setDoOutput(true); + con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); + try (OutputStream output = con.getOutputStream(); + PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true)) { + String CRLF = "\r\n"; + writer.append("--").append(boundary).append(CRLF); + writer.append("Content-Disposition: form-data; name=\"param\"").append(CRLF); + writer.append("Content-Type: text/plain; charset=").append(StandardCharsets.UTF_8.displayName()).append(CRLF); + String param = "value"; + writer.append(CRLF).append(param).append(CRLF).flush(); + writer.append("--").append(boundary).append(CRLF); + writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"").append(filename) + .append(String.valueOf('"')).append(CRLF); + writer.append("Content-Type: ").append(URLConnection.guessContentTypeFromName(filename)).append(CRLF); + writer.append("Content-Transfer-Encoding: binary").append(CRLF); + writer.append(CRLF).flush(); + writeTask.value = new AbstractDelegateOutputStream(output) { + @Override + public void close() { + } // Don't close + }; + writeTask.run(); + output.flush(); + writer.append(CRLF).flush(); + writer.append("--").append(boundary).append("--").append(CRLF).flush(); + } + String content; + try (Scanner scanner = new Scanner(con.getInputStream()).useDelimiter("\\A")) { + content = scanner.next().trim(); + } + if (!content.startsWith("<")) { + } + int responseCode = ((HttpURLConnection) con).getResponseCode(); + if (responseCode == 200) { + whenDone.value = url; + } + TaskManager.runTask(whenDone); + } catch (IOException e) { + e.printStackTrace(); + TaskManager.runTask(whenDone); + } + }); + } + public boolean exportAll( Collection collection, final File outputDir, @@ -436,6 +514,24 @@ public abstract class SchematicHandler { return null; } + @Deprecated(forRemoval = true, since = "6.0.0") + public void upload(final CompoundTag tag, UUID uuid, String file, RunnableVal whenDone) { + if (tag == null) { + TaskManager.runTask(whenDone); + return; + } + upload(uuid, file, "schem", new RunnableVal<>() { + @Override + public void run(OutputStream output) { + try (NBTOutputStream nos = new NBTOutputStream(new GZIPOutputStream(output, true))) { + nos.writeNamedTag("Schematic", tag); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + }, whenDone); + } + /** * Saves a schematic to a file path. * From ffbec24290d4fd13a5b746ece75d824ca41947de Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Jan 2023 22:35:15 +0100 Subject: [PATCH 28/32] Update dependency com.intellectualsites.bom:bom-1.18.x to v1.23 (#3948) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3ef77914f..19635d1e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -74,7 +74,7 @@ subprojects { } dependencies { - implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.22")) + implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.23")) } dependencies { From 0d359ade0c3a78b78f2dd368350c6f9c66056f57 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 28 Jan 2023 19:21:35 +0100 Subject: [PATCH 29/32] Update dependency com.diffplug.spotless to v6.14.0 (#3950) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3fb14d96b..79d494352 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ http4j = "1.3" # Gradle plugins shadow = "7.1.2" grgit = "4.1.1" -spotless = "6.13.0" +spotless = "6.14.0" nexus = "1.1.0" [libraries] From d7c2ab1d169df9b062ab0db2192d9a14bc14efc4 Mon Sep 17 00:00:00 2001 From: Traks <58818927+traksag@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:22:13 +0100 Subject: [PATCH 30/32] Make farmland keep its moisture (#3952) Handle MoistureChangeEvent for farm land --- .../bukkit/listener/BlockEventListener.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index 343acce06..fe58c41b7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -98,6 +98,7 @@ import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.CauldronLevelChangeEvent; import org.bukkit.event.block.EntityBlockFormEvent; import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.block.MoistureChangeEvent; import org.bukkit.event.block.SpongeAbsorbEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.projectiles.BlockProjectileSource; @@ -703,6 +704,28 @@ public class BlockEventListener implements Listener { } } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onMoistureChange(MoistureChangeEvent event) { + Block block = event.getBlock(); + Location location = BukkitUtil.adapt(block.getLocation()); + PlotArea area = location.getPlotArea(); + if (area == null) { + return; + } + Plot plot = area.getOwnedPlot(location); + if (plot == null) { + event.setCancelled(true); + return; + } + Material blockType = block.getType(); + if (blockType == Material.FARMLAND) { + if (!plot.getFlag(SoilDryFlag.class)) { + plot.debug("Soil could not dry because soil-dry = false"); + event.setCancelled(true); + } + } + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onChange(BlockFromToEvent event) { Block fromBlock = event.getBlock(); From 84567bcb009e8a8b50e3f27fbf58e75d21bc299c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 12:48:30 +0100 Subject: [PATCH 31/32] Update dependency com.diffplug.spotless to v6.14.1 (#3957) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 79d494352..fc02d8785 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ http4j = "1.3" # Gradle plugins shadow = "7.1.2" grgit = "4.1.1" -spotless = "6.14.0" +spotless = "6.14.1" nexus = "1.1.0" [libraries] From 5cce86d9247c9b72bf0d58676fdfce140d4f6605 Mon Sep 17 00:00:00 2001 From: ByteExceptionM Date: Thu, 9 Feb 2023 20:51:59 +0100 Subject: [PATCH 32/32] feat: Add event firing on remove road entity (#3955) * feat: Add event firing on remove road entity Signed-off-by: ByteExceptionM * chore: Add some more entity vars Signed-off-by: ByteExceptionM * chore: Rename method Signed-off-by: ByteExceptionM * chore: Code cleanup Signed-off-by: ByteExceptionM * chore: Code reformat Signed-off-by: ByteExceptionM * chore: Change iterator removal Signed-off-by: ByteExceptionM * Comply with checkstyle --------- Signed-off-by: ByteExceptionM Co-authored-by: Alexander Brandes --- .../plotsquared/bukkit/BukkitPlatform.java | 31 +++++---- .../plotsquared/core/events/EntityEvent.java | 63 +++++++++++++++++++ .../core/events/RemoveRoadEntityEvent.java | 50 +++++++++++++++ .../core/util/EventDispatcher.java | 8 +++ 4 files changed, 141 insertions(+), 11 deletions(-) create mode 100644 Core/src/main/java/com/plotsquared/core/events/EntityEvent.java create mode 100644 Core/src/main/java/com/plotsquared/core/events/RemoveRoadEntityEvent.java diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 8055bd5cb..c82de570e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -71,6 +71,8 @@ import com.plotsquared.core.configuration.Storage; import com.plotsquared.core.configuration.caption.ChatFormatter; import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.database.DBFunc; +import com.plotsquared.core.events.RemoveRoadEntityEvent; +import com.plotsquared.core.events.Result; import com.plotsquared.core.generator.GeneratorWrapper; import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.SingleWorldGenerator; @@ -109,6 +111,7 @@ import com.plotsquared.core.uuid.CacheUUIDService; import com.plotsquared.core.uuid.UUIDPipeline; import com.plotsquared.core.uuid.offline.OfflineModeUUIDService; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import io.papermc.lib.PaperLib; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; @@ -810,8 +813,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } continue; } @@ -824,8 +826,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } } continue; @@ -835,7 +836,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl case "DROPPED_ITEM": if (Settings.Enabled_Components.KILL_ROAD_ITEMS && plotArea.getOwnedPlotAbs(BukkitUtil.adapt(entity.getLocation())) == null) { - entity.remove(); + this.removeRoadEntity(entity, iterator); } // dropped item continue; @@ -866,8 +867,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } } } @@ -972,8 +972,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } } } else { @@ -984,8 +983,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } } } @@ -999,6 +997,17 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl }), TaskTime.seconds(1L)); } + private void removeRoadEntity(Entity entity, Iterator entityIterator) { + RemoveRoadEntityEvent event = eventDispatcher.callRemoveRoadEntity(BukkitAdapter.adapt(entity)); + + if (event.getEventResult() == Result.DENY) { + return; + } + + entityIterator.remove(); + entity.remove(); + } + @Override public @Nullable final ChunkGenerator getDefaultWorldGenerator( diff --git a/Core/src/main/java/com/plotsquared/core/events/EntityEvent.java b/Core/src/main/java/com/plotsquared/core/events/EntityEvent.java new file mode 100644 index 000000000..5642342b6 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/EntityEvent.java @@ -0,0 +1,63 @@ +/* + * PlotSquared, a land and world management plugin for Minecraft. + * Copyright (C) IntellectualSites + * Copyright (C) IntellectualSites team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.plotsquared.core.events; + +import com.sk89q.worldedit.entity.Entity; +import org.checkerframework.checker.nullness.qual.NonNull; + +/** + * @since TODO + */ +public abstract class EntityEvent { + + private final Entity entity; + + private String name; + + /** + * @since TODO + */ + public EntityEvent(Entity entity) { + this.entity = entity; + } + + /** + * Obtain the entity involved in the event + * + * @return Entity + * @since TODO + */ + public Entity getEntity() { + return this.entity; + } + + /** + * Obtain the event's class name + * + * @return the event class name + * @since TODO + */ + @NonNull public String getEventName() { + if (this.name == null) { + this.name = this.getClass().getSimpleName(); + } + return this.name; + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/events/RemoveRoadEntityEvent.java b/Core/src/main/java/com/plotsquared/core/events/RemoveRoadEntityEvent.java new file mode 100644 index 000000000..aa7155cc7 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/RemoveRoadEntityEvent.java @@ -0,0 +1,50 @@ +/* + * PlotSquared, a land and world management plugin for Minecraft. + * Copyright (C) IntellectualSites + * Copyright (C) IntellectualSites team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.plotsquared.core.events; + +import com.sk89q.worldedit.entity.Entity; + +/** + * @since TODO + */ +public class RemoveRoadEntityEvent extends EntityEvent implements CancellablePlotEvent { + + private Result eventResult; + + /** + * RemoveRoadEntityEvent: Called when an entity on road is removed. + * + * @param entity The entity to remove + * @since TODO + */ + public RemoveRoadEntityEvent(Entity entity) { + super(entity); + } + + @Override + public Result getEventResult() { + return this.eventResult; + } + + @Override + public void setEventResult(Result eventResult) { + this.eventResult = eventResult; + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java index 9318cccd0..f935c50f7 100644 --- a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java +++ b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java @@ -45,6 +45,7 @@ import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotMergeEvent; import com.plotsquared.core.events.PlotRateEvent; import com.plotsquared.core.events.PlotUnlinkEvent; +import com.plotsquared.core.events.RemoveRoadEntityEvent; import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.events.post.PostPlayerAutoPlotEvent; import com.plotsquared.core.events.post.PostPlotChangeOwnerEvent; @@ -71,6 +72,7 @@ import com.plotsquared.core.plot.flag.types.BlockTypeWrapper; import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.util.task.TaskManager; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -296,6 +298,12 @@ public class EventDispatcher { return event; } + public RemoveRoadEntityEvent callRemoveRoadEntity(Entity entity) { + RemoveRoadEntityEvent event = new RemoveRoadEntityEvent(entity); + eventBus.post(event); + return event; + } + public void doJoinTask(final PlotPlayer player) { if (player == null) { return; //possible future warning message to figure out where we are retrieving null