From 6442922d864647ac2b86fd56116bdc8401f7acec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Wed, 27 May 2020 14:08:48 +0200 Subject: [PATCH] Implement some more generic types to make the player objects easier to work with and also create wrapper objects for fake players (NPCs). Potentially fixes PS-27 --- .../com/plotsquared/bukkit/BukkitMain.java | 9 ++- .../bukkit/listener/PlayerEvents.java | 60 +++++++++---------- .../bukkit/player/BukkitPlayer.java | 18 ++++-- .../bukkit/player/BukkitPlayerManager.java | 10 +++- .../plotsquared/bukkit/util/BukkitUtil.java | 21 ++++--- .../java/com/plotsquared/core/IPlotMain.java | 9 ++- .../com/plotsquared/core/PlotSquared.java | 4 +- .../com/plotsquared/core/command/Add.java | 2 +- .../com/plotsquared/core/command/Alias.java | 2 +- .../com/plotsquared/core/command/Area.java | 2 +- .../com/plotsquared/core/command/Auto.java | 2 +- .../com/plotsquared/core/command/Backup.java | 2 +- .../com/plotsquared/core/command/Buy.java | 2 +- .../com/plotsquared/core/command/Caps.java | 2 +- .../com/plotsquared/core/command/Chat.java | 2 +- .../com/plotsquared/core/command/Claim.java | 2 +- .../com/plotsquared/core/command/Clear.java | 2 +- .../com/plotsquared/core/command/Cluster.java | 2 +- .../plotsquared/core/command/CmdConfirm.java | 6 +- .../com/plotsquared/core/command/Command.java | 4 +- .../com/plotsquared/core/command/Comment.java | 2 +- .../plotsquared/core/command/Condense.java | 2 +- .../com/plotsquared/core/command/Confirm.java | 2 +- .../plotsquared/core/command/Continue.java | 2 +- .../com/plotsquared/core/command/Copy.java | 2 +- .../core/command/CreateRoadSchematic.java | 2 +- .../core/command/DatabaseCommand.java | 2 +- .../com/plotsquared/core/command/Debug.java | 2 +- .../core/command/DebugAllowUnsafe.java | 2 +- .../plotsquared/core/command/DebugExec.java | 4 +- .../core/command/DebugImportWorlds.java | 2 +- .../core/command/DebugLoadTest.java | 2 +- .../plotsquared/core/command/DebugPaste.java | 2 +- .../core/command/DebugRoadRegen.java | 2 +- .../core/command/DebugSaveTest.java | 2 +- .../com/plotsquared/core/command/Delete.java | 2 +- .../com/plotsquared/core/command/Deny.java | 2 +- .../com/plotsquared/core/command/Dislike.java | 2 +- .../com/plotsquared/core/command/Done.java | 2 +- .../plotsquared/core/command/Download.java | 2 +- .../plotsquared/core/command/FlagCommand.java | 2 +- .../com/plotsquared/core/command/Grant.java | 2 +- .../com/plotsquared/core/command/Help.java | 2 +- .../com/plotsquared/core/command/Inbox.java | 2 +- .../com/plotsquared/core/command/Info.java | 2 +- .../com/plotsquared/core/command/Kick.java | 2 +- .../com/plotsquared/core/command/Leave.java | 2 +- .../com/plotsquared/core/command/Like.java | 2 +- .../com/plotsquared/core/command/ListCmd.java | 2 +- .../com/plotsquared/core/command/Load.java | 4 +- .../plotsquared/core/command/MainCommand.java | 2 +- .../com/plotsquared/core/command/Merge.java | 2 +- .../com/plotsquared/core/command/Middle.java | 2 +- .../com/plotsquared/core/command/Move.java | 4 +- .../com/plotsquared/core/command/Music.java | 2 +- .../com/plotsquared/core/command/Near.java | 2 +- .../plotsquared/core/command/PluginCmd.java | 2 +- .../com/plotsquared/core/command/Purge.java | 2 +- .../com/plotsquared/core/command/Rate.java | 2 +- .../core/command/RegenAllRoads.java | 2 +- .../com/plotsquared/core/command/Relight.java | 2 +- .../com/plotsquared/core/command/Reload.java | 2 +- .../com/plotsquared/core/command/Remove.java | 2 +- .../com/plotsquared/core/command/Save.java | 2 +- .../core/command/SchematicCmd.java | 2 +- .../com/plotsquared/core/command/Set.java | 2 +- .../plotsquared/core/command/SetCommand.java | 2 +- .../com/plotsquared/core/command/Setup.java | 2 +- .../plotsquared/core/command/SubCommand.java | 4 +- .../com/plotsquared/core/command/Swap.java | 4 +- .../com/plotsquared/core/command/Target.java | 2 +- .../plotsquared/core/command/Template.java | 2 +- .../com/plotsquared/core/command/Trim.java | 2 +- .../com/plotsquared/core/command/Trust.java | 2 +- .../com/plotsquared/core/command/Unlink.java | 2 +- .../com/plotsquared/core/command/Visit.java | 2 +- .../plotsquared/core/command/WE_Anywhere.java | 2 +- .../core/components/ComponentCommand.java | 2 +- .../core/listener/PlotListener.java | 4 +- .../core/player/ConsolePlayer.java | 6 +- .../plotsquared/core/player/PlotPlayer.java | 6 +- .../java/com/plotsquared/core/plot/Plot.java | 10 ++-- .../plotsquared/core/plot/PlotInventory.java | 14 ++--- .../core/plot/comment/CommentManager.java | 2 +- .../core/plot/expiration/ExpireManager.java | 2 +- .../plotsquared/core/util/Permissions.java | 2 +- .../plotsquared/core/util/PlayerManager.java | 21 ++++++- .../com/plotsquared/core/util/WEManager.java | 2 +- 88 files changed, 203 insertions(+), 155 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 02cf4db04..a9ec5b374 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -156,7 +156,7 @@ import static com.plotsquared.core.util.PremiumVerification.getResourceID; import static com.plotsquared.core.util.PremiumVerification.getUserID; import static com.plotsquared.core.util.ReflectionUtils.getRefClass; -public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { +public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { private static final int BSTATS_ID = 1404; @Getter private static WorldEdit worldEdit; @@ -175,8 +175,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain private boolean methodUnloadSetup = false; private boolean metricsStarted; @Getter private BackupManager backupManager; - @Getter private PlatformWorldManager worldManager; - @Getter private final PlayerManager playerManager = new BukkitPlayerManager(); + @Getter private PlatformWorldManager worldManager; + private final BukkitPlayerManager playerManager = new BukkitPlayerManager(); @Override public int[] getServerVersion() { if (this.version == null) { @@ -1079,4 +1079,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain return wePlugin.wrapCommandSender(console); } + @Override @NotNull public PlayerManager, ? extends Player> getPlayerManager() { + return this.playerManager; + } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index 70d3c6d6b..073b7939d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -695,7 +695,7 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTeleport(PlayerTeleportEvent event) { Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); org.bukkit.Location to = event.getTo(); //noinspection ConstantConditions @@ -805,7 +805,7 @@ public class PlayerEvents extends PlotListener implements Listener { int x2; if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) { Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); // Cancel teleport TaskManager.TELEPORT_QUEUE.remove(pp.getName()); // Set last location @@ -865,7 +865,7 @@ public class PlayerEvents extends PlotListener implements Listener { int z2; if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) { Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); // Cancel teleport TaskManager.TELEPORT_QUEUE.remove(pp.getName()); // Set last location @@ -929,7 +929,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } - PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); Location location = plotPlayer.getLocation(); PlotArea area = location.getPlotArea(); if (area == null) { @@ -997,7 +997,7 @@ public class PlayerEvents extends PlotListener implements Listener { } Plot plot = area.getPlot(location); if (plot != null) { - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); if (event.getBlock().getY() == 0) { if (!Permissions .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) { @@ -1046,7 +1046,7 @@ public class PlayerEvents extends PlotListener implements Listener { } return; } - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) { return; } @@ -1114,7 +1114,7 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onWorldChanged(PlayerChangedWorldEvent event) { Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); // Delete last location Plot plot = (Plot) pp.deleteMeta(PlotPlayer.META_LAST_PLOT); pp.deleteMeta(PlotPlayer.META_LOCATION); @@ -1177,14 +1177,14 @@ public class PlayerEvents extends PlotListener implements Listener { if (entity instanceof Player) { Player player = (Player) entity; if (!plot.hasOwner()) { - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); if (plot.getFlag(IceFormFlag.class)) { return; } event.setCancelled(true); return; } - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); if (!plot.isAdded(plotPlayer.getUUID())) { if (plot.getFlag(IceFormFlag.class)) { return; @@ -1297,7 +1297,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } if (!plot.hasOwner()) { - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); if (Permissions .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) { return; @@ -1305,7 +1305,7 @@ public class PlayerEvents extends PlotListener implements Listener { event.setCancelled(true); return; } - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); if (!plot.isAdded(plotPlayer.getUUID())) { List destroy = plot.getFlag(BreakFlag.class); Block block = event.getBlock(); @@ -1320,7 +1320,7 @@ public class PlayerEvents extends PlotListener implements Listener { } return; } - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) { return; } @@ -1671,7 +1671,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } Player player = (Player) clicker; - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); final PlotInventory inventory = PlotInventory.getOpenPlotInventory(pp); if (inventory != null && event.getRawSlot() == event.getSlot()) { if (!inventory.onClick(event.getSlot())) { @@ -1812,7 +1812,7 @@ public class PlayerEvents extends PlotListener implements Listener { } EntitySpawnListener.testNether(entity); Plot plot = location.getPlotAbs(); - PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); + BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); if (plot == null) { if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road"); @@ -1881,7 +1881,7 @@ public class PlayerEvents extends PlotListener implements Listener { public void onCancelledInteract(PlayerInteractEvent event) { if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) { Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); PlotArea area = pp.getPlotAreaAbs(); if (area == null) { return; @@ -1918,7 +1918,7 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); PlotArea area = pp.getPlotAreaAbs(); if (area == null) { return; @@ -2195,7 +2195,7 @@ public class PlayerEvents extends PlotListener implements Listener { Plot plot = area.getOwnedPlot(location1); if (player != null) { - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); if (plot == null) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, @@ -2271,7 +2271,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (area == null) { return; } - PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); + BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); Plot plot = area.getPlot(location); if (plot == null) { if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { @@ -2322,7 +2322,7 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerQuitEvent event) { TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName()); - PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); + BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); pp.unregister(); PlotListener.logout(pp.getUUID()); } @@ -2336,7 +2336,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } Player player = event.getPlayer(); - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); Plot plot = area.getPlot(location); if (plot == null) { if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { @@ -2409,7 +2409,7 @@ public class PlayerEvents extends PlotListener implements Listener { event.setCancelled(true); return; } - PlotPlayer pp = BukkitUtil.getPlayer(p); + BukkitPlayer pp = BukkitUtil.getPlayer(p); Plot plot = area.getPlot(location); if (plot == null) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { @@ -2453,7 +2453,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (area == null) { return; } - PlotPlayer pp = BukkitUtil.getPlayer(p); + BukkitPlayer pp = BukkitUtil.getPlayer(p); Plot plot = area.getPlot(location); if (plot == null) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) { @@ -2486,7 +2486,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (area == null) { return; } - PlotPlayer player = BukkitUtil.getPlayer(shooter); + BukkitPlayer player = BukkitUtil.getPlayer(shooter); Plot plot = area.getPlot(BukkitUtil.getLocation(event.getEntity())); if (plot != null) { if (!plot.hasOwner()) { @@ -2521,7 +2521,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } Player p = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(p); + BukkitPlayer pp = BukkitUtil.getPlayer(p); Plot plot = area.getPlot(location); if (plot == null) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) { @@ -2595,7 +2595,7 @@ public class PlayerEvents extends PlotListener implements Listener { Entity attacker = event.getAttacker(); if (attacker instanceof Player) { Player p = (Player) attacker; - PlotPlayer pp = BukkitUtil.getPlayer(p); + BukkitPlayer pp = BukkitUtil.getPlayer(p); Plot plot = area.getPlot(location); if (plot == null) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) { @@ -2778,7 +2778,7 @@ public class PlayerEvents extends PlotListener implements Listener { player = null; } if (player != null) { - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); final com.sk89q.worldedit.world.entity.EntityType entityType; @@ -2901,7 +2901,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } Player player = event.getPlayer(); - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); Plot plot = area.getPlot(location); if (plot == null) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) { @@ -2932,7 +2932,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); Plot plot = area.getPlot(location); if (plot != null) { if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area @@ -3000,7 +3000,7 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler public void onItemDrop(PlayerDropItemEvent event) { Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); Plot plot = BukkitUtil.getLocation(player).getOwnedPlot(); if (plot == null) { return; @@ -3017,7 +3017,7 @@ public class PlayerEvents extends PlotListener implements Listener { LivingEntity ent = event.getEntity(); if (ent instanceof Player) { Player player = (Player) ent; - PlotPlayer pp = BukkitUtil.getPlayer(player); + BukkitPlayer pp = BukkitUtil.getPlayer(player); Plot plot = BukkitUtil.getLocation(player).getOwnedPlot(); if (plot == null) { return; 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 23d856860..acbc31984 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -63,12 +63,11 @@ import static com.sk89q.worldedit.world.gamemode.GameModes.CREATIVE; import static com.sk89q.worldedit.world.gamemode.GameModes.SPECTATOR; import static com.sk89q.worldedit.world.gamemode.GameModes.SURVIVAL; -public class BukkitPlayer extends PlotPlayer { +public class BukkitPlayer extends PlotPlayer { private static boolean CHECK_EFFECTIVE = true; public final Player player; private boolean offline; - private UUID uuid; private String name; /** @@ -78,20 +77,29 @@ public class BukkitPlayer extends PlotPlayer { * @param player Bukkit player instance */ public BukkitPlayer(@NotNull final Player player) { - this.player = player; - super.populatePersistentMetaMap(); + this(player, false); } public BukkitPlayer(@NotNull final Player player, final boolean offline) { + this(player, offline, true); + } + + public BukkitPlayer(@NotNull final Player player, final boolean offline, final boolean realPlayer) { this.player = player; this.offline = offline; - super.populatePersistentMetaMap(); + if (realPlayer) { + super.populatePersistentMetaMap(); + } } @Override public Actor toActor() { return BukkitAdapter.adapt(player); } + @Override public Player getPlatformPlayer() { + return this.player; + } + @NotNull @Override public Location getLocation() { final Location location = super.getLocation(); return location == null ? BukkitUtil.getLocation(this.player) : location; 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 cdb770e2f..a15718a5f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java @@ -36,7 +36,15 @@ import java.util.UUID; /** * Player manager providing {@link BukkitPlayer Bukkit players} */ -public class BukkitPlayerManager extends PlayerManager { +public class BukkitPlayerManager extends PlayerManager { + + @NotNull @Override public BukkitPlayer getPlayer(@NotNull final Player object) { + try { + return getPlayer(object.getUniqueId()); + } catch (final NoSuchPlayerException exception) { + return new BukkitPlayer(object, object.isOnline(), false); + } + } @Override @NotNull public BukkitPlayer createPlayer(@NotNull final UUID uuid) { final Player player = Bukkit.getPlayer(uuid); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index 8ba3caa9b..b21301251 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -27,6 +27,7 @@ package com.plotsquared.bukkit.util; import com.plotsquared.bukkit.BukkitMain; import com.plotsquared.bukkit.player.BukkitPlayer; +import com.plotsquared.bukkit.player.BukkitPlayerManager; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.location.Location; @@ -35,6 +36,7 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.util.BlockUtil; import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MathMan; +import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.StringComparison; import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.task.RunnableVal; @@ -112,14 +114,14 @@ public class BukkitUtil extends WorldUtil { private static World lastWorld = null; private static Player lastPlayer = null; - private static PlotPlayer lastPlotPlayer = null; + private static BukkitPlayer lastPlotPlayer = null; public static void removePlayer(String player) { lastPlayer = null; lastPlotPlayer = null; } - public static PlotPlayer getPlayer(@NonNull final OfflinePlayer op) { + public static PlotPlayer getPlayer(@NonNull final OfflinePlayer op) { if (op.isOnline()) { return getPlayer(op.getPlayer()); } @@ -164,7 +166,7 @@ public class BukkitUtil extends WorldUtil { * @return a {@code PlotPlayer} * @see PlotPlayer#wrap(Object) */ - public static PlotPlayer wrapPlayer(OfflinePlayer player) { + public static PlotPlayer wrapPlayer(OfflinePlayer player) { return PlotPlayer.wrap(player); } @@ -176,7 +178,7 @@ public class BukkitUtil extends WorldUtil { * @return a {@code PlotPlayer} * @see PlotPlayer#wrap(Object) */ - public static PlotPlayer wrapPlayer(Player player) { + public static PlotPlayer wrapPlayer(Player player) { return PlotPlayer.wrap(player); } @@ -188,7 +190,7 @@ public class BukkitUtil extends WorldUtil { * @return a {@code PlotPlayer} * @see PlotPlayer#wrap(Object) */ - @Override public PlotPlayer wrapPlayer(UUID uuid) { + @Override public PlotPlayer wrapPlayer(UUID uuid) { return PlotPlayer.wrap(Bukkit.getOfflinePlayer(uuid)); } @@ -199,7 +201,7 @@ public class BukkitUtil extends WorldUtil { * @return the number of allowed plots */ public static int getAllowedPlots(Player player) { - PlotPlayer plotPlayer = PlotPlayer.wrap(player); + PlotPlayer plotPlayer = PlotPlayer.wrap(player); return plotPlayer.getAllowedPlots(); } @@ -225,7 +227,7 @@ public class BukkitUtil extends WorldUtil { if (world == null) { return new HashSet<>(); } - return PlotPlayer.wrap(player).getPlots(world); + return BukkitPlayer.wrap(player).getPlots(world); } /** @@ -263,11 +265,12 @@ public class BukkitUtil extends WorldUtil { MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption); } - public static PlotPlayer getPlayer(@NonNull final Player player) { + public static BukkitPlayer getPlayer(@NonNull final Player player) { if (player == lastPlayer) { return lastPlotPlayer; } - return PlotSquared.imp().getPlayerManager().getPlayer(player.getUniqueId()); + final PlayerManager playerManager = PlotSquared.imp().getPlayerManager(); + return ((BukkitPlayerManager) player).getPlayer(player); } public static Location getLocation(@NonNull final org.bukkit.Location location) { diff --git a/Core/src/main/java/com/plotsquared/core/IPlotMain.java b/Core/src/main/java/com/plotsquared/core/IPlotMain.java index 9e04d85ec..57625ee3f 100644 --- a/Core/src/main/java/com/plotsquared/core/IPlotMain.java +++ b/Core/src/main/java/com/plotsquared/core/IPlotMain.java @@ -50,7 +50,12 @@ import java.io.File; import java.util.List; import java.util.Map; -public interface IPlotMain extends ILogger { +/** + * PlotSquared main utility class + * + * @param

Player type + */ +public interface IPlotMain

extends ILogger { /** * Logs a message to console. @@ -286,6 +291,6 @@ public interface IPlotMain extends ILogger { * * @return Player manager */ - @NotNull PlayerManager getPlayerManager(); + @NotNull PlayerManager, ? extends P> getPlayerManager(); } diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index a33fd502e..3f7f35229 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -141,7 +141,7 @@ public class PlotSquared { private static final Set EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet()); private static PlotSquared instance; // Implementation - public final IPlotMain IMP; + public final IPlotMain IMP; // Current thread private final Thread thread; // UUID pipelines @@ -386,7 +386,7 @@ public class PlotSquared { return PlotSquared.instance; } - @NotNull public static IPlotMain imp() { + @NotNull public static IPlotMain imp() { if (instance != null && instance.IMP != null) { return instance.IMP; } 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 3a3aa7ab7..6d86f7532 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Add.java +++ b/Core/src/main/java/com/plotsquared/core/command/Add.java @@ -56,7 +56,7 @@ public class Add extends Command { } @Override - public CompletableFuture execute(final PlotPlayer player, String[] args, + public CompletableFuture execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); 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 3f1273014..a10bf8a6e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Alias.java +++ b/Core/src/main/java/com/plotsquared/core/command/Alias.java @@ -45,7 +45,7 @@ import java.util.concurrent.TimeoutException; requiredType = RequiredType.PLAYER) public class Alias extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { if (args.length == 0) { Captions.COMMAND_SYNTAX.send(player, getUsage()); 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 932bbf0ab..7cdca5c6f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Area.java +++ b/Core/src/main/java/com/plotsquared/core/command/Area.java @@ -83,7 +83,7 @@ import java.util.Set; confirmation = true) public class Area extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length == 0) { Captions.COMMAND_SYNTAX.send(player, getUsage()); return false; 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 518a017d6..9658556d9 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -154,7 +154,7 @@ public class Auto extends SubCommand { () -> autoClaimFromDatabase(player, area, plot.getId(), whenDone)); } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { PlotArea plotarea = player.getApplicablePlotArea(); if (plotarea == null) { if (EconHandler.manager != null) { 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 e06d8208a..944eaaf6b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Backup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java @@ -70,7 +70,7 @@ public final class Backup extends Command { } @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { if (args.length == 0 || !Arrays.asList("save", "list", "load") diff --git a/Core/src/main/java/com/plotsquared/core/command/Buy.java b/Core/src/main/java/com/plotsquared/core/command/Buy.java index b986a7983..036e2412f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Buy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java @@ -54,7 +54,7 @@ public class Buy extends Command { } @Override - public CompletableFuture execute(final PlotPlayer player, String[] args, + public CompletableFuture execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, final RunnableVal2 whenDone) { 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 372e415b8..b56d33dc0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Caps.java +++ b/Core/src/main/java/com/plotsquared/core/command/Caps.java @@ -50,7 +50,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE; usage = "/plot caps") public class Caps extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, final String[] args) { + @Override public boolean onCommand(final PlotPlayer player, final String[] args) { final Plot plot = player.getCurrentPlot(); if (plot == null) { return Captions.NOT_IN_PLOT.send(player); diff --git a/Core/src/main/java/com/plotsquared/core/command/Chat.java b/Core/src/main/java/com/plotsquared/core/command/Chat.java index e8c9e395c..3bf04f223 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Chat.java +++ b/Core/src/main/java/com/plotsquared/core/command/Chat.java @@ -37,7 +37,7 @@ import com.plotsquared.core.util.MainUtil; requiredType = RequiredType.PLAYER) public class Chat extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { if (player.getPlotAreaAbs().isForcingPlotChat()) { MainUtil.sendMessage(player, Captions.PLOT_CHAT_FORCED); return true; 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 2f4ee7781..488b2dc84 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -54,7 +54,7 @@ import com.plotsquared.core.util.task.TaskManager; usage = "/plot claim") public class Claim extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { String schematic = null; if (args.length >= 1) { schematic = args[0]; 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 5e8c2757a..9d8279eda 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Clear.java +++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java @@ -64,7 +64,7 @@ public class Clear extends Command { } @Override - public CompletableFuture execute(final PlotPlayer player, String[] args, + public CompletableFuture execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage()); 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 c9ce3d5ef..557ba084b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Cluster.java +++ b/Core/src/main/java/com/plotsquared/core/command/Cluster.java @@ -54,7 +54,7 @@ import java.util.concurrent.TimeoutException; description = "Manage a plot cluster") public class Cluster extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome if (args.length == 0) { diff --git a/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java b/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java index 8b657992d..f7096834b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java +++ b/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java @@ -32,15 +32,15 @@ import com.plotsquared.core.util.task.TaskManager; public class CmdConfirm { - public static CmdInstance getPending(PlotPlayer player) { + public static CmdInstance getPending(PlotPlayer player) { return player.getMeta("cmdConfirm"); } - public static void removePending(PlotPlayer player) { + public static void removePending(PlotPlayer player) { player.deleteMeta("cmdConfirm"); } - public static void addPending(final PlotPlayer player, String commandStr, + public static void addPending(final PlotPlayer player, String commandStr, final Runnable runnable) { removePending(player); if (commandStr != null) { 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 6e97eb30a..7238d4566 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Command.java +++ b/Core/src/main/java/com/plotsquared/core/command/Command.java @@ -106,7 +106,7 @@ public abstract class Command { && types[4] == RunnableVal2.class) { Command tmp = new Command(this, true) { @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { try { @@ -300,7 +300,7 @@ public abstract class Command { * @return CompletableFuture true if the command executed fully, false in * any other case */ - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { if (args.length == 0 || args[0] == null) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Comment.java b/Core/src/main/java/com/plotsquared/core/command/Comment.java index 501ba4247..a5615533f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Comment.java +++ b/Core/src/main/java/com/plotsquared/core/command/Comment.java @@ -46,7 +46,7 @@ import java.util.Locale; permission = "plots.comment") public class Comment extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { if (args.length < 2) { sendMessage(player, Captions.COMMENT_SYNTAX, StringMan.join(CommentManager.inboxes.keySet(), "|")); diff --git a/Core/src/main/java/com/plotsquared/core/command/Condense.java b/Core/src/main/java/com/plotsquared/core/command/Condense.java index f8a65407d..8f792ee7e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Condense.java +++ b/Core/src/main/java/com/plotsquared/core/command/Condense.java @@ -54,7 +54,7 @@ public class Condense extends SubCommand { public static boolean TASK = false; - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length != 2 && args.length != 3) { MainUtil.sendMessage(player, getUsage()); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/Confirm.java b/Core/src/main/java/com/plotsquared/core/command/Confirm.java index 04723ac48..311c1c437 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Confirm.java +++ b/Core/src/main/java/com/plotsquared/core/command/Confirm.java @@ -37,7 +37,7 @@ import com.plotsquared.core.util.task.TaskManager; category = CommandCategory.INFO) public class Confirm extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { CmdInstance command = CmdConfirm.getPending(player); if (command == null) { MainUtil.sendMessage(player, Captions.FAILED_CONFIRM); 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 d366b2ff6..23f5e93a0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Continue.java +++ b/Core/src/main/java/com/plotsquared/core/command/Continue.java @@ -44,7 +44,7 @@ import com.plotsquared.core.util.Permissions; requiredType = RequiredType.PLAYER) public class Continue extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { Plot plot = player.getCurrentPlot(); if ((plot == null) || !plot.hasOwner()) { return !sendMessage(player, Captions.NOT_IN_PLOT); 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 702255064..6743074ff 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Copy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Copy.java @@ -41,7 +41,7 @@ import com.plotsquared.core.util.Permissions; requiredType = RequiredType.NONE) public class Copy extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { Location location = player.getLocation(); Plot plot1 = location.getPlotAbs(); if (plot1 == null) { diff --git a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java index 258467500..d5800896a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java +++ b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java @@ -42,7 +42,7 @@ import com.plotsquared.core.util.MainUtil; usage = "/plot createroadschematic") public class CreateRoadSchematic extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); if (plot == null) { diff --git a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java index c652957e4..41690b5af 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java @@ -74,7 +74,7 @@ public class DatabaseCommand extends SubCommand { }); } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length < 1) { MainUtil.sendMessage(player, getUsage()); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java index e104da337..8a4ef1737 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -48,7 +48,7 @@ import java.util.Map; permission = "plots.admin") public class Debug extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { if (args.length > 0) { if ("player".equalsIgnoreCase(args[0])) { for (Map.Entry meta : player.getMeta().entrySet()) { diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java b/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java index e4de7e351..d424b809f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java @@ -42,7 +42,7 @@ public class DebugAllowUnsafe extends SubCommand { public static final List unsafeAllowed = new ArrayList<>(); - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { if (unsafeAllowed.contains(player.getUUID())) { unsafeAllowed.remove(player.getUUID()); 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 9f179803f..381582c57 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -178,7 +178,7 @@ public class DebugExec extends SubCommand { } } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { List allowed_params = Arrays .asList("analyze", "calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "seen", "list-scripts", "start-rgar", "stop-rgar", "help", "addcmd", "runasync", @@ -312,7 +312,7 @@ public class DebugExec extends SubCommand { new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null, RequiredType.NONE, CommandCategory.DEBUG) { @Override - public CompletableFuture execute(PlotPlayer player, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { try { diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java b/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java index 1eedabb71..bdb5a13b2 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java @@ -52,7 +52,7 @@ public class DebugImportWorlds extends Command { } @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { // UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)) diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugLoadTest.java b/Core/src/main/java/com/plotsquared/core/command/DebugLoadTest.java index 47bf4d6c5..387c5204e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugLoadTest.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugLoadTest.java @@ -37,7 +37,7 @@ import com.plotsquared.core.player.PlotPlayer; requiredType = RequiredType.CONSOLE) public class DebugLoadTest extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { PlotSquared.get().plots_tmp = DBFunc.getPlots(); return true; } diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java index 0c805d6bc..441fbdd84 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java @@ -71,7 +71,7 @@ public class DebugPaste extends SubCommand { return content.toString(); } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { TaskManager.runTaskAsync(() -> { try { diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java index 07ce9a516..b20924586 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java @@ -46,7 +46,7 @@ import java.util.Arrays; public class DebugRoadRegen extends SubCommand { public static final String USAGE = "/plot debugroadregen "; - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { if (args.length < 1) { MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE); return false; diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java b/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java index dc2fc612d..7307ca185 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java @@ -41,7 +41,7 @@ import java.util.ArrayList; description = "This command will force the recreation of all plots in the DB") public class DebugSaveTest extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { ArrayList plots = new ArrayList<>(PlotSquared.get().getPlots()); MainUtil.sendMessage(player, "&6Starting `DEBUGSAVETEST`"); DBFunc.createPlotsAndData(plots, 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 1a95046df..6d8ea243e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Delete.java +++ b/Core/src/main/java/com/plotsquared/core/command/Delete.java @@ -53,7 +53,7 @@ public class Delete extends SubCommand { // Note: To delete a specific plot use /plot delete // The syntax also works with any command: /plot - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { Location location = player.getLocation(); final Plot plot = location.getPlotAbs(); if (plot == null) { 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 3cf742f0c..4ed0d0ed5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Deny.java +++ b/Core/src/main/java/com/plotsquared/core/command/Deny.java @@ -51,7 +51,7 @@ public class Deny extends SubCommand { super(Argument.PlayerName); } - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); 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 ee6664f81..410e13b57 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Dislike.java +++ b/Core/src/main/java/com/plotsquared/core/command/Dislike.java @@ -35,7 +35,7 @@ import com.plotsquared.core.player.PlotPlayer; requiredType = RequiredType.PLAYER) public class Dislike extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { return Like.handleLike(player, args, false); } 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 4e9015e04..258454f8a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Done.java +++ b/Core/src/main/java/com/plotsquared/core/command/Done.java @@ -51,7 +51,7 @@ import com.plotsquared.core.util.task.RunnableVal; requiredType = RequiredType.NONE) public class Done extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { Location location = player.getLocation(); final Plot plot = location.getPlotAbs(); if ((plot == null) || !plot.hasOwner()) { 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 25e3c13d7..efd4079d5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Download.java +++ b/Core/src/main/java/com/plotsquared/core/command/Download.java @@ -50,7 +50,7 @@ import java.net.URL; permission = "plots.download") public class Download extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { String world = player.getLocation().getWorld(); if (!PlotSquared.get().hasPlotArea(world)) { return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); 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 80ee2512a..d6b5a58e8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java @@ -207,7 +207,7 @@ public final class FlagCommand extends Command { } @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { if (args.length == 0 || !Arrays 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 39351c27f..2d41da2e3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Grant.java +++ b/Core/src/main/java/com/plotsquared/core/command/Grant.java @@ -53,7 +53,7 @@ public class Grant extends Command { } @Override - public CompletableFuture execute(final PlotPlayer player, String[] args, + public CompletableFuture execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { checkTrue(args.length >= 1 && args.length <= 2, Captions.COMMAND_SYNTAX, getUsage()); diff --git a/Core/src/main/java/com/plotsquared/core/command/Help.java b/Core/src/main/java/com/plotsquared/core/command/Help.java index a1bbdc244..ef4b5a753 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Help.java +++ b/Core/src/main/java/com/plotsquared/core/command/Help.java @@ -52,7 +52,7 @@ public class Help extends Command { } @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { switch (args.length) { 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 938033758..a042e72cb 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Inbox.java +++ b/Core/src/main/java/com/plotsquared/core/command/Inbox.java @@ -86,7 +86,7 @@ public class Inbox extends SubCommand { MainUtil.sendMessage(player, string.toString()); } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { final Plot plot = player.getCurrentPlot(); if (plot == null) { sendMessage(player, Captions.NOT_IN_PLOT); 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 23c63450b..125d0008d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Info.java +++ b/Core/src/main/java/com/plotsquared/core/command/Info.java @@ -41,7 +41,7 @@ import com.plotsquared.core.util.task.RunnableVal; category = CommandCategory.INFO) public class Info extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { Plot plot; String arg; if (args.length > 0) { 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 69ace1482..0c83fa24e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Kick.java +++ b/Core/src/main/java/com/plotsquared/core/command/Kick.java @@ -53,7 +53,7 @@ public class Kick extends SubCommand { super(Argument.PlayerName); } - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { Location location = player.getLocation(); Plot plot = location.getPlot(); if (plot == null) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Leave.java b/Core/src/main/java/com/plotsquared/core/command/Leave.java index fdd2d70b4..3a0d7f09d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Leave.java +++ b/Core/src/main/java/com/plotsquared/core/command/Leave.java @@ -48,7 +48,7 @@ public class Leave extends Command { } @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); 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 9414985c3..216c6524c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Like.java +++ b/Core/src/main/java/com/plotsquared/core/command/Like.java @@ -175,7 +175,7 @@ public class Like extends SubCommand { return numLikes / (numLikes + numDislikes); } - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { return handleLike(player, args, true); } 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 0054df62e..811eb88a7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java @@ -116,7 +116,7 @@ public class ListCmd extends SubCommand { .toString(getArgumentList(player))); } - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { if (args.length < 1) { noArgs(player); return false; 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 58e2197b9..aa952a007 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Load.java +++ b/Core/src/main/java/com/plotsquared/core/command/Load.java @@ -52,7 +52,7 @@ import java.util.List; usage = "/plot load") public class Load extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { String world = player.getLocation().getWorld(); if (!PlotSquared.get().hasPlotArea(world)) { return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); @@ -152,7 +152,7 @@ public class Load extends SubCommand { return true; } - public void displaySaves(PlotPlayer player) { + public void displaySaves(PlotPlayer player) { List schematics = player.getMeta("plot_schematics"); for (int i = 0; i < Math.min(schematics.size(), 32); i++) { try { 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 133e27ab2..6e1151c4c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/MainCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/MainCommand.java @@ -217,7 +217,7 @@ public class MainCommand extends Command { } @Override - public CompletableFuture execute(final PlotPlayer player, String[] args, + public CompletableFuture execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { // Clear perm caching // 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 53f88e2e7..962b48163 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -78,7 +78,7 @@ public class Merge extends SubCommand { } } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { Location location = player.getLocationFull(); final Plot plot = location.getPlotAbs(); if (plot == null) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Middle.java b/Core/src/main/java/com/plotsquared/core/command/Middle.java index 58e7e437b..14c760eef 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Middle.java +++ b/Core/src/main/java/com/plotsquared/core/command/Middle.java @@ -42,7 +42,7 @@ import com.plotsquared.core.plot.Plot; requiredType = RequiredType.PLAYER) public class Middle extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] arguments) { + @Override public boolean onCommand(PlotPlayer player, String[] arguments) { Location location = player.getLocation(); Plot plot = location.getPlot(); if (plot == null) { 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 e95c35a1c..136bbcfaa 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Move.java +++ b/Core/src/main/java/com/plotsquared/core/command/Move.java @@ -47,7 +47,7 @@ import java.util.concurrent.CompletableFuture; public class Move extends SubCommand { @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { Location location = player.getLocation(); @@ -107,7 +107,7 @@ public class Move extends SubCommand { }); } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { return true; } 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 78e0b74e1..91b756a81 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Music.java +++ b/Core/src/main/java/com/plotsquared/core/command/Music.java @@ -55,7 +55,7 @@ public class Music extends SubCommand { "music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal", "music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait"); - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { Location location = player.getLocation(); final Plot plot = location.getPlotAbs(); if (plot == null) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Near.java b/Core/src/main/java/com/plotsquared/core/command/Near.java index a7c020762..20780613a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Near.java +++ b/Core/src/main/java/com/plotsquared/core/command/Near.java @@ -46,7 +46,7 @@ public class Near extends Command { } @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); diff --git a/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java b/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java index 503e65586..b0bf24d40 100644 --- a/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java @@ -39,7 +39,7 @@ import com.plotsquared.core.util.task.TaskManager; category = CommandCategory.INFO) public class PluginCmd extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { TaskManager.IMP.taskAsync(() -> { MainUtil.sendMessage(player, String.format( "$2>> $1&l" + PlotSquared.imp().getPluginName() + " $2($1Version$2: $1%s$2)", diff --git a/Core/src/main/java/com/plotsquared/core/command/Purge.java b/Core/src/main/java/com/plotsquared/core/command/Purge.java index 50b323300..9a89b2230 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Purge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Purge.java @@ -53,7 +53,7 @@ import java.util.concurrent.atomic.AtomicBoolean; confirmation = true) public class Purge extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length == 0) { Captions.COMMAND_SYNTAX.send(player, getUsage()); return false; 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 1d80a0c37..23affc37d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Rate.java +++ b/Core/src/main/java/com/plotsquared/core/command/Rate.java @@ -56,7 +56,7 @@ import java.util.UUID; requiredType = RequiredType.PLAYER) public class Rate extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length == 1) { switch (args[0].toLowerCase()) { case "next": { diff --git a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java index c5334241e..69d0022f6 100644 --- a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java +++ b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java @@ -43,7 +43,7 @@ import com.plotsquared.core.util.MainUtil; permission = "plots.regenallroads") public class RegenAllRoads extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { int height = 0; if (args.length == 2) { try { diff --git a/Core/src/main/java/com/plotsquared/core/command/Relight.java b/Core/src/main/java/com/plotsquared/core/command/Relight.java index b41e80baa..4a2475b5f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Relight.java +++ b/Core/src/main/java/com/plotsquared/core/command/Relight.java @@ -47,7 +47,7 @@ public class Relight extends Command { } @Override - public CompletableFuture execute(final PlotPlayer player, String[] args, + public CompletableFuture execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { final Plot plot = player.getCurrentPlot(); diff --git a/Core/src/main/java/com/plotsquared/core/command/Reload.java b/Core/src/main/java/com/plotsquared/core/command/Reload.java index 2fc594d23..0b8f4b6fe 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Reload.java +++ b/Core/src/main/java/com/plotsquared/core/command/Reload.java @@ -45,7 +45,7 @@ import java.util.Objects; category = CommandCategory.ADMINISTRATION) public class Reload extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { try { // The following won't affect world generation, as that has to be // loaded during startup unfortunately. 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 1a079f709..da00e5748 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Remove.java +++ b/Core/src/main/java/com/plotsquared/core/command/Remove.java @@ -50,7 +50,7 @@ public class Remove extends SubCommand { super(Argument.PlayerName); } - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); if (plot == null) { 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 6196f08b7..480167576 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Save.java +++ b/Core/src/main/java/com/plotsquared/core/command/Save.java @@ -49,7 +49,7 @@ import java.util.UUID; permission = "plots.save") public class Save extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { String world = player.getLocation().getWorld(); if (!PlotSquared.get().hasPlotArea(world)) { return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); 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 89c29b6c2..66e4a0662 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java @@ -57,7 +57,7 @@ public class SchematicCmd extends SubCommand { private boolean running = false; - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length < 1) { sendMessage(player, Captions.SCHEMATIC_MISSING_ARG); return true; 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 bf5285691..ec75fd9eb 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -176,7 +176,7 @@ public class Set extends SubCommand { return false; } - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { if (args.length == 0) { return noArgs(player); } 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 9531790cb..c487fb0c0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java @@ -36,7 +36,7 @@ import com.plotsquared.core.util.StringMan; public abstract class SetCommand extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); if (plot == null) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Setup.java b/Core/src/main/java/com/plotsquared/core/command/Setup.java index ea76e36cf..c01f604f9 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Setup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Setup.java @@ -90,7 +90,7 @@ public class Setup extends SubCommand { MainUtil.sendMessage(player, message.toString()); } - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { // going through setup SetupObject object = player.getMeta("setup"); if (object == null) { diff --git a/Core/src/main/java/com/plotsquared/core/command/SubCommand.java b/Core/src/main/java/com/plotsquared/core/command/SubCommand.java index 4a8d0e9fd..8692d1cae 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SubCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/SubCommand.java @@ -54,11 +54,11 @@ public abstract class SubCommand extends Command { } @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { return CompletableFuture.completedFuture(onCommand(player, args)); } - public abstract boolean onCommand(PlotPlayer player, String[] args); + public abstract boolean onCommand(PlotPlayer player, String[] args); } 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 d8447c84e..9e7ce5208 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Swap.java +++ b/Core/src/main/java/com/plotsquared/core/command/Swap.java @@ -45,7 +45,7 @@ import java.util.concurrent.CompletableFuture; public class Swap extends SubCommand { @Override - public CompletableFuture execute(PlotPlayer player, String[] args, + public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { Location location = player.getLocation(); @@ -93,7 +93,7 @@ public class Swap extends SubCommand { }); } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { return true; } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Target.java b/Core/src/main/java/com/plotsquared/core/command/Target.java index 5edc9b5a5..a70ac3451 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Target.java +++ b/Core/src/main/java/com/plotsquared/core/command/Target.java @@ -45,7 +45,7 @@ public class Target extends SubCommand { super(Argument.PlotID); } - @Override public boolean onCommand(PlotPlayer player, String[] args) { + @Override public boolean onCommand(PlotPlayer player, String[] args) { Location location = player.getLocation(); if (!location.isPlotArea()) { MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD); 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 373f3b38e..d19fbab51 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Template.java +++ b/Core/src/main/java/com/plotsquared/core/command/Template.java @@ -134,7 +134,7 @@ public class Template extends SubCommand { } } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length != 2 && args.length != 3) { if (args.length == 1) { if (args[0].equalsIgnoreCase("export")) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Trim.java b/Core/src/main/java/com/plotsquared/core/command/Trim.java index 4e4e8e900..ad5e5c0fe 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Trim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Trim.java @@ -159,7 +159,7 @@ public class Trim extends SubCommand { return true; } - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length == 0) { Captions.COMMAND_SYNTAX.send(player, getUsage()); return false; 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 4f9c15e38..1c4064543 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Trust.java +++ b/Core/src/main/java/com/plotsquared/core/command/Trust.java @@ -56,7 +56,7 @@ public class Trust extends Command { } @Override - public CompletableFuture execute(final PlotPlayer player, String[] args, + public CompletableFuture execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { final Plot currentPlot = player.getCurrentPlot(); 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 d2d5fa8d2..1f309df57 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Unlink.java +++ b/Core/src/main/java/com/plotsquared/core/command/Unlink.java @@ -46,7 +46,7 @@ import com.plotsquared.core.util.task.TaskManager; confirmation = true) public class Unlink extends SubCommand { - @Override public boolean onCommand(final PlotPlayer player, String[] args) { + @Override public boolean onCommand(final PlotPlayer player, String[] args) { Location location = player.getLocation(); final Plot plot = location.getPlotAbs(); if (plot == null) { 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 651a1c0b0..077f1f6de 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Visit.java +++ b/Core/src/main/java/com/plotsquared/core/command/Visit.java @@ -139,7 +139,7 @@ public class Visit extends Command { } @Override - public CompletableFuture execute(final PlotPlayer player, + public CompletableFuture execute(final PlotPlayer player, String[] args, final RunnableVal3 confirm, final RunnableVal2 whenDone) throws CommandException { diff --git a/Core/src/main/java/com/plotsquared/core/command/WE_Anywhere.java b/Core/src/main/java/com/plotsquared/core/command/WE_Anywhere.java index 6ac51f57c..50cda457a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/WE_Anywhere.java +++ b/Core/src/main/java/com/plotsquared/core/command/WE_Anywhere.java @@ -37,7 +37,7 @@ import com.plotsquared.core.player.PlotPlayer; @Deprecated public class WE_Anywhere extends SubCommand { - @Override public boolean onCommand(PlotPlayer player, String[] arguments) { + @Override public boolean onCommand(PlotPlayer player, String[] arguments) { MainCommand.getInstance().toggle.worldedit(this, player, new String[0], null, null); return true; } diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentCommand.java b/Core/src/main/java/com/plotsquared/core/components/ComponentCommand.java index f79b68063..8c158c417 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentCommand.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentCommand.java @@ -46,7 +46,7 @@ public class ComponentCommand extends SubCommand { this.componentPresetManager = componentPresetManager; } - @Override public boolean onCommand(final PlotPlayer player, final String[] args) { + @Override public boolean onCommand(final PlotPlayer player, final String[] args) { final PlotInventory inventory = componentPresetManager.buildInventory(player); if (inventory != null) { inventory.openInventory(); 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 5a4e43142..361a71b28 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java @@ -123,7 +123,7 @@ public class PlotListener { }, 20); } - public static boolean plotEntry(final PlotPlayer player, final Plot plot) { + public static boolean plotEntry(final PlotPlayer player, final Plot plot) { if (plot.isDenied(player.getUUID()) && !Permissions .hasPermission(player, "plots.admin.entry.denied")) { return false; @@ -293,7 +293,7 @@ public class PlotListener { return true; } - public static boolean plotExit(final PlotPlayer player, Plot plot) { + public static boolean plotExit(final PlotPlayer player, Plot plot) { Object previous = player.deleteMeta(PlotPlayer.META_LAST_PLOT); PlotSquared.get().getEventDispatcher().callLeave(player, plot); if (plot.hasOwner()) { diff --git a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java index bf295c9d7..9a97800e7 100644 --- a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java @@ -41,7 +41,7 @@ import org.jetbrains.annotations.NotNull; import java.util.UUID; -public class ConsolePlayer extends PlotPlayer { +public class ConsolePlayer extends PlotPlayer { private static ConsolePlayer instance; @@ -71,6 +71,10 @@ public class ConsolePlayer extends PlotPlayer { return PlotSquared.get().IMP.getConsole(); } + @Override public Actor getPlatformPlayer() { + return this.toActor(); + } + @Override public boolean canTeleport(@NotNull Location location) { return true; } 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 586809880..1a4e668c5 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -68,7 +68,7 @@ import java.util.stream.Collectors; /** * The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}. */ -public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { +public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer { public static final String META_LAST_PLOT = "lastplot"; public static final String META_LOCATION = "location"; @@ -103,12 +103,14 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { * @param player * @return */ - public static PlotPlayer wrap(Object player) { + public static PlotPlayer wrap(Object player) { return PlotSquared.get().IMP.wrapPlayer(player); } public abstract Actor toActor(); + public abstract P getPlatformPlayer(); + /** * Set some session only metadata for this player. * 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 df9ee12c4..5def886a8 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -399,9 +399,9 @@ public class Plot { * * @return list of PlotPlayer(s) or an empty list */ - public List getPlayersInPlot() { - final List players = new ArrayList<>(); - for (final PlotPlayer player : PlotSquared.imp().getPlayerManager().getPlayers()) { + public List> getPlayersInPlot() { + final List> players = new ArrayList<>(); + for (final PlotPlayer player : PlotSquared.imp().getPlayerManager().getPlayers()) { if (this.equals(player.getCurrentPlot())) { players.add(player); } @@ -1323,8 +1323,8 @@ public class Plot { return false; } for (Plot current : getConnectedPlots()) { - List players = current.getPlayersInPlot(); - for (PlotPlayer pp : players) { + List> players = current.getPlayersInPlot(); + for (PlotPlayer pp : players) { PlotListener.plotExit(pp, current); } diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java b/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java index 1a3abd5e0..88f9c100c 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java @@ -33,40 +33,40 @@ import lombok.NonNull; public class PlotInventory { private static final String META_KEY = "inventory"; - public final PlotPlayer player; + public final PlotPlayer player; public final int size; private final PlotItemStack[] items; private String title; private boolean open = false; - public PlotInventory(PlotPlayer player) { + public PlotInventory(PlotPlayer player) { this.size = 4; this.title = null; this.player = player; this.items = InventoryUtil.manager.getItems(player); } - public PlotInventory(PlotPlayer player, int size, String name) { + public PlotInventory(PlotPlayer player, int size, String name) { this.size = size; this.title = name == null ? "" : name; this.player = player; this.items = new PlotItemStack[size * 9]; } - public static boolean hasPlotInventoryOpen(@NonNull final PlotPlayer plotPlayer) { + public static boolean hasPlotInventoryOpen(@NonNull final PlotPlayer plotPlayer) { return getOpenPlotInventory(plotPlayer) != null; } - public static PlotInventory getOpenPlotInventory(@NonNull final PlotPlayer plotPlayer) { + public static PlotInventory getOpenPlotInventory(@NonNull final PlotPlayer plotPlayer) { return plotPlayer.getMeta(META_KEY, null); } - public static void setPlotInventoryOpen(@NonNull final PlotPlayer plotPlayer, + public static void setPlotInventoryOpen(@NonNull final PlotPlayer plotPlayer, @NonNull final PlotInventory plotInventory) { plotPlayer.setMeta(META_KEY, plotInventory); } - public static void removePlotInventoryOpen(@NonNull final PlotPlayer plotPlayer) { + public static void removePlotInventoryOpen(@NonNull final PlotPlayerplotPlayer) { plotPlayer.deleteMeta(META_KEY); } diff --git a/Core/src/main/java/com/plotsquared/core/plot/comment/CommentManager.java b/Core/src/main/java/com/plotsquared/core/plot/comment/CommentManager.java index 1e945a8bb..141d729c7 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/comment/CommentManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/comment/CommentManager.java @@ -75,7 +75,7 @@ import java.util.concurrent.atomic.AtomicInteger; }, 20); } - public static long getTimestamp(PlotPlayer player, String inbox) { + public static long getTimestamp(PlotPlayer player, String inbox) { return player.getMeta("inbox:" + inbox, player.getLastPlayed()); } 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 16d4ee41f..88d167a50 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 @@ -83,7 +83,7 @@ public class ExpireManager { this.tasks.add(task); } - public void handleJoin(PlotPlayer pp) { + public void handleJoin(PlotPlayer pp) { storeDate(pp.getUUID(), System.currentTimeMillis()); if (plotsToDelete != null && !plotsToDelete.isEmpty()) { for (Plot plot : pp.getPlots()) { 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 186439fc9..34754e7c8 100644 --- a/Core/src/main/java/com/plotsquared/core/util/Permissions.java +++ b/Core/src/main/java/com/plotsquared/core/util/Permissions.java @@ -61,7 +61,7 @@ public class Permissions { * @param permission * @return */ - public static boolean hasPermission(PlotPlayer player, String permission) { + public static boolean hasPermission(PlotPlayer player, String permission) { if (!Settings.Enabled_Components.PERMISSION_CACHE) { return hasPermission((CommandCaller) player, permission); } diff --git a/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java b/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java index 473826b2d..a5f8add50 100644 --- a/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java +++ b/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java @@ -39,7 +39,7 @@ import java.util.UUID; /** * Manages player instances */ -public abstract class PlayerManager

{ +public abstract class PlayerManager

, T> { private final Map playerMap = new HashMap<>(); private final Object playerLock = new Object(); @@ -77,6 +77,18 @@ public abstract class PlayerManager

+ * The method will throw an exception if there is no such + * player online. + * + * @param object Platform player object + * @return Player object + */ + @NotNull public abstract P getPlayer(@NotNull final T object); + /** * Get a plot player from a UUID. This method requires * that the caller actually knows that the player exists. @@ -106,7 +118,7 @@ public abstract class PlayerManager

getMask(PlotPlayer player) { + public static HashSet getMask(PlotPlayer player) { HashSet regions = new HashSet<>(); UUID uuid = player.getUUID(); Location location = player.getLocation();