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

This commit is contained in:
Alexander Söderberg 2020-05-27 14:08:48 +02:00
parent edbacb8e47
commit 6442922d86
88 changed files with 203 additions and 155 deletions

View File

@ -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.PremiumVerification.getUserID;
import static com.plotsquared.core.util.ReflectionUtils.getRefClass; 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<Player> {
private static final int BSTATS_ID = 1404; private static final int BSTATS_ID = 1404;
@Getter private static WorldEdit worldEdit; @Getter private static WorldEdit worldEdit;
@ -175,8 +175,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
private boolean methodUnloadSetup = false; private boolean methodUnloadSetup = false;
private boolean metricsStarted; private boolean metricsStarted;
@Getter private BackupManager backupManager; @Getter private BackupManager backupManager;
@Getter private PlatformWorldManager worldManager; @Getter private PlatformWorldManager<World> worldManager;
@Getter private final PlayerManager playerManager = new BukkitPlayerManager(); private final BukkitPlayerManager playerManager = new BukkitPlayerManager();
@Override public int[] getServerVersion() { @Override public int[] getServerVersion() {
if (this.version == null) { if (this.version == null) {
@ -1079,4 +1079,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return wePlugin.wrapCommandSender(console); return wePlugin.wrapCommandSender(console);
} }
@Override @NotNull public PlayerManager<? extends PlotPlayer<Player>, ? extends Player> getPlayerManager() {
return this.playerManager;
}
} }

View File

@ -695,7 +695,7 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT);
org.bukkit.Location to = event.getTo(); org.bukkit.Location to = event.getTo();
//noinspection ConstantConditions //noinspection ConstantConditions
@ -805,7 +805,7 @@ public class PlayerEvents extends PlotListener implements Listener {
int x2; int x2;
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) { if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); TaskManager.TELEPORT_QUEUE.remove(pp.getName());
// Set last location // Set last location
@ -865,7 +865,7 @@ public class PlayerEvents extends PlotListener implements Listener {
int z2; int z2;
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) { if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); TaskManager.TELEPORT_QUEUE.remove(pp.getName());
// Set last location // Set last location
@ -929,7 +929,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation(); Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
@ -997,7 +997,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot != null) { if (plot != null) {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (event.getBlock().getY() == 0) { if (event.getBlock().getY() == 0) {
if (!Permissions if (!Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) { .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
@ -1046,7 +1046,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
return; return;
} }
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) { if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
return; return;
} }
@ -1114,7 +1114,7 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldChanged(PlayerChangedWorldEvent event) { public void onWorldChanged(PlayerChangedWorldEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
// Delete last location // Delete last location
Plot plot = (Plot) pp.deleteMeta(PlotPlayer.META_LAST_PLOT); Plot plot = (Plot) pp.deleteMeta(PlotPlayer.META_LAST_PLOT);
pp.deleteMeta(PlotPlayer.META_LOCATION); pp.deleteMeta(PlotPlayer.META_LOCATION);
@ -1177,14 +1177,14 @@ public class PlayerEvents extends PlotListener implements Listener {
if (entity instanceof Player) { if (entity instanceof Player) {
Player player = (Player) entity; Player player = (Player) entity;
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (plot.getFlag(IceFormFlag.class)) { if (plot.getFlag(IceFormFlag.class)) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (!plot.isAdded(plotPlayer.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
if (plot.getFlag(IceFormFlag.class)) { if (plot.getFlag(IceFormFlag.class)) {
return; return;
@ -1297,7 +1297,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (Permissions if (Permissions
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) { .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return; return;
@ -1305,7 +1305,7 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (!plot.isAdded(plotPlayer.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class); List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
Block block = event.getBlock(); Block block = event.getBlock();
@ -1320,7 +1320,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
return; return;
} }
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) { if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
return; return;
} }
@ -1671,7 +1671,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
Player player = (Player) clicker; Player player = (Player) clicker;
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
final PlotInventory inventory = PlotInventory.getOpenPlotInventory(pp); final PlotInventory inventory = PlotInventory.getOpenPlotInventory(pp);
if (inventory != null && event.getRawSlot() == event.getSlot()) { if (inventory != null && event.getRawSlot() == event.getSlot()) {
if (!inventory.onClick(event.getSlot())) { if (!inventory.onClick(event.getSlot())) {
@ -1812,7 +1812,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
EntitySpawnListener.testNether(entity); EntitySpawnListener.testNether(entity);
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "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) { public void onCancelledInteract(PlayerInteractEvent event) {
if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) { if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
PlotArea area = pp.getPlotAreaAbs(); PlotArea area = pp.getPlotAreaAbs();
if (area == null) { if (area == null) {
return; return;
@ -1918,7 +1918,7 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent event) { public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
PlotArea area = pp.getPlotAreaAbs(); PlotArea area = pp.getPlotAreaAbs();
if (area == null) { if (area == null) {
return; return;
@ -2195,7 +2195,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Plot plot = area.getOwnedPlot(location1); Plot plot = area.getOwnedPlot(location1);
if (player != null) { if (player != null) {
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
@ -2271,7 +2271,7 @@ public class PlayerEvents extends PlotListener implements Listener {
if (area == null) { if (area == null) {
return; return;
} }
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot == null) { if (plot == null) {
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { 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) { @EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerQuitEvent event) {
TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName()); TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName());
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
pp.unregister(); pp.unregister();
PlotListener.logout(pp.getUUID()); PlotListener.logout(pp.getUUID());
} }
@ -2336,7 +2336,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot == null) { if (plot == null) {
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
@ -2409,7 +2409,7 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
PlotPlayer pp = BukkitUtil.getPlayer(p); BukkitPlayer pp = BukkitUtil.getPlayer(p);
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
@ -2453,7 +2453,7 @@ public class PlayerEvents extends PlotListener implements Listener {
if (area == null) { if (area == null) {
return; return;
} }
PlotPlayer pp = BukkitUtil.getPlayer(p); BukkitPlayer pp = BukkitUtil.getPlayer(p);
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
@ -2486,7 +2486,7 @@ public class PlayerEvents extends PlotListener implements Listener {
if (area == null) { if (area == null) {
return; return;
} }
PlotPlayer player = BukkitUtil.getPlayer(shooter); BukkitPlayer player = BukkitUtil.getPlayer(shooter);
Plot plot = area.getPlot(BukkitUtil.getLocation(event.getEntity())); Plot plot = area.getPlot(BukkitUtil.getLocation(event.getEntity()));
if (plot != null) { if (plot != null) {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
@ -2521,7 +2521,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
Player p = event.getPlayer(); Player p = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(p); BukkitPlayer pp = BukkitUtil.getPlayer(p);
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) {
@ -2595,7 +2595,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Entity attacker = event.getAttacker(); Entity attacker = event.getAttacker();
if (attacker instanceof Player) { if (attacker instanceof Player) {
Player p = (Player) attacker; Player p = (Player) attacker;
PlotPlayer pp = BukkitUtil.getPlayer(p); BukkitPlayer pp = BukkitUtil.getPlayer(p);
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
@ -2778,7 +2778,7 @@ public class PlayerEvents extends PlotListener implements Listener {
player = null; player = null;
} }
if (player != null) { if (player != null) {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
final com.sk89q.worldedit.world.entity.EntityType entityType; final com.sk89q.worldedit.world.entity.EntityType entityType;
@ -2901,7 +2901,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
@ -2932,7 +2932,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot != null) { if (plot != null) {
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area 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) { @EventHandler public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot(); Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
if (plot == null) { if (plot == null) {
return; return;
@ -3017,7 +3017,7 @@ public class PlayerEvents extends PlotListener implements Listener {
LivingEntity ent = event.getEntity(); LivingEntity ent = event.getEntity();
if (ent instanceof Player) { if (ent instanceof Player) {
Player player = (Player) ent; Player player = (Player) ent;
PlotPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot(); Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
if (plot == null) { if (plot == null) {
return; return;

View File

@ -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.SPECTATOR;
import static com.sk89q.worldedit.world.gamemode.GameModes.SURVIVAL; import static com.sk89q.worldedit.world.gamemode.GameModes.SURVIVAL;
public class BukkitPlayer extends PlotPlayer { public class BukkitPlayer extends PlotPlayer<Player> {
private static boolean CHECK_EFFECTIVE = true; private static boolean CHECK_EFFECTIVE = true;
public final Player player; public final Player player;
private boolean offline; private boolean offline;
private UUID uuid;
private String name; private String name;
/** /**
@ -78,20 +77,29 @@ public class BukkitPlayer extends PlotPlayer {
* @param player Bukkit player instance * @param player Bukkit player instance
*/ */
public BukkitPlayer(@NotNull final Player player) { public BukkitPlayer(@NotNull final Player player) {
this.player = player; this(player, false);
super.populatePersistentMetaMap();
} }
public BukkitPlayer(@NotNull final Player player, final boolean offline) { 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.player = player;
this.offline = offline; this.offline = offline;
if (realPlayer) {
super.populatePersistentMetaMap(); super.populatePersistentMetaMap();
} }
}
@Override public Actor toActor() { @Override public Actor toActor() {
return BukkitAdapter.adapt(player); return BukkitAdapter.adapt(player);
} }
@Override public Player getPlatformPlayer() {
return this.player;
}
@NotNull @Override public Location getLocation() { @NotNull @Override public Location getLocation() {
final Location location = super.getLocation(); final Location location = super.getLocation();
return location == null ? BukkitUtil.getLocation(this.player) : location; return location == null ? BukkitUtil.getLocation(this.player) : location;

View File

@ -36,7 +36,15 @@ import java.util.UUID;
/** /**
* Player manager providing {@link BukkitPlayer Bukkit players} * Player manager providing {@link BukkitPlayer Bukkit players}
*/ */
public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, BukkitOfflinePlayer> { public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
@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) { @Override @NotNull public BukkitPlayer createPlayer(@NotNull final UUID uuid) {
final Player player = Bukkit.getPlayer(uuid); final Player player = Bukkit.getPlayer(uuid);

View File

@ -27,6 +27,7 @@ package com.plotsquared.bukkit.util;
import com.plotsquared.bukkit.BukkitMain; import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.player.BukkitPlayer; import com.plotsquared.bukkit.player.BukkitPlayer;
import com.plotsquared.bukkit.player.BukkitPlayerManager;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.location.Location; 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.BlockUtil;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.StringComparison; import com.plotsquared.core.util.StringComparison;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
@ -112,14 +114,14 @@ public class BukkitUtil extends WorldUtil {
private static World lastWorld = null; private static World lastWorld = null;
private static Player lastPlayer = null; private static Player lastPlayer = null;
private static PlotPlayer lastPlotPlayer = null; private static BukkitPlayer lastPlotPlayer = null;
public static void removePlayer(String player) { public static void removePlayer(String player) {
lastPlayer = null; lastPlayer = null;
lastPlotPlayer = null; lastPlotPlayer = null;
} }
public static PlotPlayer getPlayer(@NonNull final OfflinePlayer op) { public static PlotPlayer<?> getPlayer(@NonNull final OfflinePlayer op) {
if (op.isOnline()) { if (op.isOnline()) {
return getPlayer(op.getPlayer()); return getPlayer(op.getPlayer());
} }
@ -164,7 +166,7 @@ public class BukkitUtil extends WorldUtil {
* @return a {@code PlotPlayer} * @return a {@code PlotPlayer}
* @see PlotPlayer#wrap(Object) * @see PlotPlayer#wrap(Object)
*/ */
public static PlotPlayer wrapPlayer(OfflinePlayer player) { public static PlotPlayer<?> wrapPlayer(OfflinePlayer player) {
return PlotPlayer.wrap(player); return PlotPlayer.wrap(player);
} }
@ -176,7 +178,7 @@ public class BukkitUtil extends WorldUtil {
* @return a {@code PlotPlayer} * @return a {@code PlotPlayer}
* @see PlotPlayer#wrap(Object) * @see PlotPlayer#wrap(Object)
*/ */
public static PlotPlayer wrapPlayer(Player player) { public static PlotPlayer<?> wrapPlayer(Player player) {
return PlotPlayer.wrap(player); return PlotPlayer.wrap(player);
} }
@ -188,7 +190,7 @@ public class BukkitUtil extends WorldUtil {
* @return a {@code PlotPlayer} * @return a {@code PlotPlayer}
* @see PlotPlayer#wrap(Object) * @see PlotPlayer#wrap(Object)
*/ */
@Override public PlotPlayer wrapPlayer(UUID uuid) { @Override public PlotPlayer<?> wrapPlayer(UUID uuid) {
return PlotPlayer.wrap(Bukkit.getOfflinePlayer(uuid)); return PlotPlayer.wrap(Bukkit.getOfflinePlayer(uuid));
} }
@ -199,7 +201,7 @@ public class BukkitUtil extends WorldUtil {
* @return the number of allowed plots * @return the number of allowed plots
*/ */
public static int getAllowedPlots(Player player) { public static int getAllowedPlots(Player player) {
PlotPlayer plotPlayer = PlotPlayer.wrap(player); PlotPlayer<?> plotPlayer = PlotPlayer.wrap(player);
return plotPlayer.getAllowedPlots(); return plotPlayer.getAllowedPlots();
} }
@ -225,7 +227,7 @@ public class BukkitUtil extends WorldUtil {
if (world == null) { if (world == null) {
return new HashSet<>(); 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); 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) { if (player == lastPlayer) {
return lastPlotPlayer; 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) { public static Location getLocation(@NonNull final org.bukkit.Location location) {

View File

@ -50,7 +50,12 @@ import java.io.File;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface IPlotMain extends ILogger { /**
* PlotSquared main utility class
*
* @param <P> Player type
*/
public interface IPlotMain<P> extends ILogger {
/** /**
* Logs a message to console. * Logs a message to console.
@ -286,6 +291,6 @@ public interface IPlotMain extends ILogger {
* *
* @return Player manager * @return Player manager
*/ */
@NotNull PlayerManager<?, ?> getPlayerManager(); @NotNull PlayerManager<? extends PlotPlayer<P>, ? extends P> getPlayerManager();
} }

View File

@ -141,7 +141,7 @@ public class PlotSquared {
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet()); private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
private static PlotSquared instance; private static PlotSquared instance;
// Implementation // Implementation
public final IPlotMain IMP; public final IPlotMain<?> IMP;
// Current thread // Current thread
private final Thread thread; private final Thread thread;
// UUID pipelines // UUID pipelines
@ -386,7 +386,7 @@ public class PlotSquared {
return PlotSquared.instance; return PlotSquared.instance;
} }
@NotNull public static IPlotMain imp() { @NotNull public static IPlotMain<?> imp() {
if (instance != null && instance.IMP != null) { if (instance != null && instance.IMP != null) {
return instance.IMP; return instance.IMP;
} }

View File

@ -56,7 +56,7 @@ public class Add extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);

View File

@ -45,7 +45,7 @@ import java.util.concurrent.TimeoutException;
requiredType = RequiredType.PLAYER) requiredType = RequiredType.PLAYER)
public class Alias extends SubCommand { 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) { if (args.length == 0) {
Captions.COMMAND_SYNTAX.send(player, getUsage()); Captions.COMMAND_SYNTAX.send(player, getUsage());

View File

@ -83,7 +83,7 @@ import java.util.Set;
confirmation = true) confirmation = true)
public class Area extends SubCommand { 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) { if (args.length == 0) {
Captions.COMMAND_SYNTAX.send(player, getUsage()); Captions.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;

View File

@ -154,7 +154,7 @@ public class Auto extends SubCommand {
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone)); () -> 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(); PlotArea plotarea = player.getApplicablePlotArea();
if (plotarea == null) { if (plotarea == null) {
if (EconHandler.manager != null) { if (EconHandler.manager != null) {

View File

@ -70,7 +70,7 @@ public final class Backup extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
if (args.length == 0 || !Arrays.asList("save", "list", "load") if (args.length == 0 || !Arrays.asList("save", "list", "load")

View File

@ -54,7 +54,7 @@ public class Buy extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) { final RunnableVal2<Command, CommandResult> whenDone) {

View File

@ -50,7 +50,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
usage = "/plot caps") usage = "/plot caps")
public class Caps extends SubCommand { 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(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
return Captions.NOT_IN_PLOT.send(player); return Captions.NOT_IN_PLOT.send(player);

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.util.MainUtil;
requiredType = RequiredType.PLAYER) requiredType = RequiredType.PLAYER)
public class Chat extends SubCommand { 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()) { if (player.getPlotAreaAbs().isForcingPlotChat()) {
MainUtil.sendMessage(player, Captions.PLOT_CHAT_FORCED); MainUtil.sendMessage(player, Captions.PLOT_CHAT_FORCED);
return true; return true;

View File

@ -54,7 +54,7 @@ import com.plotsquared.core.util.task.TaskManager;
usage = "/plot claim") usage = "/plot claim")
public class Claim extends SubCommand { 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; String schematic = null;
if (args.length >= 1) { if (args.length >= 1) {
schematic = args[0]; schematic = args[0];

View File

@ -64,7 +64,7 @@ public class Clear extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage()); checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage());

View File

@ -54,7 +54,7 @@ import java.util.concurrent.TimeoutException;
description = "Manage a plot cluster") description = "Manage a plot cluster")
public class Cluster extends SubCommand { 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 // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
if (args.length == 0) { if (args.length == 0) {

View File

@ -32,15 +32,15 @@ import com.plotsquared.core.util.task.TaskManager;
public class CmdConfirm { public class CmdConfirm {
public static CmdInstance getPending(PlotPlayer player) { public static CmdInstance getPending(PlotPlayer<?> player) {
return player.getMeta("cmdConfirm"); return player.getMeta("cmdConfirm");
} }
public static void removePending(PlotPlayer player) { public static void removePending(PlotPlayer<?> player) {
player.deleteMeta("cmdConfirm"); player.deleteMeta("cmdConfirm");
} }
public static void addPending(final PlotPlayer player, String commandStr, public static void addPending(final PlotPlayer<?> player, String commandStr,
final Runnable runnable) { final Runnable runnable) {
removePending(player); removePending(player);
if (commandStr != null) { if (commandStr != null) {

View File

@ -106,7 +106,7 @@ public abstract class Command {
&& types[4] == RunnableVal2.class) { && types[4] == RunnableVal2.class) {
Command tmp = new Command(this, true) { Command tmp = new Command(this, true) {
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
try { try {
@ -300,7 +300,7 @@ public abstract class Command {
* @return CompletableFuture true if the command executed fully, false in * @return CompletableFuture true if the command executed fully, false in
* any other case * any other case
*/ */
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
if (args.length == 0 || args[0] == null) { if (args.length == 0 || args[0] == null) {

View File

@ -46,7 +46,7 @@ import java.util.Locale;
permission = "plots.comment") permission = "plots.comment")
public class Comment extends SubCommand { 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) { if (args.length < 2) {
sendMessage(player, Captions.COMMENT_SYNTAX, sendMessage(player, Captions.COMMENT_SYNTAX,
StringMan.join(CommentManager.inboxes.keySet(), "|")); StringMan.join(CommentManager.inboxes.keySet(), "|"));

View File

@ -54,7 +54,7 @@ public class Condense extends SubCommand {
public static boolean TASK = false; 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) { if (args.length != 2 && args.length != 3) {
MainUtil.sendMessage(player, getUsage()); MainUtil.sendMessage(player, getUsage());
return false; return false;

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.util.task.TaskManager;
category = CommandCategory.INFO) category = CommandCategory.INFO)
public class Confirm extends SubCommand { 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); CmdInstance command = CmdConfirm.getPending(player);
if (command == null) { if (command == null) {
MainUtil.sendMessage(player, Captions.FAILED_CONFIRM); MainUtil.sendMessage(player, Captions.FAILED_CONFIRM);

View File

@ -44,7 +44,7 @@ import com.plotsquared.core.util.Permissions;
requiredType = RequiredType.PLAYER) requiredType = RequiredType.PLAYER)
public class Continue extends SubCommand { 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(); Plot plot = player.getCurrentPlot();
if ((plot == null) || !plot.hasOwner()) { if ((plot == null) || !plot.hasOwner()) {
return !sendMessage(player, Captions.NOT_IN_PLOT); return !sendMessage(player, Captions.NOT_IN_PLOT);

View File

@ -41,7 +41,7 @@ import com.plotsquared.core.util.Permissions;
requiredType = RequiredType.NONE) requiredType = RequiredType.NONE)
public class Copy extends SubCommand { 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(); Location location = player.getLocation();
Plot plot1 = location.getPlotAbs(); Plot plot1 = location.getPlotAbs();
if (plot1 == null) { if (plot1 == null) {

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.util.MainUtil;
usage = "/plot createroadschematic") usage = "/plot createroadschematic")
public class CreateRoadSchematic extends SubCommand { 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(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {

View File

@ -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) { if (args.length < 1) {
MainUtil.sendMessage(player, getUsage()); MainUtil.sendMessage(player, getUsage());
return false; return false;

View File

@ -48,7 +48,7 @@ import java.util.Map;
permission = "plots.admin") permission = "plots.admin")
public class Debug extends SubCommand { 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 (args.length > 0) {
if ("player".equalsIgnoreCase(args[0])) { if ("player".equalsIgnoreCase(args[0])) {
for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) { for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) {

View File

@ -42,7 +42,7 @@ public class DebugAllowUnsafe extends SubCommand {
public static final List<UUID> unsafeAllowed = new ArrayList<>(); public static final List<UUID> unsafeAllowed = new ArrayList<>();
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (unsafeAllowed.contains(player.getUUID())) { if (unsafeAllowed.contains(player.getUUID())) {
unsafeAllowed.remove(player.getUUID()); unsafeAllowed.remove(player.getUUID());

View File

@ -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<String> allowed_params = Arrays List<String> allowed_params = Arrays
.asList("analyze", "calibrate-analysis", "remove-flag", "stop-expire", "start-expire", .asList("analyze", "calibrate-analysis", "remove-flag", "stop-expire", "start-expire",
"seen", "list-scripts", "start-rgar", "stop-rgar", "help", "addcmd", "runasync", "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, new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null,
RequiredType.NONE, CommandCategory.DEBUG) { RequiredType.NONE, CommandCategory.DEBUG) {
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, public CompletableFuture<Boolean> execute(PlotPlayer<?> player,
String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
try { try {

View File

@ -52,7 +52,7 @@ public class DebugImportWorlds extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)) // UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.player.PlotPlayer;
requiredType = RequiredType.CONSOLE) requiredType = RequiredType.CONSOLE)
public class DebugLoadTest extends SubCommand { 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(); PlotSquared.get().plots_tmp = DBFunc.getPlots();
return true; return true;
} }

View File

@ -71,7 +71,7 @@ public class DebugPaste extends SubCommand {
return content.toString(); return content.toString();
} }
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
try { try {

View File

@ -46,7 +46,7 @@ import java.util.Arrays;
public class DebugRoadRegen extends SubCommand { public class DebugRoadRegen extends SubCommand {
public static final String USAGE = "/plot debugroadregen <plot|region [height]>"; public static final String USAGE = "/plot debugroadregen <plot|region [height]>";
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (args.length < 1) { if (args.length < 1) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE); MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE);
return false; return false;

View File

@ -41,7 +41,7 @@ import java.util.ArrayList;
description = "This command will force the recreation of all plots in the DB") description = "This command will force the recreation of all plots in the DB")
public class DebugSaveTest extends SubCommand { public class DebugSaveTest extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots()); ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
MainUtil.sendMessage(player, "&6Starting `DEBUGSAVETEST`"); MainUtil.sendMessage(player, "&6Starting `DEBUGSAVETEST`");
DBFunc.createPlotsAndData(plots, DBFunc.createPlotsAndData(plots,

View File

@ -53,7 +53,7 @@ public class Delete extends SubCommand {
// Note: To delete a specific plot use /plot <plot> delete // Note: To delete a specific plot use /plot <plot> delete
// The syntax also works with any command: /plot <plot> <command> // The syntax also works with any command: /plot <plot> <command>
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {

View File

@ -51,7 +51,7 @@ public class Deny extends SubCommand {
super(Argument.PlayerName); super(Argument.PlayerName);
} }
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();

View File

@ -35,7 +35,7 @@ import com.plotsquared.core.player.PlotPlayer;
requiredType = RequiredType.PLAYER) requiredType = RequiredType.PLAYER)
public class Dislike extends SubCommand { 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); return Like.handleLike(player, args, false);
} }

View File

@ -51,7 +51,7 @@ import com.plotsquared.core.util.task.RunnableVal;
requiredType = RequiredType.NONE) requiredType = RequiredType.NONE)
public class Done extends SubCommand { 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(); Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if ((plot == null) || !plot.hasOwner()) { if ((plot == null) || !plot.hasOwner()) {

View File

@ -50,7 +50,7 @@ import java.net.URL;
permission = "plots.download") permission = "plots.download")
public class Download extends SubCommand { 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(); String world = player.getLocation().getWorld();
if (!PlotSquared.get().hasPlotArea(world)) { if (!PlotSquared.get().hasPlotArea(world)) {
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);

View File

@ -207,7 +207,7 @@ public final class FlagCommand extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
if (args.length == 0 || !Arrays if (args.length == 0 || !Arrays

View File

@ -53,7 +53,7 @@ public class Grant extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
checkTrue(args.length >= 1 && args.length <= 2, Captions.COMMAND_SYNTAX, getUsage()); checkTrue(args.length >= 1 && args.length <= 2, Captions.COMMAND_SYNTAX, getUsage());

View File

@ -52,7 +52,7 @@ public class Help extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
switch (args.length) { switch (args.length) {

View File

@ -86,7 +86,7 @@ public class Inbox extends SubCommand {
MainUtil.sendMessage(player, string.toString()); 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(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
sendMessage(player, Captions.NOT_IN_PLOT); sendMessage(player, Captions.NOT_IN_PLOT);

View File

@ -41,7 +41,7 @@ import com.plotsquared.core.util.task.RunnableVal;
category = CommandCategory.INFO) category = CommandCategory.INFO)
public class Info extends SubCommand { 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; Plot plot;
String arg; String arg;
if (args.length > 0) { if (args.length > 0) {

View File

@ -53,7 +53,7 @@ public class Kick extends SubCommand {
super(Argument.PlayerName); super(Argument.PlayerName);
} }
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlot(); Plot plot = location.getPlot();
if (plot == null) { if (plot == null) {

View File

@ -48,7 +48,7 @@ public class Leave extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);

View File

@ -175,7 +175,7 @@ public class Like extends SubCommand {
return numLikes / (numLikes + numDislikes); 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); return handleLike(player, args, true);
} }

View File

@ -116,7 +116,7 @@ public class ListCmd extends SubCommand {
.toString(getArgumentList(player))); .toString(getArgumentList(player)));
} }
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (args.length < 1) { if (args.length < 1) {
noArgs(player); noArgs(player);
return false; return false;

View File

@ -52,7 +52,7 @@ import java.util.List;
usage = "/plot load") usage = "/plot load")
public class Load extends SubCommand { 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(); String world = player.getLocation().getWorld();
if (!PlotSquared.get().hasPlotArea(world)) { if (!PlotSquared.get().hasPlotArea(world)) {
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
@ -152,7 +152,7 @@ public class Load extends SubCommand {
return true; return true;
} }
public void displaySaves(PlotPlayer player) { public void displaySaves(PlotPlayer<?> player) {
List<String> schematics = player.getMeta("plot_schematics"); List<String> schematics = player.getMeta("plot_schematics");
for (int i = 0; i < Math.min(schematics.size(), 32); i++) { for (int i = 0; i < Math.min(schematics.size(), 32); i++) {
try { try {

View File

@ -217,7 +217,7 @@ public class MainCommand extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
// Clear perm caching // // Clear perm caching //

View File

@ -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(); Location location = player.getLocationFull();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.plot.Plot;
requiredType = RequiredType.PLAYER) requiredType = RequiredType.PLAYER)
public class Middle extends SubCommand { 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(); Location location = player.getLocation();
Plot plot = location.getPlot(); Plot plot = location.getPlot();
if (plot == null) { if (plot == null) {

View File

@ -47,7 +47,7 @@ import java.util.concurrent.CompletableFuture;
public class Move extends SubCommand { public class Move extends SubCommand {
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
Location location = player.getLocation(); 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; return true;
} }

View File

@ -55,7 +55,7 @@ public class Music extends SubCommand {
"music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal", "music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal",
"music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait"); "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(); Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {

View File

@ -46,7 +46,7 @@ public class Near extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);

View File

@ -39,7 +39,7 @@ import com.plotsquared.core.util.task.TaskManager;
category = CommandCategory.INFO) category = CommandCategory.INFO)
public class PluginCmd extends SubCommand { 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(() -> { TaskManager.IMP.taskAsync(() -> {
MainUtil.sendMessage(player, String.format( MainUtil.sendMessage(player, String.format(
"$2>> $1&l" + PlotSquared.imp().getPluginName() + " $2($1Version$2: $1%s$2)", "$2>> $1&l" + PlotSquared.imp().getPluginName() + " $2($1Version$2: $1%s$2)",

View File

@ -53,7 +53,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
confirmation = true) confirmation = true)
public class Purge extends SubCommand { 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) { if (args.length == 0) {
Captions.COMMAND_SYNTAX.send(player, getUsage()); Captions.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;

View File

@ -56,7 +56,7 @@ import java.util.UUID;
requiredType = RequiredType.PLAYER) requiredType = RequiredType.PLAYER)
public class Rate extends SubCommand { 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) { if (args.length == 1) {
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "next": { case "next": {

View File

@ -43,7 +43,7 @@ import com.plotsquared.core.util.MainUtil;
permission = "plots.regenallroads") permission = "plots.regenallroads")
public class RegenAllRoads extends SubCommand { public class RegenAllRoads extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
int height = 0; int height = 0;
if (args.length == 2) { if (args.length == 2) {
try { try {

View File

@ -47,7 +47,7 @@ public class Relight extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();

View File

@ -45,7 +45,7 @@ import java.util.Objects;
category = CommandCategory.ADMINISTRATION) category = CommandCategory.ADMINISTRATION)
public class Reload extends SubCommand { public class Reload extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
try { try {
// The following won't affect world generation, as that has to be // The following won't affect world generation, as that has to be
// loaded during startup unfortunately. // loaded during startup unfortunately.

View File

@ -50,7 +50,7 @@ public class Remove extends SubCommand {
super(Argument.PlayerName); super(Argument.PlayerName);
} }
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {

View File

@ -49,7 +49,7 @@ import java.util.UUID;
permission = "plots.save") permission = "plots.save")
public class Save extends SubCommand { 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(); String world = player.getLocation().getWorld();
if (!PlotSquared.get().hasPlotArea(world)) { if (!PlotSquared.get().hasPlotArea(world)) {
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);

View File

@ -57,7 +57,7 @@ public class SchematicCmd extends SubCommand {
private boolean running = false; 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) { if (args.length < 1) {
sendMessage(player, Captions.SCHEMATIC_MISSING_ARG); sendMessage(player, Captions.SCHEMATIC_MISSING_ARG);
return true; return true;

View File

@ -176,7 +176,7 @@ public class Set extends SubCommand {
return false; return false;
} }
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (args.length == 0) { if (args.length == 0) {
return noArgs(player); return noArgs(player);
} }

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.util.StringMan;
public abstract class SetCommand extends SubCommand { 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(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {

View File

@ -90,7 +90,7 @@ public class Setup extends SubCommand {
MainUtil.sendMessage(player, message.toString()); MainUtil.sendMessage(player, message.toString());
} }
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
// going through setup // going through setup
SetupObject object = player.getMeta("setup"); SetupObject object = player.getMeta("setup");
if (object == null) { if (object == null) {

View File

@ -54,11 +54,11 @@ public abstract class SubCommand extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
return CompletableFuture.completedFuture(onCommand(player, args)); return CompletableFuture.completedFuture(onCommand(player, args));
} }
public abstract boolean onCommand(PlotPlayer player, String[] args); public abstract boolean onCommand(PlotPlayer<?> player, String[] args);
} }

View File

@ -45,7 +45,7 @@ import java.util.concurrent.CompletableFuture;
public class Swap extends SubCommand { public class Swap extends SubCommand {
@Override @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
Location location = player.getLocation(); 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; return true;
} }
} }

View File

@ -45,7 +45,7 @@ public class Target extends SubCommand {
super(Argument.PlotID); super(Argument.PlotID);
} }
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();
if (!location.isPlotArea()) { if (!location.isPlotArea()) {
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD); MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD);

View File

@ -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 != 2 && args.length != 3) {
if (args.length == 1) { if (args.length == 1) {
if (args[0].equalsIgnoreCase("export")) { if (args[0].equalsIgnoreCase("export")) {

View File

@ -159,7 +159,7 @@ public class Trim extends SubCommand {
return true; return true;
} }
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
if (args.length == 0) { if (args.length == 0) {
Captions.COMMAND_SYNTAX.send(player, getUsage()); Captions.COMMAND_SYNTAX.send(player, getUsage());
return false; return false;

View File

@ -56,7 +56,7 @@ public class Trust extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot currentPlot = player.getCurrentPlot(); final Plot currentPlot = player.getCurrentPlot();

View File

@ -46,7 +46,7 @@ import com.plotsquared.core.util.task.TaskManager;
confirmation = true) confirmation = true)
public class Unlink extends SubCommand { 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(); Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {

View File

@ -139,7 +139,7 @@ public class Visit extends Command {
} }
@Override @Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, public CompletableFuture<Boolean> execute(final PlotPlayer<?> player,
String[] args, String[] args,
final RunnableVal3<Command, Runnable, Runnable> confirm, final RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) throws CommandException { final RunnableVal2<Command, CommandResult> whenDone) throws CommandException {

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.player.PlotPlayer;
@Deprecated @Deprecated
public class WE_Anywhere extends SubCommand { 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); MainCommand.getInstance().toggle.worldedit(this, player, new String[0], null, null);
return true; return true;
} }

View File

@ -46,7 +46,7 @@ public class ComponentCommand extends SubCommand {
this.componentPresetManager = componentPresetManager; 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); final PlotInventory inventory = componentPresetManager.buildInventory(player);
if (inventory != null) { if (inventory != null) {
inventory.openInventory(); inventory.openInventory();

View File

@ -123,7 +123,7 @@ public class PlotListener {
}, 20); }, 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 if (plot.isDenied(player.getUUID()) && !Permissions
.hasPermission(player, "plots.admin.entry.denied")) { .hasPermission(player, "plots.admin.entry.denied")) {
return false; return false;
@ -293,7 +293,7 @@ public class PlotListener {
return true; 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); Object previous = player.deleteMeta(PlotPlayer.META_LAST_PLOT);
PlotSquared.get().getEventDispatcher().callLeave(player, plot); PlotSquared.get().getEventDispatcher().callLeave(player, plot);
if (plot.hasOwner()) { if (plot.hasOwner()) {

View File

@ -41,7 +41,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.UUID; import java.util.UUID;
public class ConsolePlayer extends PlotPlayer { public class ConsolePlayer extends PlotPlayer<Actor> {
private static ConsolePlayer instance; private static ConsolePlayer instance;
@ -71,6 +71,10 @@ public class ConsolePlayer extends PlotPlayer {
return PlotSquared.get().IMP.getConsole(); return PlotSquared.get().IMP.getConsole();
} }
@Override public Actor getPlatformPlayer() {
return this.toActor();
}
@Override public boolean canTeleport(@NotNull Location location) { @Override public boolean canTeleport(@NotNull Location location) {
return true; return true;
} }

View File

@ -68,7 +68,7 @@ import java.util.stream.Collectors;
/** /**
* The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}. * The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}.
*/ */
public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer {
public static final String META_LAST_PLOT = "lastplot"; public static final String META_LAST_PLOT = "lastplot";
public static final String META_LOCATION = "location"; public static final String META_LOCATION = "location";
@ -103,12 +103,14 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
* @param player * @param player
* @return * @return
*/ */
public static PlotPlayer wrap(Object player) { public static PlotPlayer<?> wrap(Object player) {
return PlotSquared.get().IMP.wrapPlayer(player); return PlotSquared.get().IMP.wrapPlayer(player);
} }
public abstract Actor toActor(); public abstract Actor toActor();
public abstract P getPlatformPlayer();
/** /**
* Set some session only metadata for this player. * Set some session only metadata for this player.
* *

View File

@ -399,9 +399,9 @@ public class Plot {
* *
* @return list of PlotPlayer(s) or an empty list * @return list of PlotPlayer(s) or an empty list
*/ */
public List<PlotPlayer> getPlayersInPlot() { public List<PlotPlayer<?>> getPlayersInPlot() {
final List<PlotPlayer> players = new ArrayList<>(); final List<PlotPlayer<?>> players = new ArrayList<>();
for (final PlotPlayer player : PlotSquared.imp().getPlayerManager().getPlayers()) { for (final PlotPlayer<?> player : PlotSquared.imp().getPlayerManager().getPlayers()) {
if (this.equals(player.getCurrentPlot())) { if (this.equals(player.getCurrentPlot())) {
players.add(player); players.add(player);
} }
@ -1323,8 +1323,8 @@ public class Plot {
return false; return false;
} }
for (Plot current : getConnectedPlots()) { for (Plot current : getConnectedPlots()) {
List<PlotPlayer> players = current.getPlayersInPlot(); List<PlotPlayer<?>> players = current.getPlayersInPlot();
for (PlotPlayer pp : players) { for (PlotPlayer<?> pp : players) {
PlotListener.plotExit(pp, current); PlotListener.plotExit(pp, current);
} }

View File

@ -33,40 +33,40 @@ import lombok.NonNull;
public class PlotInventory { public class PlotInventory {
private static final String META_KEY = "inventory"; private static final String META_KEY = "inventory";
public final PlotPlayer player; public final PlotPlayer<?> player;
public final int size; public final int size;
private final PlotItemStack[] items; private final PlotItemStack[] items;
private String title; private String title;
private boolean open = false; private boolean open = false;
public PlotInventory(PlotPlayer player) { public PlotInventory(PlotPlayer<?> player) {
this.size = 4; this.size = 4;
this.title = null; this.title = null;
this.player = player; this.player = player;
this.items = InventoryUtil.manager.getItems(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.size = size;
this.title = name == null ? "" : name; this.title = name == null ? "" : name;
this.player = player; this.player = player;
this.items = new PlotItemStack[size * 9]; 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; 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); 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) { @NonNull final PlotInventory plotInventory) {
plotPlayer.setMeta(META_KEY, plotInventory); plotPlayer.setMeta(META_KEY, plotInventory);
} }
public static void removePlotInventoryOpen(@NonNull final PlotPlayer plotPlayer) { public static void removePlotInventoryOpen(@NonNull final PlotPlayer<?>plotPlayer) {
plotPlayer.deleteMeta(META_KEY); plotPlayer.deleteMeta(META_KEY);
} }

View File

@ -75,7 +75,7 @@ import java.util.concurrent.atomic.AtomicInteger;
}, 20); }, 20);
} }
public static long getTimestamp(PlotPlayer player, String inbox) { public static long getTimestamp(PlotPlayer<?> player, String inbox) {
return player.getMeta("inbox:" + inbox, player.getLastPlayed()); return player.getMeta("inbox:" + inbox, player.getLastPlayed());
} }

View File

@ -83,7 +83,7 @@ public class ExpireManager {
this.tasks.add(task); this.tasks.add(task);
} }
public void handleJoin(PlotPlayer pp) { public void handleJoin(PlotPlayer<?> pp) {
storeDate(pp.getUUID(), System.currentTimeMillis()); storeDate(pp.getUUID(), System.currentTimeMillis());
if (plotsToDelete != null && !plotsToDelete.isEmpty()) { if (plotsToDelete != null && !plotsToDelete.isEmpty()) {
for (Plot plot : pp.getPlots()) { for (Plot plot : pp.getPlots()) {

View File

@ -61,7 +61,7 @@ public class Permissions {
* @param permission * @param permission
* @return * @return
*/ */
public static boolean hasPermission(PlotPlayer player, String permission) { public static boolean hasPermission(PlotPlayer<?> player, String permission) {
if (!Settings.Enabled_Components.PERMISSION_CACHE) { if (!Settings.Enabled_Components.PERMISSION_CACHE) {
return hasPermission((CommandCaller) player, permission); return hasPermission((CommandCaller) player, permission);
} }

View File

@ -39,7 +39,7 @@ import java.util.UUID;
/** /**
* Manages player instances * Manages player instances
*/ */
public abstract class PlayerManager<P extends PlotPlayer, O extends OfflinePlotPlayer> { public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
private final Map<UUID, P> playerMap = new HashMap<>(); private final Map<UUID, P> playerMap = new HashMap<>();
private final Object playerLock = new Object(); private final Object playerLock = new Object();
@ -77,6 +77,18 @@ public abstract class PlayerManager<P extends PlotPlayer, O extends OfflinePlotP
return null; return null;
} }
/**
* Get a plot player from a platform player object. This method requires
* that the caller actually knows that the player exists.
* <p>
* 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 * Get a plot player from a UUID. This method requires
* that the caller actually knows that the player exists. * that the caller actually knows that the player exists.
@ -106,7 +118,7 @@ public abstract class PlayerManager<P extends PlotPlayer, O extends OfflinePlotP
* @param uuid Player UUID * @param uuid Player UUID
* @return Offline player object * @return Offline player object
*/ */
@Nullable public abstract O getOfflinePlayer(@Nullable final UUID uuid); @Nullable public abstract OfflinePlotPlayer getOfflinePlayer(@Nullable final UUID uuid);
/** /**
* Get an offline player object from the player's username * Get an offline player object from the player's username
@ -114,7 +126,7 @@ public abstract class PlayerManager<P extends PlotPlayer, O extends OfflinePlotP
* @param username Player name * @param username Player name
* @return Offline player object * @return Offline player object
*/ */
@Nullable public abstract O getOfflinePlayer(@NotNull final String username); @Nullable public abstract OfflinePlotPlayer getOfflinePlayer(@NotNull final String username);
/** /**
* Get all online players * Get all online players
@ -132,6 +144,9 @@ public abstract class PlayerManager<P extends PlotPlayer, O extends OfflinePlotP
super(String.format("There is no online player with UUID '%s'", uuid.toString())); super(String.format("There is no online player with UUID '%s'", uuid.toString()));
} }
@Override public synchronized Throwable fillInStackTrace() {
return this;
}
} }
} }

View File

@ -83,7 +83,7 @@ public class WEManager {
return false; return false;
} }
public static HashSet<CuboidRegion> getMask(PlotPlayer player) { public static HashSet<CuboidRegion> getMask(PlotPlayer<?> player) {
HashSet<CuboidRegion> regions = new HashSet<>(); HashSet<CuboidRegion> regions = new HashSet<>();
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
Location location = player.getLocation(); Location location = player.getLocation();