2015-03-02 05:23:30 +01:00
|
|
|
package com.intellectualcrafters.plot.util;
|
|
|
|
|
2015-03-07 06:22:15 +01:00
|
|
|
import com.intellectualcrafters.plot.config.C;
|
2015-03-07 05:00:56 +01:00
|
|
|
import com.intellectualcrafters.plot.object.CmdInstance;
|
2015-03-07 06:22:15 +01:00
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
2015-03-02 14:28:38 +01:00
|
|
|
|
2015-07-27 19:50:04 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
2015-03-02 05:23:30 +01:00
|
|
|
public class CmdConfirm {
|
2015-03-07 06:22:15 +01:00
|
|
|
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
|
|
|
}
|