Class Nation

All Implemented Interfaces:
InviteReceiver, InviteSender, BankEconomyHandler, EconomyHandler, Identifiable, Inviteable, Nameable, ResidentList, Savable, SpawnLocation, SpawnPosition, net.kyori.adventure.audience.Audience, net.kyori.adventure.audience.ForwardingAudience, net.kyori.adventure.pointer.Pointered

public class Nation extends Government
  • Constructor Details

    • Nation

      public Nation(String name)
  • Method Details

    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • addAlly

      public void addAlly(Nation nation)
    • removeAlly

      public boolean removeAlly(Nation nation)
    • removeAllAllies

      public boolean removeAllAllies()
    • hasAlly

      public boolean hasAlly(Nation nation)
    • hasMutualAlly

      public boolean hasMutualAlly(Nation nation)
    • addEnemy

      public void addEnemy(Nation nation)
    • removeEnemy

      public boolean removeEnemy(Nation nation)
    • removeAllEnemies

      public boolean removeAllEnemies()
    • hasEnemy

      public boolean hasEnemy(Nation nation)
    • getTowns

      public List<Town> getTowns()
    • isKing

      public boolean isKing(Resident resident)
    • hasCapital

      public boolean hasCapital()
    • hasAssistant

      public boolean hasAssistant(Resident resident)
    • isCapital

      public boolean isCapital(Town town)
    • hasTown

      public boolean hasTown(String name)
    • hasTown

      public boolean hasTown(Town town)
    • addTown

      public void addTown(Town town)
    • forceSetCapital

      public void forceSetCapital(Town capital) throws EmptyNationException
      Only to be called from the loading methods.
      Parameters:
      capital - - Town to make capital.
      Throws:
      EmptyNationException - Thrown when no capital can be set.
    • setCapital

      public void setCapital(Town capital)
    • getCapital

      public Town getCapital()
    • findNewCapital

      public boolean findNewCapital()
      Finds the town in the nation with the most residents and makes it the capital.
      Returns:
      whether it successfully set a capital.
    • getSpawn

      @NotNull public @NotNull org.bukkit.Location getSpawn() throws TownyException
      Description copied from interface: SpawnLocation
      Get the spawn location of this object.
      Returns:
      The spawn location
      Throws:
      TownyException - If no location is found.
    • spawnPosition

      @Nullable public @Nullable Position spawnPosition()
      Description copied from interface: SpawnPosition
      Gets the spawn location of this object.
      Returns:
      The spawn location or null if none has been set.
    • setSpawn

      public void setSpawn(@Nullable @Nullable org.bukkit.Location spawn)
      Description copied from interface: SpawnLocation
      Sets the spawn point of this object.
      Parameters:
      spawn - The Location of the new spawn.
    • spawnPosition

      public void spawnPosition(@Nullable @Nullable Position spawn)
      Description copied from interface: SpawnPosition
      Sets the spawn position of this object.
      Parameters:
      spawn - The position of the new spawn.
    • getAssistants

      public List<Resident> getAssistants()
    • setEnemies

      public void setEnemies(List<Nation> enemies)
    • getEnemies

      public List<Nation> getEnemies()
    • setAllies

      public void setAllies(List<Nation> allies)
    • getAllies

      public List<Nation> getAllies()
    • hasReachedMaximumAllies

      public boolean hasReachedMaximumAllies()
    • getMutualAllies

      public List<Nation> getMutualAllies()
    • getNumTowns

      public int getNumTowns()
    • getNumResidents

      public int getNumResidents()
    • canAddResidents

      public boolean canAddResidents(int additionalResidents)
    • hasReachedMaxResidents

      public boolean hasReachedMaxResidents()
    • hasReachedMaxTowns

      public boolean hasReachedMaxTowns()
    • removeTown

      protected void removeTown(Town town) throws EmptyNationException
      Should only be called by Town.removeNation(); Removes town from towns list and will choose a new Capital if necessary.
      Parameters:
      town - - Town to remove from nation.
      Throws:
      EmptyNationException - - Thrown when last town is being removed.
    • setTaxes

      public void setTaxes(double taxes)
      Description copied from class: Government
      Sets the tax amount of this object.
      Specified by:
      setTaxes in class Government
      Parameters:
      taxes - The taxes as a percentage or flat number.
    • getMaxPercentTaxAmount

      public double getMaxPercentTaxAmount()
    • setMaxPercentTaxAmount

      public void setMaxPercentTaxAmount(double maxPercentTaxAmount)
    • setTaxPercentage

      public void setTaxPercentage(boolean isPercentage)
    • isTaxPercentage

      public boolean isTaxPercentage()
    • clear

      public void clear()
    • removeOutOfRangeTowns

      @Deprecated public void removeOutOfRangeTowns()
      Deprecated.
      since 0.100.0.9 use ProximityUtil.removeOutOfRangeTowns(Nation) instead.
      Method for rechecking town distances to a new nation capital/moved nation capital homeblock. Results in towns whose homeblocks are no longer close enough to the capital homeblock being removed from the nation.
    • gatherOutOfRangeTowns

      @Deprecated public List<Town> gatherOutOfRangeTowns(List<Town> towns, Town capital)
      Deprecated.
      since 0.100.0.9 use ProximityUtil.gatherOutOfRangeTowns(Nation) instead.
      A method which returns a list of Towns too far from the given capital town.
      Parameters:
      towns - - The list of towns to check.
      capital - - The Town from which to check the distance.
      Returns:
      removedTowns - A list of Towns which would be removed by removeOutOfRangeTowns().
    • setKing

      public void setKing(Resident king) throws TownyException
      Throws:
      TownyException
    • hasResident

      public boolean hasResident(Resident resident)
    • collect

      public void collect(double amount)
    • getResidents

      public List<Resident> getResidents()
      Description copied from interface: ResidentList
      Returns an unmodifiable list of residents.
      Returns:
      The list of residents in this object.
    • getTreeString

      public List<String> getTreeString(int depth)
      Overrides:
      getTreeString in class TownyObject
    • hasResident

      public boolean hasResident(String name)
      Description copied from interface: ResidentList
      Whether a given object contains a resident.
      Parameters:
      name - The name of the resident.
      Returns:
      true if found, false otherwise.
    • getOutlaws

      public Collection<Resident> getOutlaws()
      Description copied from interface: ResidentList
      Gets the unmodifiable list of outlaws.
      Returns:
      The list of outlaws in this object.
    • hasValidUUID

      public boolean hasValidUUID()
    • newSentAllyInvite

      public void newSentAllyInvite(Invite invite) throws TooManyInvitesException
      Throws:
      TooManyInvitesException
    • deleteSentAllyInvite

      public void deleteSentAllyInvite(Invite invite)
    • getSentAllyInvites

      public List<Invite> getSentAllyInvites()
    • getTownBlocks

      public Collection<TownBlock> getTownBlocks()
      Specified by:
      getTownBlocks in class Government
    • getNumTownblocks

      public int getNumTownblocks()
    • getKing

      public Resident getKing()
    • hasKing

      public boolean hasKing()
    • getFormattedName

      public String getFormattedName()
      Description copied from interface: Nameable
      Gets the formatted name of the object.
      Returns:
      The formatted name.
    • addMetaData

      public void addMetaData(@NotNull @NotNull CustomDataField<?> md)
      Description copied from class: TownyObject
      Add a specific metadata to this TownyObject. Overrides existing metadata of the same key. Most implementations will save the object after this method is called.
      Overrides:
      addMetaData in class TownyObject
      Parameters:
      md - CustomDataField to add.
    • removeMetaData

      public void removeMetaData(@NotNull @NotNull CustomDataField<?> md)
      Description copied from class: TownyObject
      Remove a specific metadata from the TownyObject. The metadata does not need to be the same instance of the one added, but must have the same key. Most implementations will save the TownyObject after removing the metadata.
      Overrides:
      removeMetaData in class TownyObject
      Parameters:
      md - CustomDataField to remove.
    • getWorld

      public org.bukkit.World getWorld()
      Description copied from class: Government
      Gets the world in which this object resides.
      Specified by:
      getWorld in class Government
      Returns:
      The World this object is in.
    • getBankAccountPrefix

      public String getBankAccountPrefix()
      Description copied from interface: BankEconomyHandler
      The prefix to be used for the bank account.
      Returns:
      A string providing the prefix.
    • getBankCap

      public double getBankCap()
      Description copied from interface: BankEconomyHandler
      Gets the max amount of money that can be in the bank.
      Returns:
      The max amount of money.
    • isAlliedWith

      public boolean isAlliedWith(Nation nation)
      Shows if the nation is allied with the specified nation.
      Parameters:
      nation - The nation that is allied.
      Returns:
      true if it is allied, false otherwise.
    • save

      public void save()
      Description copied from interface: Savable
      Schedules the object to be saved to the database.
    • getNationZoneSize

      public int getNationZoneSize()
      Specified by:
      getNationZoneSize in class Government
    • getNationLevel

      public TownySettings.NationLevel getNationLevel()
      Get the Nation's current NationLevel.

      Note that Nation Levels are not hard-coded. They can be defined by the server administrator, and may be different from the default configuration.

      Returns:
      NationLevel of the nation.
    • getLevelNumber

      public int getLevelNumber()
      Get the Nation's current Nation Level number, ie: 1 to TownySettings.getNationLevelMax(). This is used as a key to determine which NationLevel a Nation receives, and ultimately which attributes that Nation will receive.

      Note that Nation Levels are not hard-coded. They can be defined by the server administrator, and may be different from the default configuration.

      Returns:
      Nation Level (int) for current population or amount of towns.
    • audiences

      @NotNull public @NotNull Iterable<? extends net.kyori.adventure.audience.Audience> audiences()
    • getConqueredTax

      public double getConqueredTax()
    • setConqueredTax

      public void setConqueredTax(double conqueredTax)
    • exists

      @Internal public boolean exists()
      Description copied from class: TownyObject
      An internal method used to determine if an object exists in the TownyUniverse's maps.
      Specified by:
      exists in class TownyObject
      Returns:
      true if this TownyObject exists.
    • getLevel

      @Deprecated public int getLevel()
      Deprecated.
      since 0.99.6.2, use getLevelNumber() instead. Get the Nation's current Nation Level.

      Note that Nation Levels are not hard-coded. They can be defined by the server administrator, and may be different from the default configuration.

      Returns:
      Nation Level (int) for current population or amount of towns.
    • getMaxLevel

      @Deprecated public int getMaxLevel()
      Deprecated.
      since 0.99.6.2 use TownySettings.getNationLevelMax() instead. Get the maximum level a Nation may achieve.
      Returns:
      Size of TownySettings' configNationLevel SortedMap.
    • getLevel

      @Deprecated public int getLevel(int populationSize)
      Deprecated.
      since 0.99.6.2 use TownySettings.getNationLevelFromGivenInt(int) instead. Get the Nation's Level for a supposed population size.

      Note that Nation Levels are not hard-coded. They can be defined by the server administrator, and may be different from the default configuration.

      Parameters:
      populationSize - Number of residents in the Nation, theoretical or real.
      Returns:
      Nation Level (int) for the supplied populationSize.
    • playerBroadCastMessageToNation

      public void playerBroadCastMessageToNation(org.bukkit.entity.Player player, String message)
    • getSanctionedTowns

      public List<Town> getSanctionedTowns()
    • hasSanctionedTown

      public boolean hasSanctionedTown(Town town)
    • addSanctionedTown

      public void addSanctionedTown(Town town)
    • removeSanctionedTown

      public void removeSanctionedTown(Town town)
    • getSanctionedTownsForSaving

      public List<String> getSanctionedTownsForSaving()
    • loadSanctionedTowns

      public void loadSanctionedTowns(String[] tokens)