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