Class District

All Implemented Interfaces:
Identifiable, Nameable, Savable

public class District extends ObjectGroup implements Nameable, Savable
Author:
LlmDl
  • Constructor Details

    • District

      public District(UUID id, String name, Town town)
      Parameters:
      id - A unique identifier for the district id.
      name - An alias for the id used for player in-game interaction via commands.
      town - The town that this district is owned by.
  • Method Details

    • toString

      public String toString()
      Store district in format "name,id,town,price"
      Overrides:
      toString in class ObjectGroup
      Returns:
      The string in the format described.
    • exists

      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.
    • setName

      public void setName(String name)
      Override the name change method to internally rehash the district map.
      Overrides:
      setName in class TownyObject
      Parameters:
      name - The name of the district.
    • setTown

      public void setTown(Town town)
    • hashCode

      public int hashCode()
      Description copied from class: ObjectGroup
      Get hashcode for object group name. The reason we hash the name and not the UUID is for quicker common access from commands.
      Overrides:
      hashCode in class ObjectGroup
      Returns:
      name hashcode
    • equals

      public boolean equals(Object obj)
      Description copied from class: ObjectGroup
      Determines whether a group is equivalent or not.
      Overrides:
      equals in class ObjectGroup
      Parameters:
      obj - The group to be compared
      Returns:
      Returns true if the id (UUID) of the group matches the given group object. False otherwise.
    • getTown

      public Town getTown()
    • toModeString

      public String toModeString()
      Returns:
      The qualified resident mode string.
    • addTownBlock

      public void addTownBlock(TownBlock townBlock)
    • removeTownBlock

      public void removeTownBlock(TownBlock townBlock)
    • setTownblocks

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

      public Collection<TownBlock> getTownBlocks()
    • hasTownBlocks

      public boolean hasTownBlocks()
    • hasTownBlock

      public boolean hasTownBlock(TownBlock townBlock)
    • 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.
    • save

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

      @Internal public Map<String,Object> getObjectDataMap(SerializationContext context) throws ObjectSaveException
      Specified by:
      getObjectDataMap in interface Savable
      Parameters:
      context - SerializationContext with information.
      Returns:
      a Map which stores keys and values, meant to be written to a database.
      Throws:
      ObjectSaveException - when something cannot be saved.
    • load

      @Internal public boolean load(Map<String,String> districtAsMap)