PlotSquared/src/main/java/com/intellectualcrafters/plot/util/CmdConfirm.java

45 lines
1.2 KiB
Java
Raw Normal View History

2015-03-02 05:23:30 +01:00
package com.intellectualcrafters.plot.util;
2015-03-02 14:28:38 +01:00
import java.util.HashMap;
import com.intellectualcrafters.plot.config.C;
2015-03-07 05:00:56 +01:00
import com.intellectualcrafters.plot.object.CmdInstance;
import com.intellectualcrafters.plot.object.PlotPlayer;
2015-03-02 14:28:38 +01:00
2015-03-02 05:23:30 +01:00
public class CmdConfirm {
private static HashMap<String, CmdInstance> pending = new HashMap<>();
public static CmdInstance getPending(PlotPlayer player) {
if (player == null) {
return pending.get("__CONSOLE__");
}
return pending.get(player.getName());
}
public static void removePending(PlotPlayer player) {
if (player == null) {
pending.remove("__CONSOLE__");
}
else {
pending.remove(player.getName());
}
}
public static void removePending(String name) {
pending.remove(name);
}
public static void addPending(PlotPlayer player, String commandStr, Runnable runnable) {
MainUtil.sendMessage(player, C.REQUIRES_CONFIRM, commandStr);
CmdInstance cmd = new CmdInstance(runnable);
String name;
if (player == null) {
name = "__CONSOLE__";
}
else {
name = player.getName();
}
pending.put(name, cmd);
}
2015-03-02 05:23:30 +01:00
}