Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
M mmoitems
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 47
    • Issues 47
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Administrator
  • mmoitems
  • Wiki
  • Stat API

Stat API · Changes

Page history
Updated Stat API (markdown) authored May 09, 2020 by Indyuce's avatar Indyuce
Show whitespace changes
Inline Side-by-side
Showing with 47 additions and 1 deletion
+47 -1
  • Stat-API.md Stat-API.md +47 -1
  • No files found.
Stat-API.md
View page @ 99451e4f
......@@ -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.
## 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
Clone repository

  • Home
  • Installation Guide
  • Commands

General

  • Item Types
  • Item Stats & Options
  • Item Creation

Features

  • Mitigation
  • Elemental Damage
  • Item Identification
  • Item Tiers
  • Gem Stones
  • Custom Durability
  • Item Sets
  • Item Upgrading
  • Soulbound

Crafting Stations

  • Crafting Stations
  • Upgrading Recipes
  • Recipe Conditions
  • Recipe Ingredients
  • Recipe Triggers

Custom Blocks

  • Custom Blocks
  • World Gen Templates

Item Management

  • Item Updater
  • Item Drop Tables

Item Generator

  • General
  • Item Templates
  • Item Modifiers
  • Complex Stats

Abilities

  • Abilities
  • Ability List

Compatibility & API

  • Supported Plugins
  • Custom Item Textures
  • Main API Features