This commit is contained in:
nossr50 2020-08-18 21:11:15 -07:00
parent 1feee7f312
commit 500ab628dd
6 changed files with 60 additions and 30 deletions

View File

@ -1,11 +1,12 @@
Version 2.1.143 Version 2.1.143
mcMMO now tracks super ability boosted items through item metadata mcMMO now tracks super ability boosted items through persistent metadata
mcMMO no longer relies on lore to tell if an item has been modified by a super ability mcMMO no longer relies on lore to tell if an item has been modified by a super ability
Slight buff to Rupture Slight buff to Rupture (1 more tick duration across all ranks)
Lore no longer gets added to items being buffed by mcMMO
NOTES: NOTES:
The item tracking on 1.14+ is persistent (up until now its been temporary) The item tracking is persistent for MC versions 1.13-1.16.2 (and beyond). However the code handling the persistence for 1.13.2 differs from the other versions. It shouldn't result in any problems.
Lore still gets added and removed from the item, this is sort of a failsafe. It can be considered optional. Any items that currently have the "mcMMO Ability Tool" lore on them won't get touched by anything this update does, there is no way to tell what the true enchant values on those items should be.
Version 2.1.142 Version 2.1.142
Iron Arm Style renamed to Steel Arm Style Iron Arm Style renamed to Steel Arm Style

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.1.143-SNAPSHOT</version> <version>2.1.143</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm> <scm>

View File

@ -15,7 +15,6 @@ import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public final class ItemUtils { 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")); return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
} }
public static void addAbilityLore(@NotNull ItemStack itemStack) { // public static void addAbilityLore(@NotNull ItemStack itemStack) {
ItemMeta itemMeta = itemStack.getItemMeta(); // ItemMeta itemMeta = itemStack.getItemMeta();
List<String> itemLore = new ArrayList<>(); // List<String> itemLore = new ArrayList<>();
//
if(itemMeta == null) // if(itemMeta == null)
return; // return;
//
if (itemMeta.hasLore()) { // if (itemMeta.hasLore()) {
itemLore = itemMeta.getLore(); // itemLore = itemMeta.getLore();
} // }
//
itemLore.add("mcMMO Ability Tool"); // itemLore.add("mcMMO Ability Tool");
//
itemMeta.setLore(itemLore); // itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta); // itemStack.setItemMeta(itemMeta);
} // }
public static void removeAbilityLore(@NotNull ItemStack itemStack) { public static void removeAbilityLore(@NotNull ItemStack itemStack) {
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();

View File

@ -5,13 +5,16 @@ import com.gmail.nossr50.util.compat.layers.AbstractCompatibilityLayer;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.block.Furnace; import org.bukkit.block.Furnace;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.UUID; import java.util.UUID;
public abstract class AbstractPersistentDataLayer extends AbstractCompatibilityLayer { public abstract class AbstractPersistentDataLayer extends AbstractCompatibilityLayer {
public static final String LEGACY_ABILITY_TOOL_LORE = "mcMMO Ability Tool";
public final NamespacedKey superAbilityBoosted; public final NamespacedKey superAbilityBoosted;
public final String SUPER_ABILITY_BOOSTED = "super_ability_boosted"; 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 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);
}
} }

View File

@ -19,7 +19,6 @@ import java.util.UUID;
public class SpigotTemporaryDataLayer extends AbstractPersistentDataLayer { public class SpigotTemporaryDataLayer extends AbstractPersistentDataLayer {
private final String FURNACE_OWNER_METADATA_KEY = "mcMMO_furnace_owner"; private final String FURNACE_OWNER_METADATA_KEY = "mcMMO_furnace_owner";
private final String ABILITY_TOOL_METADATA_KEY = "mcMMO_super_ability_tool";
@Override @Override
public boolean initializeLayer() { public boolean initializeLayer() {

View File

@ -27,6 +27,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe; import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -145,11 +146,13 @@ public class SkillUtils {
int originalDigSpeed = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED); int originalDigSpeed = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED);
//Add lore, add dig speed //Add dig speed
ItemUtils.addAbilityLore(heldItem); //lore can be a secondary failsafe for 1.13 and below
//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)); 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(); AbstractPersistentDataLayer compatLayer = mcMMO.getCompatibilityManager().getPersistentDataLayer();
compatLayer.setSuperAbilityBoostedItem(heldItem, originalDigSpeed); compatLayer.setSuperAbilityBoostedItem(heldItem, originalDigSpeed);
} }
@ -211,15 +214,26 @@ public class SkillUtils {
if(!ItemUtils.canBeSuperAbilityDigBoosted(itemStack)) if(!ItemUtils.canBeSuperAbilityDigBoosted(itemStack))
return; 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(); 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); compatLayer.removeBonusDigSpeedOnSuperAbilityTool(itemStack);
} }
}
public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier) { public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier) {
handleDurabilityChange(itemStack, durabilityModifier, 1.0); handleDurabilityChange(itemStack, durabilityModifier, 1.0);