use of com.palmergames.bukkit.towny.questioner.JoinNationTask 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);
}
}
Aggregations