Variable: properties - ScreamingSandals/SimpleInventories GitHub Wiki
properties
Properties is not used by this library but you can use it in your plugin. We recommended to use properties if you want to do some action after click and if you want to modify item in gui, we recommended to use custom variable but it depends on your mind.
There are more variants how to work with properties!
Yaml: Properties with variables:
- stack: ...
properties:
- name: myProperty
variable: "Hello World"
- name: anotherProperty
variable: "Hello"
variable2: "World"
Multiple properties without variables:
- stack: ...
properties:
- myProperty
- anotherProperty
Single property without variable:
- stack: ...
properties: myProperty
Groovy:
item('...') {
property 'myProperty' // single property without variables
property('anotherProperty', [ // single property with variables
variable: 'Hello',
variable2: 'World!'
])
}
How to use it in code:
...
PlayerItemInfo item = /* here you can get item from somewhere, example from event by */ event.getItem();
if (item.hasProperties()) { // Check if properties are exists
for (Property property : item.getProperties()) {
/* Here you can do some actions with property */
}
}
...