Class Resident

java.lang.Object
com.palmergames.bukkit.towny.object.TownyObject
com.palmergames.bukkit.towny.object.Resident
All Implemented Interfaces:
InviteReceiver, EconomyHandler, Identifiable, Nameable, Permissible, Savable, TownBlockOwner, net.kyori.adventure.audience.Audience, net.kyori.adventure.audience.ForwardingAudience, net.kyori.adventure.audience.ForwardingAudience.Single, net.kyori.adventure.pointer.Pointered

public class Resident extends TownyObject implements InviteReceiver, EconomyHandler, TownBlockOwner, Identifiable, net.kyori.adventure.audience.ForwardingAudience.Single
  • Field Details

    • cachedTaxOwing

      protected com.palmergames.bukkit.towny.object.Resident.CachedTaxOwing cachedTaxOwing
  • Constructor Details

    • Resident

      public Resident(String name)
  • Method Details

    • equals

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

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

      public void setLastOnline(long lastOnline)
    • getLastOnline

      public long getLastOnline()
    • setNPC

      public void setNPC(boolean isNPC)
    • isNPC

      public boolean isNPC()
    • getUUID

      public UUID getUUID()
      Specified by:
      getUUID in interface Identifiable
    • setUUID

      public void setUUID(UUID uuid)
      Description copied from interface: Identifiable
      This should only be used by internal loading methods!
      Specified by:
      setUUID in interface Identifiable
      Parameters:
      uuid - the UUID to set.
    • hasUUID

      public boolean hasUUID()
    • getJail

      public Jail getJail()
    • setJail

      public void setJail(Jail jail)
    • isJailed

      public boolean isJailed()
    • getJailCell

      public int getJailCell()
    • setJailCell

      public void setJailCell(int i)
    • getJailTown

      public Town getJailTown()
    • hasJailTown

      public boolean hasJailTown(String jailtown)
    • getJailHours

      public int getJailHours()
    • setJailHours

      public void setJailHours(Integer hours)
    • getJailBailCost

      public double getJailBailCost()
    • setJailBailCost

      public void setJailBailCost(double bail)
    • hasJailTime

      public boolean hasJailTime()
    • getJailSpawn

      public org.bukkit.Location getJailSpawn()
    • getPrimaryRankPrefix

      public String getPrimaryRankPrefix()
    • setTitle

      public void setTitle(String title)
    • getTitle

      public String getTitle()
    • hasTitle

      public boolean hasTitle()
    • setSurname

      public void setSurname(String surname)
    • getSurname

      public String getSurname()
    • hasSurname

      public boolean hasSurname()
    • setAbout

      public void setAbout(@NotNull @NotNull String about)
    • getAbout

      @NotNull public @NotNull String getAbout()
    • isKing

      public boolean isKing()
    • isMayor

      public boolean isMayor()
    • hasTown

      public boolean hasTown()
    • hasNation

      public boolean hasNation()
    • getTown

      public Town getTown() throws NotRegisteredException
      Throws:
      NotRegisteredException
    • getTownOrNull

      @Nullable public @Nullable Town getTownOrNull()
      Relatively safe to use after confirming there is a town using hasTown().
      Returns:
      Town the resident belongs to or null.
    • setTown

      public void setTown(Town town) throws AlreadyRegisteredException
      Throws:
      AlreadyRegisteredException
    • setTown

      public void setTown(Town town, boolean updateJoinedAt) throws AlreadyRegisteredException
      Throws:
      AlreadyRegisteredException
    • removeTown

      public void removeTown()
    • removeTown

      public void removeTown(boolean townDeleted)
    • setFriends

      public void setFriends(List<Resident> newFriends)
    • getFriends

      public List<Resident> getFriends()
    • removeFriend

      public void removeFriend(Resident resident)
    • hasFriend

      public boolean hasFriend(Resident resident)
    • addFriend

      public void addFriend(Resident resident)
    • removeAllFriends

      public void removeAllFriends()
    • updatePerms

      public void updatePerms()
    • updatePermsForNationRemoval

      public void updatePermsForNationRemoval()
    • setRegistered

      public void setRegistered(long registered)
    • getRegistered

      public long getRegistered()
    • getTreeString

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

      @Deprecated public void clearTeleportRequest()
      Deprecated.
      Deprecated as of 0.99.0.10, clearing teleport requests is no longer needed. Use TownyAPI.abortTeleportRequest(Resident) to abort an active teleport request.
    • setTeleportRequestTime

      @Deprecated public void setTeleportRequestTime()
      Deprecated.
      Deprecated as of 0.99.0.10, teleport request related values are no longer modifiable once the teleport has been requested.
    • getTeleportRequestTime

      @Obsolete public long getTeleportRequestTime()
    • setTeleportDestination

      @Deprecated public void setTeleportDestination(org.bukkit.Location spawnLoc)
      Deprecated.
      Deprecated as of 0.99.0.10, teleport request related values are no longer modifiable once the teleport has been requested.
    • getTeleportDestination

      @Obsolete public org.bukkit.Location getTeleportDestination()
    • setTeleportCooldown

      @Deprecated public void setTeleportCooldown(int cooldown)
      Deprecated.
      Deprecated as of 0.99.0.10, teleport request related values are no longer modifiable once the teleport has been requested.
    • getTeleportCooldown

      @Obsolete public int getTeleportCooldown()
    • hasRequestedTeleport

      public boolean hasRequestedTeleport()
      Returns:
      Whether this resident has an active teleport warmup that they're waiting for.
    • setTeleportCost

      @Deprecated public void setTeleportCost(double cost)
      Deprecated.
      Deprecated as of 0.99.0.10, teleport request related values are no longer modifiable once the teleport has been requested.
    • getTeleportCost

      @Obsolete public double getTeleportCost()
    • setTeleportAccount

      @Deprecated public void setTeleportAccount(Account payee)
      Deprecated.
      Deprecated as of 0.99.0.10, teleport request related values are no longer modifiable once the teleport has been requested.
    • getTeleportAccount

      @Obsolete public Account getTeleportAccount()
    • hasPermissionNode

      public boolean hasPermissionNode(String node)
      Parameters:
      node - String representing a PermissionNode to test for.
      Returns:
      true if the Player of the Resident has the permission node assigned to them according to the TownyPermissionSource.
    • isAdmin

      public boolean isAdmin()
      Returns:
      true if the Player of the Resident is a server OP or has the towny.admin permission node according to the TownyPermissionSource.
    • getModes

      public List<String> getModes()
    • hasMode

      public boolean hasMode(String mode)
    • toggleMode

      @Deprecated public void toggleMode(String[] newModes, boolean notify)
      Parameters:
      newModes -
      notify -
    • setModes

      @Deprecated public void setModes(String[] modes, boolean notify)
      Parameters:
      modes -
      notify -
    • clearModes

      public void clearModes()
    • clearModes

      public void clearModes(boolean notify)
    • resetModes

      public void resetModes(String[] modes, boolean notify)
      Only for internal Towny use. NEVER call this from any other plugin.
      Parameters:
      modes - - String Array of modes
      notify - - If notifications should be sent
    • getPlayer

      @Nullable public @Nullable org.bukkit.entity.Player getPlayer()
    • addTownRank

      public boolean addTownRank(String rank)
    • setTownRanks

      public void setTownRanks(List<String> ranks)
    • hasTownRank

      public boolean hasTownRank(String rank)
    • getTownRanks

      public List<String> getTownRanks()
    • removeTownRank

      public boolean removeTownRank(String rank)
    • getHighestPriorityTownRank

      @Nullable public @Nullable String getHighestPriorityTownRank()
    • addNationRank

      public boolean addNationRank(String rank)
    • setNationRanks

      public void setNationRanks(List<String> ranks)
    • hasNationRank

      public boolean hasNationRank(String rank)
    • getNationRanks

      public List<String> getNationRanks()
    • removeNationRank

      public boolean removeNationRank(String rank)
    • getHighestPriorityNationRank

      @Nullable public @Nullable String getHighestPriorityNationRank()
    • isAlliedWith

      public boolean isAlliedWith(Resident otherresident)
    • getReceivedInvites

      public List<Invite> getReceivedInvites()
      Description copied from interface: InviteReceiver
      Gets the collection of invites received.
      Specified by:
      getReceivedInvites in interface InviteReceiver
      Returns:
      An unmodifiable collection of received invites.
    • newReceivedInvite

      public void newReceivedInvite(Invite invite) throws TooManyInvitesException
      Description copied from interface: InviteReceiver
      Adds an invite to the received collection.
      Specified by:
      newReceivedInvite in interface InviteReceiver
      Parameters:
      invite - The invite to add.
      Throws:
      TooManyInvitesException - When the invite cap is reached.
    • deleteReceivedInvite

      public void deleteReceivedInvite(Invite invite)
      Description copied from interface: InviteReceiver
      Removes an invite from the received collection.
      Specified by:
      deleteReceivedInvite in interface InviteReceiver
      Parameters:
      invite - The invite to remove.
    • 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.
    • getAccount

      public Account getAccount()
      Description copied from interface: EconomyHandler
      Gets the Account associated with this object.
      Specified by:
      getAccount in interface EconomyHandler
      Returns:
      An Account for this class.
    • getAccountOrNull

      @Nullable public @Nullable Account getAccountOrNull()
    • getFormattedName

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

      public String getNamePrefix()
      Returns King or Mayor prefix set in the Town and Nation Levels of the config.
      Returns:
      Prefix of a King or Mayor if resident is a king or mayor.
    • getNamePostfix

      public String getNamePostfix()
      Returns King or Mayor postfix set in the Town and Nation Levels of the config.
      Returns:
      Postfix of a King or Mayor if resident is a king or mayor.
    • getFormattedTitleName

      public String getFormattedTitleName()
    • setTownblocks

      public void setTownblocks(Collection<TownBlock> townBlocks)
    • getTownBlocks

      public Collection<TownBlock> getTownBlocks()
      Description copied from interface: TownBlockOwner
      Gets the unmodifiable collection of townblocks.
      Specified by:
      getTownBlocks in interface TownBlockOwner
      Returns:
      The townblocks this object contains.
    • getTownsOutlawedIn

      public List<Town> getTownsOutlawedIn()
      Returns:
      All towns that the resident is outlawed in
    • hasTownBlock

      public boolean hasTownBlock(TownBlock townBlock)
      Description copied from interface: TownBlockOwner
      Checks whether object has townblock or not.
      Specified by:
      hasTownBlock in interface TownBlockOwner
      Parameters:
      townBlock - The townblock to check for.
      Returns:
      A boolean indicating if it was found or not.
    • addTownBlock

      public void addTownBlock(TownBlock townBlock) throws AlreadyRegisteredException
      Description copied from interface: TownBlockOwner
      Adds a townblock to the list of existing townblocks.
      Specified by:
      addTownBlock in interface TownBlockOwner
      Parameters:
      townBlock - The townblock to add.
      Throws:
      AlreadyRegisteredException - When the townblock is already in the list.
    • removeTownBlock

      public void removeTownBlock(TownBlock townBlock)
      Description copied from interface: TownBlockOwner
      Removes townblock from the list of existing townblocks.
      Specified by:
      removeTownBlock in interface TownBlockOwner
      Parameters:
      townBlock - The townblock to remove.
    • setPermissions

      public void setPermissions(String line)
      Description copied from interface: Permissible
      The the permissions of this object.
      Specified by:
      setPermissions in interface Permissible
      Parameters:
      line - The String line representation of the permissions.
    • getPermissions

      public TownyPermission getPermissions()
      Description copied from interface: Permissible
      Gets the permissions of the object.
      Specified by:
      getPermissions in interface Permissible
      Returns:
      TownyPermission the permissions of the object.
    • getConfirmation

      public Confirmation getConfirmation()
    • setConfirmation

      public void setConfirmation(Confirmation confirmation)
    • getGUIPage

      public org.bukkit.inventory.Inventory getGUIPage()
      Returns:
      the current inventory which the player is looking at for the GUIs.
    • getGUIPages

      public ArrayList<org.bukkit.inventory.Inventory> getGUIPages()
    • setGUIPages

      public void setGUIPages(ArrayList<org.bukkit.inventory.Inventory> inventory)
    • getGUIPageNum

      public int getGUIPageNum()
    • setGUIPageNum

      public void setGUIPageNum(int currentInventoryPage)
    • getGUISelectionType

      public SelectionGUI.SelectionType getGUISelectionType()
    • setGUISelectionType

      public void setGUISelectionType(SelectionGUI.SelectionType selectionType)
    • save

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

      public List<Town> getEmbassyTowns()
      Gets a list of Towns which the given resident owns embassy plots in.
      Returns:
      List of Towns in which the resident owns embassies.
    • getJoinedTownAt

      public long getJoinedTownAt()
    • setJoinedTownAt

      public void setJoinedTownAt(long joinedTownAt)
    • getNation

      public Nation getNation() throws TownyException
      Throws:
      TownyException
    • getNationOrNull

      @Nullable public @Nullable Nation getNationOrNull()
    • isOnline

      public boolean isOnline()
    • hasRespawnProtection

      public boolean hasRespawnProtection()
    • addRespawnProtection

      public void addRespawnProtection(long protectionTime)
    • removeRespawnProtection

      public void removeRespawnProtection()
    • isRespawnPickupWarningShown

      public boolean isRespawnPickupWarningShown()
    • setRespawnPickupWarningShown

      public void setRespawnPickupWarningShown(boolean respawnPickupWarningShown)
    • audience

      @NotNull public @NotNull net.kyori.adventure.audience.Audience audience()
      Specified by:
      audience in interface net.kyori.adventure.audience.ForwardingAudience.Single
    • isSeeingBorderTitles

      public boolean isSeeingBorderTitles()
    • hasPlotGroupName

      public boolean hasPlotGroupName()
    • getPlotGroupName

      public String getPlotGroupName()
    • setPlotGroupName

      public void setPlotGroupName(String plotGroupName)
    • hasDistrictName

      public boolean hasDistrictName()
    • getDistrictName

      public String getDistrictName()
    • setDistrictName

      public void setDistrictName(String districtName)
    • 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.
    • getTaxOwing

      public double getTaxOwing(boolean useCache)
    • getCachedTaxOwing

      public double getCachedTaxOwing()
      Returns a cached amount of taxes that a resident will pay daily.
      Returns:
      tax Double which is from a Resident.CachedTaxOwing.owing.
    • getCachedTaxOwing

      public double getCachedTaxOwing(boolean refreshIfStale)
      Returns a cached amount of taxes that a resident will pay daily, with the ability to only refresh the cache if it is stale.
      Parameters:
      refreshIfStale - when true, if the cache is stale it will update.
      Returns:
      cachedTaxOwing Double which is from a Resident.CachedTaxOwing.owing.