Class TownyObject
java.lang.Object
com.palmergames.bukkit.towny.object.TownyObject
- Direct Known Subclasses:
Government
,ObjectGroup
,Resident
,TownBlock
,TownyWorld
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMetaData
(@NotNull CustomDataField<?> md) Add a specific metadata to this TownyObject.void
addMetaData
(@NotNull CustomDataField<?> md, boolean save) Add a specific metadata to this TownyObject.abstract boolean
exists()
An internal method used to determine if an object exists in the TownyUniverse's maps.@Unmodifiable Collection<CustomDataField<?>>
A collection of all metadata on the TownyObject.@Nullable CustomDataField<?>
getMetadata
(@NotNull String key) Fetch the metadata associated with the specific key.<T extends CustomDataField<?>>
TgetMetadata
(@NotNull String key, @NotNull Class<T> cdfClass) Fetch the metadata associated with the specific key and class.getName()
Get the name of the specified objectgetTreeDepth
(int depth) getTreeString
(int depth) boolean
hasMeta()
boolean
Check whether metadata associated with the key exists.<T extends CustomDataField<?>>
booleanCheck whether metadata associated with the given key and class exists.void
removeMetaData
(@NotNull CustomDataField<?> md) Remove a specific metadata from the TownyObject.boolean
removeMetaData
(@NotNull CustomDataField<?> md, boolean save) Remove a specific metadata from the TownyObject.boolean
removeMetaData
(@NotNull String key) Remove a specific metadata from the TownyObject.boolean
removeMetaData
(@NotNull String key, boolean save) Remove a specific metadata from the TownyObject.void
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.palmergames.bukkit.towny.object.Nameable
getFormattedName
-
Constructor Details
-
TownyObject
-
-
Method Details
-
setName
-
getName
Description copied from interface:Nameable
Get the name of the specified object -
getTreeString
-
getTreeDepth
-
toString
-
addMetaData
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.- Parameters:
md
- CustomDataField to add.
-
addMetaData
Add a specific metadata to this TownyObject. Overrides existing metadata of the same key.- Parameters:
md
- CustomDataField to add.save
- whether to save this object after the metadata is added.
-
removeMetaData
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.- Parameters:
md
- CustomDataField to remove.
-
removeMetaData
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.- Parameters:
md
- CustomDataField to remove.save
- whether to save the object or not after the metadata is removed.- Returns:
- whether the metadata was successfully removed.
-
removeMetaData
Remove a specific metadata from the TownyObject. Most implementations will save the TownyObject after removing the metadata.- Parameters:
key
- Key of the data field to remove.- Returns:
- whether the metadata was successfully removed.
-
removeMetaData
Remove a specific metadata from the TownyObject.- Parameters:
key
- Key of the data field to remove.save
- whether to save the object or not after the metadata is removed.- Returns:
- whether the metadata was successfully removed.
-
getMetadata
A collection of all metadata on the TownyObject. This collection cannot be modified. Collection reflects current metadata, and is not thread safe.- Returns:
- an unmodifiable collection of all metadata on the object.
-
getMetadata
Fetch the metadata associated with the specific key.- Parameters:
key
- Key of the metadata to fetch.- Returns:
- the metadata associated with the key or
null
if none associated.
-
getMetadata
@Nullable public <T extends CustomDataField<?>> T getMetadata(@NotNull @NotNull String key, @NotNull @NotNull Class<T> cdfClass) Fetch the metadata associated with the specific key and class.- Type Parameters:
T
- The Class.- Parameters:
key
- Key of the metadata to fetch.cdfClass
- Class of the CustomDataField to fetch.- Returns:
- the specific metadata associated with the key and class or
null
if none exist.
-
hasMeta
public boolean hasMeta()- Returns:
- whether this object has metadata or not.
-
hasMeta
Check whether metadata associated with the key exists.- Parameters:
key
- Key of the metadata to check.- Returns:
- whether metadata associated with the key exists.
-
hasMeta
public <T extends CustomDataField<?>> boolean hasMeta(@NotNull @NotNull String key, @NotNull @NotNull Class<T> cdfClass) Check whether metadata associated with the given key and class exists.- Type Parameters:
T
- The Class.- Parameters:
key
- Key of the metadata to checkcdfClass
- Class extending CustomDataField to check.- Returns:
- whether metadata associated with the key and class exists.
-
exists
@Internal public abstract boolean exists()An internal method used to determine if an object exists in the TownyUniverse's maps.- Returns:
- true if this TownyObject exists.
-