Generating an item [1.13]
Since 4.6 you now have to load an item before generating it. Loaded items are stored into MMOItem instances. By using the newBuilder() method (from the MMOItem class), you can create an MMOItemBuilder which can build an ItemStack instance out of an MMOItem. Items may be loaded & generated using the ItemManager instance saved in the main java plugin class. You can access the item manager using MMOItems.getItems().
Code (Text):ItemManager itemManager = MMOItems.getItems();
MMOItem mmoitem = itemManager.getMMOItem(MMOItems.getTypes().get("SWORD"), "CUTLASS");
ItemStack item = mmoitem.newBuilder().build();
The following method directly returns the ItemStack instance:
Code (Text):MMOItems.getItems().getItem(MMOItems.getTypes().get("SWORD"), "CUTLASS")
Retrieving item type instances
Since 4.6, types are not stored in an enum anymore since you can add as many as you want. Type instances are now stored in a TypeManager class instance, which can be accessed using the following method:
Code (Text):TypeManager types = MMOItems.getTypes();
Type sword = types.get("SWORD") // e.g get the type which ID is SWORD
Collection<Type> all = types.getAll() // get all loaded types
In Legacy MI, use Type.valueOf(String) as types are still stored in an enum.
Casting an ability
You need to use the cast method from the Ability class to make a player cast an ability. You also need to specify the ability modifiers, and eventually the ability target, if your ability is an on-hit ability. If you don't want the ability to display any message when cast/not successfully cast, you will have to toggle off a boolean value.
Code (Text):// the ability modifiers
AbilityModifiers modifiers = new AbilityModifiers(ability);
// target -> LivingEntity, the ability target
// message -> set it to true if you want ability messages displayed
// player -> the player casting the ability
// damage -> some abilities change the event damage, abilities calculate the ability extra damage based on that value
ability.cast(PlayerData.get(player), target, damage, modifiers, message);
// an easier way of casting abilities WITH NO TARGET
ability.cast(PlayerData.get(player), mods, true);
Getting an ability instance
Abilities are stored in an instance of the AbilityManager class that is accessible using a static method from the MMOItems class. To get the ability class instance, simply use the get(String) method from the AbilityManager class and specify the ability ID as argument.
Code (Text):Ability ability = MMOItems.getAbilities().get("FIREBOLT");
Opening plugin GUIs
Code (Text):new AdvancedTypeList(player, 1).open(); // opens the recipe list at type selection
new AdvancedRecipeList(player, MMOItems.getTypes().get("SWORD")).open(); // opens the recipe list (after selecting item type)
new AdvancedRecipeWorkbench(player).open(); // opens the advanced workbench
new ItemEdition(player, MMOItems.getTypes().get("STAFF"), "EARTH_STAFF").open(); // opens the edition gui for a specific item