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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidaddMetaData(@NotNull CustomDataField<?> md) Add a specific metadata to this TownyObject.voidaddSanctionedTown(Town town) void@NotNull Iterable<? extends net.kyori.adventure.audience.Audience> booleancanAddResidents(int additionalResidents) voidclear()voidcollect(double amount) voiddeleteSentAllyInvite(Invite invite) booleanbooleanexists()An internal method used to determine if an object exists in the TownyUniverse's maps.booleanFinds the town in the nation with the most residents and makes it the capital.voidforceSetCapital(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.doubleGets the max amount of money that can be in the bank.doubleGets the formatted name of the object.getKing()intGet the Nation's current Nation Level number, ie: 1 toTownySettings.getNationLevelMax().doubleGet the Nation's current NationLevel.intintintintGets the unmodifiable list of outlaws.Returns an unmodifiable list of residents.@NotNull org.bukkit.LocationgetSpawn()Get the spawn location of this object.getTowns()getTreeString(int depth) org.bukkit.WorldgetWorld()Gets the world in which this object resides.booleanbooleanhasAssistant(Resident resident) booleanbooleaninthashCode()booleanhasKing()booleanhasMutualAlly(Nation nation) booleanbooleanbooleanbooleanhasResident(Resident resident) booleanhasResident(String name) Whether a given object contains a resident.booleanhasSanctionedTown(Town town) booleanbooleanbooleanbooleanisAlliedWith(Nation nation) Shows if the nation is allied with the specified nation.booleanbooleanbooleanvoidloadSanctionedTowns(String[] tokens) voidnewSentAllyInvite(Invite invite) voidplayerBroadCastMessageToNation(org.bukkit.entity.Player player, String message) booleanbooleanbooleanremoveAlly(Nation nation) booleanremoveEnemy(Nation nation) voidremoveMetaData(@NotNull CustomDataField<?> md) Remove a specific metadata from the TownyObject.voidDeprecated.since 0.100.0.9 useProximityUtil.removeOutOfRangeTowns(Nation)instead.voidremoveSanctionedTown(Town town) protected voidremoveTown(Town town) Should only be called by Town.removeNation(); Removes town fromtownslist and will choose a new Capital if necessary.voidsave()Schedules the object to be saved to the database.voidvoidsetCapital(Town capital) voidsetConqueredTax(double conqueredTax) voidsetEnemies(List<Nation> enemies) voidvoidsetMaxPercentTaxAmount(double maxPercentTaxAmount) voidsetSpawn(@Nullable org.bukkit.Location spawn) Sets the spawn point of this object.voidsetTaxes(double taxes) Sets the tax amount of this object.voidsetTaxPercentage(boolean isPercentage) @Nullable PositionGets the spawn location of this object.voidspawnPosition(@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, withdrawFromBankMethods inherited from class com.palmergames.bukkit.towny.object.TownyObject
addMetaData, getMetadata, getMetadata, getMetadata, getName, getTreeDepth, hasMeta, hasMeta, hasMeta, removeMetaData, removeMetaData, removeMetaData, setName, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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, stopSoundMethods 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, showDialog, stopSoundMethods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFromMethods 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:SpawnLocationGet the spawn location of this object.- Returns:
- The spawn location
- Throws:
TownyException- If no location is found.
-
spawnPosition
Description copied from interface:SpawnPositionGets the spawn location of this object.- Returns:
- The spawn location or
nullif none has been set.
-
setSpawn
public void setSpawn(@Nullable @Nullable org.bukkit.Location spawn) Description copied from interface:SpawnLocationSets the spawn point of this object.- Parameters:
spawn- The Location of the new spawn.
-
spawnPosition
Description copied from interface:SpawnPositionSets 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 fromtownslist 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:GovernmentSets the tax amount of this object.- Specified by:
setTaxesin 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:ResidentListReturns an unmodifiable list of residents.- Returns:
- The list of residents in this object.
-
getTreeString
- Overrides:
getTreeStringin classTownyObject
-
hasResident
Description copied from interface:ResidentListWhether a given object contains a resident.- Parameters:
name- The name of the resident.- Returns:
trueif found,falseotherwise.
-
getOutlaws
Description copied from interface:ResidentListGets 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:
getTownBlocksin classGovernment
-
getNumTownblocks
public int getNumTownblocks() -
getKing
-
hasKing
public boolean hasKing() -
getFormattedName
Description copied from interface:NameableGets the formatted name of the object.- Returns:
- The formatted name.
-
addMetaData
Description copied from class:TownyObjectAdd 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:
addMetaDatain classTownyObject- Parameters:
md- CustomDataField to add.
-
removeMetaData
Description copied from class:TownyObjectRemove 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:
removeMetaDatain classTownyObject- Parameters:
md- CustomDataField to remove.
-
getWorld
public org.bukkit.World getWorld()Description copied from class:GovernmentGets the world in which this object resides.- Specified by:
getWorldin classGovernment- Returns:
- The
Worldthis object is in.
-
getBankAccountPrefix
Description copied from interface:BankEconomyHandlerThe prefix to be used for the bank account.- Returns:
- A string providing the prefix.
-
getBankCap
public double getBankCap()Description copied from interface:BankEconomyHandlerGets 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:SavableSchedules the object to be saved to the database. -
getNationZoneSize
public int getNationZoneSize()- Specified by:
getNationZoneSizein 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:TownyObjectAn internal method used to determine if an object exists in the TownyUniverse's maps.- Specified by:
existsin classTownyObject- Returns:
- true if this TownyObject exists.
-
playerBroadCastMessageToNation
-
getSanctionedTowns
-
hasSanctionedTown
-
addSanctionedTown
-
removeSanctionedTown
-
getSanctionedTownsForSaving
-
loadSanctionedTowns
-
ProximityUtil.gatherOutOfRangeTowns(Nation)instead.