mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-23 04:47:34 +01:00
!New item level stat
This commit is contained in:
parent
f4b8a1c321
commit
ab9eec1412
@ -41,7 +41,7 @@ public class ItemStackBuilder {
|
||||
private static final AttributeModifier fakeModifier = new AttributeModifier(UUID.fromString("87851e28-af12-43f6-898e-c62bde6bd0ec"),
|
||||
"mmoitemsDecoy", 0, Operation.ADD_NUMBER);
|
||||
|
||||
/***
|
||||
/**
|
||||
* Used to build an MMOItem into an ItemStack
|
||||
*
|
||||
* @param mmoitem
|
||||
@ -106,9 +106,9 @@ public class ItemStackBuilder {
|
||||
meta.setLore(lore.build().toStringList());
|
||||
|
||||
/*
|
||||
* this tag is added to entirely override default vanilla item attribute
|
||||
* This tag is added to entirely override default vanilla item attribute
|
||||
* modifiers, this way armor gives no ARMOR or ARMOR TOUGHNESS to the
|
||||
* holder. since 4.7 attributes are handled via custom calculations
|
||||
* holder. Since 4.7 attributes are handled via custom calculations
|
||||
*/
|
||||
try {
|
||||
|
||||
@ -117,7 +117,7 @@ public class ItemStackBuilder {
|
||||
return MMOLib.plugin.getVersion().getWrapper().getNBTItem(item).addTag(tags);
|
||||
|
||||
/*
|
||||
* on legacy spigot, it is not required to add a fake modifier to
|
||||
* On legacy spigot, it is not required to add a fake modifier to
|
||||
* the modifier list, so just override the string tag and it works
|
||||
* fine.
|
||||
*/
|
||||
|
@ -15,6 +15,7 @@ import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate.TemplateOption;
|
||||
import net.Indyuce.mmoitems.api.item.template.NameModifier;
|
||||
import net.Indyuce.mmoitems.api.item.template.NameModifier.ModifierType;
|
||||
import net.Indyuce.mmoitems.api.item.template.TemplateModifier;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.StringData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.Mergeable;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
@ -61,6 +62,7 @@ public class MMOItemBuilder {
|
||||
|
||||
if (tier != null)
|
||||
mmoitem.setData(ItemStat.TIER, new StringData(tier.getId()));
|
||||
mmoitem.setData(ItemStat.ITEM_LEVEL, new DoubleData(level));
|
||||
|
||||
// roll item gen modifiers
|
||||
for (TemplateModifier modifier : rollModifiers(template)) {
|
||||
|
@ -10,6 +10,14 @@ import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class LiveMMOItem extends ReadMMOItem {
|
||||
|
||||
/**
|
||||
* This class is used to load ALL the data from an item in one constructor.
|
||||
* They should be used with care because it is quite performance heavy
|
||||
*
|
||||
* @param item
|
||||
* The item to read
|
||||
*/
|
||||
public LiveMMOItem(ItemStack item) {
|
||||
this(MMOLib.plugin.getVersion().getWrapper().getNBTItem(item));
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.Indyuce.mmoitems.api.item.mmoitem;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -15,12 +15,11 @@ public class MMOItem implements ItemReference {
|
||||
private final String id;
|
||||
|
||||
/*
|
||||
* where data about all the item stats is stored. when the item is
|
||||
* generated, this map is read and all the stats are applied. the order in
|
||||
* which stats are added is very important because the material needs to be
|
||||
* applied first
|
||||
* Where data about all the item stats is stored. When the item is
|
||||
* generated, this map is read and all the stats are applied. The order in
|
||||
* which stats are added is not very important anymore
|
||||
*/
|
||||
private final Map<ItemStat, StatData> stats = new LinkedHashMap<>();
|
||||
private final Map<ItemStat, StatData> stats = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructor used to generate an ItemStack based on some stat data
|
||||
|
26
src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java
Normal file
26
src/main/java/net/Indyuce/mmoitems/stat/ItemLevel.java
Normal file
@ -0,0 +1,26 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.InternalStat;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class ItemLevel extends InternalStat {
|
||||
public ItemLevel() {
|
||||
super("ITEM_LEVEL", VersionMaterial.EXPERIENCE_BOTTLE.toItem(), "Item Level", new String[] { "The item level" }, new String[] { "all" });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenApplied(ItemStackBuilder item, StatData data) {
|
||||
item.addItemTag(new ItemTag("MMOITEMS_ITEM_LEVEL", (int) ((DoubleData) data).getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenLoaded(ReadMMOItem mmoitem) {
|
||||
if (mmoitem.getNBT().hasTag("MMOITEMS_ITEM_LEVEL"))
|
||||
mmoitem.setData(this, new DoubleData(mmoitem.getNBT().getDouble("MMOITEMS_ITEM_LEVEL")));
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@ import net.Indyuce.mmoitems.stat.HideEnchants;
|
||||
import net.Indyuce.mmoitems.stat.HidePotionEffects;
|
||||
import net.Indyuce.mmoitems.stat.Inedible;
|
||||
import net.Indyuce.mmoitems.stat.ItemDamage;
|
||||
import net.Indyuce.mmoitems.stat.ItemLevel;
|
||||
import net.Indyuce.mmoitems.stat.ItemParticles;
|
||||
import net.Indyuce.mmoitems.stat.ItemSetStat;
|
||||
import net.Indyuce.mmoitems.stat.ItemTierStat;
|
||||
@ -273,6 +274,7 @@ public abstract class ItemStat {
|
||||
*/
|
||||
public static final Soulbound SOULBOUND = new Soulbound();
|
||||
public static final ItemStat STORED_TAGS = new StoredTags();
|
||||
public static final ItemStat ITEM_LEVEL = new ItemLevel();
|
||||
|
||||
private final String id, name;
|
||||
private final ItemStack item;
|
||||
|
Loading…
Reference in New Issue
Block a user