final Pair<String, String> pair = new Pair<String, String>(target.getName(), sName);
if (requests.containsKey(pair)){
requests.remove(pair);
}
BukkitTask task = Bukkit.getScheduler().runTaskLaterAsynchronously(CommandsEX.plugin, new Runnable(){
@Override
public void run() {
requests.remove(pair);
Player player = Bukkit.getPlayerExact(pair.second);
if (player != null){
LogHelper.showWarning("economyRequestExpired1#####[" + getCurrencySymbol() + fixDecimals(amount) + " #####from#####[ " + pair.first + "#####economyRequestExpired2", player);
}
Player target = Bukkit.getPlayerExact(pair.first);
if (target != null){
LogHelper.showInfo("economyRequestExpiredNotify1#####[" + pair.second + " #####for#####[ " + getCurrencySymbol() + fixDecimals(amount) + " #####economyRequestExpiredNotify1", target);
}
}
}, CommandsEX.getConf().getInt("economy.requestExpireTime") * 20);
requests.put(pair, new Pair<Double, BukkitTask>(amount, task));
LogHelper.showInfo("economyRequest#####[" + getCurrencySymbol() + fixDecimals(amount) + " #####to#####[ " + target, sender);
LogHelper.showInfo("[" + sName + "economyRequestNotify1#####[" + fixDecimals(amount) + " #####economyRequestNotify2", target);
LogHelper.showInfo("economyRequestNotify3#####[" + sName, target);
LogHelper.showInfo("economyRequestNotify4#####[" + sName, target);
} else {
LogHelper.showWarning("economyTakeNotEnough", sender);
}
} catch (NumberFormatException e){
LogHelper.showWarning("economyIncorrectAmount", sender);
}
} else {
LogHelper.showWarning("invalidPlayer", sender);
}
} else {
sender.sendMessage(getEconomyHelp(sender));
}
}
}
} else {
sender.sendMessage(getEconomyHelp(sender));
}
} else if (function.equalsIgnoreCase("spawn")){
if (Permissions.checkPerms(sender, "cex.economy.spawn")){
if (args.length != 2 || args.length != 3){
sender.sendMessage(getEconomyHelp(sender));
} else {
Player target = null;
if (args.length == 2){
if (sender instanceof Player){
target = (Player) sender;
} else {
sender.sendMessage(getEconomyHelp(sender));
return true;
}
} else {
target = Bukkit.getPlayer(args[1]);
}
if (target == null){
LogHelper.showWarning("invalidPlayer", sender);
}
boolean self = false;
if (target.equals(sender)){
self = true;
}
try {
double amount = Double.parseDouble((self ? args[1] : args[2]));
// this avoids players giving a negative number
if (amount < 0){
LogHelper.showWarning("economyNegative", sender);
return true;
}
deposit(target.getName(), amount);
LogHelper.showInfo("economySpawn#####[" + fixDecimals(amount) + " #####" + (self ? "economySpawnAccount" : "for#####[ " + target.getName()), sender);
} catch (NumberFormatException e){
LogHelper.showWarning("economyIncorrectAmount", sender);
}
}
}
} else if (function.equalsIgnoreCase("purge")){
if (args.length > 1){
sender.sendMessage(getEconomyHelp(sender));
} else {
if (Permissions.checkPerms(sender, "cex.economy.purge")){
int amount = Econ.purgeAccounts();
if (amount > 1){
LogHelper.showInfo("economyPurge1#####[" + amount + " #####economyPurge2", sender);
} else {
LogHelper.showWarning("economyPurgeNone", sender);
}
}
}
} else if (function.equalsIgnoreCase("save")){
if (Permissions.checkPerms(sender, "cex.economy.save")){
Econ.saveDatabase();
LogHelper.showInfo("economySave", sender);
}
} else if (function.equalsIgnoreCase("clear")){
if (args.length == 1){
if (clearRequests.containsKey(sName)){
} else {
LogHelper.showWarnings(sender, "economyClear1", "economyClear2", "economyClear3");
BukkitTask task = Bukkit.getScheduler().runTaskLaterAsynchronously(CommandsEX.plugin, new Runnable(){
@Override
public void run() {
if (clearRequests.containsKey(sName)){
clearRequests.remove(sName);
LogHelper.showWarning("economyClearExpired", sender);