Search in sources :

Example 1 with JoinNationTask

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);
    }
}
Also used : ResidentNationQuestionTask(com.palmergames.bukkit.towny.questioner.ResidentNationQuestionTask) JoinNationTask(com.palmergames.bukkit.towny.questioner.JoinNationTask) Questioner(ca.xshade.bukkit.questioner.Questioner) ArrayList(java.util.ArrayList) Resident(com.palmergames.bukkit.towny.object.Resident) Option(ca.xshade.questionmanager.Option) Question(ca.xshade.questionmanager.Question) NotRegisteredException(com.palmergames.bukkit.towny.exceptions.NotRegisteredException) EmptyNationException(com.palmergames.bukkit.towny.exceptions.EmptyNationException) EconomyException(com.palmergames.bukkit.towny.exceptions.EconomyException) AlreadyRegisteredException(com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException) InvalidNameException(javax.naming.InvalidNameException) TownyException(com.palmergames.bukkit.towny.exceptions.TownyException) 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 AlreadyRegisteredException (com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException)1 EconomyException (com.palmergames.bukkit.towny.exceptions.EconomyException)1 EmptyNationException (com.palmergames.bukkit.towny.exceptions.EmptyNationException)1 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)1 TownyException (com.palmergames.bukkit.towny.exceptions.TownyException)1 Resident (com.palmergames.bukkit.towny.object.Resident)1 JoinNationTask (com.palmergames.bukkit.towny.questioner.JoinNationTask)1 ResidentNationQuestionTask (com.palmergames.bukkit.towny.questioner.ResidentNationQuestionTask)1 ArrayList (java.util.ArrayList)1 InvalidNameException (javax.naming.InvalidNameException)1 Plugin (org.bukkit.plugin.Plugin)1