Examples of Nation


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

    List<Resident> toSave = new ArrayList<Resident>(town.getResidents());
    TownyWorld world = town.getWorld();

    try {
      if (town.hasNation()) {
        Nation nation = town.getNation();
        nation.removeTown(town);

        saveNation(nation);
      }
      town.clear();
    } catch (EmptyNationException e) {
View Full Code Here

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

    universe.getTownsMap().put(filteredName.toLowerCase(), town);

    //Check if this is a nation capitol
    if (town.isCapital()) {
      Nation nation = town.getNation();
      nation.setCapital(town);
      saveNation(nation);
    }

    Town oldTown = new Town(oldName);
View Full Code Here

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

    //Tidy up old files
    deleteNation(nation);

    universe.getNationsMap().remove(oldName.toLowerCase());
    nation.setName(filteredName);
    Nation oldNation = new Nation(oldName);

    if (plugin.isEcoActive())
      try {
        nation.pay(nation.getHoldingBalance(), "Rename Nation - Empty account of new nation name.");
        oldNation.payTo(oldNation.getHoldingBalance(), nation, "Rename Nation - Transfer to new account");
      } catch (EconomyException e) {
      }

    for (Town town : toSave) {
      saveTown(town);
View Full Code Here

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

         */
       
        //TODO: Proceduralize and make parse function for /towny prices [town]
        public List<String> getTownyPrices(Town town) {
                List<String> output = new ArrayList<String>();
                Nation nation = null;
               
                if (town != null)
                        if (town.hasNation())
                                try {
                                        nation = town.getNation();
                                } catch (NotRegisteredException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                }

               
                output.add(ChatTools.formatTitle("Prices"));
                output.add(Colors.Yellow + "[New] "
                                + Colors.Green + "Town: " + Colors.LightGreen + TownyFormatter.formatMoney(TownySettings.getNewTownPrice())
                                + Colors.Gray + " | "
                                + Colors.Green + "Nation: " + Colors.LightGreen + TownyFormatter.formatMoney(TownySettings.getNewNationPrice()));
                output.add(Colors.Yellow + "[Upkeep] "
                                + Colors.Green + "Town: " + Colors.LightGreen + TownyFormatter.formatMoney(TownySettings.getTownUpkeepCost(town))
                                + Colors.Gray + " | "
                                + Colors.Green + "Nation: " + Colors.LightGreen + TownyFormatter.formatMoney(TownySettings.getNationUpkeepCost(nation)));
                output.add(Colors.Gray + "Town upkeep is based on " + Colors.LightGreen + " the " + (TownySettings.isUpkeepByPlot() ? " number of plots" : " town level (num residents)."));
               
                if (town != null) {
                        output.add(Colors.Yellow + "Town [" + TownyFormatter.getFormattedName(town)+"]");
                        output.add(Colors.Rose + "    [Price] "
                                        + Colors.Green + "Plot: " + Colors.LightGreen + Double.toString(town.getPlotPrice())
                                        + Colors.Gray + " | "
                                        + Colors.Green + "Outpost: " + Colors.LightGreen + TownyFormatter.formatMoney(TownySettings.getOutpostCost()));
                        output.add(Colors.Rose + "    [Upkeep] "
                                        + Colors.Green + "Resident: " + Colors.LightGreen + Double.toString(town.getTaxes())
                                        + Colors.Gray + " | "
                                        + Colors.Green + "Plot: " + Colors.LightGreen + Double.toString(town.getPlotTax()));
                       
                       
                        if (nation != null) {
                                output.add(Colors.Yellow + "Nation [" + TownyFormatter.getFormattedName(nation)+"]");
                                output.add(Colors.Rose + "    [Upkeep] "
                                        + Colors.Green + "Town: " + Colors.LightGreen + Double.toString(nation.getTaxes())
                                        + Colors.Gray + " | "
                                        + Colors.Green + "Neutrality: " + Colors.LightGreen + TownyFormatter.formatMoney(TownySettings.getNationNeutralityCost()));
                        }
                }
                return output;
View Full Code Here

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

            } else if (resident.hasNation()) {
              if (resident.getTown().getNation().hasTown(townblock.getTown()))
                // towns
                townyMap[y][x] = Colors.Green;
              else if (townblock.getTown().hasNation()) {
                Nation nation = resident.getTown().getNation();
                if (nation.hasAlly(townblock.getTown().getNation()))
                  townyMap[y][x] = Colors.Green;
                else if (nation.hasEnemy(townblock.getTown().getNation()))
                  // towns
                  townyMap[y][x] = Colors.Red;
                else
                  townyMap[y][x] = Colors.White;
              } else
View Full Code Here

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

    if (split.length == 0)
      try {
        Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
        Town town = resident.getTown();
        Nation nation = town.getNation();
        TownyMessaging.sendMessage(player, TownyFormatter.getStatus(nation));
      } catch (NotRegisteredException x) {
        TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_dont_belong_nation"));
      }
    else if (split[0].equalsIgnoreCase("?"))
      for (String line : nation_help)
        player.sendMessage(line);
    else if (split[0].equalsIgnoreCase("list"))
      listNations(player);
    else if (split[0].equalsIgnoreCase("new")) {
      // TODO: Make an overloaded function
      // newNation(Player,String,Town)
      if (split.length == 1)
        TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_specify_nation_name"));
      else if (split.length == 2)
        try { // TODO: Make sure of the error catching
          Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
          if (!resident.isMayor() && !resident.getTown().hasAssistant(resident))
            throw new TownyException(TownySettings.getLangString("msg_peasant_right"));
          newNation(player, split[1], resident.getTown().getName());
        } catch (TownyException x) {
          TownyMessaging.sendErrorMsg(player, x.getMessage());
        }
      else
        // TODO: Check if player is an admin
        newNation(player, split[1], split[2]);
    } else if (split[0].equalsIgnoreCase("leave"))
      nationLeave(player);
    else if (split[0].equalsIgnoreCase("withdraw")) {
      if (split.length == 2)
        try {
          nationWithdraw(player, Integer.parseInt(split[1].trim()));
        } catch (NumberFormatException e) {
          TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_error_must_be_int"));
        }
      else
        TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_must_specify_amnt"), nationCom));
    } else if (split[0].equalsIgnoreCase("deposit")) {
      if (split.length == 2)
        try {
          nationDeposit(player, Integer.parseInt(split[1].trim()));
        } catch (NumberFormatException e) {
          TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_error_must_be_int"));
        }
      else
        TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_must_specify_amnt"), nationCom + " deposit"));
    } else {
      String[] newSplit = StringMgmt.remFirstArg(split);

      if (split[0].equalsIgnoreCase("king"))
        nationKing(player, newSplit);
      else if (split[0].equalsIgnoreCase("add"))
        nationAdd(player, newSplit);
      else if (split[0].equalsIgnoreCase("kick"))
        nationKick(player, newSplit);
      else if (split[0].equalsIgnoreCase("assistant"))
        nationAssistant(player, newSplit);
      else if (split[0].equalsIgnoreCase("set"))
        nationSet(player, newSplit);
      else if (split[0].equalsIgnoreCase("toggle"))
        nationToggle(player, newSplit);
      else if (split[0].equalsIgnoreCase("ally"))
        nationAlly(player, newSplit);
      else if (split[0].equalsIgnoreCase("enemy"))
        nationEnemy(player, newSplit);
      else if (split[0].equalsIgnoreCase("delete"))
        nationDelete(player, newSplit);
      else if (split[0].equalsIgnoreCase("online")) {
        try {
          Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
          Town town = resident.getTown();
          Nation nation = town.getNation();
          TownyMessaging.sendMessage(player, TownyFormatter.getFormattedOnlineResidents(plugin, TownySettings.getLangString("msg_nation_online"), nation));
        } catch (NotRegisteredException x) {
          TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_dont_belong_nation"));
        }
      } else
        try {
          Nation nation = TownyUniverse.getDataSource().getNation(split[0]);
          TownyMessaging.sendMessage(player, TownyFormatter.getStatus(nation));
        } catch (NotRegisteredException x) {
          TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_err_not_registered_1"), split[0]));
        }
    }
View Full Code Here

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

    }
  }

  private void nationWithdraw(Player player, int amount) {
    Resident resident;
    Nation nation;
    try {
      if (!TownySettings.geNationBankAllowWithdrawls())
        throw new TownyException(TownySettings.getLangString("msg_err_withdraw_disabled"));

      if (amount < 0)
        throw new TownyException(TownySettings.getLangString("msg_err_negative_money")); //TODO

      resident = TownyUniverse.getDataSource().getResident(player.getName());
      nation = resident.getTown().getNation();

      nation.withdrawFromBank(resident, amount);
      TownyMessaging.sendNationMessage(nation, String.format(TownySettings.getLangString("msg_xx_withdrew_xx"), resident.getName(), amount, "nation"));
    } 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.Nation

    }
  }

  private void nationDeposit(Player player, int amount) {
    Resident resident;
    Nation nation;
    try {
      resident = TownyUniverse.getDataSource().getResident(player.getName());
      nation = resident.getTown().getNation();

      double bankcap = TownySettings.getNationBankCap();
      if (bankcap > 0) {
        if (amount + nation.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"));
View Full Code Here

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

    }
  }

  public Nation newNation(TownyUniverse universe, String name, Town town) throws AlreadyRegisteredException, NotRegisteredException {
    TownyUniverse.getDataSource().newNation(name);
    Nation nation = TownyUniverse.getDataSource().getNation(name);
    nation.addTown(town);
    nation.setCapital(town);
    if (TownySettings.isUsingEconomy()) {
      nation.setBalance(0);
    }
    TownyUniverse.getDataSource().saveTown(town);
    TownyUniverse.getDataSource().saveNation(nation);
    TownyUniverse.getDataSource().saveNationList();
View Full Code Here

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

  public void nationLeave(Player player) {
    try {
      Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
      Town town = resident.getTown();
      Nation nation = town.getNation();
      if (!resident.isMayor())
        if (!town.hasAssistant(resident))
          throw new TownyException(TownySettings.getLangString("msg_not_mayor_ass"));

      nation.removeTown(town);

      TownyUniverse.getDataSource().saveTown(town);
      TownyUniverse.getDataSource().saveNation(nation);
      TownyUniverse.getDataSource().saveNationList();

      TownyMessaging.sendNationMessage(nation, ChatTools.color(String.format(TownySettings.getLangString("msg_nation_town_left"), town.getName())));
      TownyMessaging.sendTownMessage(town, ChatTools.color(String.format(TownySettings.getLangString("msg_town_left_nation"), nation.getName())));
    } catch (TownyException x) {
      TownyMessaging.sendErrorMsg(player, x.getMessage());
      return;
    } catch (EmptyNationException en) {
      TownyUniverse.getDataSource().removeNation(en.getNation());
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.