... | @@ -280,3 +280,49 @@ public class DoubleData implements StatData, Mergeable { |
... | @@ -280,3 +280,49 @@ public class DoubleData implements StatData, Mergeable { |
|
}
|
|
}
|
|
```
|
|
```
|
|
Simple enough: MMOItems just adds the two values together. A little specification here: the `min` and `max` options are used to have a stat range but whenever that `StatData` is loaded from an NBTItem using `whenLoading(MMOItem mmoitem, NBTItem)`, only the `min` variable is used because a generated item does not have stat ranges anymore, they have already been rolled on item generation.
|
|
Simple enough: MMOItems just adds the two values together. A little specification here: the `min` and `max` options are used to have a stat range but whenever that `StatData` is loaded from an NBTItem using `whenLoading(MMOItem mmoitem, NBTItem)`, only the `min` variable is used because a generated item does not have stat ranges anymore, they have already been rolled on item generation.
|
|
|
|
|
|
|
|
## Registering a stat
|
|
|
|
You now need to register your stat by running
|
|
|
|
```MMOItems.plugin.getStats().register(ItemStat);```
|
|
|
|
Make sure you register your stat before MMOItems enables, either right after MMOItems loads if it's a depend, or when your plugin enables if it's a loadbefore. MMOItems does handle `Listener` stats, no need to register them later on.
|
|
|
|
|
|
|
|
## Item Restrictions
|
|
|
|
```
|
|
|
|
public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* stat that uses a custom DoubleStatData because the merge algorithm is
|
|
|
|
* slightly different. when merging two "required level", MMOItems should
|
|
|
|
* only keep the highest levels of the two and not sum the two values
|
|
|
|
*/
|
|
|
|
public RequiredLevel() {
|
|
|
|
super("REQUIRED_LEVEL", new ItemStack(VersionMaterial.EXPERIENCE_BOTTLE.toMaterial()), "Required Level",
|
|
|
|
new String[] { "The level your item needs", "in order to be used." }, new String[] { "all" });
|
|
|
|
}
|
|
|
|
|
|
|
|
..........
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
|
|
|
|
int level = item.getInteger("MMOITEMS_REQUIRED_LEVEL");
|
|
|
|
if (player.getLevel() < level && !player.getPlayer().hasPermission("mmoitems.bypass.level")) {
|
|
|
|
if (message) {
|
|
|
|
Message.NOT_ENOUGH_LEVELS.format(ChatColor.RED).send(player.getPlayer(), "cant-use-item");
|
|
|
|
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
Simply let your class implement `ItemRestriction` and override the `canUse(RPGPlayer, NBTItem, boolean)` method.
|
|
|
|
|
|
|
|
## Proper Stats
|
|
|
|
""Proper"" stats are a very specific type of stats. These are stats which are supported by gem stones but which **must not** be applied onto the target item when a gem stone is being attached onto another item.\
|
|
|
|
Examples: custom model data, shield patterns, custom sounds...
|
|
|
|
|
|
|
|
Let your stat class implement the `ProperStat` interface if you don't want gems to apply the potential gem stone stat data onto the target item.
|
|
|
|
|
|
|
|
## Upgradable
|
|
|
|
More on this later when API is reworked. It's used to make stats upgradable using item upgrade templates. |
|
|
|
\ No newline at end of file |