mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
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:
parent
edbacb8e47
commit
6442922d86
@ -156,7 +156,7 @@ import static com.plotsquared.core.util.PremiumVerification.getResourceID;
|
||||
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
||||
import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<Player> {
|
||||
|
||||
private static final int BSTATS_ID = 1404;
|
||||
@Getter private static WorldEdit worldEdit;
|
||||
@ -175,8 +175,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
private boolean methodUnloadSetup = false;
|
||||
private boolean metricsStarted;
|
||||
@Getter private BackupManager backupManager;
|
||||
@Getter private PlatformWorldManager worldManager;
|
||||
@Getter private final PlayerManager playerManager = new BukkitPlayerManager();
|
||||
@Getter private PlatformWorldManager<World> worldManager;
|
||||
private final BukkitPlayerManager playerManager = new BukkitPlayerManager();
|
||||
|
||||
@Override public int[] getServerVersion() {
|
||||
if (this.version == null) {
|
||||
@ -1079,4 +1079,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
return wePlugin.wrapCommandSender(console);
|
||||
}
|
||||
|
||||
@Override @NotNull public PlayerManager<? extends PlotPlayer<Player>, ? extends Player> getPlayerManager() {
|
||||
return this.playerManager;
|
||||
}
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTeleport(PlayerTeleportEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT);
|
||||
org.bukkit.Location to = event.getTo();
|
||||
//noinspection ConstantConditions
|
||||
@ -805,7 +805,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
int x2;
|
||||
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
// Set last location
|
||||
@ -865,7 +865,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
int z2;
|
||||
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
// Set last location
|
||||
@ -929,7 +929,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
|
||||
Location location = plotPlayer.getLocation();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
@ -997,7 +997,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (event.getBlock().getY() == 0) {
|
||||
if (!Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
|
||||
@ -1046,7 +1046,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||
return;
|
||||
}
|
||||
@ -1114,7 +1114,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onWorldChanged(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Delete last location
|
||||
Plot plot = (Plot) pp.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
||||
pp.deleteMeta(PlotPlayer.META_LOCATION);
|
||||
@ -1177,14 +1177,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
if (!plot.hasOwner()) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (plot.getFlag(IceFormFlag.class)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
if (plot.getFlag(IceFormFlag.class)) {
|
||||
return;
|
||||
@ -1297,7 +1297,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||
return;
|
||||
@ -1305,7 +1305,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
|
||||
Block block = event.getBlock();
|
||||
@ -1320,7 +1320,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||
return;
|
||||
}
|
||||
@ -1671,7 +1671,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) clicker;
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final PlotInventory inventory = PlotInventory.getOpenPlotInventory(pp);
|
||||
if (inventory != null && event.getRawSlot() == event.getSlot()) {
|
||||
if (!inventory.onClick(event.getSlot())) {
|
||||
@ -1812,7 +1812,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
EntitySpawnListener.testNether(entity);
|
||||
Plot plot = location.getPlotAbs();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
|
||||
@ -1881,7 +1881,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
public void onCancelledInteract(PlayerInteractEvent event) {
|
||||
if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
PlotArea area = pp.getPlotAreaAbs();
|
||||
if (area == null) {
|
||||
return;
|
||||
@ -1918,7 +1918,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
PlotArea area = pp.getPlotAreaAbs();
|
||||
if (area == null) {
|
||||
return;
|
||||
@ -2195,7 +2195,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
Plot plot = area.getOwnedPlot(location1);
|
||||
if (player != null) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
@ -2271,7 +2271,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
@ -2322,7 +2322,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerQuitEvent event) {
|
||||
TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName());
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||
pp.unregister();
|
||||
PlotListener.logout(pp.getUUID());
|
||||
}
|
||||
@ -2336,7 +2336,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
@ -2409,7 +2409,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
@ -2453,7 +2453,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||
@ -2486,7 +2486,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
PlotPlayer player = BukkitUtil.getPlayer(shooter);
|
||||
BukkitPlayer player = BukkitUtil.getPlayer(shooter);
|
||||
Plot plot = area.getPlot(BukkitUtil.getLocation(event.getEntity()));
|
||||
if (plot != null) {
|
||||
if (!plot.hasOwner()) {
|
||||
@ -2521,7 +2521,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player p = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
||||
@ -2595,7 +2595,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Entity attacker = event.getAttacker();
|
||||
if (attacker instanceof Player) {
|
||||
Player p = (Player) attacker;
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
|
||||
@ -2778,7 +2778,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
player = null;
|
||||
}
|
||||
if (player != null) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
|
||||
final com.sk89q.worldedit.world.entity.EntityType entityType;
|
||||
|
||||
@ -2901,7 +2901,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
|
||||
@ -2932,7 +2932,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
|
||||
@ -3000,7 +3000,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
@ -3017,7 +3017,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
LivingEntity ent = event.getEntity();
|
||||
if (ent instanceof Player) {
|
||||
Player player = (Player) ent;
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
|
@ -63,12 +63,11 @@ import static com.sk89q.worldedit.world.gamemode.GameModes.CREATIVE;
|
||||
import static com.sk89q.worldedit.world.gamemode.GameModes.SPECTATOR;
|
||||
import static com.sk89q.worldedit.world.gamemode.GameModes.SURVIVAL;
|
||||
|
||||
public class BukkitPlayer extends PlotPlayer {
|
||||
public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
|
||||
private static boolean CHECK_EFFECTIVE = true;
|
||||
public final Player player;
|
||||
private boolean offline;
|
||||
private UUID uuid;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
@ -78,20 +77,29 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
* @param player Bukkit player instance
|
||||
*/
|
||||
public BukkitPlayer(@NotNull final Player player) {
|
||||
this.player = player;
|
||||
super.populatePersistentMetaMap();
|
||||
this(player, false);
|
||||
}
|
||||
|
||||
public BukkitPlayer(@NotNull final Player player, final boolean offline) {
|
||||
this(player, offline, true);
|
||||
}
|
||||
|
||||
public BukkitPlayer(@NotNull final Player player, final boolean offline, final boolean realPlayer) {
|
||||
this.player = player;
|
||||
this.offline = offline;
|
||||
super.populatePersistentMetaMap();
|
||||
if (realPlayer) {
|
||||
super.populatePersistentMetaMap();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public Actor toActor() {
|
||||
return BukkitAdapter.adapt(player);
|
||||
}
|
||||
|
||||
@Override public Player getPlatformPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@NotNull @Override public Location getLocation() {
|
||||
final Location location = super.getLocation();
|
||||
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
||||
|
@ -36,7 +36,15 @@ import java.util.UUID;
|
||||
/**
|
||||
* 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) {
|
||||
final Player player = Bukkit.getPlayer(uuid);
|
||||
|
@ -27,6 +27,7 @@ package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.location.Location;
|
||||
@ -35,6 +36,7 @@ import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.util.BlockUtil;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
import com.plotsquared.core.util.PlayerManager;
|
||||
import com.plotsquared.core.util.StringComparison;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
@ -112,14 +114,14 @@ public class BukkitUtil extends WorldUtil {
|
||||
private static World lastWorld = null;
|
||||
|
||||
private static Player lastPlayer = null;
|
||||
private static PlotPlayer lastPlotPlayer = null;
|
||||
private static BukkitPlayer lastPlotPlayer = null;
|
||||
|
||||
public static void removePlayer(String player) {
|
||||
lastPlayer = null;
|
||||
lastPlotPlayer = null;
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(@NonNull final OfflinePlayer op) {
|
||||
public static PlotPlayer<?> getPlayer(@NonNull final OfflinePlayer op) {
|
||||
if (op.isOnline()) {
|
||||
return getPlayer(op.getPlayer());
|
||||
}
|
||||
@ -164,7 +166,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
* @return a {@code PlotPlayer}
|
||||
* @see PlotPlayer#wrap(Object)
|
||||
*/
|
||||
public static PlotPlayer wrapPlayer(OfflinePlayer player) {
|
||||
public static PlotPlayer<?> wrapPlayer(OfflinePlayer player) {
|
||||
return PlotPlayer.wrap(player);
|
||||
}
|
||||
|
||||
@ -176,7 +178,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
* @return a {@code PlotPlayer}
|
||||
* @see PlotPlayer#wrap(Object)
|
||||
*/
|
||||
public static PlotPlayer wrapPlayer(Player player) {
|
||||
public static PlotPlayer<?> wrapPlayer(Player player) {
|
||||
return PlotPlayer.wrap(player);
|
||||
}
|
||||
|
||||
@ -188,7 +190,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
* @return a {@code PlotPlayer}
|
||||
* @see PlotPlayer#wrap(Object)
|
||||
*/
|
||||
@Override public PlotPlayer wrapPlayer(UUID uuid) {
|
||||
@Override public PlotPlayer<?> wrapPlayer(UUID uuid) {
|
||||
return PlotPlayer.wrap(Bukkit.getOfflinePlayer(uuid));
|
||||
}
|
||||
|
||||
@ -199,7 +201,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
* @return the number of allowed plots
|
||||
*/
|
||||
public static int getAllowedPlots(Player player) {
|
||||
PlotPlayer plotPlayer = PlotPlayer.wrap(player);
|
||||
PlotPlayer<?> plotPlayer = PlotPlayer.wrap(player);
|
||||
return plotPlayer.getAllowedPlots();
|
||||
}
|
||||
|
||||
@ -225,7 +227,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
if (world == null) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
return PlotPlayer.wrap(player).getPlots(world);
|
||||
return BukkitPlayer.wrap(player).getPlots(world);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,11 +265,12 @@ public class BukkitUtil extends WorldUtil {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption);
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(@NonNull final Player player) {
|
||||
public static BukkitPlayer getPlayer(@NonNull final Player player) {
|
||||
if (player == lastPlayer) {
|
||||
return lastPlotPlayer;
|
||||
}
|
||||
return PlotSquared.imp().getPlayerManager().getPlayer(player.getUniqueId());
|
||||
final PlayerManager<?, ?> playerManager = PlotSquared.imp().getPlayerManager();
|
||||
return ((BukkitPlayerManager) player).getPlayer(player);
|
||||
}
|
||||
|
||||
public static Location getLocation(@NonNull final org.bukkit.Location location) {
|
||||
|
@ -50,7 +50,12 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IPlotMain extends ILogger {
|
||||
/**
|
||||
* PlotSquared main utility class
|
||||
*
|
||||
* @param <P> Player type
|
||||
*/
|
||||
public interface IPlotMain<P> extends ILogger {
|
||||
|
||||
/**
|
||||
* Logs a message to console.
|
||||
@ -286,6 +291,6 @@ public interface IPlotMain extends ILogger {
|
||||
*
|
||||
* @return Player manager
|
||||
*/
|
||||
@NotNull PlayerManager<?, ?> getPlayerManager();
|
||||
@NotNull PlayerManager<? extends PlotPlayer<P>, ? extends P> getPlayerManager();
|
||||
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ public class PlotSquared {
|
||||
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
||||
private static PlotSquared instance;
|
||||
// Implementation
|
||||
public final IPlotMain IMP;
|
||||
public final IPlotMain<?> IMP;
|
||||
// Current thread
|
||||
private final Thread thread;
|
||||
// UUID pipelines
|
||||
@ -386,7 +386,7 @@ public class PlotSquared {
|
||||
return PlotSquared.instance;
|
||||
}
|
||||
|
||||
@NotNull public static IPlotMain imp() {
|
||||
@NotNull public static IPlotMain<?> imp() {
|
||||
if (instance != null && instance.IMP != null) {
|
||||
return instance.IMP;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class Add extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
|
@ -45,7 +45,7 @@ import java.util.concurrent.TimeoutException;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Alias extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
|
||||
if (args.length == 0) {
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
|
@ -83,7 +83,7 @@ import java.util.Set;
|
||||
confirmation = true)
|
||||
public class Area extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
|
@ -154,7 +154,7 @@ public class Auto extends SubCommand {
|
||||
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
PlotArea plotarea = player.getApplicablePlotArea();
|
||||
if (plotarea == null) {
|
||||
if (EconHandler.manager != null) {
|
||||
|
@ -70,7 +70,7 @@ public final class Backup extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
if (args.length == 0 || !Arrays.asList("save", "list", "load")
|
||||
|
@ -54,7 +54,7 @@ public class Buy extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
final RunnableVal2<Command, CommandResult> whenDone) {
|
||||
|
||||
|
@ -50,7 +50,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||
usage = "/plot caps")
|
||||
public class Caps extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return Captions.NOT_IN_PLOT.send(player);
|
||||
|
@ -37,7 +37,7 @@ import com.plotsquared.core.util.MainUtil;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Chat extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
if (player.getPlotAreaAbs().isForcingPlotChat()) {
|
||||
MainUtil.sendMessage(player, Captions.PLOT_CHAT_FORCED);
|
||||
return true;
|
||||
|
@ -54,7 +54,7 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
usage = "/plot claim")
|
||||
public class Claim extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
String schematic = null;
|
||||
if (args.length >= 1) {
|
||||
schematic = args[0];
|
||||
|
@ -64,7 +64,7 @@ public class Clear extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage());
|
||||
|
@ -54,7 +54,7 @@ import java.util.concurrent.TimeoutException;
|
||||
description = "Manage a plot cluster")
|
||||
public class Cluster extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
|
||||
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
|
||||
if (args.length == 0) {
|
||||
|
@ -32,15 +32,15 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
|
||||
public class CmdConfirm {
|
||||
|
||||
public static CmdInstance getPending(PlotPlayer player) {
|
||||
public static CmdInstance getPending(PlotPlayer<?> player) {
|
||||
return player.getMeta("cmdConfirm");
|
||||
}
|
||||
|
||||
public static void removePending(PlotPlayer player) {
|
||||
public static void removePending(PlotPlayer<?> player) {
|
||||
player.deleteMeta("cmdConfirm");
|
||||
}
|
||||
|
||||
public static void addPending(final PlotPlayer player, String commandStr,
|
||||
public static void addPending(final PlotPlayer<?> player, String commandStr,
|
||||
final Runnable runnable) {
|
||||
removePending(player);
|
||||
if (commandStr != null) {
|
||||
|
@ -106,7 +106,7 @@ public abstract class Command {
|
||||
&& types[4] == RunnableVal2.class) {
|
||||
Command tmp = new Command(this, true) {
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
try {
|
||||
@ -300,7 +300,7 @@ public abstract class Command {
|
||||
* @return CompletableFuture true if the command executed fully, false in
|
||||
* any other case
|
||||
*/
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
if (args.length == 0 || args[0] == null) {
|
||||
|
@ -46,7 +46,7 @@ import java.util.Locale;
|
||||
permission = "plots.comment")
|
||||
public class Comment extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
sendMessage(player, Captions.COMMENT_SYNTAX,
|
||||
StringMan.join(CommentManager.inboxes.keySet(), "|"));
|
||||
|
@ -54,7 +54,7 @@ public class Condense extends SubCommand {
|
||||
|
||||
public static boolean TASK = false;
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
MainUtil.sendMessage(player, getUsage());
|
||||
return false;
|
||||
|
@ -37,7 +37,7 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
category = CommandCategory.INFO)
|
||||
public class Confirm extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
CmdInstance command = CmdConfirm.getPending(player);
|
||||
if (command == null) {
|
||||
MainUtil.sendMessage(player, Captions.FAILED_CONFIRM);
|
||||
|
@ -44,7 +44,7 @@ import com.plotsquared.core.util.Permissions;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Continue extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
|
@ -41,7 +41,7 @@ import com.plotsquared.core.util.Permissions;
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Copy extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
Plot plot1 = location.getPlotAbs();
|
||||
if (plot1 == null) {
|
||||
|
@ -42,7 +42,7 @@ import com.plotsquared.core.util.MainUtil;
|
||||
usage = "/plot createroadschematic")
|
||||
public class CreateRoadSchematic extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
|
@ -74,7 +74,7 @@ public class DatabaseCommand extends SubCommand {
|
||||
});
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length < 1) {
|
||||
MainUtil.sendMessage(player, getUsage());
|
||||
return false;
|
||||
|
@ -48,7 +48,7 @@ import java.util.Map;
|
||||
permission = "plots.admin")
|
||||
public class Debug extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
if (args.length > 0) {
|
||||
if ("player".equalsIgnoreCase(args[0])) {
|
||||
for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) {
|
||||
|
@ -42,7 +42,7 @@ public class DebugAllowUnsafe extends SubCommand {
|
||||
|
||||
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())) {
|
||||
unsafeAllowed.remove(player.getUUID());
|
||||
|
@ -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
|
||||
.asList("analyze", "calibrate-analysis", "remove-flag", "stop-expire", "start-expire",
|
||||
"seen", "list-scripts", "start-rgar", "stop-rgar", "help", "addcmd", "runasync",
|
||||
@ -312,7 +312,7 @@ public class DebugExec extends SubCommand {
|
||||
new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null,
|
||||
RequiredType.NONE, CommandCategory.DEBUG) {
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player,
|
||||
String[] args, RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
try {
|
||||
|
@ -52,7 +52,7 @@ public class DebugImportWorlds extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
|
||||
|
@ -37,7 +37,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
||||
requiredType = RequiredType.CONSOLE)
|
||||
public class DebugLoadTest extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
PlotSquared.get().plots_tmp = DBFunc.getPlots();
|
||||
return true;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class DebugPaste extends SubCommand {
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
try {
|
||||
|
||||
|
@ -46,7 +46,7 @@ import java.util.Arrays;
|
||||
public class DebugRoadRegen extends SubCommand {
|
||||
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) {
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE);
|
||||
return false;
|
||||
|
@ -41,7 +41,7 @@ import java.util.ArrayList;
|
||||
description = "This command will force the recreation of all plots in the DB")
|
||||
public class DebugSaveTest extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
|
||||
MainUtil.sendMessage(player, "&6Starting `DEBUGSAVETEST`");
|
||||
DBFunc.createPlotsAndData(plots,
|
||||
|
@ -53,7 +53,7 @@ public class Delete extends SubCommand {
|
||||
// Note: To delete a specific plot use /plot <plot> delete
|
||||
// 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();
|
||||
final Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
|
@ -51,7 +51,7 @@ public class Deny extends SubCommand {
|
||||
super(Argument.PlayerName);
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
|
@ -35,7 +35,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Dislike extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
return Like.handleLike(player, args, false);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ import com.plotsquared.core.util.task.RunnableVal;
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Done extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
final Plot plot = location.getPlotAbs();
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
|
@ -50,7 +50,7 @@ import java.net.URL;
|
||||
permission = "plots.download")
|
||||
public class Download extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
String world = player.getLocation().getWorld();
|
||||
if (!PlotSquared.get().hasPlotArea(world)) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
|
@ -207,7 +207,7 @@ public final class FlagCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
if (args.length == 0 || !Arrays
|
||||
|
@ -53,7 +53,7 @@ public class Grant extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
checkTrue(args.length >= 1 && args.length <= 2, Captions.COMMAND_SYNTAX, getUsage());
|
||||
|
@ -52,7 +52,7 @@ public class Help extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
switch (args.length) {
|
||||
|
@ -86,7 +86,7 @@ public class Inbox extends SubCommand {
|
||||
MainUtil.sendMessage(player, string.toString());
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
|
@ -41,7 +41,7 @@ import com.plotsquared.core.util.task.RunnableVal;
|
||||
category = CommandCategory.INFO)
|
||||
public class Info extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
Plot plot;
|
||||
String arg;
|
||||
if (args.length > 0) {
|
||||
|
@ -53,7 +53,7 @@ public class Kick extends SubCommand {
|
||||
super(Argument.PlayerName);
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlot();
|
||||
if (plot == null) {
|
||||
|
@ -48,7 +48,7 @@ public class Leave extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
|
@ -175,7 +175,7 @@ public class Like extends SubCommand {
|
||||
return numLikes / (numLikes + numDislikes);
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
return handleLike(player, args, true);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class ListCmd extends SubCommand {
|
||||
.toString(getArgumentList(player)));
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
if (args.length < 1) {
|
||||
noArgs(player);
|
||||
return false;
|
||||
|
@ -52,7 +52,7 @@ import java.util.List;
|
||||
usage = "/plot load")
|
||||
public class Load extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
String world = player.getLocation().getWorld();
|
||||
if (!PlotSquared.get().hasPlotArea(world)) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
@ -152,7 +152,7 @@ public class Load extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void displaySaves(PlotPlayer player) {
|
||||
public void displaySaves(PlotPlayer<?> player) {
|
||||
List<String> schematics = player.getMeta("plot_schematics");
|
||||
for (int i = 0; i < Math.min(schematics.size(), 32); i++) {
|
||||
try {
|
||||
|
@ -217,7 +217,7 @@ public class MainCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
// Clear perm caching //
|
||||
|
@ -78,7 +78,7 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocationFull();
|
||||
final Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
|
@ -42,7 +42,7 @@ import com.plotsquared.core.plot.Plot;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Middle extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] arguments) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] arguments) {
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlot();
|
||||
if (plot == null) {
|
||||
|
@ -47,7 +47,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class Move extends SubCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
Location location = player.getLocation();
|
||||
@ -107,7 +107,7 @@ public class Move extends SubCommand {
|
||||
});
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class Music extends SubCommand {
|
||||
"music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal",
|
||||
"music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait");
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
final Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
|
@ -46,7 +46,7 @@ public class Near extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
|
@ -39,7 +39,7 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
category = CommandCategory.INFO)
|
||||
public class PluginCmd extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
TaskManager.IMP.taskAsync(() -> {
|
||||
MainUtil.sendMessage(player, String.format(
|
||||
"$2>> $1&l" + PlotSquared.imp().getPluginName() + " $2($1Version$2: $1%s$2)",
|
||||
|
@ -53,7 +53,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
confirmation = true)
|
||||
public class Purge extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
|
@ -56,7 +56,7 @@ import java.util.UUID;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Rate extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length == 1) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "next": {
|
||||
|
@ -43,7 +43,7 @@ import com.plotsquared.core.util.MainUtil;
|
||||
permission = "plots.regenallroads")
|
||||
public class RegenAllRoads extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
int height = 0;
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
|
@ -47,7 +47,7 @@ public class Relight extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
|
@ -45,7 +45,7 @@ import java.util.Objects;
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Reload extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
try {
|
||||
// The following won't affect world generation, as that has to be
|
||||
// loaded during startup unfortunately.
|
||||
|
@ -50,7 +50,7 @@ public class Remove extends SubCommand {
|
||||
super(Argument.PlayerName);
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
|
@ -49,7 +49,7 @@ import java.util.UUID;
|
||||
permission = "plots.save")
|
||||
public class Save extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
String world = player.getLocation().getWorld();
|
||||
if (!PlotSquared.get().hasPlotArea(world)) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
|
@ -57,7 +57,7 @@ public class SchematicCmd extends SubCommand {
|
||||
|
||||
private boolean running = false;
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length < 1) {
|
||||
sendMessage(player, Captions.SCHEMATIC_MISSING_ARG);
|
||||
return true;
|
||||
|
@ -176,7 +176,7 @@ public class Set extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
return noArgs(player);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import com.plotsquared.core.util.StringMan;
|
||||
|
||||
public abstract class SetCommand extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
|
@ -90,7 +90,7 @@ public class Setup extends SubCommand {
|
||||
MainUtil.sendMessage(player, message.toString());
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
// going through setup
|
||||
SetupObject object = player.getMeta("setup");
|
||||
if (object == null) {
|
||||
|
@ -54,11 +54,11 @@ public abstract class SubCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
return CompletableFuture.completedFuture(onCommand(player, args));
|
||||
}
|
||||
|
||||
public abstract boolean onCommand(PlotPlayer player, String[] args);
|
||||
public abstract boolean onCommand(PlotPlayer<?> player, String[] args);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class Swap extends SubCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
Location location = player.getLocation();
|
||||
@ -93,7 +93,7 @@ public class Swap extends SubCommand {
|
||||
});
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class Target extends SubCommand {
|
||||
super(Argument.PlotID);
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
if (!location.isPlotArea()) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
|
@ -134,7 +134,7 @@ public class Template extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("export")) {
|
||||
|
@ -159,7 +159,7 @@ public class Trim extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
|
@ -56,7 +56,7 @@ public class Trust extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot currentPlot = player.getCurrentPlot();
|
||||
|
@ -46,7 +46,7 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
confirmation = true)
|
||||
public class Unlink extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
final Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
|
@ -139,7 +139,7 @@ public class Visit extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player,
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player,
|
||||
String[] args,
|
||||
final RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
final RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
|
@ -37,7 +37,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
||||
@Deprecated
|
||||
public class WE_Anywhere extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] arguments) {
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] arguments) {
|
||||
MainCommand.getInstance().toggle.worldedit(this, player, new String[0], null, null);
|
||||
return true;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class ComponentCommand extends SubCommand {
|
||||
this.componentPresetManager = componentPresetManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
|
||||
final PlotInventory inventory = componentPresetManager.buildInventory(player);
|
||||
if (inventory != null) {
|
||||
inventory.openInventory();
|
||||
|
@ -123,7 +123,7 @@ public class PlotListener {
|
||||
}, 20);
|
||||
}
|
||||
|
||||
public static boolean plotEntry(final PlotPlayer player, final Plot plot) {
|
||||
public static boolean plotEntry(final PlotPlayer<?> player, final Plot plot) {
|
||||
if (plot.isDenied(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, "plots.admin.entry.denied")) {
|
||||
return false;
|
||||
@ -293,7 +293,7 @@ public class PlotListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean plotExit(final PlotPlayer player, Plot plot) {
|
||||
public static boolean plotExit(final PlotPlayer<?> player, Plot plot) {
|
||||
Object previous = player.deleteMeta(PlotPlayer.META_LAST_PLOT);
|
||||
PlotSquared.get().getEventDispatcher().callLeave(player, plot);
|
||||
if (plot.hasOwner()) {
|
||||
|
@ -41,7 +41,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ConsolePlayer extends PlotPlayer {
|
||||
public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||
|
||||
private static ConsolePlayer instance;
|
||||
|
||||
@ -71,6 +71,10 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
return PlotSquared.get().IMP.getConsole();
|
||||
}
|
||||
|
||||
@Override public Actor getPlatformPlayer() {
|
||||
return this.toActor();
|
||||
}
|
||||
|
||||
@Override public boolean canTeleport(@NotNull Location location) {
|
||||
return true;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}.
|
||||
*/
|
||||
public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
||||
public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer {
|
||||
|
||||
public static final String META_LAST_PLOT = "lastplot";
|
||||
public static final String META_LOCATION = "location";
|
||||
@ -103,12 +103,14 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static PlotPlayer wrap(Object player) {
|
||||
public static PlotPlayer<?> wrap(Object player) {
|
||||
return PlotSquared.get().IMP.wrapPlayer(player);
|
||||
}
|
||||
|
||||
public abstract Actor toActor();
|
||||
|
||||
public abstract P getPlatformPlayer();
|
||||
|
||||
/**
|
||||
* Set some session only metadata for this player.
|
||||
*
|
||||
|
@ -399,9 +399,9 @@ public class Plot {
|
||||
*
|
||||
* @return list of PlotPlayer(s) or an empty list
|
||||
*/
|
||||
public List<PlotPlayer> getPlayersInPlot() {
|
||||
final List<PlotPlayer> players = new ArrayList<>();
|
||||
for (final PlotPlayer player : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
||||
public List<PlotPlayer<?>> getPlayersInPlot() {
|
||||
final List<PlotPlayer<?>> players = new ArrayList<>();
|
||||
for (final PlotPlayer<?> player : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
||||
if (this.equals(player.getCurrentPlot())) {
|
||||
players.add(player);
|
||||
}
|
||||
@ -1323,8 +1323,8 @@ public class Plot {
|
||||
return false;
|
||||
}
|
||||
for (Plot current : getConnectedPlots()) {
|
||||
List<PlotPlayer> players = current.getPlayersInPlot();
|
||||
for (PlotPlayer pp : players) {
|
||||
List<PlotPlayer<?>> players = current.getPlayersInPlot();
|
||||
for (PlotPlayer<?> pp : players) {
|
||||
PlotListener.plotExit(pp, current);
|
||||
}
|
||||
|
||||
|
@ -33,40 +33,40 @@ import lombok.NonNull;
|
||||
public class PlotInventory {
|
||||
|
||||
private static final String META_KEY = "inventory";
|
||||
public final PlotPlayer player;
|
||||
public final PlotPlayer<?> player;
|
||||
public final int size;
|
||||
private final PlotItemStack[] items;
|
||||
private String title;
|
||||
private boolean open = false;
|
||||
|
||||
public PlotInventory(PlotPlayer player) {
|
||||
public PlotInventory(PlotPlayer<?> player) {
|
||||
this.size = 4;
|
||||
this.title = null;
|
||||
this.player = player;
|
||||
this.items = InventoryUtil.manager.getItems(player);
|
||||
}
|
||||
|
||||
public PlotInventory(PlotPlayer player, int size, String name) {
|
||||
public PlotInventory(PlotPlayer<?> player, int size, String name) {
|
||||
this.size = size;
|
||||
this.title = name == null ? "" : name;
|
||||
this.player = player;
|
||||
this.items = new PlotItemStack[size * 9];
|
||||
}
|
||||
|
||||
public static boolean hasPlotInventoryOpen(@NonNull final PlotPlayer plotPlayer) {
|
||||
public static boolean hasPlotInventoryOpen(@NonNull final PlotPlayer<?> plotPlayer) {
|
||||
return getOpenPlotInventory(plotPlayer) != null;
|
||||
}
|
||||
|
||||
public static PlotInventory getOpenPlotInventory(@NonNull final PlotPlayer plotPlayer) {
|
||||
public static PlotInventory getOpenPlotInventory(@NonNull final PlotPlayer<?> plotPlayer) {
|
||||
return plotPlayer.getMeta(META_KEY, null);
|
||||
}
|
||||
|
||||
public static void setPlotInventoryOpen(@NonNull final PlotPlayer plotPlayer,
|
||||
public static void setPlotInventoryOpen(@NonNull final PlotPlayer<?> plotPlayer,
|
||||
@NonNull final PlotInventory plotInventory) {
|
||||
plotPlayer.setMeta(META_KEY, plotInventory);
|
||||
}
|
||||
|
||||
public static void removePlotInventoryOpen(@NonNull final PlotPlayer plotPlayer) {
|
||||
public static void removePlotInventoryOpen(@NonNull final PlotPlayer<?>plotPlayer) {
|
||||
plotPlayer.deleteMeta(META_KEY);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
}, 20);
|
||||
}
|
||||
|
||||
public static long getTimestamp(PlotPlayer player, String inbox) {
|
||||
public static long getTimestamp(PlotPlayer<?> player, String inbox) {
|
||||
return player.getMeta("inbox:" + inbox, player.getLastPlayed());
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class ExpireManager {
|
||||
this.tasks.add(task);
|
||||
}
|
||||
|
||||
public void handleJoin(PlotPlayer pp) {
|
||||
public void handleJoin(PlotPlayer<?> pp) {
|
||||
storeDate(pp.getUUID(), System.currentTimeMillis());
|
||||
if (plotsToDelete != null && !plotsToDelete.isEmpty()) {
|
||||
for (Plot plot : pp.getPlots()) {
|
||||
|
@ -61,7 +61,7 @@ public class Permissions {
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasPermission(PlotPlayer player, String permission) {
|
||||
public static boolean hasPermission(PlotPlayer<?> player, String permission) {
|
||||
if (!Settings.Enabled_Components.PERMISSION_CACHE) {
|
||||
return hasPermission((CommandCaller) player, permission);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import java.util.UUID;
|
||||
/**
|
||||
* 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 Object playerLock = new Object();
|
||||
@ -77,6 +77,18 @@ public abstract class PlayerManager<P extends PlotPlayer, O extends OfflinePlotP
|
||||
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
|
||||
* 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
|
||||
* @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
|
||||
@ -114,7 +126,7 @@ public abstract class PlayerManager<P extends PlotPlayer, O extends OfflinePlotP
|
||||
* @param username Player name
|
||||
* @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
|
||||
@ -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()));
|
||||
}
|
||||
|
||||
@Override public synchronized Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class WEManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static HashSet<CuboidRegion> getMask(PlotPlayer player) {
|
||||
public static HashSet<CuboidRegion> getMask(PlotPlayer<?> player) {
|
||||
HashSet<CuboidRegion> regions = new HashSet<>();
|
||||
UUID uuid = player.getUUID();
|
||||
Location location = player.getLocation();
|
||||
|
Loading…
Reference in New Issue
Block a user