Class CustomDataField<T>
java.lang.Object
com.palmergames.bukkit.towny.object.metadata.CustomDataField<T>
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
BooleanDataField
,ByteDataField
,DecimalDataField
,IntegerDataField
,ListDataField
,LocationDataField
,LongDataField
,StringDataField
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCustomDataField
(String key) CustomDataField
(String key, String label) CustomDataField
(String key, T value) CustomDataField
(String key, T value, String label) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
canParseFromString
(String strValue) Determines whether the given input can be parsed to the appropriate value.abstract @NotNull CustomDataField
<T> clone()
protected abstract String
Formats and colors the value of the custom data field object.boolean
net.kyori.adventure.text.Component
Get the value as a formatted component.@NotNull String
getKey()
@NotNull String
getLabel()
@NotNull net.kyori.adventure.text.Component
Get label as a formatted component.abstract @NotNull String
Gets the type id for the given CustomDataField class.getValue()
int
hashCode()
boolean
hasLabel()
final void
isValidType
(String str) protected @Nullable String
Serializes the current value to a string.void
void
abstract void
setValueFromString
(String strValue) Sets the value based on the given input.boolean
toString()
-
Field Details
-
label
-
-
Constructor Details
-
CustomDataField
-
CustomDataField
-
CustomDataField
-
CustomDataField
-
-
Method Details
-
getTypeID
Gets the type id for the given CustomDataField class. This value is attached to the class, and not a specific instance. Used for serialization purposes.- Returns:
- type id of the given CustomDataField class.
-
getValue
-
setValue
-
setValueFromString
Sets the value based on the given input. Used when admins want to edit metadata in-game.- Parameters:
strValue
- input.
-
serializeValueToString
Serializes the current value to a string. Used for saving the CustomDataField object.- Returns:
- serialized string
-
getKey
-
shouldDisplayInStatus
public boolean shouldDisplayInStatus() -
getLabel
-
getLabelAsComp
@NotNull public @NotNull net.kyori.adventure.text.Component getLabelAsComp()Get label as a formatted component.This function is intentionally overridable by child classes.
- Returns:
- formatted label component.
-
hasLabel
public boolean hasLabel() -
setLabel
-
toString
-
canParseFromString
Determines whether the given input can be parsed to the appropriate value. Used to parse admin input for in-game metadata editing.- Parameters:
strValue
- admin input- Returns:
- whether the string can be parsed or not
-
isValidType
- Throws:
InvalidMetadataTypeException
-
displayFormattedValue
Formats and colors the value of the custom data field object.- Returns:
- the formatted value of this data field.
-
formatValueAsComp
public net.kyori.adventure.text.Component formatValueAsComp()Get the value as a formatted component.This function is intentionally overridable by child classes.
- Returns:
- formatted component of value.
-
equals
-
hashCode
public int hashCode() -
clone
-