use of ca.xshade.questionmanager.Option in project Towny by ElgarL.
the class TownCommand method townDelete.
public void townDelete(Player player, String[] split) {
Town town = null;
if (split.length == 0)
try {
Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
town = resident.getTown();
} catch (TownyException x) {
TownyMessaging.sendErrorMsg(player, x.getMessage());
return;
}
else
try {
if (!TownyUniverse.getPermissionSource().testPermission(player, PermissionNodes.TOWNY_COMMAND_TOWNYADMIN_TOWN_DELETE.getNode()))
throw new TownyException(TownySettings.getLangString("msg_err_admin_only_delete_town"));
town = TownyUniverse.getDataSource().getTown(split[0]);
} catch (TownyException x) {
TownyMessaging.sendErrorMsg(player, x.getMessage());
return;
}
// Use questioner to confirm.
Plugin test = BukkitTools.getServer().getPluginManager().getPlugin("Questioner");
if (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 TownQuestionTask(player, town) {
@Override
public void run() {
TownyUniverse.getDataSource().removeTown(town);
TownyMessaging.sendGlobalMessage(TownySettings.getDelTownMsg(town));
}
}));
options.add(new Option(TownySettings.questionerDeny(), new TownQuestionTask(player, town) {
@Override
public void run() {
TownyMessaging.sendMessage(getSender(), "Delete Aborted!");
}
}));
Question question = new Question(player.getName(), "Do you really want to delete this town", options);
try {
plugin.appendQuestion(questioner, question);
} catch (Exception e) {
System.out.println(e.getMessage());
}
} else {
TownyUniverse.getDataSource().removeTown(town);
TownyMessaging.sendGlobalMessage(TownySettings.getDelTownMsg(town));
}
}
use of ca.xshade.questionmanager.Option in project Towny by ElgarL.
the class NationCommand method nationInviteTown.
private static void nationInviteTown(Player player, Nation nation, Town town) throws AlreadyRegisteredException {
Plugin test = plugin.getServer().getPluginManager().getPlugin("Questioner");
Resident townMayor = town.getMayor();
if (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 JoinNationTask(townMayor, nation)));
options.add(new Option(TownySettings.questionerDeny(), new ResidentNationQuestionTask(townMayor, nation) {
@Override
public void run() {
TownyMessaging.sendNationMessage(nation, String.format(TownySettings.getLangString("msg_deny_invite"), getResident().getName()));
}
}));
Question question = new Question(townMayor.getName(), String.format(TownySettings.getLangString("msg_invited"), nation.getName()), options);
try {
plugin.appendQuestion(questioner, question);
} catch (Exception e) {
System.out.println(e.getMessage());
}
} else {
nation.addTown(town);
plugin.resetCache();
TownyUniverse.getDataSource().saveTown(town);
}
}
use of ca.xshade.questionmanager.Option in project Towny by ElgarL.
the class TownCommand method townInviteResident.
private static void townInviteResident(Town town, Resident newMember) throws AlreadyRegisteredException {
Plugin test = BukkitTools.getServer().getPluginManager().getPlugin("Questioner");
if (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 JoinTownTask(newMember, town)));
options.add(new Option(TownySettings.questionerDeny(), new ResidentTownQuestionTask(newMember, town) {
@Override
public void run() {
TownyMessaging.sendTownMessage(getTown(), String.format(TownySettings.getLangString("msg_deny_invite"), getResident().getName()));
}
}));
Question question = new Question(newMember.getName(), String.format(TownySettings.getLangString("msg_invited"), town.getName()), options);
try {
plugin.appendQuestion(questioner, question);
} catch (Exception e) {
System.out.println(e.getMessage());
}
} else
try {
townAddResident(town, newMember);
} catch (AlreadyRegisteredException e) {
}
}
use of ca.xshade.questionmanager.Option 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