New type integration

Integration of the new type into the plugin, there still are some lines to fix, basically every code using old hardcoded Type class or getSet() function
This commit is contained in:
Roch Blonndiaux 2023-02-28 17:20:25 +01:00
parent 1b759c9cf6
commit e0a0154d1b
72 changed files with 471 additions and 520 deletions

View File

@ -6,10 +6,10 @@ import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import io.lumine.mythic.lib.version.SpigotPlugin;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.SoulboundInfo;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.crafting.MMOItemUIFilter;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
@ -49,6 +49,7 @@ import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
@ -168,7 +169,7 @@ public class MMOItems extends JavaPlugin {
dropTableManager = new DropTableManager();
worldGenManager = new WorldGenManager();
blockManager = new BlockManager();
statManager.reload(false);
statManager.reload(false);
PluginUtils.hookDependencyIfPresent("Vault", u -> vaultSupport = new VaultSupport());
@ -507,11 +508,10 @@ public class MMOItems extends JavaPlugin {
* template has the 'tiered' option
*/
@Nullable
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id, @Nullable PlayerData player) {
if (type == null || id == null) {
@Contract("_, _, null -> null")
public MMOItem getMMOItem(@Nullable MMOItemType type, @Nullable String id, @Nullable PlayerData player) {
if (type == null || id == null)
return null;
}
// Valid template?
MMOItemTemplate found = getTemplates().getTemplate(type, id);
if (found == null) return null;
@ -527,8 +527,7 @@ public class MMOItems extends JavaPlugin {
* template has the 'tiered' option
*/
@Nullable
public ItemStack getItem(@Nullable Type type, @Nullable String id, @NotNull PlayerData player) {
public ItemStack getItem(@Nullable MMOItemType type, @Nullable String id, @NotNull PlayerData player) {
// Valid MMOItem?
MMOItem m = getMMOItem(type, id, player);
if (m == null) return null;
@ -544,11 +543,10 @@ public class MMOItems extends JavaPlugin {
* specific item level and item tier
*/
@Nullable
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id, int itemLevel, @Nullable ItemTier itemTier) {
if (type == null || id == null) {
@Contract("null, null, _, _ -> null")
public MMOItem getMMOItem(@Nullable MMOItemType type, @Nullable String id, int itemLevel, @Nullable ItemTier itemTier) {
if (type == null || id == null)
return null;
}
// Valid template?
MMOItemTemplate found = getTemplates().getTemplate(type, id);
if (found == null) return null;
@ -564,8 +562,7 @@ public class MMOItems extends JavaPlugin {
* specific item level and item tier
*/
@Nullable
public ItemStack getItem(@Nullable Type type, @Nullable String id, int itemLevel, @Nullable ItemTier itemTier) {
public ItemStack getItem(@Nullable MMOItemType type, @Nullable String id, int itemLevel, @Nullable ItemTier itemTier) {
// Valid MMOItem?
MMOItem m = getMMOItem(type, id, itemLevel, itemTier);
if (m == null) return null;
@ -582,7 +579,8 @@ public class MMOItems extends JavaPlugin {
* Will return <code>null</code> if such MMOItem does not exist.
*/
@Nullable
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id) {
@Contract("null, _ -> null")
public MMOItem getMMOItem(@Nullable MMOItemType type, @Nullable String id) {
return getMMOItem(type, id, 0, null);
}
@ -595,10 +593,10 @@ public class MMOItems extends JavaPlugin {
*/
@Nullable
@Contract("null, _ -> null")
public ItemStack getItem(@Nullable String type, @Nullable String id) {
if (type == null || id == null) {
if (type == null || id == null)
return null;
}
return getItem(getTypes().get(type), id);
}
@ -610,16 +608,15 @@ public class MMOItems extends JavaPlugin {
* Will return <code>null</code> if such MMOItem does not exist.
*/
@Nullable
public ItemStack getItem(@Nullable Type type, @Nullable String id) {
if (type == null || id == null) {
@Contract("null, _ -> null")
public ItemStack getItem(@Nullable MMOItemType type, @Nullable String id) {
if (type == null || id == null)
return null;
}
// Valid MMOItem?
MMOItem m = getMMOItem(type, id);
if (m == null) {
if (m == null)
return null;
}
// Build if found
return m.newBuilder().build();
@ -633,7 +630,8 @@ public class MMOItems extends JavaPlugin {
* @see #getType(NBTItem)
*/
@Nullable
public static Type getType(@Nullable ItemStack stack) {
@Contract("null -> null")
public static MMOItemType getType(@Nullable ItemStack stack) {
// Get from nbt
return getType(NBTItem.get(stack));
@ -644,8 +642,7 @@ public class MMOItems extends JavaPlugin {
* @return The MMOItems type of this nbt, if it has one
*/
@Nullable
public static Type getType(@Nullable NBTItem nbt) {
public static MMOItemType getType(@Nullable NBTItem nbt) {
// That's it
return plugin.getTypes().get(getTypeName(nbt));
}
@ -657,7 +654,6 @@ public class MMOItems extends JavaPlugin {
*/
@Nullable
public static String getTypeName(@Nullable ItemStack stack) {
// Get from nbt
return getTypeName(NBTItem.get(stack));
}
@ -667,18 +663,11 @@ public class MMOItems extends JavaPlugin {
* @return The MMOItems type of this nbt, if it has one
*/
@Nullable
@Contract("null -> null")
public static String getTypeName(@Nullable NBTItem nbt) {
// Straight up no
if (nbt == null) {
if (nbt == null || !nbt.hasType())
return null;
}
// Get from nbt
if (!nbt.hasType()) {
return null;
}
// That's it
return nbt.getType();
}
@ -700,12 +689,11 @@ public class MMOItems extends JavaPlugin {
* @return The MMOItems ID of this nbt, if it has one
*/
@Nullable
@Contract("null -> null")
public static String getID(@Nullable NBTItem nbt) {
// Straight up no
if (nbt == null) {
if (nbt == null)
return null;
}
// That's it
return nbt.getString("MMOITEMS_ITEM_ID");
@ -720,16 +708,16 @@ public class MMOItems extends JavaPlugin {
* @author Gunging
*/
public static void print(@Nullable Level level, @Nullable String message, @Nullable String prefix, @NotNull String... replaces) {
if (message == null) {
if (message == null)
message = "< null >";
}
if (level != null) {
plugin.getLogger().log(level, FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get(), message, replaces));
} else {
FriendlyFeedbackMessage p = new FriendlyFeedbackMessage("", prefix);
FriendlyFeedbackMessage r = FriendlyFeedbackProvider.generateMessage(p, message, replaces);
getConsole().sendMessage(r.forConsole(FFPMMOItems.get()));
return;
}
FriendlyFeedbackMessage p = new FriendlyFeedbackMessage("", prefix);
FriendlyFeedbackMessage r = FriendlyFeedbackProvider.generateMessage(p, message, replaces);
getConsole().sendMessage(r.forConsole(FFPMMOItems.get()));
}
/**

View File

@ -11,6 +11,7 @@ import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
@ -18,7 +19,12 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @deprecated Use {@link net.Indyuce.mmoitems.api.item.type.MMOItemType} instead.
*/
@SuppressWarnings("unused")
@Deprecated
@ApiStatus.ScheduledForRemoval
public class Type {
@ -106,7 +112,8 @@ public class Type {
public Type(@NotNull TypeManager manager, @NotNull ConfigurationSection config) {
id = config.getName().toUpperCase().replace("-", "_").replace(" ", "_");
parent = manager.get(config.getString("parent", "").toUpperCase().replace("-", "_").replace(" ", "_"));
// parent = manager.get(config.getString("parent", "").toUpperCase().replace("-", "_").replace(" ", "_"));
parent = null;
set = (parent != null ? parent.set : TypeSet.EXTRA);
weapon = (parent != null && parent.weapon);
@ -120,7 +127,7 @@ public class Type {
name = config.getString("name", name);
item = read(config.getString("display", item == null ? Material.STONE.toString() : item.getType().toString()));
(unidentifiedTemplate = new UnidentifiedItem(this)).update(config.getConfigurationSection("unident-item"));
// (unidentifiedTemplate = new UnidentifiedItem(this)).update(config.getConfigurationSection("unident-item"));
// Getting overridden?
loreFormat = config.getString("LoreFormat", (parent != null ? parent.loreFormat : loreFormat));
@ -303,7 +310,8 @@ public class Type {
return null;
}
String format = id.toUpperCase().replace("-", "_").replace(" ", "_");
return MMOItems.plugin.getTypes().has(format) ? MMOItems.plugin.getTypes().get(format) : null;
// return MMOItems.plugin.getTypes().has(format) ? MMOItems.plugin.getTypes().get(format) : null;
return null;
}
/**

View File

@ -1,9 +1,9 @@
package net.Indyuce.mmoitems.api.crafting;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection;
@ -23,7 +23,7 @@ public class ConfigMMOItem {
Validate.notNull(config, "Could not read MMOItem config");
Validate.isTrue(config.contains("type") && config.contains("id"), "Config must contain type and ID");
Type type = MMOItems.plugin.getTypes().getOrThrow(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
MMOItemType type = MMOItems.plugin.getTypes().getOrThrow(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
template = MMOItems.plugin.getTemplates().getTemplateOrThrow(type, config.getString("id"));
this.amount = Math.max(1, config.getInt("amount"));

View File

@ -10,11 +10,11 @@ import io.lumine.mythic.lib.api.util.ui.QuickNumberRange;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.stat.data.UpgradeData;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -116,12 +116,12 @@ public class MMOItemUIFilter implements UIFilter {
@Override
public boolean isValid(@NotNull String argument, @NotNull String data, @Nullable FriendlyFeedbackProvider ffp) {
if (reg) { return true; }
if (reg) return true;
argument = argument.replace(" ", "_").replace("-", "_").toUpperCase();
data = data.replace(" ", "_").replace("-", "_").toUpperCase();
// Type exists?
Type t = MMOItems.plugin.getTypes().get(argument);
MMOItemType t = MMOItems.plugin.getTypes().get(argument);
// Nope
if (t == null) {
@ -161,7 +161,7 @@ public class MMOItemUIFilter implements UIFilter {
public ArrayList<String> tabCompleteArgument(@NotNull String argument) {
// Filter from the available types
return SilentNumbers.smartFilter(MMOItems.plugin.getTypes().getAllTypeNames(), argument, true);
return SilentNumbers.smartFilter(new ArrayList<>(MMOItems.plugin.getTypes().getAllTypeNames()), argument, true);
}
@NotNull
@ -169,7 +169,7 @@ public class MMOItemUIFilter implements UIFilter {
public ArrayList<String> tabCompleteData(@NotNull String argument, @NotNull String data) {
//Find type?
Type t = MMOItems.plugin.getTypes().get(argument);
MMOItemType t = MMOItems.plugin.getTypes().get(argument);
if (t != null) {
@ -189,7 +189,7 @@ public class MMOItemUIFilter implements UIFilter {
}
// Just filter among template names of this type
ArrayList<String> suggestions = SilentNumbers.smartFilter(MMOItems.plugin.getTemplates().getTemplateNames(t), data, true);
ArrayList<String> suggestions = SilentNumbers.smartFilter(new ArrayList<>(MMOItems.plugin.getTemplates().getTemplateNames(t)), data, true);
ArrayList<String> trueSuggestions = suggestions;
// So, what things may be put in data?

View File

@ -6,15 +6,15 @@ import io.lumine.mythic.lib.api.util.ui.QuickNumberRange;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.crafting.ConfigMMOItem;
import net.Indyuce.mmoitems.api.crafting.ingredient.inventory.MMOItemPlayerIngredient;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.stat.DisplayName;
import net.Indyuce.mmoitems.stat.data.MaterialData;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
@ -30,7 +30,7 @@ public class MMOItemIngredient extends Ingredient<MMOItemPlayerIngredient> {
// Which MMOItem?
config.validate("type", "id");
Type type = MMOItems.plugin.getTypes().getOrThrow(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
MMOItemType type = MMOItems.plugin.getTypes().getOrThrow(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
template = MMOItems.plugin.getTemplates().getTemplateOrThrow(type, config.getString("id"));
// Read level, the default is that any level will work

View File

@ -1,16 +1,15 @@
package net.Indyuce.mmoitems.api.crafting.trigger;
import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.util.SmartGive;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.player.PlayerData;
import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.util.SmartGive;
public class MMOItemTrigger extends Trigger {
private final MMOItemTemplate template;
private final int amount;
@ -20,7 +19,7 @@ public class MMOItemTrigger extends Trigger {
config.validate("type", "id");
Type type = MMOItems.plugin.getTypes().getOrThrow(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
MMOItemType type = MMOItems.plugin.getTypes().getOrThrow(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
String id = config.getString("id").replace("-", "_").toUpperCase();
Validate.isTrue(MMOItems.plugin.getTemplates().hasTemplate(type, id), "Could not find MMOItem with ID '" + id + "'");

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmoitems.api.droptable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.droptable.item.BlockDropItem;
import net.Indyuce.mmoitems.api.droptable.item.DropItem;
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection;
@ -83,7 +83,7 @@ public class DropTable {
if (subtable.contains("items"))
for (String typeFormat : subtable.getConfigurationSection("items").getKeys(false)) {
Type type = MMOItems.plugin.getTypes().getOrThrow(typeFormat.toUpperCase().replace("-", "_"));
MMOItemType type = MMOItems.plugin.getTypes().getOrThrow(typeFormat.toUpperCase().replace("-", "_"));
for (String id : subtable.getConfigurationSection("items." + typeFormat).getKeys(false))
items.add(new MMOItemDropItem(type, id, subtable.getString("items." + typeFormat + "." + id)));
}

View File

@ -1,24 +1,23 @@
package net.Indyuce.mmoitems.api.droptable.item;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.RandomAmount;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.RandomAmount;
import io.lumine.mythic.lib.api.item.NBTItem;
public class MMOItemDropItem extends DropItem {
private final Type type;
private final MMOItemType type;
private final String id;
private final double unidentification;
public MMOItemDropItem(Type type, String id, double drop, double unidentification, RandomAmount amount) {
public MMOItemDropItem(MMOItemType type, String id, double drop, double unidentification, RandomAmount amount) {
this(type, id, drop, unidentification, amount.getMin(), amount.getMax());
}
public MMOItemDropItem(Type type, String id, double drop, double unidentification, int min, int max) {
public MMOItemDropItem(MMOItemType type, String id, double drop, double unidentification, int min, int max) {
super(drop, min, max);
this.type = type;
@ -26,7 +25,7 @@ public class MMOItemDropItem extends DropItem {
this.unidentification = unidentification;
}
public MMOItemDropItem(Type type, String id, String info) {
public MMOItemDropItem(MMOItemType type, String id, String info) {
super(info);
this.type = type;
@ -36,7 +35,7 @@ public class MMOItemDropItem extends DropItem {
unidentification = Double.parseDouble(argSplit[2]) / 100;
}
public Type getType() {
public MMOItemType getType() {
return type;
}

View File

@ -1,14 +1,10 @@
package net.Indyuce.mmoitems.api.event;
import net.Indyuce.mmoitems.api.ReforgeOptions;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
import net.Indyuce.mmoitems.stat.data.type.Mergeable;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.stat.type.StatHistory;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@ -68,7 +64,7 @@ public class MMOItemReforgeEvent extends Event implements Cancellable {
/**
* @return MMOItems Type we are working with
*/
@NotNull public Type getType() { return getReforger().getTemplate().getType(); }
@NotNull public MMOItemType getType() { return getReforger().getTemplate().getType(); }
/**
* @return MMOItems Type we are working with

View File

@ -1,9 +1,9 @@
package net.Indyuce.mmoitems.api.event;
import net.Indyuce.mmoitems.api.ReforgeOptions;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@ -76,7 +76,7 @@ public class MMOItemReforgeFinishEvent extends Event implements Cancellable {
/**
* @return MMOItems Type we are working with
*/
@NotNull public Type getType() { return getReforger().getTemplate().getType(); }
@NotNull public MMOItemType getType() { return getReforger().getTemplate().getType(); }
/**
* @return MMOItems Type we are working with

View File

@ -7,9 +7,9 @@ import io.lumine.mythic.lib.api.util.SmartGive;
import io.lumine.mythic.lib.comp.flags.CustomFlag;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.ConsumableConsumedEvent;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.item.util.LoreUpdate;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.PlayerConsumable;
@ -43,7 +43,7 @@ public class Consumable extends UseItem {
return false;
// Make sure it is an MMOItem
Type targetType = MMOItems.getType(target);
MMOItemType targetType = MMOItems.getType(target);
for (ConsumableItemInteraction action : MMOItems.plugin.getStats().getConsumableActions())
if (action.handleConsumableEffect(event, playerData, this, target, targetType))

View File

@ -6,6 +6,7 @@ import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.ApplyGemStoneEvent;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.Enchants;
import net.Indyuce.mmoitems.stat.GemUpgradeScaling;
@ -34,7 +35,7 @@ public class GemStone extends UseItem {
}
@NotNull
public ApplyResult applyOntoItem(@NotNull NBTItem target, @NotNull Type targetType) {
public ApplyResult applyOntoItem(@NotNull NBTItem target, @NotNull MMOItemType targetType) {
/*
* Entirely loads the MMOItem and checks if it has the required empty
@ -45,7 +46,7 @@ public class GemStone extends UseItem {
}
@NotNull
public ApplyResult applyOntoItem(@NotNull MMOItem targetMMO, @NotNull Type targetType, @NotNull String itemName, boolean buildStack, boolean silent) {
public ApplyResult applyOntoItem(@NotNull MMOItem targetMMO, @NotNull MMOItemType targetType, @NotNull String itemName, boolean buildStack, boolean silent) {
if (!targetMMO.hasData(ItemStats.GEM_SOCKETS))
return new ApplyResult(ResultType.NONE);

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmoitems.api.item;
import io.lumine.mythic.lib.player.cooldown.CooldownObject;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
/**
* Referenced objects are either item templates or MMOItems. They contain the
@ -19,7 +19,7 @@ public interface ItemReference extends CooldownObject {
* <p>
* Example: <b>GREATSWORD</b> STEEL_CLAYMORE
*/
Type getType();
MMOItemType getType();
/**
* MMOItem templates have to identifiers: TYPE and <b>ID</b>

View File

@ -1,18 +1,17 @@
package net.Indyuce.mmoitems.api.item.mmoitem;
import java.util.logging.Level;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.stat.type.StatHistory;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem;
import java.util.logging.Level;
public class LiveMMOItem extends ReadMMOItem {
@ -38,7 +37,7 @@ public class LiveMMOItem extends ReadMMOItem {
super(item);
// Reads all the stats that this type could possibly have.
for (ItemStat stat : getType().getAvailableStats())
for (ItemStat<?, ?> stat : getType().getStats())
// Attempts to load it
try {

View File

@ -5,10 +5,10 @@ import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.UpgradeTemplate;
import net.Indyuce.mmoitems.api.item.ItemReference;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
import net.Indyuce.mmoitems.stat.Enchants;
import net.Indyuce.mmoitems.stat.data.*;
@ -26,7 +26,7 @@ import java.util.*;
@SuppressWarnings("unused")
public class MMOItem implements ItemReference {
private final Type type;
private final MMOItemType type;
private final String id;
/**
@ -47,13 +47,13 @@ public class MMOItem implements ItemReference {
* existing items not to interfere with MI features like the
* dynamic item updater
*/
public MMOItem(Type type, String id) {
public MMOItem(MMOItemType type, String id) {
this.type = type;
this.id = id;
}
@Override
public Type getType() { return type; }
public MMOItemType getType() { return type; }
@Override
public String getId() { return id; }

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.api.item.mmoitem;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
@ -19,7 +19,7 @@ public abstract class ReadMMOItem extends MMOItem {
* The NBTItem being read to generate an MMOItem
*/
public ReadMMOItem(@NotNull NBTItem item) {
super(Type.get(item.getType()), item.getString("MMOITEMS_ITEM_ID"));
super(MMOItemType.get(item.getType()), item.getString("MMOITEMS_ITEM_ID"));
this.item = item;
}

View File

@ -5,9 +5,9 @@ import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackCategory;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.ItemReference;
import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
@ -22,7 +22,7 @@ import javax.annotation.Nullable;
import java.util.*;
public class MMOItemTemplate extends PostLoadObject implements ItemReference {
private final Type type;
private final MMOItemType type;
private final String id;
private final int revId;
@ -40,7 +40,7 @@ public class MMOItemTemplate extends PostLoadObject implements ItemReference {
* @param id The template identifier, it's ok if two templates with
* different item types share the same ID
*/
public MMOItemTemplate(Type type, String id) {
public MMOItemTemplate(MMOItemType type, String id) {
super(null);
this.type = type;
@ -54,7 +54,7 @@ public class MMOItemTemplate extends PostLoadObject implements ItemReference {
* @param type The item type of your template
* @param config The config file read to load the template
*/
public MMOItemTemplate(Type type, ConfigurationSection config) {
public MMOItemTemplate(MMOItemType type, ConfigurationSection config) {
super(config);
Validate.notNull(config, "Could not load template config");
@ -127,7 +127,7 @@ public class MMOItemTemplate extends PostLoadObject implements ItemReference {
}
@Override
public Type getType() {
public MMOItemType getType() {
return type;
}

View File

@ -1,17 +1,17 @@
package net.Indyuce.mmoitems.api.item.template.explorer;
import java.util.function.Predicate;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import java.util.function.Predicate;
/**
* Filters items with a specific type
*/
public class TypeFilter implements Predicate<MMOItemTemplate> {
private final Type type;
private final MMOItemType type;
public TypeFilter(Type type) {
public TypeFilter(MMOItemType type) {
this.type = type;
}

View File

@ -3,10 +3,10 @@ package net.Indyuce.mmoitems.api.item.type;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.player.modifier.ModifierSource;
import io.lumine.mythic.lib.script.Script;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.item.util.identify.UnidentifiedItem;
import net.Indyuce.mmoitems.manager.TypeManager;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
@ -36,9 +36,10 @@ public class MMOItemType {
private final ItemStack item;
private final UnidentifiedItem unidentifiedTemplate;
private final List<ItemStat<?, ?>> stats;
private final @org.jetbrains.annotations.Nullable Script script;
private MMOItemType(String id, String name, ModifierSource modifierSource, boolean weapon, String loreFormat, ItemStack item, List<ItemStat<?, ?>> stats) {
protected MMOItemType(String id, String name, ModifierSource modifierSource, boolean weapon, String loreFormat, ItemStack item, @org.jetbrains.annotations.Nullable Script script, List<ItemStat<?, ?>> stats) {
this.id = id;
this.name = name;
this.modifierSource = modifierSource;
@ -46,6 +47,7 @@ public class MMOItemType {
this.loreFormat = loreFormat;
this.item = item;
this.unidentifiedTemplate = new UnidentifiedItem(this);
this.script = script;
this.stats = stats;
}
@ -90,21 +92,8 @@ public class MMOItemType {
return new ConfigFile("/item", getId().toLowerCase());
}
public static MMOItemType load(@NotNull TypeManager manager, @NotNull ConfigurationSection section) {
final String id = section.getName();
final String name = section.getString("name");
final ModifierSource modifierSource = ModifierSource.valueOf(section.getString("modifier-source"));
final boolean weapon = section.getBoolean("weapon");
final String loreFormat = section.getString("lore-format");
final ItemStack item = read(section.getString("display", Material.STONE.toString()));
// TODO: Load the stats
final List<ItemStat<?, ?>> stats = new ArrayList<>();
MMOItemType type = new MMOItemType(id, name, modifierSource, weapon, loreFormat, item, stats);
type.getUnidentifiedTemplate().update(section.getConfigurationSection("unident-item"));
return type;
public @org.jetbrains.annotations.Nullable Script getScript() {
return script;
}
public static ItemStack read(String str) {
@ -175,4 +164,22 @@ public class MMOItemType {
public static boolean isValid(@Nullable String id) {
return id != null && MMOItems.plugin.getTypes().has(id.toUpperCase().replace("-", "_").replace(" ", "_"));
}
public static MMOItemType load(@NotNull ConfigurationSection section) {
final String id = section.getName();
final String name = section.getString("name");
final ModifierSource modifierSource = ModifierSource.valueOf(section.getString("modifier-source"));
final boolean weapon = section.getBoolean("weapon");
final String loreFormat = section.getString("lore-format");
final ItemStack item = read(section.getString("display", Material.STONE.toString()));
final Script script = section.isString("script") ? MythicLib.plugin.getSkills().getScriptOrThrow(section.getString("script")) : null;
// TODO: Load the stats
final List<ItemStat<?, ?>> stats = new ArrayList<>();
MMOItemType type = new MMOItemType(id, name, modifierSource, weapon, loreFormat, item, script, stats);
type.getUnidentifiedTemplate().update(section.getConfigurationSection("unident-item"));
return type;
}
}

View File

@ -5,8 +5,8 @@ import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.player.modifier.ModifierSource;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
@ -70,7 +70,7 @@ public abstract class EquippedItem {
if (typeFormat == null)
return false;
final @Nullable Type type = MMOItems.plugin.getTypes().get(typeFormat);
final @Nullable MMOItemType type = MMOItems.plugin.getTypes().get(typeFormat);
if (type == null)
return false;

View File

@ -1,17 +1,16 @@
package net.Indyuce.mmoitems.api.recipe.workbench.ingredients;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import io.lumine.mythic.lib.api.item.NBTItem;
public class MMOItemIngredient extends WorkbenchIngredient {
private final Type type;
private final MMOItemType type;
private final String id;
public MMOItemIngredient(Type type, String id, int amount) {
public MMOItemIngredient(MMOItemType type, String id, int amount) {
super(amount);
this.type = type;
@ -21,7 +20,7 @@ public class MMOItemIngredient extends WorkbenchIngredient {
@Override
public boolean corresponds(ItemStack stack) {
NBTItem nbt = NBTItem.get(stack);
return type.equals(Type.get(nbt.getType())) && nbt.getString("MMOITEMS_ITEM_ID").equalsIgnoreCase(id);
return type.equals(MMOItemType.get(nbt.getType())) && nbt.getString("MMOITEMS_ITEM_ID").equalsIgnoreCase(id);
}
@Override

View File

@ -1,7 +1,8 @@
package net.Indyuce.mmoitems.api.util;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -12,116 +13,97 @@ import java.util.function.Consumer;
* Allows the use of two nested maps to efficiently store data about mmoitem
* templates. The first nested map is for the item type, the second is for the
* item ID.
*
* @author cympe
*
* @param <C>
* The class of the value you want to assign to every mmoitem
* @param <C> The class of the value you want to assign to every mmoitem
* template
* @author cympe
*/
public class TemplateMap<C> {
private final Map<Type, Submap> typeMap = new HashMap<>();
/**
* @param type
* The item type
* @param id
* The template identifier
* @return If a template has some value stored in that map
*/
public boolean hasValue(@Nullable Type type, @Nullable String id) {
if(type == null || id == null) { return false; }
return typeMap.containsKey(type) && typeMap.get(type).idMap.containsKey(id);
}
private final Map<MMOItemType, Map<String, C>> typeMap = new HashMap<>();
/**
* @param type
* The item type
* @param id
* The template identifier
* @return Returns the value stored in the template map
*/
@Nullable public C getValue(@Nullable Type type, @Nullable String id) {
if(type == null || id == null) { return null; }
Submap m = typeMap.get(type);
if (m == null) { return null; }
return m.idMap.get(id);
}
/**
* @param type The item type
* @param id The template identifier
* @return If a template has some value stored in that map
*/
@Contract("null, _ -> false; _, null -> false")
public boolean hasValue(@Nullable MMOItemType type, @Nullable String id) {
if (type == null || id == null)
return false;
return typeMap.containsKey(type) && typeMap.getOrDefault(type, new HashMap<>()).containsKey(id);
}
/**
* Unregisters a value from the map
*
* @param type
* The item type
* @param id
* The template identifier
*/
public void removeValue(@Nullable Type type, @Nullable String id) {
if(type == null || id == null) { return; }
if (typeMap.containsKey(type))
typeMap.get(type).idMap.remove(id);
}
/**
* @param type The item type
* @param id The template identifier
* @return Returns the value stored in the template map
*/
@Nullable
@Contract("null, _ -> null; _, null -> null")
public C getValue(@Nullable MMOItemType type, @Nullable String id) {
if (type == null || id == null) return null;
return typeMap.getOrDefault(type, new HashMap<>()).get(id);
}
/**
* Registers a value for a specific mmoitem template
*
* @param type
* The item type
* @param id
* The template identifier
* @param value
* The value to registered
*/
public void setValue(@NotNull Type type, @NotNull String id, @NotNull C value) {
Validate.notNull(value, "Value cannot be null");
/**
* Unregisters a value from the map
*
* @param type The item type
* @param id The template identifier
*/
public void removeValue(@Nullable MMOItemType type, @Nullable String id) {
if (type == null || id == null) return;
typeMap.getOrDefault(type, new HashMap<>()).remove(id);
}
if (!typeMap.containsKey(type))
typeMap.put(type, new Submap());
typeMap.get(type).idMap.put(id, value);
}
/**
* Registers a value for a specific mmoitem template
*
* @param type The item type
* @param id The template identifier
* @param value The value to registered
*/
public void setValue(@NotNull MMOItemType type, @NotNull String id, @NotNull C value) {
Validate.notNull(value, "Value cannot be null");
/**
* Applies a specific consumer for every template. This is used to postload
* all templates when MMOItems enables
*
* @param action
* Action performed for every registered template
*/
public void forEach(@NotNull Consumer<C> action) { typeMap.values().forEach(submap -> submap.idMap.values().forEach(action)); }
this.typeMap.computeIfAbsent(type, k -> new HashMap<>()).put(id, value);
}
/**
* @return Collects all the values registered in this template map.
*/
@NotNull public Collection<C> collectValues() {
Set<C> collected = new HashSet<>();
typeMap.values().forEach(submap -> collected.addAll(submap.idMap.values()));
return collected;
}
/**
* Applies a specific consumer for every template. This is used to postload
* all templates when MMOItems enables
*
* @param action Action performed for every registered template
*/
public void forEach(@NotNull Consumer<C> action) {
typeMap.values().forEach(stringCMap -> stringCMap.values().forEach(action));
}
/**
* @param type
* The item type
* @return Collects all the values registered in this template map with a
* specific item type
*/
@NotNull public Collection<C> collectValues(@NotNull Type type) {
return typeMap.containsKey(type) ? typeMap.get(type).idMap.values() : new HashSet<>();
}
/**
* @return Collects all the values registered in this template map.
*/
@NotNull
public Collection<C> collectValues() {
Set<C> collected = new HashSet<>();
typeMap.values().forEach(submap -> collected.addAll(submap.values()));
return collected;
}
/**
* Clears the map
*/
public void clear() { typeMap.clear(); }
/**
* @param type The item type
* @return Collects all the values registered in this template map with a
* specific item type
*/
@NotNull
public Collection<C> collectValues(@NotNull MMOItemType type) {
return typeMap.containsKey(type) ? typeMap.get(type).values() : new HashSet<>();
}
/**
* For memory leak purposes we cannot directly use a nested map into another
* map (must resort to using an object). No methods are required however
* because this class is completely private.
*
* @author cympe
*
*/
private class Submap {
private final Map<String, C> idMap = new LinkedHashMap<>();
}
/**
* Clears the map
*/
public void clear() {
typeMap.clear();
}
}

View File

@ -3,10 +3,10 @@ package net.Indyuce.mmoitems.command;
import io.lumine.mythic.lib.command.api.CommandTreeRoot;
import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.command.mmoitems.item.ItemCommandTreeNode;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.command.mmoitems.*;
import net.Indyuce.mmoitems.command.mmoitems.debug.DebugCommandTreeNode;
import net.Indyuce.mmoitems.command.mmoitems.item.ItemCommandTreeNode;
import net.Indyuce.mmoitems.command.mmoitems.list.ListCommandTreeNode;
import net.Indyuce.mmoitems.command.mmoitems.revid.RevisionIDCommandTreeNode;
import net.Indyuce.mmoitems.command.mmoitems.stations.StationsCommandTreeNode;
@ -17,7 +17,7 @@ public class MMOItemsCommandTreeRoot extends CommandTreeRoot {
(explorer, list) -> MMOItems.plugin.getTypes().getAll().forEach(type -> list.add(type.getId())));
public static final Parameter ID_2 = new Parameter("<id>", (explorer, list) -> {
try {
Type type = Type.get(explorer.getArguments()[1]);
MMOItemType type = MMOItemType.get(explorer.getArguments()[1]);
MMOItems.plugin.getTemplates().getTemplates(type).forEach(template -> list.add(template.getId()));
} catch (Exception ignored) {
}

View File

@ -1,15 +1,14 @@
package net.Indyuce.mmoitems.command.completion;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class UpdateItemCompletion implements TabCompleter {
@Override
@ -20,11 +19,11 @@ public class UpdateItemCompletion implements TabCompleter {
List<String> list = new ArrayList<>();
if (args.length == 1)
for (Type type : MMOItems.plugin.getTypes().getAll())
for (MMOItemType type : MMOItems.plugin.getTypes().getAll())
list.add(type.getId());
if (args.length == 2 && Type.isValid(args[0]))
Type.get(args[0]).getConfigFile().getConfig().getKeys(false).forEach(id -> list.add(id.toUpperCase()));
if (args.length == 2 && MMOItemType.isValid(args[0]))
MMOItemType.get(args[0]).getConfigFile().getConfig().getKeys(false).forEach(id -> list.add(id.toUpperCase()));
return args[args.length - 1].isEmpty() ? list : list.stream().filter(string -> string.toLowerCase().startsWith(args[args.length - 1].toLowerCase())).collect(Collectors.toList());
}

View File

@ -1,14 +1,13 @@
package net.Indyuce.mmoitems.command.mmoitems;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class AllItemsCommandTreeNode extends CommandTreeNode {
public AllItemsCommandTreeNode(CommandTreeNode parent) {
super(parent, "allitems");
@ -18,7 +17,7 @@ public class AllItemsCommandTreeNode extends CommandTreeNode {
public CommandResult execute(CommandSender sender, String[] args) {
sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
sender.sendMessage(ChatColor.GREEN + "List of all MMOItems:");
for (Type type : MMOItems.plugin.getTypes().getAll()) {
for (MMOItemType type : MMOItems.plugin.getTypes().getAll()) {
FileConfiguration config = type.getConfigFile().getConfig();
for (String s : config.getKeys(false))
sender.sendMessage("* " + ChatColor.GREEN + s

View File

@ -1,15 +1,14 @@
package net.Indyuce.mmoitems.command.mmoitems;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import net.Indyuce.mmoitems.gui.ItemBrowser;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.gui.ItemBrowser;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class BrowseCommandTreeNode extends CommandTreeNode {
public BrowseCommandTreeNode(CommandTreeNode parent) {
super(parent, "browse");
@ -29,12 +28,12 @@ public class BrowseCommandTreeNode extends CommandTreeNode {
return CommandResult.SUCCESS;
}
if (!Type.isValid(args[1])) {
if (!MMOItemType.isValid(args[1])) {
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Please specify a valid item type.");
return CommandResult.FAILURE;
}
new ItemBrowser((Player) sender, Type.get(args[1])).open();
new ItemBrowser((Player) sender, MMOItemType.get(args[1])).open();
return CommandResult.SUCCESS;
}
}

View File

@ -1,17 +1,16 @@
package net.Indyuce.mmoitems.command.mmoitems;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
public class CopyCommandTreeNode extends CommandTreeNode {
public CopyCommandTreeNode(CommandTreeNode parent) {
super(parent, "copy");
@ -27,7 +26,7 @@ public class CopyCommandTreeNode extends CommandTreeNode {
if (args.length < 4)
return CommandResult.THROW_USAGE;
if (!Type.isValid(args[1])) {
if (!MMOItemType.isValid(args[1])) {
sender.sendMessage(
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
sender.sendMessage(MMOItems.plugin.getPrefix() + "Type " + ChatColor.GREEN + "/mi list type " + ChatColor.GRAY
@ -35,7 +34,7 @@ public class CopyCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
Type type = Type.get(args[1]);
MMOItemType type = MMOItemType.get(args[1]);
ConfigFile config = type.getConfigFile();
String id1 = args[2].toUpperCase().replace("-", "_");
if (!config.getConfig().contains(id1)) {

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
import org.bukkit.ChatColor;
@ -24,7 +24,7 @@ public class CreateCommandTreeNode extends CommandTreeNode {
if (args.length < 3)
return CommandResult.THROW_USAGE;
if (!Type.isValid(args[1])) {
if (!MMOItemType.isValid(args[1])) {
sender.sendMessage(
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED
@ -32,7 +32,7 @@ public class CreateCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
Type type = Type.get(args[1]);
MMOItemType type = MMOItemType.get(args[1]);
String name = args[2].toUpperCase().replace("-", "_");
ConfigFile config = type.getConfigFile();
if (config.getConfig().contains(name)) {

View File

@ -1,13 +1,12 @@
package net.Indyuce.mmoitems.command.mmoitems;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class DeleteCommandTreeNode extends CommandTreeNode {
public DeleteCommandTreeNode(CommandTreeNode parent) {
super(parent, "delete");
@ -21,7 +20,7 @@ public class DeleteCommandTreeNode extends CommandTreeNode {
if (args.length < 3)
return CommandResult.THROW_USAGE;
if (!Type.isValid(args[1])) {
if (!MMOItemType.isValid(args[1])) {
sender.sendMessage(
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED
@ -29,7 +28,7 @@ public class DeleteCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
Type type = Type.get(args[1]);
MMOItemType type = MMOItemType.get(args[1]);
String id = args[2].toUpperCase().replace("-", "_");
if (!MMOItems.plugin.getTemplates().hasTemplate(type, id)) {
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item called " + id + ".");

View File

@ -1,21 +1,16 @@
package net.Indyuce.mmoitems.command.mmoitems;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import org.bukkit.*;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
public class DropCommandTreeNode extends CommandTreeNode {
public DropCommandTreeNode(CommandTreeNode parent) {
super(parent, "drop");
@ -36,7 +31,7 @@ public class DropCommandTreeNode extends CommandTreeNode {
if (args.length != 10)
return CommandResult.THROW_USAGE;
if (!Type.isValid(args[1])) {
if (!MMOItemType.isValid(args[1])) {
sender.sendMessage(
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type " + ChatColor.RED
@ -44,7 +39,7 @@ public class DropCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
Type type = Type.get(args[1].toUpperCase());
MMOItemType type = MMOItemType.get(args[1].toUpperCase());
String name = args[2].toUpperCase().replace("-", "_");
FileConfiguration config = type.getConfigFile().getConfig();
if (!config.contains(name)) {

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.command.mmoitems;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
import org.bukkit.ChatColor;
@ -27,7 +27,7 @@ public class EditCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
if (!Type.isValid(args[1])) {
if (!MMOItemType.isValid(args[1])) {
sender.sendMessage(
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED
@ -35,7 +35,7 @@ public class EditCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
Type type = Type.get(args[1]);
MMOItemType type = MMOItemType.get(args[1]);
String id = args[2].toUpperCase().replace("-", "_");
if (!MMOItems.plugin.getTemplates().hasTemplate(type, id)) {
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Could not find a template called '" + id + "'.");

View File

@ -6,9 +6,9 @@ import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.template.explorer.*;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import org.apache.commons.lang.Validate;
@ -68,8 +68,8 @@ public class GenerateCommandTreeNode extends CommandTreeNode {
}
if (handler.hasArgument("type")) {
type = handler.getValue("type");
Validate.isTrue(Type.isValid(type), "Could not find type with ID '" + type + "'");
builder.applyFilter(new TypeFilter(Type.get(type)));
Validate.isTrue(MMOItemType.isValid(type), "Could not find type with ID '" + type + "'");
builder.applyFilter(new TypeFilter(MMOItemType.get(type)));
}
if (handler.hasArgument("id")) {
Validate.isTrue(type != null, "You have to specify a type if using the id option!");

View File

@ -1,5 +1,13 @@
package net.Indyuce.mmoitems.command.mmoitems;
import io.lumine.mythic.lib.api.util.SmartGive;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.util.RandomAmount;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -8,15 +16,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
import net.Indyuce.mmoitems.api.util.RandomAmount;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import io.lumine.mythic.lib.api.util.SmartGive;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
public class GiveAllCommandTreeNode extends CommandTreeNode {
public GiveAllCommandTreeNode(CommandTreeNode parent) {
super(parent, "giveall");
@ -33,7 +32,7 @@ public class GiveAllCommandTreeNode extends CommandTreeNode {
Validate.isTrue(args.length > 4, "Usage: /mi giveall <type> <item-id> <min-max> <unidentified-chance>");
// item
Type type = MMOItems.plugin.getTypes().getOrThrow(args[1]);
MMOItemType type = MMOItems.plugin.getTypes().getOrThrow(args[1]);
ItemStack item = new MMOItemDropItem(type, args[2], 1, Double.parseDouble(args[4]) / 100, new RandomAmount(args[3])).getItem(null);
Validate.isTrue(item != null && item.getType() != Material.AIR, "Couldn't find/generate the item called '" + args[1].toUpperCase()
+ "'. Check your console for potential item generation issues.");

View File

@ -5,9 +5,9 @@ import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.RandomAmount;
import net.Indyuce.mmoitems.api.util.message.Message;
@ -54,7 +54,7 @@ public class GiveCommandTreeNode extends CommandTreeNode {
Validate.notNull(target, "Could not find player called '" + args[args.length > 3 ? 3 : 2] + "'.");
// item
Type type = MMOItems.plugin.getTypes().getOrThrow(args[1].toUpperCase().replace("-", "_"));
MMOItemType type = MMOItems.plugin.getTypes().getOrThrow(args[1].toUpperCase().replace("-", "_"));
MMOItemTemplate template = MMOItems.plugin.getTemplates().getTemplateOrThrow(type, args[2].toUpperCase().replace("-", "_"));
RandomAmount amount = args.length > 4 ? new RandomAmount(args[4]) : new RandomAmount(1, 1);
double unidentify = args.length > 5 ? Double.parseDouble(args[5]) / 100 : 0;

View File

@ -1,16 +1,15 @@
package net.Indyuce.mmoitems.command.mmoitems;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class ItemListCommandTreeNode extends CommandTreeNode {
public ItemListCommandTreeNode(CommandTreeNode parent) {
super(parent, "itemlist");
@ -23,7 +22,7 @@ public class ItemListCommandTreeNode extends CommandTreeNode {
if (args.length < 2)
return CommandResult.THROW_USAGE;
if (!Type.isValid(args[1])) {
if (!MMOItemType.isValid(args[1])) {
sender.sendMessage(
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_"));
sender.sendMessage(MMOItems.plugin.getPrefix() + "Type " + ChatColor.GREEN + "/mi list type " + ChatColor.GRAY
@ -31,7 +30,7 @@ public class ItemListCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
Type type = Type.get(args[1]);
MMOItemType type = MMOItemType.get(args[1]);
sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
sender.sendMessage(ChatColor.GREEN + "List of all items in " + type.getId().toLowerCase() + ".yml:");
FileConfiguration config = type.getConfigFile().getConfig();

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
@ -36,7 +36,7 @@ public class TakeCommandTreeNode extends CommandTreeNode {
try {
// Target item & player
final Type type = MMOItems.plugin.getTypes().getOrThrow(args[1].toUpperCase().replace("-", "_"));
final MMOItemType type = MMOItems.plugin.getTypes().getOrThrow(args[1].toUpperCase().replace("-", "_"));
final String id = args[2].toUpperCase().replace("-", "_");
final Player target = Bukkit.getPlayer(args[3]);
Validate.notNull(target, "Could not find player called '" + args[3] + "'.");

View File

@ -1,12 +1,11 @@
package net.Indyuce.mmoitems.command.mmoitems.list;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class TypeCommandTreeNode extends CommandTreeNode {
public TypeCommandTreeNode(CommandTreeNode parent) {
super(parent, "type");
@ -17,7 +16,7 @@ public class TypeCommandTreeNode extends CommandTreeNode {
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Item Types "
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + ChatColor.LIGHT_PURPLE + " Item Types " + ChatColor.DARK_GRAY + ""
+ ChatColor.STRIKETHROUGH + "]-----------------");
for (Type type : MMOItems.plugin.getTypes().getAll())
for (MMOItemType type : MMOItems.plugin.getTypes().getAll())
sender.sendMessage("* " + ChatColor.LIGHT_PURPLE + type.getName() + " (" + type.getId() + ")");
return CommandResult.SUCCESS;
}

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmoitems.command.mmoitems.revid;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -28,13 +28,13 @@ public class RevIDActionCommandTreeNode extends CommandTreeNode {
public CommandResult execute(CommandSender sender, String[] args) {
if (args.length < 3) return CommandResult.THROW_USAGE;
if (!Type.isValid(args[2]) && !args[2].equalsIgnoreCase("all")) {
if (!MMOItemType.isValid(args[2]) && !args[2].equalsIgnoreCase("all")) {
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[2].toUpperCase().replace("-", "_") + ".");
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED + " to see all the available item types.");
return CommandResult.FAILURE;
}
Type type = args[2].equalsIgnoreCase("all") ? null : Type.get(args[2]);
MMOItemType type = args[2].equalsIgnoreCase("all") ? null : MMOItemType.get(args[2]);
List<MMOItemTemplate> templates = new ArrayList<>(type == null ? MMOItems.plugin.getTemplates().collectTemplates() : MMOItems.plugin.getTemplates().getTemplates(type));
int failed = 0;
for(MMOItemTemplate template : templates) {

View File

@ -2,17 +2,16 @@ package net.Indyuce.mmoitems.comp;
import io.lumine.mythic.lib.metrics.bukkit.Metrics;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
public class MMOItemsMetrics extends Metrics {
public MMOItemsMetrics() {
super(MMOItems.plugin);
addCustomChart(new Metrics.SingleLineChart("items", () -> {
int total = 0;
for (Type type : MMOItems.plugin.getTypes().getAll())
total += type.getConfigFile().getConfig().getKeys(false).size();
return total;
}));
addCustomChart(new Metrics.SingleLineChart("items", () -> MMOItems.plugin.getTypes().getAll()
.stream()
.map(MMOItemType::getConfigFile)
.map(configFile -> configFile.getConfig().getKeys(false).size())
.reduce(0, Integer::sum)));
}
}

View File

@ -1,7 +1,8 @@
package net.Indyuce.mmoitems.comp;
import java.util.List;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import org.black_ixx.bossshop.core.BSBuy;
import org.black_ixx.bossshop.core.rewards.BSRewardType;
import org.black_ixx.bossshop.managers.ClassManager;
@ -10,9 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.player.PlayerData;
import java.util.List;
public class MMOItemsRewardTypes extends BSRewardType {
@ -49,7 +48,7 @@ public class MMOItemsRewardTypes extends BSRewardType {
for (String item : (List<String>) reward)
try {
String[] split = item.split("\\.");
Type type = MMOItems.plugin.getTypes().get(split[0].toUpperCase().replace("-", "_"));
MMOItemType type = MMOItems.plugin.getTypes().get(split[0].toUpperCase().replace("-", "_"));
for (ItemStack drop : player.getInventory().addItem(MMOItems.plugin.getItem(type, split[1], PlayerData.get(player)))
.values())
player.getWorld().dropItem(player.getLocation(), drop);

View File

@ -7,7 +7,7 @@ import com.denizenscript.denizencore.objects.core.MapTag;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.denizencore.tags.TagManager;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
public class DenizenHook {
/**
@ -53,7 +53,7 @@ public class DenizenHook {
}
String typeName = type.toString().replace("-", "_").toUpperCase();
Type parsedType = MMOItems.plugin.getTypes().get(typeName);
MMOItemType parsedType = MMOItems.plugin.getTypes().get(typeName);
if (parsedType == null) {
attribute.echoError("Invalid type - cannot find type with name '" + typeName + "'");
return null;

View File

@ -10,19 +10,19 @@ import com.denizenscript.denizencore.tags.ObjectTagProcessor;
import com.denizenscript.denizencore.tags.TagContext;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import java.util.Random;
public class MMOItemTemplateTag extends SimpleTag {
private final Type type;
private final MMOItemType type;
private final String id;
private static final Random random = new Random();
public MMOItemTemplateTag(Type type, String id) {
public MMOItemTemplateTag(MMOItemType type, String id) {
this.type = type;
this.id = id;
}
@ -134,7 +134,7 @@ public class MMOItemTemplateTag extends SimpleTag {
String typeId = split[0];
String itemId = split[1];
Type type = MMOItems.plugin.getTypes().getOrThrow(typeId);
MMOItemType type = MMOItems.plugin.getTypes().getOrThrow(typeId);
MMOItems.plugin.getTemplates().getTemplateOrThrow(type, itemId);
return new MMOItemTemplateTag(type, itemId);

View File

@ -1,22 +1,21 @@
package net.Indyuce.mmoitems.comp.mmocore.load;
import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.comp.citizens.CitizenInteractEvent;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.comp.citizens.CitizenInteractEvent;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.item.NBTItem;
public class GetMMOItemObjective extends Objective {
private final Type type;
private final MMOItemType type;
private final String id;
private final int required, npcId;

View File

@ -1,18 +1,17 @@
package net.Indyuce.mmoitems.comp.mmocore.load;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.api.player.PlayerData;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.loot.LootBuilder;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.stat.data.SoulboundData;
import io.lumine.mythic.lib.api.MMOLineConfig;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
public class ItemTemplateDropItem extends ItemGenerationDropItem {
private final MMOItemTemplate template;
@ -24,7 +23,7 @@ public class ItemTemplateDropItem extends ItemGenerationDropItem {
String format = config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_");
Validate.isTrue(MMOItems.plugin.getTypes().has(format), "Could not find item type with ID '" + format + "'");
Type type = MMOItems.plugin.getTypes().get(format);
MMOItemType type = MMOItems.plugin.getTypes().get(format);
String id = config.getString("id").replace("-", "_").toUpperCase();
Validate.isTrue(MMOItems.plugin.getTemplates().hasTemplate(type, id), "Could not find MMOItem with ID '" + id + "'");

View File

@ -5,8 +5,8 @@ import io.lumine.mythic.lib.api.util.SmartGive;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
@ -21,7 +21,7 @@ public class MMOItemTrigger extends Trigger {
String format = config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_");
Validate.isTrue(MMOItems.plugin.getTypes().has(format), "Could not find item type with ID '" + format + "'");
Type type = MMOItems.plugin.getTypes().get(format);
MMOItemType type = MMOItems.plugin.getTypes().get(format);
String id = config.getString("id").replace("-", "_").toUpperCase();
Validate.isTrue(MMOItems.plugin.getTemplates().hasTemplate(type, id), "Could not find MMOItem with ID '" + id + "'");

View File

@ -6,13 +6,13 @@ import net.Indyuce.mmocore.loot.LootBuilder;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.template.explorer.ClassFilter;
import net.Indyuce.mmoitems.api.item.template.explorer.TemplateExplorer;
import net.Indyuce.mmoitems.api.item.template.explorer.TierFilter;
import net.Indyuce.mmoitems.api.item.template.explorer.TypeFilter;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.stat.data.SoulboundData;
@ -26,7 +26,7 @@ public class RandomItemDropItem extends ItemGenerationDropItem {
// generation options
private final boolean matchClass;
private final String profess;
private final Type type;
private final MMOItemType type;
private final ItemTier tier;
public RandomItemDropItem(MMOLineConfig config) {

View File

@ -8,7 +8,7 @@ import io.lumine.mythic.lib.manager.StatManager;
import io.lumine.mythic.lib.util.DefenseFormula;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@ -69,7 +69,7 @@ public class MMOItemsPlaceholders extends PlaceholderExpansion {
if(identifier.startsWith("type_")) {
String t = identifier.substring(5, identifier.lastIndexOf("_")).toUpperCase();
if(!MMOItems.plugin.getTypes().has(t)) return "Invalid type";
Type type = Type.get(t);
MMOItemType type = MMOItemType.get(t);
String pholder = identifier.substring(6 + t.length()).toLowerCase();
if ("total".equals(pholder))
return "" + MMOItems.plugin.getTemplates().getTemplates(type).size();

View File

@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.edition.NewItemEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
import net.Indyuce.mmoitems.stat.BrowserDisplayIDX;
import net.Indyuce.mmoitems.util.MMOUtils;
@ -32,7 +33,7 @@ import java.util.*;
public class ItemBrowser extends PluginInventory {
private final Map<String, ItemStack> cached = new LinkedHashMap<>();
private final Type type;
private final MMOItemType type;
private boolean deleteMode;
// Slots used to display items based on the item type explored
@ -43,7 +44,7 @@ public class ItemBrowser extends PluginInventory {
this(player, null);
}
public ItemBrowser(Player player, Type type) {
public ItemBrowser(Player player, MMOItemType type) {
super(player);
this.type = type;
@ -72,11 +73,11 @@ public class ItemBrowser extends PluginInventory {
Inventory inv = Bukkit.createInventory(this, 54, "Item Explorer");
// Fetch the list of types
List<Type> types = new ArrayList<>(MMOItems.plugin.getTypes().getAll());
List<MMOItemType> types = new ArrayList<>(MMOItems.plugin.getTypes().getAll());
for (int j = min; j < Math.min(max, types.size()); j++) {
// Current type to display into the GUI
Type currentType = types.get(j);
MMOItemType currentType = types.get(j);
// Get number of items
int items = MMOItems.plugin.getTemplates().getTemplates(currentType).size();
@ -326,7 +327,7 @@ public class ItemBrowser extends PluginInventory {
return inv;
}
public Type getType() {
public MMOItemType getType() {
return type;
}

View File

@ -40,7 +40,7 @@ public class ItemEdition extends EditionInventory {
* it has to determine what stats can be applied first because otherwise
* the for loop will just let some slots empty
*/
List<ItemStat> appliable = new ArrayList<>(getEdited().getType().getAvailableStats()).stream()
List<ItemStat<?, ?>> appliable = new ArrayList<>(getEdited().getType().getStats()).stream()
.filter(stat -> stat.hasValidMaterial(getCachedItem()) && !(stat instanceof InternalStat)).toList();
Inventory inv = Bukkit.createInventory(this, 54, "Item Edition: " + getEdited().getId());

View File

@ -17,6 +17,7 @@ import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.Staff;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import org.bukkit.Bukkit;
@ -242,7 +243,7 @@ public class ItemUse implements Listener {
if (!picked.hasType())
return;
GemStone.ApplyResult result = ((GemStone) useItem).applyOntoItem(picked, Type.get(picked.getType()));
GemStone.ApplyResult result = ((GemStone) useItem).applyOntoItem(picked, MMOItemType.get(picked.getType()));
if (result.getType() == GemStone.ResultType.NONE)
return;

View File

@ -1,10 +1,9 @@
package net.Indyuce.mmoitems.manager;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.bukkit.inventory.ItemStack;
/**
* ItemStack and MMOItem getters were moved over to MMOItems. There is no longer
@ -22,7 +21,7 @@ public class ItemManager {
* @deprecated Use MMOItems.plugin.getMMOItem(Type, String) instead
*/
@Deprecated
public MMOItem getMMOItem(Type type, String id) {
public MMOItem getMMOItem(MMOItemType type, String id) {
return MMOItems.plugin.getMMOItem(type, id);
}
@ -33,7 +32,7 @@ public class ItemManager {
* @deprecated Use MMOItems.plugin.getItem(Type, String) instead
*/
@Deprecated
public ItemStack getItem(Type type, String id) {
public ItemStack getItem(MMOItemType type, String id) {
return MMOItems.plugin.getItem(type, id);
}
}

View File

@ -5,7 +5,7 @@ import io.lumine.mythic.lib.skill.handler.SkillHandler;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.PluginUpdate;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.skill.RegisteredSkill;
import net.md_5.bungee.api.ChatColor;
import org.apache.commons.lang.Validate;
@ -32,7 +32,7 @@ public class PluginUpdateManager {
new String[]{"Applies a fix for skull textures values in 4.7.1.", "Texture values data storage changed in 4.7.1 due to the UUID change."},
sender -> {
for (Type type : MMOItems.plugin.getTypes().getAll()) {
for (MMOItemType type : MMOItems.plugin.getTypes().getAll()) {
ConfigFile config = type.getConfigFile();
for (String key : config.getConfig().getKeys(false)) {
ConfigurationSection section = config.getConfig().getConfigurationSection(key);
@ -130,7 +130,7 @@ public class PluginUpdateManager {
register(new PluginUpdate(5, new String[]{"Transition to trigger types in 6.6.3", "Only scans through item configs"}, sender -> {
for (Type type : MMOItems.plugin.getTypes().getAll()) {
for (MMOItemType type : MMOItems.plugin.getTypes().getAll()) {
ConfigFile config = type.getConfigFile();
for (String id : config.getConfig().getKeys(false)) {
ConfigurationSection itemConfig = config.getConfig().getConfigurationSection(id);
@ -153,7 +153,7 @@ public class PluginUpdateManager {
sender -> {
// fixes stat formats
for (Type type : MMOItems.plugin.getTypes().getAll()) {
for (MMOItemType type : MMOItems.plugin.getTypes().getAll()) {
ConfigFile config = type.getConfigFile();
for (String id : config.getConfig().getKeys(false)) {

View File

@ -10,10 +10,10 @@ import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackMessage;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.crafting.MMOItemUIFilter;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.recipe.workbench.ingredients.AirIngredient;
import net.Indyuce.mmoitems.api.recipe.workbench.ingredients.MMOItemIngredient;
import net.Indyuce.mmoitems.api.recipe.workbench.ingredients.VanillaIngredient;
@ -75,7 +75,7 @@ public class RecipeManager implements Reloadable {
ffp.activatePrefix(true, "Custom Crafting");
// Every single type yes
for (Type type : MMOItems.plugin.getTypes().getAll()) {
for (MMOItemType type : MMOItems.plugin.getTypes().getAll()) {
// Find their config
FileConfiguration config = type.getConfigFile().getConfig();
@ -198,7 +198,7 @@ public class RecipeManager implements Reloadable {
}
@NotNull
public NamespacedKey getRecipeKey(@NotNull Type type, @NotNull String id, @NotNull String recipeType, @NotNull String number) {
public NamespacedKey getRecipeKey(@NotNull MMOItemType type, @NotNull String id, @NotNull String recipeType, @NotNull String number) {
return new NamespacedKey(MMOItems.plugin, recipeType + "_" + type.getId() + "_" + id + "_" + number);
}
@ -364,7 +364,7 @@ public class RecipeManager implements Reloadable {
if (poof.getParent() instanceof MMOItemUIFilter) {
// Get those
Type miType = MMOItems.plugin.getTypes().getOrThrow(poof.getArgument());
MMOItemType miType = MMOItems.plugin.getTypes().getOrThrow(poof.getArgument());
// Find template
MMOItemTemplate mmo = MMOItems.plugin.getTemplates().getTemplateOrThrow(miType, poof.getData());

View File

@ -196,7 +196,7 @@ public class StatManager {
.getAll()
.stream()
.filter(stat::isCompatible)
.forEach(type -> type.getAvailableStats().add(stat));
.forEach(type -> type.getStats().add(stat));
}
private void registerCustomStat(@NotNull ConfigurationSection section) {

View File

@ -1,25 +1,27 @@
package net.Indyuce.mmoitems.manager;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackCategory;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.template.TemplateModifier;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.util.TemplateMap;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class TemplateManager implements Reloadable {
@ -42,7 +44,7 @@ public class TemplateManager implements Reloadable {
*
* @return If these two Strings represent a loaded MMOItem Template
*/
public boolean hasTemplate(@Nullable Type type, @Nullable String id) {
public boolean hasTemplate(@Nullable MMOItemType type, @Nullable String id) {
if (type == null || id == null) { return false; }
return templates.hasValue(type, id);
}
@ -54,7 +56,7 @@ public class TemplateManager implements Reloadable {
*/
public boolean hasTemplate(@Nullable NBTItem nbt) {
if (nbt == null) { return false; }
return hasTemplate(Type.get(nbt.getType()), nbt.getString("MMOITEMS_ITEM_ID"));
return hasTemplate(MMOItemType.get(nbt.getType()), nbt.getString("MMOITEMS_ITEM_ID"));
}
/**
@ -65,8 +67,10 @@ public class TemplateManager implements Reloadable {
*
* @return A template of these qualifications if it found them,
*/
@Nullable public MMOItemTemplate getTemplate(@Nullable Type type, @Nullable String id) {
if (type == null || id == null) { return null; }
@Nullable
@Contract("_, null -> null")
public MMOItemTemplate getTemplate(@Nullable MMOItemType type, @Nullable String id) {
if (type == null || id == null) return null;
return templates.getValue(type, id);
}
@ -77,9 +81,11 @@ public class TemplateManager implements Reloadable {
*
* @return The MMOItem Template parent of it, if it has any.
*/
@Nullable public MMOItemTemplate getTemplate(@Nullable NBTItem nbt) {
if (nbt == null) { return null; }
return getTemplate(Type.get(nbt.getType()), nbt.getString("MMOITEMS_ITEM_ID"));
@Nullable
@Contract("null -> null")
public MMOItemTemplate getTemplate(@Nullable NBTItem nbt) {
if (nbt == null) return null;
return getTemplate(MMOItemType.get(nbt.getType()), nbt.getString("MMOITEMS_ITEM_ID"));
}
/**
@ -89,18 +95,22 @@ public class TemplateManager implements Reloadable {
* @param id The item ID
* @return MMOItem template if it exists, or throws an IAE otherwise
*/
@NotNull public MMOItemTemplate getTemplateOrThrow(@Nullable Type type, @Nullable String id) {
@NotNull
@Contract("_, null -> fail")
public MMOItemTemplate getTemplateOrThrow(@Nullable MMOItemType type, @Nullable String id) {
Validate.isTrue(type != null && hasTemplate(type, id), "Could not find a template with ID '" + id + "'");
return templates.getValue(type, id);
}
@NotNull public Collection<MMOItemTemplate> getTemplates(@NotNull Type type) {
@NotNull public Collection<MMOItemTemplate> getTemplates(@NotNull MMOItemType type) {
return templates.collectValues(type);
}
@NotNull public ArrayList<String> getTemplateNames(@NotNull Type type) {
ArrayList<String> names = new ArrayList<>();
for (MMOItemTemplate t : templates.collectValues(type)) { names.add(t.getId()); }
return names;
@NotNull public List<String> getTemplateNames(@NotNull MMOItemType type) {
return this.templates.collectValues(type)
.stream()
.map(MMOItemTemplate::getId)
.collect(Collectors.toList());
}
/**
@ -122,7 +132,7 @@ public class TemplateManager implements Reloadable {
* @param type The item type
* @param id The item ID
*/
public void unregisterTemplate(@NotNull Type type, @NotNull String id) {
public void unregisterTemplate(@NotNull MMOItemType type, @NotNull String id) {
templates.removeValue(type, id);
}
@ -133,7 +143,7 @@ public class TemplateManager implements Reloadable {
* @param type The item type
* @param id The item ID
*/
public void deleteTemplate(@NotNull Type type, @NotNull String id) {
public void deleteTemplate(@NotNull MMOItemType type, @NotNull String id) {
unregisterTemplate(type, id);
ConfigFile config = type.getConfigFile();
@ -153,7 +163,7 @@ public class TemplateManager implements Reloadable {
* @param id The item ID
*/
@SuppressWarnings("UnusedReturnValue")
public MMOItemTemplate requestTemplateUpdate(@NotNull Type type, @NotNull String id) {
public MMOItemTemplate requestTemplateUpdate(@NotNull MMOItemType type, @NotNull String id) {
templates.removeValue(type, id);
try {
@ -220,7 +230,7 @@ public class TemplateManager implements Reloadable {
* are initialized
*/
public void preloadTemplates() {
for (Type type : MMOItems.plugin.getTypes().getAll()) {
for (MMOItemType type : MMOItems.plugin.getTypes().getAll()) {
FileConfiguration config = type.getConfigFile().getConfig();
for (String key : config.getKeys(false))
try {
@ -235,7 +245,6 @@ public class TemplateManager implements Reloadable {
* Loads item generator modifiers and post load item templates.
*/
public void postloadTemplates() {
FriendlyFeedbackProvider ffp = new FriendlyFeedbackProvider(FFPMMOItems.get());
ffp.activatePrefix(true, "Item Templates");
ffp.log(FriendlyFeedbackCategory.INFORMATION, "Loading template modifiers, please wait..");
@ -296,7 +305,7 @@ public class TemplateManager implements Reloadable {
ffp.activatePrefix(true, "Item Templates");
ffp.log(FriendlyFeedbackCategory.INFORMATION, "Loading item templates, please wait...");
for (Type type : MMOItems.plugin.getTypes().getAll()) {
for (MMOItemType type : MMOItems.plugin.getTypes().getAll()) {
FileConfiguration config = type.getConfigFile().getConfig();
ffp.activatePrefix(true, "Item Templates \u00a78($r" + type.getId() + "\u00a78)");
for (String key : config.getKeys(false))

View File

@ -40,13 +40,12 @@ public class TypeManager implements Reloadable {
.filter(typesSection::isConfigurationSection)
.map(typesSection::getConfigurationSection)
.filter(Objects::nonNull)
.map(s -> MMOItemType.load(this, s))
.map(MMOItemType::load)
.peek(this.types::add)
.peek(mmoItemType -> mmoItemType.getStats().clear())
.forEach(mmoItemType -> MMOItems.plugin.getStats()
.getAll()
.forEach(stat -> mmoItemType.getStats().add(stat)));
// TODO: Add stats from type category
// DEBUG
MMOItems.log("Loaded " + this.types.size() + " item types.");

View File

@ -41,7 +41,7 @@ public class BrowserDisplayIDX extends DoubleStat {
if (template == null) { continue; }
Double armorIDX = null;
if (template.getType().getAvailableStats().contains(ItemStats.BROWSER_DISPLAY_IDX)) {
if (template.getType().getStats().contains(ItemStats.BROWSER_DISPLAY_IDX)) {
NumericStatFormula indexData = (NumericStatFormula) template.getBaseItemData().get(ItemStats.BROWSER_DISPLAY_IDX);
// Get value if it existed

View File

@ -1,7 +1,16 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.event.item.DeconstructItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.type.BooleanStat;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -9,20 +18,10 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.DeconstructItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.type.BooleanStat;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import io.lumine.mythic.lib.api.item.NBTItem;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CanDeconstruct extends BooleanStat implements ConsumableItemInteraction {
public CanDeconstruct() {
super("CAN_DECONSTRUCT", Material.PAPER, "Can Deconstruct?",
@ -31,7 +30,7 @@ public class CanDeconstruct extends BooleanStat implements ConsumableItemInterac
}
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, MMOItemType targetType) {
String itemTierTag = target.getString("MMOITEMS_TIER");
if (itemTierTag.equals("") || !consumable.getNBTItem().getBoolean("MMOITEMS_CAN_DECONSTRUCT"))
return false;

View File

@ -7,6 +7,7 @@ import io.lumine.mythic.lib.api.util.SmartGive;
import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.interaction.Consumable;
@ -37,7 +38,7 @@ public class CanDeskin extends BooleanStat implements ConsumableItemInteraction
}
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, MMOItemType targetType) {
final String skinId = target.getString("MMOITEMS_SKIN_ID");
Player player = playerData.getPlayer();

View File

@ -1,22 +1,21 @@
package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.api.event.item.IdentifyItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.item.util.identify.IdentifiedItem;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.type.BooleanStat;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.IdentifyItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.util.identify.IdentifiedItem;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.type.BooleanStat;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import io.lumine.mythic.lib.api.item.NBTItem;
import org.jetbrains.annotations.NotNull;
public class CanIdentify extends BooleanStat implements ConsumableItemInteraction {
@ -26,7 +25,7 @@ public class CanIdentify extends BooleanStat implements ConsumableItemInteractio
}
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, MMOItemType targetType) {
if (targetType != null)
return false;

View File

@ -2,18 +2,18 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.data.GemSocketsData;
import net.Indyuce.mmoitems.stat.data.GemstoneData;
import net.Indyuce.mmoitems.stat.type.BooleanStat;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.util.Pair;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -37,7 +37,7 @@ public class CanUnsocket extends BooleanStat implements ConsumableItemInteractio
}
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, MMOItemType targetType) {
/*
* Cancel if the target is just not an MMOItem

View File

@ -1,36 +1,30 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import io.lumine.mythic.lib.api.util.AltChar;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.TypeSet;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.stat.data.StringData;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.StringListData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.TypeSet;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.StringListData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.StringStat;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.util.AltChar;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class ItemTypeRestriction extends ItemStat<StringListData, StringListData> {
public ItemTypeRestriction() {
super("ITEM_TYPE_RESTRICTION", Material.EMERALD, "Item Type Restriction",
@ -191,7 +185,7 @@ public class ItemTypeRestriction extends ItemStat<StringListData, StringListData
if (format.equals("WEAPON"))
return true;
for (Type type : MMOItems.plugin.getTypes().getAll())
for (MMOItemType type : MMOItems.plugin.getTypes().getAll())
if (type.getId().equals(format))
return true;

View File

@ -4,12 +4,11 @@ import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.data.DoubleData;
@ -18,6 +17,7 @@ import net.Indyuce.mmoitems.stat.data.GemstoneData;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.stat.type.StatHistory;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.util.Pair;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -45,7 +45,7 @@ public class RandomUnsocket extends DoubleStat implements ConsumableItemInteract
}
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, MMOItemType targetType) {
/*
* Must also check that the consumable itself does have this stat... bruh

View File

@ -2,9 +2,9 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.interaction.util.DurabilityItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.listener.CustomSoundListener;
@ -29,7 +29,7 @@ public class RepairPower extends DoubleStat implements ConsumableItemInteraction
private static final String REPAIR_TYPE_TAG = "MMOITEMS_REPAIR_TYPE";
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, MMOItemType targetType) {
int repairPower = (int) consumable.getNBTItem().getStat(ItemStats.REPAIR.getId());
if (repairPower <= 0)
return false;

View File

@ -2,9 +2,9 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.interaction.util.DurabilityItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.listener.CustomSoundListener;
@ -30,7 +30,7 @@ public class RepairPowerPercent extends DoubleStat implements ConsumableItemInte
private static final String REPAIR_TYPE_TAG = "MMOITEMS_REPAIR_TYPE";
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, @Nullable Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, @Nullable MMOItemType targetType) {
final double repairPower = consumable.getNBTItem().getStat(ItemStats.REPAIR_PERCENT.getId());
if (repairPower <= 0)
return false;

View File

@ -3,18 +3,18 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.BreakSoulboundEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.data.SoulboundData;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
@ -35,7 +35,7 @@ public class SoulbindingBreakChance extends DoubleStat implements ConsumableItem
}
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, MMOItemType targetType) {
Player player = playerData.getPlayer();
double soulboundBreakChance = consumable.getNBTItem().getStat("SOULBOUND_BREAK_CHANCE");

View File

@ -3,18 +3,18 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.ApplySoulboundEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.data.SoulboundData;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
@ -35,7 +35,7 @@ public class SoulbindingChance extends DoubleStat implements ConsumableItemInter
}
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, @Nullable Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, @Nullable MMOItemType targetType) {
Player player = playerData.getPlayer();
// Only MMOItems

View File

@ -8,8 +8,6 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.UpgradeItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
@ -17,6 +15,7 @@ import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
@ -25,6 +24,7 @@ import net.Indyuce.mmoitems.stat.data.UpgradeData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -183,7 +183,7 @@ public class UpgradeStat extends ItemStat<UpgradeData, UpgradeData> implements C
public UpgradeData getClearStatData() { return new UpgradeData(null, null, false, false, 0, 0, 0D); }
@Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) {
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, MMOItemType targetType) {
VolatileMMOItem mmoitem = consumable.getMMOItem();
Player player = playerData.getPlayer();

View File

@ -1,11 +1,10 @@
package net.Indyuce.mmoitems.stat.type;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.player.PlayerData;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.api.player.PlayerData;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -31,5 +30,5 @@ public interface ConsumableItemInteraction {
* (basically return true if it should be the only
* consumable effect applied).
*/
boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, @Nullable Type targetType);
boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, @Nullable MMOItemType targetType);
}

View File

@ -2,9 +2,9 @@ package net.Indyuce.mmoitems.stat.type;
import io.lumine.mythic.lib.api.item.ItemTag;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
@ -166,7 +166,7 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
/**
* @return The stat ID
* @deprecated Use getId() instead. Type is no longer an util since they can
* now be registered from external plugins
* now be registered from external plugins
*/
@Deprecated
@NotNull
@ -184,8 +184,8 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
/**
* @return The NBT path used by the stat to save data in an item's NBTTags.
* The format is 'MMOITEMS_' followed by the stat name in capital
* letters only using _
* The format is 'MMOITEMS_' followed by the stat name in capital
* letters only using _
*/
@NotNull
public String getNBTPath() {
@ -212,10 +212,9 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
* @param type The item type to check
* @return If a certain item type is compatible with this item stat
*/
public boolean isCompatible(Type type) {
public boolean isCompatible(MMOItemType type) {
String lower = type.getId().toLowerCase();
return type.isSubtype() ? isCompatible(type.getParent())
: !compatibleTypes.contains("!" + lower) && (compatibleTypes.contains("all") || compatibleTypes.contains(lower)
return !compatibleTypes.contains("!" + lower) && (compatibleTypes.contains("all") || compatibleTypes.contains(lower)
|| compatibleTypes.contains(type.getItemSet().getName().toLowerCase()));
}

View File

@ -10,6 +10,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.type.MMOItemType;
import org.apache.commons.codec.binary.Base64;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@ -25,6 +26,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
@ -190,10 +192,10 @@ public class MMOUtils {
* @return The MMOItem Type of this item, if it is a MMOItem
*/
@Nullable
public static Type getType(@Nullable NBTItem nbtItem) {
@Contract("null -> null")
public static MMOItemType getType(@Nullable NBTItem nbtItem) {
if (nbtItem == null || !nbtItem.hasType())
return null;
// Try that one instead
return MMOItems.plugin.getTypes().get(nbtItem.getType());
}

View File

@ -1,12 +0,0 @@
SPLASHING:
# The display parameter is used to display the item in both
# the item brower and the recipe list when shifting a
# workbench. You can use durability for custom textures.
# In 1.14, durability is replaced by CustomModelData.
display: IRON_SWORD:0
# Name displayed in the item lore.
name: 'Splashing'
lore-format: ""