-
Notifications
You must be signed in to change notification settings - Fork 0
Custom Trait
nahkd123 edited this page Jul 28, 2021
·
1 revision
You can add custom item traits by extending ItemTrait
class:
class MyTrait extends ItemTrait {
@Override
public TraitData createData(ConfigurationSection configData) {
return new MyTraitData(this);
}
@Override
public void modifyMeta(ManyItemsStack stack, ItemMeta meta, TraitData data, ConfigurationSection configData) {
}
@Override
public TraitData loadDataFromPOC(PersistentDataContainer container) {
return new MyTraitData(this);
}
}
-
createData()
create new trait data, based on user's configuration data -
modifyMeta()
is used to modify the item display, such as display name or lore -
loadDataFromPOC()
is used to load trait data from persistent data container, which is stored directly on items
You also need to create your own trait data class to store your item trait data:
class MyTraitData extends TraitData {
private MyTrait trait;
public MyTraitData(MyTrait trait) {
this.trait = trait;
}
@Override
public ItemTrait getTrait() {
return this.trait;
}
@Override
public void saveToPOC(PersistentDataContainer container) {
}
}
-
getTrait()
returns the trait -
saveToPOC()
is used to store trait data from persistent data container on items
ManyItems let you creates custom item and use them with plugins that uses Custom Items Driver API from FeatherPowders