Search in sources :

Example 1 with ResidentTownQuestionTask

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) {
        }
}
Also used : JoinTownTask(com.palmergames.bukkit.towny.questioner.JoinTownTask) Questioner(ca.xshade.bukkit.questioner.Questioner) ArrayList(java.util.ArrayList) Option(ca.xshade.questionmanager.Option) ResidentTownQuestionTask(com.palmergames.bukkit.towny.questioner.ResidentTownQuestionTask) Question(ca.xshade.questionmanager.Question) InvalidNameException(javax.naming.InvalidNameException) Plugin(org.bukkit.plugin.Plugin)

Aggregations

Questioner (ca.xshade.bukkit.questioner.Questioner)1 Option (ca.xshade.questionmanager.Option)1 Question (ca.xshade.questionmanager.Question)1 JoinTownTask (com.palmergames.bukkit.towny.questioner.JoinTownTask)1 ResidentTownQuestionTask (com.palmergames.bukkit.towny.questioner.ResidentTownQuestionTask)1 ArrayList (java.util.ArrayList)1 InvalidNameException (javax.naming.InvalidNameException)1 Plugin (org.bukkit.plugin.Plugin)1