Fix lore being ignored
- The lore, as specified by the translation file, was not applied on ArmoredElytras. This has now been resolved by retrieving the value when creating new AEs.
This commit is contained in:
parent
61e94ee8a1
commit
0a9ead5ffb
@ -27,8 +27,11 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
@ -239,10 +242,10 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
||||
messagePlayer(player, ChatColor.RED, message);
|
||||
}
|
||||
|
||||
public String getElytraLore(ArmorTier armorTier)
|
||||
public @Nullable List<String> getElytraLore(ArmorTier armorTier)
|
||||
{
|
||||
final String message = getMessageWithTierNames(Message.MESSAGES_LORE, armorTier);
|
||||
return message.equals("NONE") ? null : message;
|
||||
final String message = ChatColor.stripColor(getMessageWithTierNames(Message.MESSAGES_LORE, armorTier));
|
||||
return message.equals("NONE") ? null : Collections.singletonList(message);
|
||||
}
|
||||
|
||||
// Print a string to the log.
|
||||
|
@ -5,6 +5,9 @@ import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public interface INBTEditor
|
||||
{
|
||||
/**
|
||||
@ -34,7 +37,7 @@ public interface INBTEditor
|
||||
*/
|
||||
default ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, final String name)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable, name, null);
|
||||
return addArmorNBTTags(item, armorTier, unbreakable, name, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,9 +54,30 @@ public interface INBTEditor
|
||||
default ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, final Color color)
|
||||
{
|
||||
return addArmorNBTTags(item, armorTier, unbreakable,
|
||||
ArmoredElytra.getInstance().getArmoredElytraName(armorTier), color);
|
||||
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).
|
||||
@ -61,12 +85,13 @@ public interface INBTEditor
|
||||
* @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.
|
||||
* @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,
|
||||
final Color color);
|
||||
@Nullable List<String> lore, @Nullable Color color);
|
||||
|
||||
/**
|
||||
* Checks which {@link ArmorTier} is on an item.
|
||||
|
@ -14,7 +14,9 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class NBTEditor implements INBTEditor
|
||||
@ -25,8 +27,8 @@ public class NBTEditor implements INBTEditor
|
||||
"ARMORED_ELYTRA_COLOR");
|
||||
|
||||
@Override
|
||||
public ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, final String name,
|
||||
final Color color)
|
||||
public ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable, String name,
|
||||
@Nullable List<String> lore, @Nullable Color color)
|
||||
{
|
||||
if (armorTier == null || armorTier == ArmorTier.NONE)
|
||||
return new ItemStack(item);
|
||||
@ -51,6 +53,8 @@ public class NBTEditor implements INBTEditor
|
||||
|
||||
meta.setUnbreakable(unbreakable);
|
||||
meta.setDisplayName(name);
|
||||
if (lore != null)
|
||||
meta.setLore(lore);
|
||||
|
||||
ret.setItemMeta(meta);
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user