use of com.palmergames.bukkit.towny.tasks.ResidentPurge in project Towny by ElgarL.
the class TownyAdminCommand method purge.
/**
* Remove residents who havn't logged in for X amount of days.
*
* @param split
*/
public void purge(String[] split) {
if (split.length == 0) {
// command was '/townyadmin purge'
player.sendMessage(ChatTools.formatTitle("/townyadmin purge"));
player.sendMessage(ChatTools.formatCommand("", "/townyadmin purge", "[number of days]", ""));
player.sendMessage(ChatTools.formatCommand("", "", "Removes offline residents not seen for this duration.", ""));
return;
}
int days = 1;
try {
days = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
TownyMessaging.sendErrorMsg(getSender(), TownySettings.getLangString("msg_error_must_be_int"));
return;
}
// Use questioner to confirm.
Plugin test = BukkitTools.getServer().getPluginManager().getPlugin("Questioner");
if (this.sender instanceof Player && TownySettings.isUsingQuestioner() && test != null && test instanceof Questioner && test.isEnabled()) {
Questioner questioner = (Questioner) test;
questioner.loadClasses();
List<Option> options = new ArrayList<Option>();
options.add(new Option(TownySettings.questionerAccept(), new PurgeQuestionTask(plugin, this.sender, TimeTools.getMillis(days + "d"))));
options.add(new Option(TownySettings.questionerDeny(), new PurgeQuestionTask(plugin, this.sender, TimeTools.getMillis(days + "d")) {
@Override
public void run() {
TownyMessaging.sendMessage(getSender(), "Purge Aborted!");
}
}));
Question question = new Question(this.sender.getName(), "Do you really want to perform this purge", options);
try {
plugin.appendQuestion(questioner, question);
} catch (Exception e) {
System.out.println(e.getMessage());
}
} else {
// Run a purge in it's own thread
new ResidentPurge(plugin, this.sender, TimeTools.getMillis(days + "d")).start();
}
}
Aggregations