Class TownBlock

java.lang.Object
com.palmergames.bukkit.towny.object.TownyObject
com.palmergames.bukkit.towny.object.TownBlock
All Implemented Interfaces:
Nameable, Savable

public class TownBlock extends TownyObject
  • Field Details

    • permissions

      protected TownyPermission permissions
    • isChanged

      protected boolean isChanged
  • Constructor Details

    • TownBlock

      public TownBlock(int x, int z, TownyWorld world)
    • TownBlock

      public TownBlock(WorldCoord worldCoord)
  • Method Details

    • setTown

      public void setTown(Town town)
    • setTown

      public void setTown(Town town, boolean updateClaimedAt)
    • getTown

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

      @Nullable public @Nullable Town getTownOrNull()
      Relatively safe to use after confirming hasTown() is true or TownyAPI.isWilderness(org.bukkit.Location) is false.
      Returns:
      Town who owns the TownBlock or null.
    • hasTown

      public boolean hasTown()
    • removeResident

      public boolean removeResident()
      Removes the current resident as owner in this plot, while calling the appropriate events
      Returns:
      Whether the resident (if any) was successfully removed as owner.
    • setResident

      public boolean setResident(@Nullable @Nullable Resident resident)
      Changes the owner of the plot to the given resident.
      Parameters:
      resident - The resident to give ownership to, or null to give ownership back to the town.
      Returns:
      Whether the resident (if any) was successfully removed as owner.
    • setResident

      public boolean setResident(@Nullable @Nullable Resident resident, boolean callEvent)
      Changes the owner of the plot to the given resident.
      Parameters:
      resident - The resident to give ownership to, or null to give ownership back to the town.
      callEvent - Whether to call the related plot events or not, this is used by Towny to avoid calling events from database loading.
      Returns:
      Whether the resident (if any) was successfully removed as owner.
    • getResident

      public Resident getResident() throws NotRegisteredException
      Throws:
      NotRegisteredException
    • getResidentOrNull

      @Nullable public @Nullable Resident getResidentOrNull()
      Relatively safe to use after testing hasResident().
      Returns:
      Resident who personally owns the TownBlock or null.
    • hasResident

      public boolean hasResident()
    • isOwner

      public boolean isOwner(@NotNull @NotNull TownBlockOwner owner)
    • setPlotPrice

      public void setPlotPrice(double price)
    • getPlotPrice

      public double getPlotPrice()
    • isForSale

      public boolean isForSale()
    • isTaxed

      public boolean isTaxed()
    • setTaxed

      public void setTaxed(boolean value)
    • getPlotTax

      public double getPlotTax()
    • setPermissions

      public void setPermissions(String line)
    • getPermissions

      public TownyPermission getPermissions()
    • isChanged

      public boolean isChanged()
      Have the permissions been manually changed.
      Returns:
      the isChanged
    • setChanged

      public void setChanged(boolean isChanged)
      Flag the permissions as changed.
      Parameters:
      isChanged - the isChanged to set
    • isOutpost

      public boolean isOutpost()
      Returns:
      the outpost
    • setOutpost

      public void setOutpost(boolean outpost)
      Parameters:
      outpost - the outpost to set
    • getType

      public TownBlockType getType()
    • getTypeName

      public String getTypeName()
    • setType

      public void setType(@NotNull @NotNull String type)
    • setType

      public void setType(@Nullable @Nullable TownBlockType type)
    • setType

      public void setType(TownBlockType type, Resident resident) throws TownyException
      Parameters:
      type - The TownBlockType to set this plot to.
      resident - The Resident who is trying to set the type.
      Throws:
      TownyException - If this townblock has a pvp toggle cooldown.
    • isHomeBlock

      public boolean isHomeBlock()
    • setName

      public void setName(String newName)
      Overrides:
      setName in class TownyObject
    • setX

      @Deprecated public void setX(int x)
      Deprecated.
      Deprecated as of 0.99.5.3, it is no longer possible to mutate the world/coordinates of a townblock.
    • getX

      public int getX()
    • setZ

      @Deprecated public void setZ(int z)
      Deprecated.
      Deprecated as of 0.99.5.3, it is no longer possible to mutate the world/coordinates of a townblock.
    • getZ

      public int getZ()
    • getCoord

      public Coord getCoord()
    • getWorldCoord

      public WorldCoord getWorldCoord()
    • setWorld

      @Deprecated public void setWorld(TownyWorld world)
      Deprecated.
      Deprecated as of 0.99.5.3, it is no longer possible to mutate the world/coordinates of a townblock.
    • getWorld

      public TownyWorld getWorld()
    • equals

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

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

      public void clear()
    • toString

      public String toString()
      Overrides:
      toString in class TownyObject
    • isJail

      public boolean isJail()
    • getJail

      public Jail getJail()
    • setJail

      public void setJail(Jail _jail)
    • 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.
    • hasPlotObjectGroup

      public boolean hasPlotObjectGroup()
    • getPlotObjectGroup

      public PlotGroup getPlotObjectGroup()
    • removePlotObjectGroup

      public void removePlotObjectGroup()
    • setPlotObjectGroup

      public void setPlotObjectGroup(PlotGroup group)
    • save

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

      public long getClaimedAt()
    • setClaimedAt

      public void setClaimedAt(long claimedAt)
    • getPermissionOverrides

      public Map<Resident,PermissionData> getPermissionOverrides()
    • addTrustedResidents

      public void addTrustedResidents(List<Resident> residents)
    • getTrustedResidents

      public Set<Resident> getTrustedResidents()
    • hasTrustedResident

      public boolean hasTrustedResident(Resident resident)
    • addTrustedResident

      public void addTrustedResident(Resident resident)
    • removeTrustedResident

      public void removeTrustedResident(Resident resident)
    • hasResident

      public boolean hasResident(Resident resident)
    • setTrustedResidents

      public void setTrustedResidents(Set<Resident> trustedResidents)
    • setPermissionOverrides

      public void setPermissionOverrides(Map<Resident,PermissionData> permissionOverrides)
    • getTownBlockOwner

      @Nullable public @Nullable TownBlockOwner getTownBlockOwner()
      Returns the TownBlockOwner: a resident (if the plot is personally-owned,) or the Town that owns the townblock.
      Returns:
      TownBlockOwner or null (highly unlikely.)
    • getData

      public TownBlockData getData()
    • evictOwnerFromTownBlock

      public void evictOwnerFromTownBlock()
    • testTownMembershipAgePreventsThisClaimOrThrow

      public void testTownMembershipAgePreventsThisClaimOrThrow(Resident resident) throws TownyException
      Tests whether a Resident's Town membership age (join date) is too high or low, preventing them from claiming this TownBlock personally with /plot claim.
      Parameters:
      resident - Resident who wants to buy the TownBlock.
      Throws:
      TownyException - thrown with error message when the Resident is not allowed to claim the land.
    • hasMinTownMembershipDays

      public boolean hasMinTownMembershipDays()
      Returns:
      does this plot have a min number of days the player has to be a member of the town, before they can claim?
    • getMinTownMembershipDays

      public int getMinTownMembershipDays()
      Returns:
      how many days a town member has to be a part of the town in order to claim this plot personally using /plot claim.
    • setMinTownMembershipDays

      public void setMinTownMembershipDays(int minTownMembershipDays)
      Sets the number of days that a town member must be a part of the town before they can claim the plot personally using /plot claim.
      Parameters:
      minTownMembershipDays - days they have to be a part of the town for, before they can claim.
    • hasMaxTownMembershipDays

      public boolean hasMaxTownMembershipDays()
      Returns:
      does this plot have a max number of days the player can be a member of the town, before they cannot claim?
    • getMaxTownMembershipDays

      public int getMaxTownMembershipDays()
      Returns:
      how the maximum number of days a town member can be a part of the town before they are unable to claim this plot personally using /plot claim.
    • setMaxTownMembershipDays

      public void setMaxTownMembershipDays(int maxTownMembershipDays)
      Sets the maximum number of days that a town member can be a part of the town before they unable to claim the plot personally using /plot claim.
      Parameters:
      maxTownMembershipDays - days they can be a part of the town for, until they cannot claim.
    • 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.