Class Property<T>
- Type Parameters:
T- The type of the value of the property.
- All Implemented Interfaces:
IKeyed
Several properties are predefined in this class. For example, the OPEN_STATUS property is used to represent
whether a structure is open or closed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents a builder for a property. -
Field Summary
FieldsModifier and TypeFieldDescriptionA property for structures whose animation speed is variable.A property for structures that move a certain amount of blocks when activated.A property for structures that have a defined open and closed state.A property for structures that can rotate multiples of 90 degrees.static final Property<RedstoneMode> A property for structures that can have different redstone modes.A property for structures that have a defined rotation point. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadminHasAccessLevel(PropertyAccessLevel propertyAccessLevel) Checks if the admin has the given access level.static <U> Property.PropertyBuilder<U> Creates a new property builder.static <U> Property.PropertyBuilder<U> builder(NamespacedKey namespacedKey, Class<U> type) Creates a new property builder.@Nullable TCasts the given value to the type of the property.booleanstatic @Nullable Property<?> fromKey(NamespacedKey propertyKey) Gets the property with the givenstatic @Nullable Property<?> Gets the property with the given serialization name.intgetAccessLevel(ICommandSender commandSender, IStructureConst structure) Gets the access level to this property for the given command sender and structure.intgetAccessLevel(PermissionLevel permissionLevel) Gets the access level for the given permission level.intThe level of access admins have to this property.static IDebuggableGets the debuggable registry of all registered properties.The default value of the property.The namespace and key of the property.The scopes in which this property is used.getType()The type of the property.intThe level of access users have to this property.inthashCode()@NonNull StringtoString()booleanuserHasAccessLevel(PropertyAccessLevel propertyAccessLevel) Gets the full key of the property.Methods inherited from interface IKeyed
getFullKey
-
Field Details
-
ANIMATION_SPEED_MULTIPLIER
-
BLOCKS_TO_MOVE
-
OPEN_STATUS
-
QUARTER_CIRCLES
-
REDSTONE_MODE
A property for structures that can have different redstone modes. -
ROTATION_POINT
-
-
Method Details
-
builder
Creates a new property builder.This is a shortcut for
builder(NamespacedKey, Class).- Type Parameters:
U- The type of the value of the property.- Parameters:
owner- The name of the plugin that owns this property. This is used to prevent conflicts between properties between different plugins.All properties supplied by this plugin are set to
Constants.PLUGIN_NAME.Properties from other plugins should use the name of the plugin that owns the property.
name- The name of the property that is used for serialization.type- The type of the property.- Returns:
- The property builder.
-
builder
Creates a new property builder.- Type Parameters:
U- The type of the value of the property.- Parameters:
namespacedKey- The namespace and key of the property.type- The type of the property.- Returns:
- The property builder.
-
getDebuggableRegistry
Gets the debuggable registry of all registered properties.- Returns:
- The debuggable registry of all registered properties.
-
userHasAccessLevel
Gets the full key of the property.- Parameters:
propertyAccessLevel- The access level to check.- Returns:
- True if the user has the given access level.
-
adminHasAccessLevel
Checks if the admin has the given access level.- Parameters:
propertyAccessLevel- The access level to check.- Returns:
- True if the admin has the given access level.
-
fromName
Gets the property with the given serialization name.Shortcut for
Property.Registry.fromName(String)withREGISTRY.- Parameters:
propertyKey- The serialization name of the property.- Returns:
- The property with the given serialization name, or null if no property with that name exists.
-
fromKey
Gets the property with the given- Parameters:
propertyKey- The key of the property.- Returns:
- The property with the given key, or null if no property with that key exists.
-
cast
Casts the given value to the type of the property.This method is a wrapper around
Class.cast(Object)forgetType().- Parameters:
value- The value to cast.- Returns:
- The value cast to the type of the property.
- Throws:
ClassCastException- If the value cannot be cast to the type of the property.
-
getAccessLevel
@CheckReturnValue public int getAccessLevel(ICommandSender commandSender, IStructureConst structure) Gets the access level to this property for the given command sender and structure.Defaults to 0 if the command sender is not an owner of the structure.
The returned value is a bit flag whose values refer to the
PropertyAccessLevelenum.- Parameters:
commandSender- The command sender to get the access level for.structure- The structure to get the access level for.- Returns:
- The access level for the given command sender and structure.
-
getAccessLevel
Gets the access level for the given permission level.Defaults to 0 if the command sender is not an owner of the structure.
The returned value is a bit flag whose values refer to the
PropertyAccessLevelenum.- Parameters:
permissionLevel- The permission level to get the access level for.- Returns:
- The access level for the given permission level.
-
toString
-
equals
-
hashCode
-
getNamespacedKey
The namespace and key of the property.Note that this name should be unique for each property.
- Specified by:
getNamespacedKeyin interfaceIKeyed- Returns:
- The name of the property.
-
getType
-
getDefaultValue
The default value of the property.- Returns:
- The default value of the property.
-
getUserAccessLevel
public int getUserAccessLevel()The level of access users have to this property.This is a bit flag whose values refer to the
PropertyAccessLevelenum. -
getAdminAccessLevel
public int getAdminAccessLevel()The level of access admins have to this property.This is a bit flag whose values refer to the
PropertyAccessLevelenum. -
getPropertyScopes
The scopes in which this property is used.This is used to prevent side effects of changing the property value. For example, clearing cached values related to the property, such as the animation range when changing the 'blocks to move' property.
-