Get rid of INBTEditor interface
- The INBTEditor interface has been removed, as there's only a single implementation of it with absolutely no need to create any others in the future.
This commit is contained in:
parent
527d4c079c
commit
bd9380b538
@ -9,7 +9,6 @@ import nl.pim16aap2.armoredElytra.handlers.LoginHandler;
|
||||
import nl.pim16aap2.armoredElytra.handlers.NetheriteUpgradeListener;
|
||||
import nl.pim16aap2.armoredElytra.handlers.SmithingTableCraftHandler;
|
||||
import nl.pim16aap2.armoredElytra.handlers.Uninstaller;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTierName;
|
||||
@ -50,7 +49,7 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
||||
private final Map<ArmorTier, ArmorTierName> armorTierNames = new EnumMap<>(ArmorTier.class);
|
||||
private UpdateManager updateManager;
|
||||
|
||||
private INBTEditor nbtEditor;
|
||||
private NBTEditor nbtEditor;
|
||||
private DurabilityManager durabilityManager;
|
||||
|
||||
@Override
|
||||
@ -160,7 +159,7 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
||||
return messages;
|
||||
}
|
||||
|
||||
public INBTEditor getNbtEditor()
|
||||
public NBTEditor getNbtEditor()
|
||||
{
|
||||
return nbtEditor;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package nl.pim16aap2.armoredElytra.handlers;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.ArmoredElytra;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.Action;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.ConfigLoader;
|
||||
@ -28,12 +28,12 @@ import java.util.logging.Level;
|
||||
public class AnvilHandler extends ArmoredElytraHandler implements Listener
|
||||
{
|
||||
protected AnvilHandler(ArmoredElytra plugin, boolean creationEnabled,
|
||||
INBTEditor nbtEditor, DurabilityManager durabilityManager, ConfigLoader config)
|
||||
NBTEditor nbtEditor, DurabilityManager durabilityManager, ConfigLoader config)
|
||||
{
|
||||
super(plugin, creationEnabled, nbtEditor, durabilityManager, config);
|
||||
}
|
||||
|
||||
public AnvilHandler(ArmoredElytra plugin, INBTEditor nbtEditor,
|
||||
public AnvilHandler(ArmoredElytra plugin, NBTEditor nbtEditor,
|
||||
DurabilityManager durabilityManager, ConfigLoader config)
|
||||
{
|
||||
super(plugin, true, nbtEditor, durabilityManager, config);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package nl.pim16aap2.armoredElytra.handlers;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.ArmoredElytra;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.ConfigLoader;
|
||||
import nl.pim16aap2.armoredElytra.util.DurabilityManager;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -25,10 +25,10 @@ abstract class ArmoredElytraHandler
|
||||
protected final ArmoredElytra plugin;
|
||||
protected final boolean creationEnabled;
|
||||
protected final ConfigLoader config;
|
||||
protected final INBTEditor nbtEditor;
|
||||
protected final NBTEditor nbtEditor;
|
||||
protected final DurabilityManager durabilityManager;
|
||||
|
||||
protected ArmoredElytraHandler(ArmoredElytra plugin, boolean creationEnabled, INBTEditor nbtEditor,
|
||||
protected ArmoredElytraHandler(ArmoredElytra plugin, boolean creationEnabled, NBTEditor nbtEditor,
|
||||
DurabilityManager durabilityManager, ConfigLoader config)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package nl.pim16aap2.armoredElytra.handlers;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.ArmoredElytra;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.DurabilityManager;
|
||||
import nl.pim16aap2.armoredElytra.util.messages.Message;
|
||||
@ -23,11 +23,11 @@ import java.util.logging.Level;
|
||||
public class CommandHandler implements CommandExecutor
|
||||
{
|
||||
private final ArmoredElytra plugin;
|
||||
private final INBTEditor nbtEditor;
|
||||
private final NBTEditor nbtEditor;
|
||||
private final DurabilityManager durabilityManager;
|
||||
private static Field BY_KEY_FIELD;
|
||||
|
||||
public CommandHandler(ArmoredElytra plugin, INBTEditor nbtEditor, DurabilityManager durabilityManager)
|
||||
public CommandHandler(ArmoredElytra plugin, NBTEditor nbtEditor, DurabilityManager durabilityManager)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
this.nbtEditor = nbtEditor;
|
||||
|
@ -5,7 +5,7 @@ import nl.pim16aap2.armoredElytra.lib.armorequip.ArmorEquipEvent;
|
||||
import nl.pim16aap2.armoredElytra.lib.armorequip.ArmorListener;
|
||||
import nl.pim16aap2.armoredElytra.lib.armorequip.ArmorType;
|
||||
import nl.pim16aap2.armoredElytra.lib.armorequip.DispenserArmorListener;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.AllowedToWearEnum;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.DurabilityManager;
|
||||
@ -29,10 +29,10 @@ public class EventHandlers implements Listener
|
||||
{
|
||||
private final Random random = new Random();
|
||||
private final ArmoredElytra plugin;
|
||||
private final INBTEditor nbtEditor;
|
||||
private final NBTEditor nbtEditor;
|
||||
private final DurabilityManager durabilityManager;
|
||||
|
||||
public EventHandlers(ArmoredElytra plugin, INBTEditor nbtEditor, DurabilityManager durabilityManager)
|
||||
public EventHandlers(ArmoredElytra plugin, NBTEditor nbtEditor, DurabilityManager durabilityManager)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
this.nbtEditor = nbtEditor;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package nl.pim16aap2.armoredElytra.handlers;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.DurabilityManager;
|
||||
import nl.pim16aap2.armoredElytra.util.Util;
|
||||
@ -13,10 +13,10 @@ import org.bukkit.event.player.PlayerItemDamageEvent;
|
||||
public class FlyDurabilityHandler implements Listener
|
||||
{
|
||||
private final boolean disableDurability;
|
||||
private final INBTEditor nbtEditor;
|
||||
private final NBTEditor nbtEditor;
|
||||
private final DurabilityManager durabilityManager;
|
||||
|
||||
public FlyDurabilityHandler(boolean disableDurability, INBTEditor nbtEditor, DurabilityManager durabilityManager)
|
||||
public FlyDurabilityHandler(boolean disableDurability, NBTEditor nbtEditor, DurabilityManager durabilityManager)
|
||||
{
|
||||
this.disableDurability = disableDurability;
|
||||
this.nbtEditor = nbtEditor;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package nl.pim16aap2.armoredElytra.handlers;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -13,9 +13,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemDropListener implements Listener
|
||||
{
|
||||
private final INBTEditor nbtEditor;
|
||||
private final NBTEditor nbtEditor;
|
||||
|
||||
public ItemDropListener(INBTEditor nbtEditor)
|
||||
public ItemDropListener(NBTEditor nbtEditor)
|
||||
{
|
||||
this.nbtEditor = nbtEditor;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package nl.pim16aap2.armoredElytra.handlers;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.ArmoredElytra;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.ConfigLoader;
|
||||
import nl.pim16aap2.armoredElytra.util.DurabilityManager;
|
||||
@ -15,7 +15,7 @@ import org.bukkit.inventory.SmithingInventory;
|
||||
|
||||
public class NetheriteUpgradeListener extends SmithingTableListener
|
||||
{
|
||||
public NetheriteUpgradeListener(final ArmoredElytra plugin, INBTEditor nbtEditor,
|
||||
public NetheriteUpgradeListener(final ArmoredElytra plugin, NBTEditor nbtEditor,
|
||||
DurabilityManager durabilityManager, ConfigLoader config)
|
||||
{
|
||||
super(plugin, false, nbtEditor, durabilityManager, config);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package nl.pim16aap2.armoredElytra.handlers;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.ArmoredElytra;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.ConfigLoader;
|
||||
import nl.pim16aap2.armoredElytra.util.DurabilityManager;
|
||||
@ -17,7 +17,7 @@ import org.bukkit.inventory.SmithingInventory;
|
||||
|
||||
public class SmithingTableCraftHandler extends SmithingTableListener
|
||||
{
|
||||
public SmithingTableCraftHandler(final ArmoredElytra plugin, INBTEditor nbtEditor,
|
||||
public SmithingTableCraftHandler(final ArmoredElytra plugin, NBTEditor nbtEditor,
|
||||
DurabilityManager durabilityManager, ConfigLoader config)
|
||||
{
|
||||
super(plugin, true, nbtEditor, durabilityManager, config);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package nl.pim16aap2.armoredElytra.handlers;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.ArmoredElytra;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.ConfigLoader;
|
||||
import nl.pim16aap2.armoredElytra.util.DurabilityManager;
|
||||
@ -21,7 +21,7 @@ import java.util.logging.Level;
|
||||
abstract class SmithingTableListener extends ArmoredElytraHandler implements Listener
|
||||
{
|
||||
protected SmithingTableListener(ArmoredElytra plugin, boolean creationEnabled,
|
||||
INBTEditor nbtEditor, DurabilityManager durabilityManager, ConfigLoader config)
|
||||
NBTEditor nbtEditor, DurabilityManager durabilityManager, ConfigLoader config)
|
||||
{
|
||||
super(plugin, creationEnabled, nbtEditor, durabilityManager, config);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package nl.pim16aap2.armoredElytra.handlers;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.ArmoredElytra;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -18,9 +18,9 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
public class Uninstaller implements Listener
|
||||
{
|
||||
private final ArmoredElytra plugin;
|
||||
private final INBTEditor nbtEditor;
|
||||
private final NBTEditor nbtEditor;
|
||||
|
||||
public Uninstaller(ArmoredElytra plugin, INBTEditor nbtEditor)
|
||||
public Uninstaller(ArmoredElytra plugin, NBTEditor nbtEditor)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
this.nbtEditor = nbtEditor;
|
||||
|
@ -1,133 +0,0 @@
|
||||
package nl.pim16aap2.armoredElytra.nbtEditor;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.ArmoredElytra;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public interface INBTEditor
|
||||
{
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item). The default name for the given tier is
|
||||
* applied. See {@link ArmoredElytra#getArmoredElytraName(ArmorTier)}.
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
default ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable, (Color) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item).
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @param name The name fo the item.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
default ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, final String name)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable, name, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item). The default name for the given tier is
|
||||
* applied. See {@link ArmoredElytra#getArmoredElytraName(ArmorTier)}.
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @param color The color of the armor to store. May be null.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
default ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, final Color color)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable,
|
||||
ArmoredElytra.getInstance().getArmoredElytraName(armorTier),
|
||||
ArmoredElytra.getInstance().getElytraLore(armorTier), color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item). The default name for the given tier is
|
||||
* applied. See {@link ArmoredElytra#getArmoredElytraName(ArmorTier)}.
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @param name The name of the item.
|
||||
* @param color The color of the armor to store. May be null.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
default ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, String name,
|
||||
Color color)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable, name,
|
||||
ArmoredElytra.getInstance().getElytraLore(armorTier), color);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item).
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @param name The name of the item.
|
||||
* @param lore The lore of the item.
|
||||
* @param color The color of the armor to store. May be null.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, final String name,
|
||||
@Nullable List<String> lore, @Nullable Color color);
|
||||
|
||||
/**
|
||||
* Checks which {@link ArmorTier} is on an item.
|
||||
*
|
||||
* @param item The item to check.
|
||||
* @return The {@link ArmorTier} that is on the item. If none is found, {@link ArmorTier#NONE} is returned.
|
||||
*/
|
||||
ArmorTier getArmorTier(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Gets the Color of an armored elytra.
|
||||
* <p>
|
||||
* If the provided {@link ItemStack} is not an AE, null is returned.
|
||||
*
|
||||
* @param item The armored elytra to check.
|
||||
* @return The color of the armored elytra, if the input is a colored armored elytra, otherwise null.
|
||||
*/
|
||||
Color getColorOfArmoredElytra(@Nullable ItemStack item);
|
||||
|
||||
/**
|
||||
* Updates the durability values of an item.
|
||||
*
|
||||
* @param itemStack The itemstack to which the durability values will be applied.
|
||||
* @param realDurability The real durability to store in NBT.
|
||||
* @param displayDurability The durability value to display on the item. This is the durability value the client can
|
||||
* actually see.This only works if the item's meta is an instance of {@link Damageable}.
|
||||
*/
|
||||
void updateDurability(ItemStack itemStack, int realDurability, int displayDurability);
|
||||
|
||||
/**
|
||||
* Gets the real durability value as stored in the NBT of an armored elytra.
|
||||
*
|
||||
* @param itemStack The item for which to retrieve the real durability.
|
||||
* @param armorTier The armor tier of the armored elytra. If this is null, it will be retrieved from NBT.
|
||||
* @return The real durability of the itemstack if the itemstack has the AE durability attribute, or -1 otherwise.
|
||||
*/
|
||||
int getRealDurability(ItemStack itemStack, @Nullable ArmorTier armorTier);
|
||||
}
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class NBTEditor implements INBTEditor
|
||||
public class NBTEditor
|
||||
{
|
||||
private static final NamespacedKey ARMOR_TIER_KEY = new NamespacedKey(ArmoredElytra.getInstance(),
|
||||
"ARMOR_TIER_LEVEL");
|
||||
@ -30,7 +30,13 @@ public class NBTEditor implements INBTEditor
|
||||
private static final NamespacedKey DURABILITY_KEY = new NamespacedKey(ArmoredElytra.getInstance(),
|
||||
"ARMORED_ELYTRA_DURABILITY");
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Gets the real durability value as stored in the NBT of an armored elytra.
|
||||
*
|
||||
* @param itemStack The item for which to retrieve the real durability.
|
||||
* @param providedTier The armor tier of the armored elytra. If this is null, it will be retrieved from NBT.
|
||||
* @return The real durability of the itemstack if the itemstack has the AE durability attribute, or -1 otherwise.
|
||||
*/
|
||||
public int getRealDurability(ItemStack itemStack, @Nullable ArmorTier providedTier)
|
||||
{
|
||||
final @Nullable ItemMeta meta = itemStack.getItemMeta();
|
||||
@ -49,7 +55,14 @@ public class NBTEditor implements INBTEditor
|
||||
return realDurability == null ? -1 : realDurability;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Updates the durability values of an item.
|
||||
*
|
||||
* @param itemStack The itemstack to which the durability values will be applied.
|
||||
* @param realDurability The real durability to store in NBT.
|
||||
* @param displayDurability The durability value to display on the item. This is the durability value the client can
|
||||
* actually see.This only works if the item's meta is an instance of {@link Damageable}.
|
||||
*/
|
||||
public void updateDurability(ItemStack itemStack, int realDurability, int displayDurability)
|
||||
{
|
||||
final ItemMeta meta = getOrCreateItemMeta(itemStack);
|
||||
@ -61,7 +74,18 @@ public class NBTEditor implements INBTEditor
|
||||
itemStack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item).
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @param name The name of the item.
|
||||
* @param lore The lore of the item.
|
||||
* @param color The color of the armor to store. May be null.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
public ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, String name,
|
||||
@Nullable List<String> lore, @Nullable Color color)
|
||||
{
|
||||
@ -129,7 +153,12 @@ public class NBTEditor implements INBTEditor
|
||||
return ArmorTier.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Checks which {@link ArmorTier} is on an item.
|
||||
*
|
||||
* @param item The item to check.
|
||||
* @return The {@link ArmorTier} that is on the item. If none is found, {@link ArmorTier#NONE} is returned.
|
||||
*/
|
||||
public ArmorTier getArmorTier(@Nullable ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
@ -137,7 +166,14 @@ public class NBTEditor implements INBTEditor
|
||||
return getArmorTier(item.getItemMeta());
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Gets the Color of an armored elytra.
|
||||
* <p>
|
||||
* If the provided {@link ItemStack} is not an AE, null is returned.
|
||||
*
|
||||
* @param item The armored elytra to check.
|
||||
* @return The color of the armored elytra, if the input is a colored armored elytra, otherwise null.
|
||||
*/
|
||||
public Color getColorOfArmoredElytra(@Nullable ItemStack item)
|
||||
{
|
||||
if (item == null || item.getType() != Material.ELYTRA || !item.hasItemMeta())
|
||||
@ -164,4 +200,71 @@ public class NBTEditor implements INBTEditor
|
||||
throw new IllegalArgumentException("Tried to add armor to invalid item: " + item);
|
||||
return meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item). The default name for the given tier is
|
||||
* applied. See {@link ArmoredElytra#getArmoredElytraName(ArmorTier)}.
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
public ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable, (Color) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item).
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @param name The name fo the item.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
public ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, final String name)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable, name, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item). The default name for the given tier is
|
||||
* applied. See {@link ArmoredElytra#getArmoredElytraName(ArmorTier)}.
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @param color The color of the armor to store. May be null.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
public ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, final Color color)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable,
|
||||
ArmoredElytra.getInstance().getArmoredElytraName(armorTier),
|
||||
ArmoredElytra.getInstance().getElytraLore(armorTier), color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a given {@link ArmorTier} to an item. The item will be cloned. Note that setting the armor tier to {@link
|
||||
* ArmorTier#NONE} has no effect (besides making a copy of the item). The default name for the given tier is
|
||||
* applied. See {@link ArmoredElytra#getArmoredElytraName(ArmorTier)}.
|
||||
*
|
||||
* @param item The item.
|
||||
* @param armorTier The {@link ArmorTier} that will be added to it.
|
||||
* @param unbreakable Whether the resulting item should be unbreakable.
|
||||
* @param name The name of the item.
|
||||
* @param color The color of the armor to store. May be null.
|
||||
* @return The NEW item.
|
||||
*/
|
||||
public ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, String name,
|
||||
Color color)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable, name,
|
||||
ArmoredElytra.getInstance().getElytraLore(armorTier), color);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package nl.pim16aap2.armoredElytra.util;
|
||||
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.INBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nbtEditor.NBTEditor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -13,10 +13,10 @@ public class DurabilityManager
|
||||
private final int[] repairAmounts = new int[ArmorTier.values().length];
|
||||
private final int[] maxDurabilities = new int[ArmorTier.values().length];
|
||||
|
||||
private final INBTEditor nbtEditor;
|
||||
private final NBTEditor nbtEditor;
|
||||
private final ConfigLoader config;
|
||||
|
||||
public DurabilityManager(INBTEditor nbtEditor, ConfigLoader config)
|
||||
public DurabilityManager(NBTEditor nbtEditor, ConfigLoader config)
|
||||
{
|
||||
this.nbtEditor = nbtEditor;
|
||||
this.config = config;
|
||||
|
Loading…
x
Reference in New Issue
Block a user