Examples of Resident


Examples of com.palmergames.bukkit.towny.object.Resident

         * @param player
         * @param names
         */

        public void townAssistantsRemove(Player player, String[] names) {
                Resident resident;
                Town town;
                try {
                        resident = TownyUniverse.getDataSource().getResident(player.getName());
                        town = resident.getTown();
                        if (!resident.isMayor())
                                throw new TownyException(TownySettings.getLangString("msg_not_mayor"));
                } catch (TownyException x) {
                        TownyMessaging.sendErrorMsg(player, x.getMessage());
                        return;
                }
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Resident

         * @param sender
         * @param args
         */
        public static void parseTownJoin(CommandSender sender, String[] args) {
          try {
            Resident resident;
            Town town;
            String residentName, townName, contextualResidentName;
            boolean console = false;
           
            if (sender instanceof Player) {
              // Player
              if (args.length < 1)
                throw new Exception(String.format("Usage: /town join [town]"));
             
              Player player = (Player)sender;
              residentName = player.getName();
              townName = args[0];
              contextualResidentName = "You";
            } else {
              // Console
              if (args.length < 2)
                throw new Exception(String.format("Usage: town join [resident] [town]"));
             
              residentName = args[0];
              townName = args[1];
              contextualResidentName = residentName;
            }
           
            resident = TownyUniverse.getDataSource().getResident(residentName);
            town = TownyUniverse.getDataSource().getTown(townName);
           
            // Check if resident is currently in a town.
            if (resident.hasTown())
              throw new Exception(String.format(TownySettings.getLangString("msg_err_already_res"), contextualResidentName));
           
            if (!console) {
              // Check if town is town is free to join.
              if (!town.isOpen())
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Resident

          if (sender instanceof Player) {
            name = ((Player)sender).getName();
          } else {
            name = "Console";
          }
                Resident resident;
                Town town;
                try {
                  if (name.equalsIgnoreCase("Console")) {
                    town = specifiedTown;
                  } else {
                        resident = TownyUniverse.getDataSource().getResident(name);
                        if (specifiedTown == null)
                                town = resident.getTown();
                        else
                                town = specifiedTown;
                        if (!TownyUniverse.getPermissionSource().isTownyAdmin((Player)sender) && !resident.isMayor() && !town.hasAssistant(resident))
                                throw new TownyException(TownySettings.getLangString("msg_not_mayor_ass"));
                  }
                       
                } catch (TownyException x) {
                        TownyMessaging.sendErrorMsg(sender, x.getMessage());
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Resident

      player.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("mayor_sing"), "/town claim", "", TownySettings.getLangString("msg_block_claim")));
      player.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("mayor_sing"), "/town claim", "outpost", TownySettings.getLangString("mayor_help_3")));
      player.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("mayor_sing"), "/town claim", "[circle/rect] [radius]", TownySettings.getLangString("mayor_help_4")));
      player.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("mayor_sing"), "/town claim", "[circle/rect] auto", TownySettings.getLangString("mayor_help_5")));
    } else {
      Resident resident;
      Town town;
      TownyWorld world;
      try {
        if (plugin.getTownyUniverse().isWarTime())
          throw new TownyException(TownySettings.getLangString("msg_war_cannot_do"));

        if (!TownyUniverse.getPermissionSource().isTownyAdmin(player) && plugin.isPermissions() && !TownyUniverse.getPermissionSource().hasPermission(player, PermissionNodes.TOWNY_TOWN_CLAIM.getNode()))
          throw new TownyException(TownySettings.getLangString("msg_no_perms_claim"));

        resident = TownyUniverse.getDataSource().getResident(player.getName());
        town = resident.getTown();
        if (!resident.isMayor() && !town.hasAssistant(resident))
          throw new TownyException(TownySettings.getLangString("msg_not_mayor_ass"));
        world = TownyUniverse.getDataSource().getWorld(player.getWorld().getName());

        if (!world.isUsingTowny())
          throw new TownyException(TownySettings.getLangString("msg_set_use_towny_off"));
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Resident

                        player.sendMessage(ChatTools.formatTitle("/town unclaim"));
                        player.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("mayor_sing"), "/town unclaim", "", TownySettings.getLangString("mayor_help_6")));
                        player.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("mayor_sing"), "/town unclaim", "[circle/rect] [radius]", TownySettings.getLangString("mayor_help_7")));
                        player.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("mayor_sing"), "/town unclaim", "all", TownySettings.getLangString("mayor_help_8")));
                } else {
                        Resident resident;
                        Town town;
                        TownyWorld world;
                        try {
                                if (plugin.getTownyUniverse().isWarTime())
                                        throw new TownyException(TownySettings.getLangString("msg_war_cannot_do"));
                               
                                resident = TownyUniverse.getDataSource().getResident(player.getName());
                                town = resident.getTown();
                                if (!resident.isMayor())
                                        if (!town.hasAssistant(resident))
                                                throw new TownyException(TownySettings.getLangString("msg_not_mayor_ass"));
                world = TownyUniverse.getDataSource().getWorld(player.getWorld().getName());
                               
                                List<WorldCoord> selection;
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Resident

                return true;
        }
        */
       
        private void townWithdraw(Player player, int amount) {
                Resident resident;
                Town town;
                try {
                        if(!TownySettings.getTownBankAllowWithdrawls())
                                throw new TownyException(TownySettings.getLangString("msg_err_withdraw_disabled"));
                       
                        if (amount < 0)
                                throw new TownyException(TownySettings.getLangString("msg_err_negative_money"));
                       
                        resident = TownyUniverse.getDataSource().getResident(player.getName());
                        town = resident.getTown();
                       
                        town.withdrawFromBank(resident, amount);
                        TownyMessaging.sendTownMessage(town, String.format(TownySettings.getLangString("msg_xx_withdrew_xx"), resident.getName(), amount, "town"));
                } catch (TownyException x) {
                        TownyMessaging.sendErrorMsg(player, x.getMessage());
                } catch (EconomyException x) {
                        TownyMessaging.sendErrorMsg(player, x.getMessage());
                }
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Resident

                        TownyMessaging.sendErrorMsg(player, x.getMessage());
                }
        }
       
        private void townDeposit(Player player, int amount) {
                Resident resident;
                Town town;
                try {
                        resident = TownyUniverse.getDataSource().getResident(player.getName());
                        town = resident.getTown();
                       
                        double bankcap = TownySettings.getTownBankCap();
                        if (bankcap > 0) {
                                if(amount + town.getHoldingBalance() > bankcap)
                                        throw new TownyException(String.format(TownySettings.getLangString("msg_err_deposit_capped"), bankcap));
                        }
                       
                        if (amount < 0)
                                throw new TownyException(TownySettings.getLangString("msg_err_negative_money"));
                       
                        if (!resident.payTo(amount, town, "Town Deposit"))
                                throw new TownyException(TownySettings.getLangString("msg_insuf_funds"));
                       
                        TownyMessaging.sendTownMessage(town, String.format(TownySettings.getLangString("msg_xx_deposited_xx"), resident.getName(), amount, "town"));
                } catch (TownyException x) {
                        TownyMessaging.sendErrorMsg(player, x.getMessage());
                } catch (EconomyException x) {
                        TownyMessaging.sendErrorMsg(player, x.getMessage());
                }
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Resident

    @Override
    public void run() {
        long currentTime = System.currentTimeMillis();

        while (true) {
            Resident resident = teleportQueue.peek();
            if (resident == null) break;
            if (currentTime > resident.getTeleportRequestTime() + (TownySettings.getTeleportWarmupTime() * 1000)) {
                resident.clearTeleportRequest();
                try {
                  // Make sure the chunk we teleport to is loaded.
                    Chunk chunk = resident.getTeleportDestination().getSpawn().getWorld().getChunkAt(resident.getTeleportDestination().getSpawn().getBlock());
                  if (!chunk.isLoaded()) chunk.load();
                    TownyUniverse.getPlayer(resident).teleport(resident.getTeleportDestination().getSpawn());
                } catch (TownyException ignore) { }
                teleportQueue.poll();
            } else {
                break;
            }
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Resident

        // Check for embassy plot, or if the resident is is the town.
        if (!resident.getTown().equals(town) && !townBlock.getType().equals(TownBlockType.EMBASSY))
          throw new TownyException(TownySettings.getLangString("msg_err_not_part_town"));

        try {
          Resident owner = townBlock.getResident();
          if (townBlock.getPlotPrice() != -1) {
            // Plot is for sale
            if (TownySettings.isUsingEconomy() && !resident.payTo(townBlock.getPlotPrice(), owner, "Plot - Buy From Seller"))
              throw new TownyException(TownySettings.getLangString("msg_no_money_purchase_plot"));
           
            int maxPlots = TownySettings.getMaxResidentPlots(resident);
            if (maxPlots >= 0 && resident.getTownBlocks().size() + 1 > maxPlots)
              throw new TownyException(String.format(TownySettings.getLangString("msg_max_plot_own"), maxPlots));
           
            TownyMessaging.sendTownMessage(town, TownySettings.getBuyResidentPlotMsg(resident.getName(), owner.getName(), townBlock.getPlotPrice()));
            townBlock.setPlotPrice(-1);
            townBlock.setResident(resident);
           
            // Set the plot permissions to mirror the new owners.
            townBlock.setType(townBlock.getType());

            TownyUniverse.getDataSource().saveResident(owner);
            TownyUniverse.getDataSource().saveTownBlock(townBlock);
           
            plugin.updateCache();
            return true;
          } else if (town.isMayor(resident) || town.hasAssistant(resident)) {
            //Plot isn't for sale but re-possessing for town.
           
            if (TownySettings.isUsingEconomy() && !town.payTo(0.0, owner, "Plot - Buy Back"))
              throw new TownyException(TownySettings.getLangString("msg_town_no_money_purchase_plot"));
           
            TownyMessaging.sendTownMessage(town, TownySettings.getBuyResidentPlotMsg(town.getName(), owner.getName(), 0.0));
            townBlock.setResident(null);
            townBlock.setPlotPrice(-1);
           
            // Set the plot permissions to mirror the towns.
            townBlock.setType(townBlock.getType());

            TownyUniverse.getDataSource().saveResident(owner);
            TownyUniverse.getDataSource().saveTownBlock(townBlock);

            return true;
          } else {
            //Should never reach here.
            throw new AlreadyRegisteredException(String.format(TownySettings.getLangString("msg_already_claimed"), owner.getName()));
          }
               
        } catch (NotRegisteredException e) {
          //Plot has no owner so it's the town selling it
          TownyMessaging.sendMsg(player, String.format("6) %s", worldCoord.toString()));
View Full Code Here

Examples of com.palmergames.bukkit.towny.object.Resident

      //Hashtable<Resident, Double> townTaxes = new Hashtable<Resident, Double>();
      for (TownBlock townBlock : new ArrayList<TownBlock>(town.getTownBlocks())) {
        if (!townBlock.hasResident())
          continue;
        try {
          Resident resident = townBlock.getResident();
          if (town.isMayor(resident) || town.hasAssistant(resident)) {
            continue;
          }
          if (!resident.payTo(townBlock.getType().getTax(town), town, String.format("Plot Tax (%s)", townBlock.getType()))) {
            TownyMessaging.sendTownMessage(town, String.format(TownySettings.getLangString("msg_couldnt_pay_plot_taxes"), resident));
            townBlock.setResident(null);
            TownyUniverse.getDataSource().saveResident(resident);
            TownyUniverse.getDataSource().saveWorld(townBlock.getWorld());
          }// else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.