This commit is contained in:
Jesse Boyd 2017-07-08 21:50:25 +10:00
parent 1918000668
commit 248751378b
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
5 changed files with 15 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.CmdInstance; import com.intellectualcrafters.plot.object.CmdInstance;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.CmdConfirm; import com.intellectualcrafters.plot.util.CmdConfirm;
@ -22,8 +23,8 @@ public class Confirm extends SubCommand {
return false; return false;
} }
CmdConfirm.removePending(player); CmdConfirm.removePending(player);
if ((System.currentTimeMillis() - command.timestamp) > 20000) { if ((System.currentTimeMillis() - command.timestamp) > Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS * 1000) {
MainUtil.sendMessage(player, C.FAILED_CONFIRM); MainUtil.sendMessage(player, C.EXPIRED_CONFIRM);
return false; return false;
} }
TaskManager.runTask(command.command); TaskManager.runTask(command.command);

View File

@ -167,6 +167,7 @@ public enum C {
/* /*
* Confirm * Confirm
*/ */
EXPIRED_CONFIRM("$2Confirmation has expired, please run the command again!", "Confirm"),
FAILED_CONFIRM("$2You have no pending actions to confirm!", "Confirm"), FAILED_CONFIRM("$2You have no pending actions to confirm!", "Confirm"),
REQUIRES_CONFIRM("$2Are you sure you wish to execute: $1%s$2?&-$2This cannot be undone! If you are sure: $1/plot confirm", "Confirm"), REQUIRES_CONFIRM("$2Are you sure you wish to execute: $1%s$2?&-$2This cannot be undone! If you are sure: $1/plot confirm", "Confirm"),
/* /*

View File

@ -251,6 +251,11 @@ public class Settings extends Config {
public static boolean CACHE_UUDS = false; public static boolean CACHE_UUDS = false;
} }
public static final class Confirmation {
@Comment("Teleport to your plot on death")
public static int CONFIRMATION_TIMEOUT_SECONDS = 20;
}
public static final class Teleport { public static final class Teleport {
@Comment("Teleport to your plot on death") @Comment("Teleport to your plot on death")
public static boolean ON_DEATH = false; public static boolean ON_DEATH = false;

View File

@ -16,7 +16,7 @@ public class CmdConfirm {
public static void addPending(final PlotPlayer player, String commandStr, final Runnable runnable) { public static void addPending(final PlotPlayer player, String commandStr, final Runnable runnable) {
removePending(player); removePending(player);
MainUtil.sendMessage(player, C.REQUIRES_CONFIRM, commandStr); if (commandStr != null) MainUtil.sendMessage(player, C.REQUIRES_CONFIRM, commandStr);
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -8,7 +8,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@ -131,7 +130,11 @@ public class UUIDHandler {
return null; return null;
} }
if (nameOrUUIDString.length() > 16) { if (nameOrUUIDString.length() > 16) {
try {
return UUID.fromString(nameOrUUIDString); return UUID.fromString(nameOrUUIDString);
} catch (IllegalArgumentException e) {
return null;
}
} }
return UUIDHandler.getUUID(nameOrUUIDString, null); return UUIDHandler.getUUID(nameOrUUIDString, null);
} }