mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 10:14:43 +02:00
2.1.143
This commit is contained in:
@ -15,7 +15,6 @@ import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class ItemUtils {
|
||||
@ -486,22 +485,22 @@ public final class ItemUtils {
|
||||
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
|
||||
}
|
||||
|
||||
public static void addAbilityLore(@NotNull ItemStack itemStack) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
|
||||
if(itemMeta == null)
|
||||
return;
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
itemLore = itemMeta.getLore();
|
||||
}
|
||||
|
||||
itemLore.add("mcMMO Ability Tool");
|
||||
|
||||
itemMeta.setLore(itemLore);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
// public static void addAbilityLore(@NotNull ItemStack itemStack) {
|
||||
// ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
// List<String> itemLore = new ArrayList<>();
|
||||
//
|
||||
// if(itemMeta == null)
|
||||
// return;
|
||||
//
|
||||
// if (itemMeta.hasLore()) {
|
||||
// itemLore = itemMeta.getLore();
|
||||
// }
|
||||
//
|
||||
// itemLore.add("mcMMO Ability Tool");
|
||||
//
|
||||
// itemMeta.setLore(itemLore);
|
||||
// itemStack.setItemMeta(itemMeta);
|
||||
// }
|
||||
|
||||
public static void removeAbilityLore(@NotNull ItemStack itemStack) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
@ -5,13 +5,16 @@ import com.gmail.nossr50.util.compat.layers.AbstractCompatibilityLayer;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class AbstractPersistentDataLayer extends AbstractCompatibilityLayer {
|
||||
|
||||
public static final String LEGACY_ABILITY_TOOL_LORE = "mcMMO Ability Tool";
|
||||
public final NamespacedKey superAbilityBoosted;
|
||||
public final String SUPER_ABILITY_BOOSTED = "super_ability_boosted";
|
||||
|
||||
@ -36,4 +39,18 @@ public abstract class AbstractPersistentDataLayer extends AbstractCompatibilityL
|
||||
|
||||
public abstract void removeBonusDigSpeedOnSuperAbilityTool(@NotNull ItemStack itemStack);
|
||||
|
||||
public boolean isLegacyAbilityTool(ItemStack itemStack) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta == null)
|
||||
return false;
|
||||
|
||||
List<String> lore = itemMeta.getLore();
|
||||
|
||||
if(lore == null || lore.isEmpty())
|
||||
return false;
|
||||
|
||||
return lore.contains(LEGACY_ABILITY_TOOL_LORE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import java.util.UUID;
|
||||
public class SpigotTemporaryDataLayer extends AbstractPersistentDataLayer {
|
||||
|
||||
private final String FURNACE_OWNER_METADATA_KEY = "mcMMO_furnace_owner";
|
||||
private final String ABILITY_TOOL_METADATA_KEY = "mcMMO_super_ability_tool";
|
||||
|
||||
@Override
|
||||
public boolean initializeLayer() {
|
||||
|
@ -27,6 +27,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -145,11 +146,13 @@ public class SkillUtils {
|
||||
|
||||
int originalDigSpeed = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||
|
||||
//Add lore, add dig speed
|
||||
ItemUtils.addAbilityLore(heldItem); //lore can be a secondary failsafe for 1.13 and below
|
||||
//Add dig speed
|
||||
|
||||
//Lore no longer gets added, no point to it afaik
|
||||
//ItemUtils.addAbilityLore(heldItem); //lore can be a secondary failsafe for 1.13 and below
|
||||
ItemUtils.addDigSpeedToItem(heldItem, heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED));
|
||||
|
||||
//1.14+ will have persistent metadata for this item
|
||||
//1.13.2+ will have persistent metadata for this item
|
||||
AbstractPersistentDataLayer compatLayer = mcMMO.getCompatibilityManager().getPersistentDataLayer();
|
||||
compatLayer.setSuperAbilityBoostedItem(heldItem, originalDigSpeed);
|
||||
}
|
||||
@ -211,14 +214,25 @@ public class SkillUtils {
|
||||
if(!ItemUtils.canBeSuperAbilityDigBoosted(itemStack))
|
||||
return;
|
||||
|
||||
//Take the lore off
|
||||
ItemUtils.removeAbilityLore(itemStack);
|
||||
|
||||
//1.14+ will have persistent metadata for this itemStack
|
||||
//1.13.2+ will have persistent metadata for this itemStack
|
||||
AbstractPersistentDataLayer compatLayer = mcMMO.getCompatibilityManager().getPersistentDataLayer();
|
||||
|
||||
if(compatLayer.isSuperAbilityBoosted(itemStack))
|
||||
if(compatLayer.isLegacyAbilityTool(itemStack)) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
//TODO: can be optimized
|
||||
if(itemMeta.hasEnchant(Enchantment.DIG_SPEED)) {
|
||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||
}
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
ItemUtils.removeAbilityLore(itemStack);
|
||||
}
|
||||
|
||||
if(compatLayer.isSuperAbilityBoosted(itemStack)) {
|
||||
compatLayer.removeBonusDigSpeedOnSuperAbilityTool(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier) {
|
||||
|
Reference in New Issue
Block a user