Class Nation
java.lang.Object
com.palmergames.bukkit.towny.object.TownyObject
com.palmergames.bukkit.towny.object.Government
com.palmergames.bukkit.towny.object.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
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.kyori.adventure.audience.ForwardingAudience
net.kyori.adventure.audience.ForwardingAudience.Single
-
Field Summary
Fields inherited from class com.palmergames.bukkit.towny.object.Government
account, board, isNeutral, mapColorHexCode, spawn, tag, taxes, uuid
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
addMetaData
(@NotNull CustomDataField<?> md) Add a specific metadata to this TownyObject.void
addSanctionedTown
(Town town) void
@NotNull Iterable
<? extends net.kyori.adventure.audience.Audience> boolean
canAddResidents
(int additionalResidents) void
clear()
void
collect
(double amount) void
deleteSentAllyInvite
(Invite invite) boolean
boolean
exists()
An internal method used to determine if an object exists in the TownyUniverse's maps.boolean
Finds the town in the nation with the most residents and makes it the capital.void
forceSetCapital
(Town capital) Only to be called from the loading methods.gatherOutOfRangeTowns
(List<Town> towns, Town capital) Deprecated.The prefix to be used for the bank account.double
Gets the max amount of money that can be in the bank.double
Gets the formatted name of the object.getKing()
int
getLevel()
Deprecated.since 0.99.6.2, usegetLevelNumber()
instead.int
getLevel
(int populationSize) Deprecated.since 0.99.6.2 useTownySettings.getNationLevelFromGivenInt(int)
instead.int
Get the Nation's current Nation Level number, ie: 1 toTownySettings.getNationLevelMax()
.int
Deprecated.since 0.99.6.2 useTownySettings.getNationLevelMax()
instead.double
Get the Nation's current NationLevel.int
int
int
int
Gets the unmodifiable list of outlaws.Returns an unmodifiable list of residents.@NotNull org.bukkit.Location
getSpawn()
Get the spawn location of this object.getTowns()
getTreeString
(int depth) org.bukkit.World
getWorld()
Gets the world in which this object resides.boolean
boolean
hasAssistant
(Resident resident) boolean
boolean
int
hashCode()
boolean
hasKing()
boolean
hasMutualAlly
(Nation nation) boolean
boolean
boolean
boolean
hasResident
(Resident resident) boolean
hasResident
(String name) Whether a given object contains a resident.boolean
hasSanctionedTown
(Town town) boolean
boolean
boolean
boolean
isAlliedWith
(Nation nation) Shows if the nation is allied with the specified nation.boolean
boolean
boolean
void
loadSanctionedTowns
(String[] tokens) void
newSentAllyInvite
(Invite invite) void
playerBroadCastMessageToNation
(org.bukkit.entity.Player player, String message) boolean
boolean
boolean
removeAlly
(Nation nation) boolean
removeEnemy
(Nation nation) void
removeMetaData
(@NotNull CustomDataField<?> md) Remove a specific metadata from the TownyObject.void
Deprecated.since 0.100.0.9 useProximityUtil.removeOutOfRangeTowns(Nation)
instead.void
removeSanctionedTown
(Town town) protected void
removeTown
(Town town) Should only be called by Town.removeNation(); Removes town fromtowns
list and will choose a new Capital if necessary.void
save()
Schedules the object to be saved to the database.void
void
setCapital
(Town capital) void
setConqueredTax
(double conqueredTax) void
setEnemies
(List<Nation> enemies) void
void
setMaxPercentTaxAmount
(double maxPercentTaxAmount) void
setSpawn
(@Nullable org.bukkit.Location spawn) Sets the spawn point of this object.void
setTaxes
(double taxes) Sets the tax amount of this object.void
setTaxPercentage
(boolean isPercentage) @Nullable Position
Gets the spawn location of this object.void
spawnPosition
(@Nullable Position spawn) Sets the spawn position of this object.Methods inherited from class com.palmergames.bukkit.towny.object.Government
deleteReceivedInvite, deleteSentInvite, depositToBank, generateBankHistoryBook, getAccount, getBoard, getMapColor, getMapColorHexCode, getReceivedInvites, getRegistered, getSentInvites, getSpawnCost, getTag, getTaxes, getUUID, hasActiveWar, hasTag, isNeutral, isOpen, isPublic, newReceivedInvite, newSentInvite, setActiveWar, setBoard, setMapColorHexCode, setNeutral, setOpen, setPublic, setRegistered, setSpawnCost, setTag, setUUID, withdrawFromBank
Methods inherited from class com.palmergames.bukkit.towny.object.TownyObject
addMetaData, getMetadata, getMetadata, getMetadata, getName, getTreeDepth, hasMeta, hasMeta, hasMeta, removeMetaData, removeMetaData, removeMetaData, setName, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.kyori.adventure.audience.Audience
deleteMessage, openBook, removeResourcePacks, removeResourcePacks, removeResourcePacks, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendResourcePacks, sendResourcePacks, showTitle, stopSound
Methods inherited from interface net.kyori.adventure.audience.ForwardingAudience
clearResourcePacks, clearTitle, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, playSound, playSound, playSound, pointers, removeResourcePacks, removeResourcePacks, resetTitle, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendResourcePacks, sendTitlePart, showBossBar, stopSound
Methods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom
Methods inherited from interface com.palmergames.bukkit.towny.object.SpawnLocation
getSpawnOrNull, hasSpawn
-
Constructor Details
-
Nation
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
addAlly
-
removeAlly
-
removeAllAllies
public boolean removeAllAllies() -
hasAlly
-
hasMutualAlly
-
addEnemy
-
removeEnemy
-
removeAllEnemies
public boolean removeAllEnemies() -
hasEnemy
-
getTowns
-
isKing
-
hasCapital
public boolean hasCapital() -
hasAssistant
-
isCapital
-
hasTown
-
hasTown
-
addTown
-
forceSetCapital
Only to be called from the loading methods.- Parameters:
capital
- - Town to make capital.- Throws:
EmptyNationException
- Thrown when no capital can be set.
-
setCapital
-
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
Description copied from interface:SpawnLocation
Get the spawn location of this object.- Returns:
- The spawn location
- Throws:
TownyException
- If no location is found.
-
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
Description copied from interface:SpawnPosition
Sets the spawn position of this object.- Parameters:
spawn
- The position of the new spawn.
-
getAssistants
-
setEnemies
-
getEnemies
-
setAllies
-
getAllies
-
hasReachedMaximumAllies
public boolean hasReachedMaximumAllies() -
getMutualAllies
-
getNumTowns
public int getNumTowns() -
getNumResidents
public int getNumResidents() -
canAddResidents
public boolean canAddResidents(int additionalResidents) -
hasReachedMaxResidents
public boolean hasReachedMaxResidents() -
hasReachedMaxTowns
public boolean hasReachedMaxTowns() -
removeTown
Should only be called by Town.removeNation(); Removes town fromtowns
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 classGovernment
- 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.since 0.100.0.9 useProximityUtil.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.since 0.100.0.9 useProximityUtil.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
- Throws:
TownyException
-
hasResident
-
collect
public void collect(double amount) -
getResidents
Description copied from interface:ResidentList
Returns an unmodifiable list of residents.- Returns:
- The list of residents in this object.
-
getTreeString
- Overrides:
getTreeString
in classTownyObject
-
hasResident
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
Description copied from interface:ResidentList
Gets the unmodifiable list of outlaws.- Returns:
- The list of outlaws in this object.
-
hasValidUUID
public boolean hasValidUUID() -
newSentAllyInvite
- Throws:
TooManyInvitesException
-
deleteSentAllyInvite
-
getSentAllyInvites
-
getTownBlocks
- Specified by:
getTownBlocks
in classGovernment
-
getNumTownblocks
public int getNumTownblocks() -
getKing
-
hasKing
public boolean hasKing() -
getFormattedName
Description copied from interface:Nameable
Gets the formatted name of the object.- Returns:
- The formatted name.
-
addMetaData
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 classTownyObject
- Parameters:
md
- CustomDataField to add.
-
removeMetaData
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 classTownyObject
- 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 classGovernment
- Returns:
- The
World
this object is in.
-
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
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 classGovernment
-
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 toTownySettings.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
-
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 classTownyObject
- Returns:
- true if this TownyObject exists.
-
getLevel
Deprecated.since 0.99.6.2, usegetLevelNumber()
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.since 0.99.6.2 useTownySettings.getNationLevelMax()
instead. Get the maximum level a Nation may achieve.- Returns:
- Size of TownySettings' configNationLevel SortedMap.
-
getLevel
Deprecated.since 0.99.6.2 useTownySettings.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
-
getSanctionedTowns
-
hasSanctionedTown
-
addSanctionedTown
-
removeSanctionedTown
-
getSanctionedTownsForSaving
-
loadSanctionedTowns
-
ProximityUtil.gatherOutOfRangeTowns(Nation)
instead.