diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle
index 1732ebb8b..9d00d7b99 100644
--- a/Bukkit/build.gradle
+++ b/Bukkit/build.gradle
@@ -2,9 +2,11 @@ repositories {
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "http://nexus.hc.to/content/repositories/pub_releases" }
- maven { url "https://repo.codemc.org/repository/maven-public" }
- //maven { url 'http://repo.onarandombox.com/content/groups/public'}
- maven { url 'https://papermc.io/repo/repository/maven-public/' }
+ maven { url = "https://repo.codemc.org/repository/maven-public" }
+ maven {
+ name 'papermc'
+ url 'https://papermc.io/repo/repository/maven-public/'
+ }
mavenLocal()
}
@@ -15,6 +17,7 @@ dependencies {
//implementation 'com.onarandombox.multiversecore:Multiverse-Core:3.0.0-SNAPSHOT'
implementation 'org.spigotmc:spigot-api:1.14.3-R0.1-SNAPSHOT'
compile(group: 'com.sk89q.worldedit', name: 'worldedit-bukkit', version: '7.0.0')
+ compile "io.papermc:paperlib:1.0.1"
compile("net.milkbowl.vault:VaultAPI:1.7") {
exclude module: 'bukkit'
}
@@ -44,7 +47,10 @@ shadowJar {
include(dependency('com.squareup.okhttp3:okhttp:3.14.0'))
include(dependency('com.squareup.okio:okio:2.2.2'))
include(dependency('org.jetbrains.kotlin:kotlin-stdlib:1.3.30'))
+ include(dependency("io.papermc:paperlib:1.0.1"))
}
+ relocate 'io.papermc.lib', 'com.github.intellectualsites.plotsquared.bukkit.paperlib'
+ // relocate('org.mcstats', 'com.plotsquared.stats')
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
destinationDir = file '../target'
}
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
index 68169328d..b5e4ecf1b 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
@@ -39,6 +39,7 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.sk89q.worldedit.WorldEdit;
+import io.papermc.lib.PaperLib;
import lombok.Getter;
import lombok.NonNull;
import org.bukkit.*;
@@ -114,23 +115,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override public void onEnable() {
this.pluginName = getDescription().getName();
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
-
- if (Bukkit.getVersion().contains("git-Spigot")) {
- // Uses System.out.println because the logger isn't initialized yet
- System.out
- .println("[P2] ========================== USE PAPER ==========================");
- System.out.println("[P2] Paper offers a more complete API for us to work with");
- System.out.println("[P2] and we may come to rely on it in the future.");
- System.out.println("[P2] It is also recommended out of a performance standpoint as");
- System.out
- .println("[P2] it contains many improvements missing from Spigot and Bukkit.");
- System.out.println("[P2] DOWNLOAD: https://papermc.io/downloads");
- System.out.println("[P2] GUIDE: https://www.spigotmc.org/threads/21726/");
- System.out.println("[P2] NOTE: This is only a recommendation");
- System.out.println("[P2] Spigot is still supported.");
- System.out
- .println("[P2] ===============================================================");
- }
+ PaperLib.suggestPaper(this);
new PlotSquared(this, "Bukkit");
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java
index 6d9805660..f2f9efe71 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java
@@ -6,9 +6,6 @@ import org.bukkit.event.HandlerList;
import java.util.UUID;
-/**
- *
- */
public class PlayerPlotTrustedEvent extends PlotEvent {
private static final HandlerList handlers = new HandlerList();
diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java
index 7a8ad2fc5..7a34a9fdc 100644
--- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java
+++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java
@@ -6,12 +6,9 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
-import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
-import com.github.intellectualsites.plotsquared.plot.util.MathMan;
-import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
-import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
-import com.github.intellectualsites.plotsquared.plot.util.StringMan;
-import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
+import com.github.intellectualsites.plotsquared.plot.util.*;
+import com.google.common.base.Preconditions;
+import io.papermc.lib.PaperLib;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
@@ -20,11 +17,11 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventException;
import org.bukkit.event.player.PlayerTeleportEvent;
-import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.RegisteredListener;
import org.jetbrains.annotations.NotNull;
+import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Set;
import java.util.UUID;
@@ -42,21 +39,23 @@ public class BukkitPlayer extends PlotPlayer {
*
Please do not use this method. Instead use
* BukkitUtil.getPlayer(Player), as it caches player objects.
*
- * @param player
+ * @param player Bukkit player instance
*/
- public BukkitPlayer(Player player) {
+ public BukkitPlayer(@Nonnull final Player player) {
+ Preconditions.checkNotNull(player, "Bukkit player instance cannot be null");
this.player = player;
super.populatePersistentMetaMap();
}
- public BukkitPlayer(Player player, boolean offline) {
+ public BukkitPlayer(@Nonnull final Player player, final boolean offline) {
+ Preconditions.checkNotNull(player, "Bukkit player instance cannot be null");
this.player = player;
this.offline = offline;
super.populatePersistentMetaMap();
}
@Override public Location getLocation() {
- Location location = super.getLocation();
+ final Location location = super.getLocation();
return location == null ? BukkitUtil.getLocation(this.player) : location;
}
@@ -71,9 +70,10 @@ public class BukkitPlayer extends PlotPlayer {
return this.player.getLastPlayed();
}
- @Override public boolean canTeleport(Location loc) {
- org.bukkit.Location to = BukkitUtil.getLocation(loc);
- org.bukkit.Location from = player.getLocation();
+ @Override public boolean canTeleport(@Nonnull final Location loc) {
+ Preconditions.checkNotNull(loc, "Bukkit location cannot be null");
+ final org.bukkit.Location to = BukkitUtil.getLocation(loc);
+ final org.bukkit.Location from = player.getLocation();
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
callEvent(event);
if (event.isCancelled() || !event.getTo().equals(to)) {
@@ -90,32 +90,34 @@ public class BukkitPlayer extends PlotPlayer {
}
private void callEvent(final Event event) {
- RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
- for (RegisteredListener listener : listeners) {
+ Preconditions.checkNotNull(event, "Event cannot be null");
+
+ final RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
+ for (final RegisteredListener listener : listeners) {
if (listener.getPlugin().getName().equals(PlotSquared.imp().getPluginName())) {
continue;
}
try {
listener.callEvent(event);
- } catch (EventException e) {
+ } catch (final EventException e) {
e.printStackTrace();
}
}
}
- @Override public boolean hasPermission(String permission) {
+ @Override public boolean hasPermission(final String permission) {
if (this.offline && EconHandler.manager != null) {
return EconHandler.manager.hasPermission(getName(), permission);
}
return this.player.hasPermission(permission);
}
- @Override public int hasPermissionRange(String stub, int range) {
+ @Override public int hasPermissionRange(final String stub, final int range) {
if (hasPermission(Captions.PERMISSION_ADMIN.s())) {
return Integer.MAX_VALUE;
}
- String[] nodes = stub.split("\\.");
- StringBuilder n = new StringBuilder();
+ final String[] nodes = stub.split("\\.");
+ final StringBuilder n = new StringBuilder();
for (int i = 0; i < (nodes.length - 1); i++) {
n.append(nodes[i]).append(".");
if (!stub.equals(n + Captions.PERMISSION_STAR.s())) {
@@ -131,7 +133,7 @@ public class BukkitPlayer extends PlotPlayer {
if (CHECK_EFFECTIVE) {
boolean hasAny = false;
String stubPlus = stub + ".";
- Set effective = player.getEffectivePermissions();
+ final Set effective = player.getEffectivePermissions();
if (!effective.isEmpty()) {
for (PermissionAttachmentInfo attach : effective) {
String permStr = attach.getPermission();
@@ -170,11 +172,11 @@ public class BukkitPlayer extends PlotPlayer {
return max;
}
- @Override public boolean isPermissionSet(String permission) {
+ @Override public boolean isPermissionSet(final String permission) {
return this.player.isPermissionSet(permission);
}
- @Override public void sendMessage(String message) {
+ @Override public void sendMessage(final String message) {
if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (
System.currentTimeMillis() - this.getMeta("lastMessageTime") > 5000)) {
setMeta("lastMessage", message);
@@ -183,14 +185,13 @@ public class BukkitPlayer extends PlotPlayer {
}
}
- @Override public void teleport(Location location) {
+ @Override public void teleport(@Nonnull final Location location) {
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
return;
}
- this.player.teleport(
- new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5,
- location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch()),
- TeleportCause.COMMAND);
+ final org.bukkit.Location bukkitLocation = new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5,
+ location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch());
+ PaperLib.teleportAsync(player, bukkitLocation);
}
@Override public String getName() {
@@ -208,14 +209,14 @@ public class BukkitPlayer extends PlotPlayer {
this.player.setCompassTarget(
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX(),
location.getY(), location.getZ()));
-
}
@Override public Location getLocationFull() {
return BukkitUtil.getLocationFull(this.player);
}
- @Override public void setWeather(PlotWeather weather) {
+ @Override public void setWeather(@Nonnull final PlotWeather weather) {
+ Preconditions.checkNotNull(weather, "Specified weather cannot be null");
switch (weather) {
case CLEAR:
this.player.setPlayerWeather(WeatherType.CLEAR);
@@ -230,7 +231,7 @@ public class BukkitPlayer extends PlotPlayer {
}
}
- @Override public PlotGameMode getGameMode() {
+ @Nonnull @Override public PlotGameMode getGameMode() {
switch (this.player.getGameMode()) {
case ADVENTURE:
return PlotGameMode.ADVENTURE;
@@ -245,7 +246,8 @@ public class BukkitPlayer extends PlotPlayer {
}
}
- @Override public void setGameMode(PlotGameMode gameMode) {
+ @Override public void setGameMode(@Nonnull final PlotGameMode gameMode) {
+ Preconditions.checkNotNull(gameMode, "Specified gamemode cannot be null");
switch (gameMode) {
case ADVENTURE:
this.player.setGameMode(GameMode.ADVENTURE);
@@ -263,7 +265,7 @@ public class BukkitPlayer extends PlotPlayer {
}
}
- @Override public void setTime(long time) {
+ @Override public void setTime(final long time) {
if (time != Long.MAX_VALUE) {
this.player.setPlayerTime(time, false);
} else {
@@ -279,7 +281,9 @@ public class BukkitPlayer extends PlotPlayer {
this.player.setAllowFlight(fly);
}
- @Override public void playMusic(Location location, PlotBlock id) {
+ @Override public void playMusic(@Nonnull final Location location, @Nonnull final PlotBlock id) {
+ Preconditions.checkNotNull(location, "Specified location cannot be null");
+ Preconditions.checkNotNull(id, "Specified block cannot be null");
if (PlotBlock.isEverything(id) || id.isAir()) {
// Let's just stop all the discs because why not?
for (final Sound sound : Arrays.stream(Sound.values())
@@ -294,7 +298,7 @@ public class BukkitPlayer extends PlotPlayer {
}
}
- @Override public void kick(String message) {
+ @Override public void kick(final String message) {
this.player.kickPlayer(message);
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java
index 277ebe2e7..e379edbac 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
+import java.util.concurrent.CompletableFuture;
public abstract class Command {
@@ -72,14 +73,16 @@ public abstract class Command {
&& types[2] == String[].class && types[3] == RunnableVal3.class
&& types[4] == RunnableVal2.class) {
Command tmp = new Command(this, true) {
- @Override public void execute(PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
try {
method.invoke(Command.this, this, player, args, confirm, whenDone);
+ return CompletableFuture.completedFuture(true);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
+ return CompletableFuture.completedFuture(false);
}
};
tmp.init(method.getAnnotation(CommandDeclaration.class));
@@ -261,9 +264,10 @@ public abstract class Command {
* @param player Caller
* @param args Arguments
* @param confirm Instance, Success, Failure
- * @return
+ * @return CompletableFuture true if the command executed fully, false in
+ * any other case
*/
- public void execute(PlotPlayer player, String[] args,
+ public CompletableFuture execute(PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) throws CommandException {
if (args.length == 0 || args[0] == null) {
@@ -272,18 +276,18 @@ public abstract class Command {
} else {
Captions.COMMAND_SYNTAX.send(player, getUsage());
}
- return;
+ return CompletableFuture.completedFuture(false);
}
if (this.allCommands.isEmpty()) {
player.sendMessage(
"Not Implemented: https://github.com/IntellectualSites/PlotSquared/issues/new");
- return;
+ return CompletableFuture.completedFuture(false);
}
Command cmd = getCommand(args[0]);
if (cmd == null) {
if (this.parent != null) {
Captions.COMMAND_SYNTAX.send(player, getUsage());
- return;
+ return CompletableFuture.completedFuture(false);
}
// Help command
try {
@@ -293,7 +297,7 @@ public abstract class Command {
// This will default certain syntax to the help command
// e.g. /plot, /plot 1, /plot claiming
MainCommand.getInstance().help.execute(player, args, null, null);
- return;
+ return CompletableFuture.completedFuture(false);
} catch (IllegalArgumentException ignored) {
}
// Command recommendation
@@ -302,13 +306,16 @@ public abstract class Command {
if (commands.isEmpty()) {
MainUtil.sendMessage(player, Captions.DID_YOU_MEAN,
MainCommand.getInstance().help.getUsage());
- return;
+ return CompletableFuture.completedFuture(false);
}
- String[] allargs =
- Arrays.stream(args).map(String::toLowerCase).distinct().toArray(String[]::new);
+ HashSet setArgs = new HashSet<>(args.length);
+ for (String arg : args) {
+ setArgs.add(arg.toLowerCase());
+ }
+ String[] allArgs = setArgs.toArray(new String[0]);
int best = 0;
for (Command current : commands) {
- int match = getMatch(allargs, current);
+ int match = getMatch(allArgs, current);
if (match > best) {
cmd = current;
}
@@ -317,17 +324,18 @@ public abstract class Command {
cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject();
}
MainUtil.sendMessage(player, Captions.DID_YOU_MEAN, cmd.getUsage());
- return;
+ return CompletableFuture.completedFuture(false);
}
String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
if (!cmd.checkArgs(player, newArgs) || !cmd.canExecute(player, true)) {
- return;
+ return CompletableFuture.completedFuture(false);
}
try {
cmd.execute(player, newArgs, confirm, whenDone);
} catch (CommandException e) {
e.perform(player);
}
+ return CompletableFuture.completedFuture(true);
}
public boolean checkArgs(CommandCaller player, String[] args) {
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java
index 57c910ea6..f6dba37a4 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java
@@ -15,6 +15,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import java.util.Iterator;
import java.util.Set;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "add",
description = "Allow a user to build in a plot while you are online",
@@ -25,7 +26,7 @@ import java.util.UUID;
super(MainCommand.getInstance(), true);
}
- @Override public void execute(final PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(final PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
@@ -78,5 +79,7 @@ import java.util.UUID;
MainUtil.sendMessage(player, Captions.MEMBER_ADDED);
}
}, null);
+
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Buy.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Buy.java
index 6398b30be..dbfd37768 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Buy.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Buy.java
@@ -14,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.Optional;
import java.util.Set;
+import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "buy", description = "Buy the plot you are standing on",
usage = "/plot buy", permission = "plots.buy", category = CommandCategory.CLAIMING,
@@ -23,7 +24,7 @@ import java.util.Set;
super(MainCommand.getInstance(), true);
}
- @Override public void execute(final PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(final PlotPlayer player, String[] args,
RunnableVal3 confirm,
final RunnableVal2 whenDone) {
@@ -65,5 +66,6 @@ import java.util.Set;
player.deposit(price);
whenDone.run(Buy.this, CommandResult.FAILURE);
});
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java
index 6bde7ffd0..b45c52f65 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java
@@ -14,6 +14,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
+import java.util.concurrent.CompletableFuture;
+
@CommandDeclaration(command = "clear", description = "Clear the plot you stand on",
permission = "plots.clear", category = CommandCategory.APPEARANCE, usage = "/plot clear",
aliases = "reset", confirmation = true) public class Clear extends Command {
@@ -25,7 +27,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
super(MainCommand.getInstance(), true);
}
- @Override public void execute(final PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(final PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) throws CommandException {
checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage());
@@ -59,5 +61,6 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
plot.addRunning();
}
}, null);
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java
index 76d060ed3..7e8e9cf34 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java
@@ -32,6 +32,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugexec", permission = "plots.admin",
description = "Mutli-purpose debug command", aliases = {"exec", "$"},
@@ -284,7 +285,7 @@ import java.util.UUID;
System.getProperty("line.separator"));
new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null,
RequiredType.NONE, CommandCategory.DEBUG) {
- @Override public void execute(PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
try {
@@ -295,6 +296,7 @@ import java.util.UUID;
e.printStackTrace();
MainUtil.sendMessage(player, Captions.COMMAND_WENT_WRONG);
}
+ return CompletableFuture.completedFuture(true);
}
};
return true;
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugImportWorlds.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugImportWorlds.java
index ddac91e4d..6ce41e749 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugImportWorlds.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugImportWorlds.java
@@ -16,6 +16,7 @@ import com.google.common.base.Charsets;
import java.io.File;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugimportworlds", permission = "plots.admin",
description = "Import worlds by player name", requiredType = RequiredType.CONSOLE,
@@ -24,14 +25,14 @@ import java.util.UUID;
super(MainCommand.getInstance(), true);
}
- @Override public void execute(PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) throws CommandException {
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
PlotAreaManager pam = PlotSquared.get().getPlotAreaManager();
if (!(pam instanceof SinglePlotAreaManager)) {
player.sendMessage("Must be a single plot area!");
- return;
+ return CompletableFuture.completedFuture(false);
}
SinglePlotArea area = ((SinglePlotAreaManager) pam).getArea();
PlotId id = new PlotId(0, 0);
@@ -64,5 +65,6 @@ import java.util.UUID;
}
}
player.sendMessage("Done!");
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java
index a3e46dd08..60ecbeab0 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java
@@ -14,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "grant", category = CommandCategory.CLAIMING,
usage = "/plot grant [player]", permission = "plots.grant",
@@ -23,7 +24,7 @@ import java.util.UUID;
super(MainCommand.getInstance(), true);
}
- @Override public void execute(final PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(final PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) throws CommandException {
checkTrue(args.length >= 1 && args.length <= 2, Captions.COMMAND_SYNTAX, getUsage());
@@ -33,7 +34,7 @@ import java.util.UUID;
case "check":
if (!Permissions.hasPermission(player, Captions.PERMISSION_GRANT.f(arg0))) {
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_GRANT.f(arg0));
- return;
+ return CompletableFuture.completedFuture(false);
}
if (args.length > 2) {
break;
@@ -46,7 +47,7 @@ import java.util.UUID;
}
if (uuid == null) {
Captions.INVALID_PLAYER.send(player, args[1]);
- return;
+ return CompletableFuture.completedFuture(false);
}
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal() {
@Override public void run(byte[] array) {
@@ -77,7 +78,9 @@ import java.util.UUID;
}
}
});
+ return CompletableFuture.completedFuture(true);
}
Captions.COMMAND_SYNTAX.send(player, getUsage());
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Help.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Help.java
index 97c793221..bb13524da 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Help.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Help.java
@@ -12,6 +12,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.helpmenu.HelpMenu;
+import java.util.concurrent.CompletableFuture;
+
@CommandDeclaration(command = "help", description = "Get this help menu", aliases = {"he", "?"},
category = CommandCategory.INFO, usage = "help [category|#]", permission = "plots.use")
public class Help extends Command {
@@ -23,72 +25,73 @@ public class Help extends Command {
return true;
}
- @Override public void execute(PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
switch (args.length) {
case 0:
- displayHelp(player, null, 0);
- return;
+ return displayHelp(player, null, 0);
case 1:
if (MathMan.isInteger(args[0])) {
try {
- displayHelp(player, null, Integer.parseInt(args[0]));
+ return displayHelp(player, null, Integer.parseInt(args[0]));
} catch (NumberFormatException ignored) {
- displayHelp(player, null, 1);
+ return displayHelp(player, null, 1);
}
} else {
- displayHelp(player, args[0], 1);
+ return displayHelp(player, args[0], 1);
}
- return;
case 2:
if (MathMan.isInteger(args[1])) {
try {
- displayHelp(player, args[0], Integer.parseInt(args[1]));
+ return displayHelp(player, args[0], Integer.parseInt(args[1]));
} catch (NumberFormatException ignored) {
- displayHelp(player, args[0], 1);
+ return displayHelp(player, args[0], 1);
}
}
- return;
+ return CompletableFuture.completedFuture(false);
default:
Captions.COMMAND_SYNTAX.send(player, getUsage());
}
+ return CompletableFuture.completedFuture(true);
}
- public void displayHelp(CommandCaller player, String cat, int page) {
- CommandCategory catEnum = null;
- if (cat != null) {
- if (StringMan.isEqualIgnoreCase(cat, "all")) {
- catEnum = null;
- } else {
- for (CommandCategory c : CommandCategory.values()) {
- if (StringMan.isEqualIgnoreCaseToAny(cat, c.name(), c.toString())) {
- catEnum = c;
- cat = c.name();
- break;
+ public CompletableFuture displayHelp(final CommandCaller player, final String catRaw, final int page) {
+ return CompletableFuture.supplyAsync(() -> {
+ String cat = catRaw;
+
+ CommandCategory catEnum = null;
+ if (cat != null) {
+ if (!StringMan.isEqualIgnoreCase(cat, "all")) {
+ for (CommandCategory c : CommandCategory.values()) {
+ if (StringMan.isEqualIgnoreCaseToAny(cat, c.name(), c.toString())) {
+ catEnum = c;
+ cat = c.name();
+ break;
+ }
+ }
+ if (catEnum == null) {
+ cat = null;
}
}
- if (catEnum == null) {
- cat = null;
- }
}
- }
- if (cat == null && page == 0) {
- StringBuilder builder = new StringBuilder();
+ if (cat == null && page == 0) {
+ StringBuilder builder = new StringBuilder();
builder.append(Captions.HELP_HEADER.s());
- for (CommandCategory c : CommandCategory.values()) {
- builder.append("\n" + StringMan
- .replaceAll(Captions.HELP_INFO_ITEM.s(), "%category%",
- c.toString().toLowerCase(), "%category_desc%", c.toString()));
- }
+ for (CommandCategory c : CommandCategory.values()) {
+ builder.append("\n").append(StringMan
+ .replaceAll(Captions.HELP_INFO_ITEM.s(), "%category%", c.toString().toLowerCase(),
+ "%category_desc%", c.toString()));
+ }
builder.append("\n").append(Captions.HELP_INFO_ITEM.s().replaceAll("%category%", "all")
.replaceAll("%category_desc%", Captions.HELP_DISPLAY_ALL_COMMANDS.s()));
builder.append("\n" + Captions.HELP_FOOTER.s());
- MainUtil.sendMessage(player, builder.toString(), false);
- return;
- }
- page--;
- new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages()
- .generatePage(page, getParent().toString()).render();
+ MainUtil.sendMessage(player, builder.toString(), false);
+ return true;
+ }
+ new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages()
+ .generatePage(page - 1, getParent().toString()).render();
+ return true;
+ });
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Leave.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Leave.java
index be29265bf..cbc227bd3 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Leave.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Leave.java
@@ -11,6 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "leave",
description = "Removes self from being trusted or a member of the plot",
@@ -20,7 +21,7 @@ import java.util.UUID;
super(MainCommand.getInstance(), true);
}
- @Override public void execute(PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
@@ -44,5 +45,6 @@ import java.util.UUID;
MainUtil.sendMessage(player, Captions.REMOVED_PLAYERS, 1);
}
}
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java
index d1daa73cd..31e599976 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java
@@ -11,6 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import java.util.Arrays;
+import java.util.concurrent.CompletableFuture;
/**
* PlotSquared command class.
@@ -176,6 +177,8 @@ public class MainCommand extends Command {
@Override public void run(Command cmd, CommandResult result) {
// Post command stuff!?
}
+ }).thenAccept(result -> {
+ // TODO: Something with the command result
});
} catch (CommandException e) {
e.perform(player);
@@ -184,7 +187,7 @@ public class MainCommand extends Command {
return true;
}
- @Override public void execute(final PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(final PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
// Clear perm caching //
@@ -215,37 +218,32 @@ public class MainCommand extends Command {
args = Arrays.copyOfRange(args, 1, args.length);
}
if (args.length >= 2 && !args[0].isEmpty() && args[0].charAt(0) == '-') {
- switch (args[0].substring(1)) {
- case "f":
- confirm = new RunnableVal3() {
- @Override
- public void run(Command cmd, Runnable success, Runnable failure) {
- if (EconHandler.manager != null) {
- PlotArea area = player.getApplicablePlotArea();
- if (area != null) {
- Expression priceEval =
- area.PRICES.get(cmd.getFullId());
- Double price =
- priceEval != null ? priceEval.evaluate(0d) : 0d;
- if (price != 0d
- && EconHandler.manager.getMoney(player) < price) {
- if (failure != null) {
- failure.run();
- }
- return;
+ if ("f".equals(args[0].substring(1))) {
+ confirm = new RunnableVal3() {
+ @Override public void run(Command cmd, Runnable success, Runnable failure) {
+ if (EconHandler.manager != null) {
+ PlotArea area = player.getApplicablePlotArea();
+ if (area != null) {
+ Expression priceEval = area.PRICES.get(cmd.getFullId());
+ Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
+ if (price != 0d
+ && EconHandler.manager.getMoney(player) < price) {
+ if (failure != null) {
+ failure.run();
}
+ return;
}
}
- if (success != null) {
- success.run();
- }
}
- };
- args = Arrays.copyOfRange(args, 1, args.length);
- break;
- default:
- Captions.INVALID_COMMAND_FLAG.send(player);
- return;
+ if (success != null) {
+ success.run();
+ }
+ }
+ };
+ args = Arrays.copyOfRange(args, 1, args.length);
+ } else {
+ Captions.INVALID_COMMAND_FLAG.send(player);
+ return CompletableFuture.completedFuture(false);
}
}
}
@@ -275,6 +273,7 @@ public class MainCommand extends Command {
player.setMeta(PlotPlayer.META_LAST_PLOT, plot);
}
}
+ return CompletableFuture.completedFuture(true);
}
@Override public boolean canExecute(CommandCaller player, boolean message) {
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java
index 3d73c7bbe..d897fb3cf 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java
@@ -9,6 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
+import java.util.concurrent.CompletableFuture;
+
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players",
usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
public class Near extends Command {
@@ -16,10 +18,11 @@ public class Near extends Command {
super(MainCommand.getInstance(), true);
}
- @Override public void execute(PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
Captions.PLOT_NEAR.send(player, StringMan.join(plot.getPlayersInPlot(), ", "));
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Relight.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Relight.java
index 65656117a..321f91d24 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Relight.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Relight.java
@@ -7,7 +7,7 @@ import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
-import java.util.HashSet;
+import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "relight", description = "Relight your plot", usage = "/plot relight",
category = CommandCategory.DEBUG) public class Relight extends Command {
@@ -15,25 +15,24 @@ import java.util.HashSet;
super(MainCommand.getInstance(), true);
}
- @Override public void execute(final PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(final PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
Captions.NOT_IN_PLOT.send(player);
- return;
+ return CompletableFuture.completedFuture(false);
}
- HashSet regions = plot.getRegions();
final LocalBlockQueue queue = plot.getArea().getQueue(false);
ChunkManager.chunkTask(plot, new RunnableVal() {
@Override public void run(int[] value) {
queue.fixChunkLighting(value[0], value[1]);
}
- }, new Runnable() {
- @Override public void run() {
- plot.refreshChunks();
- Captions.SET_BLOCK_ACTION_FINISHED.send(player);
- }
+ }, () -> {
+ plot.refreshChunks();
+ Captions.SET_BLOCK_ACTION_FINISHED.send(player);
}, 5);
+
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SubCommand.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SubCommand.java
index 91dd83069..458442ff2 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SubCommand.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SubCommand.java
@@ -7,6 +7,8 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
+import java.util.concurrent.CompletableFuture;
+
/**
* SubCommand class
*
@@ -28,10 +30,10 @@ public abstract class SubCommand extends Command {
return true;
}
- @Override public void execute(PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) {
- onCommand(player, args);
+ return CompletableFuture.completedFuture(onCommand(player, args));
}
public abstract boolean onCommand(PlotPlayer player, String[] args);
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java
index 81a508ee3..630e636d6 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java
@@ -15,6 +15,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import java.util.Iterator;
import java.util.Set;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "trust", aliases = {"t"}, requiredType = RequiredType.PLAYER,
usage = "/plot trust ",
@@ -25,7 +26,7 @@ import java.util.UUID;
super(MainCommand.getInstance(), true);
}
- @Override public void execute(final PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(final PlotPlayer player, String[] args,
RunnableVal3 confirm,
RunnableVal2 whenDone) throws CommandException {
final Plot currentPlot = player.getCurrentPlot();
@@ -81,5 +82,7 @@ import java.util.UUID;
MainUtil.sendMessage(player, Captions.TRUSTED_ADDED);
}
}, null);
+
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java
index f5dc5710e..c9e7ed8e8 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java
@@ -12,6 +12,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.*;
+import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "visit", permission = "plots.visit",
description = "Visit someones plot", usage = "/plot visit [|||] [#]",
@@ -26,7 +27,7 @@ import java.util.*;
return tabOf(player, args, space, getUsage());
}
- @Override public void execute(final PlotPlayer player, String[] args,
+ @Override public CompletableFuture execute(final PlotPlayer player, String[] args,
RunnableVal3 confirm,
final RunnableVal2 whenDone) throws CommandException {
if (args.length == 1 && args[0].contains(":")) {
@@ -41,7 +42,7 @@ import java.util.*;
if (!MathMan.isInteger(args[1])) {
Captions.NOT_VALID_NUMBER.send(player, "(1, ∞)");
Captions.COMMAND_SYNTAX.send(player, getUsage());
- return;
+ return CompletableFuture.completedFuture(false);
}
page = Integer.parseInt(args[2]);
case 2:
@@ -50,12 +51,12 @@ import java.util.*;
if (sortByArea == null) {
Captions.NOT_VALID_NUMBER.send(player, "(1, ∞)");
Captions.COMMAND_SYNTAX.send(player, getUsage());
- return;
+ return CompletableFuture.completedFuture(false);
}
UUID user = UUIDHandler.getUUIDFromString(args[0]);
if (user == null) {
Captions.COMMAND_SYNTAX.send(player, getUsage());
- return;
+ return CompletableFuture.completedFuture(false);
}
unsorted = PlotSquared.get().getBasePlots(user);
shouldSortByArea = true;
@@ -93,7 +94,7 @@ import java.util.*;
}
if (unsorted == null || unsorted.isEmpty()) {
Captions.FOUND_NO_PLOTS.send(player);
- return;
+ return CompletableFuture.completedFuture(false);
}
unsorted = new ArrayList<>(unsorted);
if (unsorted.size() > 1) {
@@ -101,7 +102,7 @@ import java.util.*;
}
if (page < 1 || page > unsorted.size()) {
Captions.NOT_VALID_NUMBER.send(player, "(1, " + unsorted.size() + ")");
- return;
+ return CompletableFuture.completedFuture(false);
}
List plots;
if (shouldSortByArea) {
@@ -114,23 +115,23 @@ import java.util.*;
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_UNOWNED)) {
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_UNOWNED);
- return;
+ return CompletableFuture.completedFuture(false);
}
} else if (plot.isOwner(player.getUUID())) {
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OWNED) && !Permissions
.hasPermission(player, Captions.PERMISSION_HOME)) {
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OWNED);
- return;
+ return CompletableFuture.completedFuture(false);
}
} else if (plot.isAdded(player.getUUID())) {
if (!Permissions.hasPermission(player, Captions.PERMISSION_SHARED)) {
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_SHARED);
- return;
+ return CompletableFuture.completedFuture(false);
}
} else {
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER)) {
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OTHER);
- return;
+ return CompletableFuture.completedFuture(false);
}
}
confirm.run(this, () -> {
@@ -140,6 +141,8 @@ import java.util.*;
whenDone.run(Visit.this, CommandResult.FAILURE);
}
}, () -> whenDone.run(Visit.this, CommandResult.FAILURE));
+
+ return CompletableFuture.completedFuture(true);
}
}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java
index 9a2fb193b..9f4677f4f 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java
@@ -34,7 +34,7 @@ public class ConsolePlayer extends PlotPlayer {
return instance;
}
- @Override public boolean canTeleport(Location loc) {
+ @Override public boolean canTeleport(@Nonnull Location loc) {
return true;
}
@@ -100,14 +100,14 @@ public class ConsolePlayer extends PlotPlayer {
return RequiredType.CONSOLE;
}
- @Override public void setWeather(PlotWeather weather) {
+ @Override public void setWeather(@Nonnull PlotWeather weather) {
}
- @Override public PlotGameMode getGameMode() {
+ @Nonnull @Override public PlotGameMode getGameMode() {
return PlotGameMode.NOT_SET;
}
- @Override public void setGameMode(PlotGameMode gameMode) {
+ @Override public void setGameMode(@Nonnull PlotGameMode gameMode) {
}
@Override public void setTime(long time) {
@@ -120,7 +120,7 @@ public class ConsolePlayer extends PlotPlayer {
@Override public void setFlight(boolean fly) {
}
- @Override public void playMusic(Location location, PlotBlock id) {
+ @Override public void playMusic(@Nonnull Location location, @Nonnull PlotBlock id) {
}
@Override public void kick(String message) {
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java
index 23cf49e98..19441a2d1 100644
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java
+++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java
@@ -12,6 +12,7 @@ import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAre
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.util.*;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
+import com.google.common.base.Preconditions;
import lombok.NonNull;
import javax.annotation.Nonnull;
@@ -333,8 +334,9 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*/
@Override @Nonnull public abstract UUID getUUID();
- public boolean canTeleport(Location loc) {
- Location current = getLocationFull();
+ public boolean canTeleport(@Nonnull final Location loc) {
+ Preconditions.checkNotNull(loc, "Specified location cannot be null");
+ final Location current = getLocationFull();
teleport(loc);
boolean result = true;
if (!getLocation().equals(loc)) {
@@ -416,21 +418,21 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*
* @param weather the weather visible to the player
*/
- public abstract void setWeather(PlotWeather weather);
+ public abstract void setWeather(@Nonnull PlotWeather weather);
/**
* Get this player's gamemode.
*
* @return the gamemode of the player.
*/
- public abstract PlotGameMode getGameMode();
+ @Nonnull public abstract PlotGameMode getGameMode();
/**
* Set this player's gameMode.
*
* @param gameMode the gamemode to set
*/
- public abstract void setGameMode(PlotGameMode gameMode);
+ public abstract void setGameMode(@Nonnull PlotGameMode gameMode);
/**
* Set this player's local time (ticks).
@@ -459,7 +461,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
* @param location where to play the music
* @param id the record item id
*/
- public abstract void playMusic(Location location, PlotBlock id);
+ public abstract void playMusic(@Nonnull Location location, @Nonnull PlotBlock id);
/**
* Check if this player is banned.