diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java
index a31faeb2b..3c39850e7 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java
@@ -573,7 +573,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
}
final Plot plot = area.getOwnedPlot(id);
if (plot != null) {
- if (!plot.getFlag(ServerPlotFlag.class) || PlotPlayer.wrap(plot.getOwner()) == null) {
+ if (!plot.getFlag(ServerPlotFlag.class) || PlotSquared.platform().getPlayerManager()
+ .getPlayerIfExists(plot.getOwner()) == null) {
if (world.getKeepSpawnInMemory()) {
world.setKeepSpawnInMemory(false);
return;
@@ -1081,39 +1082,6 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
}
}
- /**
- * Attempt to retrieve a {@link PlotPlayer} from a player identifier.
- * This method accepts:
- * - {@link Player} objects,
- * - {@link OfflinePlayer} objects,
- * - {@link String} usernames for online players, and
- * - {@link UUID} UUIDs for online players
- *
- * In the case of offline players, a fake {@link Player} instance will be created.
- * This is a rather expensive operation, and should be avoided if possible.
- *
- * @param player The player to convert to a PlotPlayer
- * @return The plot player instance that corresponds to the identifier, or null
- * if no such player object could be created
- */
- @Override @Nullable public PlotPlayer wrapPlayer(final Object player) {
- if (player instanceof Player) {
- return BukkitUtil.adapt((Player) player);
- }
- if (player instanceof OfflinePlayer) {
- return BukkitUtil.adapt((OfflinePlayer) player);
- }
- if (player instanceof String) {
- return (PlotPlayer) PlotSquared.platform().getPlayerManager()
- .getPlayerIfExists((String) player);
- }
- if (player instanceof UUID) {
- return (PlotPlayer) PlotSquared.platform().getPlayerManager()
- .getPlayerIfExists((UUID) player);
- }
- return null;
- }
-
@Override public String getNMSPackage() {
final String name = Bukkit.getServer().getClass().getPackage().getName();
return name.substring(name.lastIndexOf('.') + 1);
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java
index 9226c5847..799fbf2b1 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitOfflinePlayer.java
@@ -30,6 +30,8 @@ import com.plotsquared.core.permissions.PermissionHandler;
import com.plotsquared.core.permissions.PermissionProfile;
import com.plotsquared.core.player.OfflinePlotPlayer;
import org.bukkit.OfflinePlayer;
+
+import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -43,8 +45,6 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
/**
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player),
* as it caches player objects.
- *
- * @param player
*/
public BukkitOfflinePlayer(@Nonnull final OfflinePlayer player, @Nonnull final
PermissionHandler permissionHandler) {
@@ -57,12 +57,8 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
return this.player.getUniqueId();
}
- @Override public long getLastPlayed() {
- return this.player.getLastPlayed();
- }
-
- @Override public boolean isOnline() {
- return this.player.isOnline();
+ @Override @Nonnegative public long getLastPlayed() {
+ return this.player.getLastSeen();
}
@Override public String getName() {
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 1415c2840..b66eed10f 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java
@@ -75,10 +75,8 @@ public class BukkitPlayer extends PlotPlayer {
private final EconHandler econHandler;
public final Player player;
- private boolean offline;
private String name;
-
/**
* Please do not use this method. Instead use
* BukkitUtil.getPlayer(Player), as it caches player objects.
@@ -90,19 +88,12 @@ public class BukkitPlayer extends PlotPlayer {
this(plotAreaManager, eventDispatcher, player, false, econHandler, permissionHandler);
}
- public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher,
- @Nonnull final Player player, final boolean offline, @Nullable final EconHandler econHandler,
- @Nonnull final PermissionHandler permissionHandler) {
- this(plotAreaManager, eventDispatcher, player, offline, true, econHandler, permissionHandler);
- }
-
public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final
- EventDispatcher eventDispatcher, @Nonnull final Player player, final boolean offline,
+ EventDispatcher eventDispatcher, @Nonnull final Player player,
final boolean realPlayer, @Nullable final EconHandler econHandler,
@Nonnull final PermissionHandler permissionHandler) {
super(plotAreaManager, eventDispatcher, econHandler, permissionHandler);
this.player = player;
- this.offline = offline;
this.econHandler = econHandler;
if (realPlayer) {
super.populatePersistentMetaMap();
@@ -130,8 +121,8 @@ public class BukkitPlayer extends PlotPlayer {
return player.getUniqueId();
}
- @Override public long getLastPlayed() {
- return this.player.getLastPlayed();
+ @Override @Nonnegative public long getLastPlayed() {
+ return this.player.getLastSeen();
}
@Override public boolean canTeleport(@Nonnull final Location location) {
@@ -255,10 +246,6 @@ public class BukkitPlayer extends PlotPlayer {
return this.name;
}
- @Override public boolean isOnline() {
- return !this.offline && this.player.isOnline();
- }
-
@Override public void setCompassTarget(Location location) {
this.player.setCompassTarget(
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorldName()), location.getX(),
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 d05fafd7a..78af765a2 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayerManager.java
@@ -60,11 +60,13 @@ import java.util.UUID;
}
@Nonnull @Override public BukkitPlayer getPlayer(@Nonnull final Player object) {
+ if (!object.isOnline()) {
+ throw new NoSuchPlayerException(object.getUniqueId());
+ }
try {
return getPlayer(object.getUniqueId());
} catch (final NoSuchPlayerException exception) {
- return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, object,
- object.isOnline(), false, this.econHandler, this.permissionHandler);
+ return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, object, false, this.econHandler, this.permissionHandler);
}
}
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 1d88f9a6f..3537c25a2 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
@@ -53,7 +53,6 @@ import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
-import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
@@ -101,7 +100,6 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
-import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.IntConsumer;
import java.util.stream.Stream;
@@ -116,24 +114,6 @@ import java.util.stream.Stream;
super(regionManager);
}
- /**
- * Get a {@link PlotPlayer} from an {@link OfflinePlayer}. If the player is
- * online, it returns a complete player. If the player is offline, it creates
- * a fake player
- *
- * @param op Offline player
- * @return Plot player instance
- */
- @Nonnull public static PlotPlayer adapt(@Nonnull final OfflinePlayer op) {
- if (op.isOnline()) {
- return adapt(Objects.requireNonNull(op.getPlayer()));
- }
- final Player player = OfflinePlayerUtil.loadPlayer(op);
- player.loadData();
- return new BukkitPlayer(PlotSquared.get().getPlotAreaManager(),
- PlotSquared.get().getEventDispatcher(), player, true, PlotSquared.platform().getEconHandler(), PlotSquared.platform().getPermissionHandler());
- }
-
/**
* Turn a Bukkit {@link Player} into a PlotSquared {@link PlotPlayer}
*
@@ -214,18 +194,6 @@ import java.util.stream.Stream;
}
}
- /**
- * Gets the PlotPlayer for a UUID. The PlotPlayer is usually cached and
- * will provide useful functions relating to players.
- *
- * @param uuid the uuid to wrap
- * @return a {@code PlotPlayer}
- * @see PlotPlayer#wrap(Object)
- */
- @Override @Nonnull public PlotPlayer> getPlayer(@Nonnull final UUID uuid) {
- return PlotPlayer.wrap(Bukkit.getOfflinePlayer(uuid));
- }
-
@Override public boolean isBlockSame(@Nonnull final BlockState block1,
@Nonnull final BlockState block2) {
if (block1.equals(block2)) {
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java
deleted file mode 100644
index 41ae4dedd..000000000
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * _____ _ _ _____ _
- * | __ \| | | | / ____| | |
- * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
- * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
- * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
- * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
- * | |
- * |_|
- * PlotSquared plot management system for Minecraft
- * Copyright (C) 2020 IntellectualSites
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.plotsquared.bukkit.util;
-
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Player;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.UUID;
-
-import static com.plotsquared.core.util.ReflectionUtils.callConstructor;
-import static com.plotsquared.core.util.ReflectionUtils.callMethod;
-import static com.plotsquared.core.util.ReflectionUtils.getCbClass;
-import static com.plotsquared.core.util.ReflectionUtils.getField;
-import static com.plotsquared.core.util.ReflectionUtils.getNmsClass;
-import static com.plotsquared.core.util.ReflectionUtils.getUtilClass;
-import static com.plotsquared.core.util.ReflectionUtils.makeConstructor;
-import static com.plotsquared.core.util.ReflectionUtils.makeField;
-import static com.plotsquared.core.util.ReflectionUtils.makeMethod;
-
-public class OfflinePlayerUtil {
-
- public static Player loadPlayer(OfflinePlayer player) {
- if (player == null) {
- return null;
- }
- if (player instanceof Player) {
- return (Player) player;
- }
- return loadPlayer(player.getUniqueId(), player.getName());
- }
-
- private static Player loadPlayer(UUID id, String name) {
- Object server = getMinecraftServer();
- Object interactManager = newPlayerInteractManager();
- Object worldServer = getWorldServer();
- Object profile = newGameProfile(id, name);
- Class> entityPlayerClass = getNmsClass("EntityPlayer");
- Constructor entityPlayerConstructor =
- makeConstructor(entityPlayerClass, getNmsClass("MinecraftServer"),
- getNmsClass("WorldServer"), getUtilClass("com.mojang.authlib.GameProfile"),
- getNmsClass("PlayerInteractManager"));
- Object entityPlayer =
- callConstructor(entityPlayerConstructor, server, worldServer, profile, interactManager);
- return (Player) getBukkitEntity(entityPlayer);
- }
-
- private static Object newGameProfile(UUID id, String name) {
- Class> gameProfileClass = getUtilClass("com.mojang.authlib.GameProfile");
- if (gameProfileClass == null) { //Before uuids
- return name;
- }
- Constructor gameProfileConstructor =
- makeConstructor(gameProfileClass, UUID.class, String.class);
- if (gameProfileConstructor == null) { //Version has string constructor
- gameProfileConstructor = makeConstructor(gameProfileClass, String.class, String.class);
- return callConstructor(gameProfileConstructor, id.toString(), name);
- } else { //Version has uuid constructor
- return callConstructor(gameProfileConstructor, id, name);
- }
- }
-
- private static Object newPlayerInteractManager() {
- Object worldServer = getWorldServer();
- Class> playerInteractClass = getNmsClass("PlayerInteractManager");
- Class> worldClass = getNmsClass("World");
- Constructor> c = makeConstructor(playerInteractClass, worldClass);
- if (c == null) {
- c = makeConstructor(playerInteractClass, getNmsClass("WorldServer"));
- }
- return callConstructor(c, worldServer);
- }
-
- public static Object getWorldServerNew() {
- Object server = getMinecraftServer();
- Class> minecraftServerClass = getNmsClass("MinecraftServer");
- Class> dimensionManager = getNmsClass("DimensionManager");
- Object overworld = getField(makeField(dimensionManager, "OVERWORLD"), null);
- Method getWorldServer =
- makeMethod(minecraftServerClass, "getWorldServer", dimensionManager);
- return callMethod(getWorldServer, server, overworld);
- }
-
- private static Object getWorldServer() {
- Object server = getMinecraftServer();
- Class> minecraftServerClass = getNmsClass("MinecraftServer");
- Method getWorldServer = makeMethod(minecraftServerClass, "getWorldServer", int.class);
- Object o;
- try {
- o = callMethod(getWorldServer, server, 0);
- } catch (final RuntimeException e) {
- o = getWorldServerNew();
- }
- return o;
- }
-
- //NMS Utils
-
- private static Object getMinecraftServer() {
- return callMethod(makeMethod(getCbClass("CraftServer"), "getServer"), Bukkit.getServer());
- }
-
- private static Entity getBukkitEntity(Object o) {
- Method getBukkitEntity = makeMethod(o.getClass(), "getBukkitEntity");
- return callMethod(getBukkitEntity, o);
- }
-}
diff --git a/Core/src/main/java/com/plotsquared/core/PlotAPI.java b/Core/src/main/java/com/plotsquared/core/PlotAPI.java
index 9a83aae5e..1450a3f4e 100644
--- a/Core/src/main/java/com/plotsquared/core/PlotAPI.java
+++ b/Core/src/main/java/com/plotsquared/core/PlotAPI.java
@@ -39,6 +39,8 @@ import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.query.PlotQuery;
import lombok.NoArgsConstructor;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Set;
import java.util.UUID;
@@ -178,10 +180,9 @@ import java.util.UUID;
*
* @param uuid the uuid of the player to wrap
* @return a {@code PlotPlayer}
- * @see PlotPlayer#wrap(Object)
*/
- public PlotPlayer wrapPlayer(UUID uuid) {
- return PlotPlayer.wrap(uuid);
+ @Nullable public PlotPlayer> wrapPlayer(@Nonnull final UUID uuid) {
+ return PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
}
/**
@@ -189,10 +190,9 @@ import java.util.UUID;
*
* @param player the player to wrap
* @return a {@code PlotPlayer}
- * @see PlotPlayer#wrap(Object)
*/
- public PlotPlayer wrapPlayer(String player) {
- return PlotPlayer.wrap(player);
+ @Nullable public PlotPlayer> wrapPlayer(@Nonnull final String player) {
+ return PlotSquared.platform().getPlayerManager().getPlayerIfExists(player);
}
/**
diff --git a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java
index c84bce2b9..51f5ff6e1 100644
--- a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java
+++ b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java
@@ -27,6 +27,7 @@ package com.plotsquared.core;
import com.google.inject.Injector;
import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
import com.plotsquared.core.backup.BackupManager;
import com.plotsquared.core.generator.GeneratorWrapper;
import com.plotsquared.core.generator.HybridUtils;
@@ -80,14 +81,6 @@ public interface PlotPlatform extends ILogger {
*/
File getWorldContainer();
- /**
- * Wraps a player into a PlotPlayer object.
- *
- * @param player The player to convert to a PlotPlayer
- * @return A PlotPlayer
- */
- @Nullable PlotPlayer
wrapPlayer(Object player);
-
/**
* Completely shuts down the plugin.
*/
@@ -186,7 +179,7 @@ public interface PlotPlatform
extends ILogger {
* @return Player manager
*/
@Nonnull default PlayerManager extends PlotPlayer
, ? extends P> getPlayerManager() {
- return getInjector().getInstance(PlayerManager.class);
+ return getInjector().getInstance(Key.get(new TypeLiteral, ? extends P>>() {}));
}
/**
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 88f4dd4af..8fe688834 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Buy.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java
@@ -93,7 +93,7 @@ public class Buy extends Command {
this.econHandler.depositMoney(PlotSquared.platform().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
- PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs());
+ PlotPlayer> owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs());
if (owner != null) {
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
}
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 2579976a4..c9fe94e41 100644
--- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java
+++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java
@@ -94,7 +94,7 @@ public class PlotListener {
++value.count;
if (value.count == value.interval) {
value.count = 0;
- PlotPlayer> player = PlotPlayer.wrap(entry.getKey());
+ final PlotPlayer> player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(entry.getKey());
if (player == null) {
iterator.remove();
continue;
@@ -114,7 +114,7 @@ public class PlotListener {
++value.count;
if (value.count == value.interval) {
value.count = 0;
- PlotPlayer> player = PlotSquared.platform().getWorldUtil().getPlayer(entry.getKey());
+ final PlotPlayer> player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(entry.getKey());
if (player == null) {
iterator.remove();
continue;
diff --git a/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java b/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java
index 4ae1c5c1f..7cfbd2751 100644
--- a/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java
+++ b/Core/src/main/java/com/plotsquared/core/listener/WESubscriber.java
@@ -26,6 +26,7 @@
package com.plotsquared.core.listener;
import com.google.inject.Inject;
+import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.player.PlotPlayer;
@@ -72,7 +73,7 @@ public class WESubscriber {
Actor actor = event.getActor();
if (actor != null && actor.isPlayer()) {
String name = actor.getName();
- PlotPlayer plotPlayer = PlotPlayer.wrap(name);
+ final PlotPlayer> plotPlayer = PlotSquared.platform().getPlayerManager().getPlayerIfExists(name);
Set mask;
if (plotPlayer == null) {
Player player = (Player) actor;
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 437e86491..60fbf7415 100644
--- a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java
+++ b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java
@@ -120,7 +120,7 @@ public class ConsolePlayer extends PlotPlayer {
}
@Override public long getLastPlayed() {
- return 0;
+ return System.currentTimeMillis();
}
@Override public void sendMessage(String message) {
@@ -132,10 +132,6 @@ public class ConsolePlayer extends PlotPlayer {
setMeta(META_LOCATION, location);
}
- @Override public boolean isOnline() {
- return true;
- }
-
@Override public String getName() {
return "*";
}
diff --git a/Core/src/main/java/com/plotsquared/core/player/OfflinePlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/OfflinePlotPlayer.java
index 92a0e6536..24d83514a 100644
--- a/Core/src/main/java/com/plotsquared/core/player/OfflinePlotPlayer.java
+++ b/Core/src/main/java/com/plotsquared/core/player/OfflinePlotPlayer.java
@@ -27,6 +27,7 @@ package com.plotsquared.core.player;
import com.plotsquared.core.permissions.PermissionHolder;
+import javax.annotation.Nonnegative;
import java.util.UUID;
public interface OfflinePlotPlayer extends PermissionHolder {
@@ -42,16 +43,8 @@ public interface OfflinePlotPlayer extends PermissionHolder {
* Gets the time in milliseconds when the player was last seen online.
*
* @return the time in milliseconds when last online
- * @deprecated This method may be inconsistent across platforms. The javadoc may be wrong depending on which platform is used.
*/
- @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated long getLastPlayed();
-
- /**
- * Checks if this player is online.
- *
- * @return {@code true} if this player is online
- */
- boolean isOnline();
+ @Nonnegative long getLastPlayed();
/**
* Gets the name of this player.
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 666d5be7b..27680b26a 100644
--- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java
+++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java
@@ -140,20 +140,6 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer
return players;
}
- /**
- * Efficiently wrap a Player, or OfflinePlayer object to get a PlotPlayer (or fetch if it's already cached)
- * - Accepts sponge/bukkit Player (online)
- * - Accepts player name (online)
- * - Accepts UUID
- * - Accepts bukkit OfflinePlayer (offline)
- *
- * @param player Player object to wrap
- * @return Wrapped player
- */
- public static PlotPlayer> wrap(Object player) {
- return PlotSquared.platform().wrapPlayer(player);
- }
-
@Override public final boolean hasPermission(@Nullable final String world,
@Nonnull final String permission) {
return this.permissionProfile.hasPermission(world, permission);
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 918388008..d4fe6ba6b 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java
@@ -1926,11 +1926,16 @@ public class Plot {
DBFunc.createPlotAndSettings(this, () -> {
PlotArea plotworld = Plot.this.area;
if (notify && plotworld.isAutoMerge()) {
- PlotPlayer player = this.worldUtil.getPlayer(uuid);
+ final PlotPlayer> player = PlotSquared.platform().getPlayerManager()
+ .getPlayerIfExists(uuid);
+
PlotMergeEvent event = this.eventDispatcher
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
+
if (event.getEventResult() == Result.DENY) {
- sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim");
+ if (player != null) {
+ sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim");
+ }
return;
}
Plot.this.autoMerge(event.getDir(), event.getMax(), uuid, true);
@@ -3083,10 +3088,10 @@ public class Plot {
if (!TaskManager.removeFromTeleportQueue(name)) {
return;
}
- if (player.isOnline()) {
+ try {
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT);
player.teleport(location, cause);
- }
+ } catch (final Exception ignored) {}
}, TaskTime.seconds(Settings.Teleport.DELAY));
resultConsumer.accept(true);
};
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 2a3514540..1171bef87 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
@@ -418,13 +418,13 @@ public class ExpireManager {
}
}
for (UUID helper : plot.getTrusted()) {
- PlotPlayer player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
+ PlotPlayer> player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
if (player != null) {
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
}
}
for (UUID helper : plot.getMembers()) {
- PlotPlayer player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
+ PlotPlayer> player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
if (player != null) {
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
}
diff --git a/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java b/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java
index 81d5e2f11..e478bfdb8 100644
--- a/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java
+++ b/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java
@@ -328,14 +328,6 @@ public abstract class WorldUtil {
*/
public abstract boolean isBlockSame(@Nonnull BlockState block1, @Nonnull BlockState block2);
- /**
- * Get a player object for the player with the given UUID
- *
- * @param uuid Player UUID
- * @return Player object
- */
- @Nonnull public abstract PlotPlayer> getPlayer(@Nonnull UUID uuid);
-
/**
* Get the player health
*