mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into tridentsxbows
This commit is contained in:
@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.skills;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
@ -60,7 +61,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
|
||||
// IRON ARM
|
||||
if (canIronArm) {
|
||||
ironArmBonus = mcMMO.getUserManager().getPlayer(player).getUnarmedManager().getIronArmDamage();
|
||||
ironArmBonus = mcMMO.getUserManager().getPlayer(player).getUnarmedManager().getSteelArmStyleDamage();
|
||||
}
|
||||
|
||||
// IRON GRIP
|
||||
@ -74,7 +75,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canBerserk = RankUtils.hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && Permissions.berserk(player);
|
||||
canIronArm = canUseSubskill(player, SubSkillType.UNARMED_IRON_ARM_STYLE);
|
||||
canIronArm = canUseSubskill(player, SubSkillType.UNARMED_STEEL_ARM_STYLE);
|
||||
canDeflect = canUseSubskill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
|
||||
canDisarm = canUseSubskill(player, SubSkillType.UNARMED_DISARM);
|
||||
canIronGrip = canUseSubskill(player, SubSkillType.UNARMED_IRON_GRIP);
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.gmail.nossr50.datatypes.meta;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
/**
|
||||
* Stores the original dig speed of a tool, also marks the tool as boosted by super abilities
|
||||
*/
|
||||
public class SuperAbilityToolMeta extends FixedMetadataValue {
|
||||
|
||||
public SuperAbilityToolMeta(int value, mcMMO plugin) {
|
||||
super(plugin, value);
|
||||
}
|
||||
}
|
@ -30,7 +30,6 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||
import com.gmail.nossr50.util.input.AbilityActivationProcessor;
|
||||
import com.gmail.nossr50.util.input.SuperAbilityManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
@ -570,4 +569,9 @@ public class McMMOPlayer extends PlayerProfile {
|
||||
public void togglePartyChatSpying() {
|
||||
getPersistentPlayerData().togglePartyChatSpying();
|
||||
}
|
||||
|
||||
//TODO: Rewrite this
|
||||
public double getAttackStrength() {
|
||||
return 1.0F;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public enum PrimarySkillType {
|
||||
TAMING(TamingManager.class, Color.PURPLE,
|
||||
ImmutableList.of(SubSkillType.TAMING_BEAST_LORE, SubSkillType.TAMING_CALL_OF_THE_WILD, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE, SubSkillType.TAMING_FAST_FOOD_SERVICE, SubSkillType.TAMING_GORE, SubSkillType.TAMING_HOLY_HOUND, SubSkillType.TAMING_SHARPENED_CLAWS, SubSkillType.TAMING_SHOCK_PROOF, SubSkillType.TAMING_THICK_FUR, SubSkillType.TAMING_PUMMEL)),
|
||||
UNARMED(UnarmedManager.class, Color.BLACK, SuperAbilityType.BERSERK,
|
||||
ImmutableList.of(SubSkillType.UNARMED_BERSERK, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, SubSkillType.UNARMED_BLOCK_CRACKER, SubSkillType.UNARMED_ARROW_DEFLECT, SubSkillType.UNARMED_DISARM, SubSkillType.UNARMED_IRON_ARM_STYLE, SubSkillType.UNARMED_IRON_GRIP)),
|
||||
ImmutableList.of(SubSkillType.UNARMED_BERSERK, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, SubSkillType.UNARMED_BLOCK_CRACKER, SubSkillType.UNARMED_ARROW_DEFLECT, SubSkillType.UNARMED_DISARM, SubSkillType.UNARMED_STEEL_ARM_STYLE, SubSkillType.UNARMED_IRON_GRIP)),
|
||||
WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, SuperAbilityType.TREE_FELLER,
|
||||
ImmutableList.of(SubSkillType.WOODCUTTING_LEAF_BLOWER, SubSkillType.WOODCUTTING_TREE_FELLER, SubSkillType.WOODCUTTING_HARVEST_LUMBER)),
|
||||
TRIDENTS(TridentManager.class, Color.TEAL, ImmutableList.of(SubSkillType.TRIDENTS_MULTI_TASKING, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK)),
|
||||
|
@ -95,7 +95,7 @@ public enum SubSkillType {
|
||||
UNARMED_BERSERK(1),
|
||||
UNARMED_BLOCK_CRACKER,
|
||||
UNARMED_DISARM(1),
|
||||
UNARMED_IRON_ARM_STYLE(5),
|
||||
UNARMED_STEEL_ARM_STYLE(20),
|
||||
UNARMED_IRON_GRIP(1),
|
||||
UNARMED_UNARMED_LIMIT_BREAK(10),
|
||||
|
||||
|
@ -686,7 +686,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
} else {
|
||||
if ((mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
|
||||
SkillUtils.handleAbilitySpeedDecrease(player);
|
||||
SkillUtils.removeAbilityBoostsFromInventory(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,6 +382,10 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryClickEvent(InventoryClickEvent event) {
|
||||
if(event.getCurrentItem() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkillUtils.removeAbilityBuff(event.getCurrentItem());
|
||||
if (event.getAction() == InventoryAction.HOTBAR_SWAP) {
|
||||
if(isOutsideWindowClick(event))
|
||||
@ -390,7 +394,7 @@ public class InventoryListener implements Listener {
|
||||
PlayerInventory playerInventory = event.getWhoClicked().getInventory();
|
||||
|
||||
if(playerInventory.getItem(event.getHotbarButton()) != null)
|
||||
SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton()));
|
||||
SkillUtils.removeAbilityBuff(playerInventory.getItem(event.getHotbarButton()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,6 +417,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
ItemStack result = event.getRecipe().getResult();
|
||||
|
||||
//TODO: what is the point of this
|
||||
if (!ItemUtils.isMcMMOItem(result)) {
|
||||
return;
|
||||
}
|
||||
|
@ -650,7 +650,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
// Make sure the player knows what he's doing when trying to salvage an enchanted item
|
||||
if (salvageManager.checkConfirmation(true)) {
|
||||
SkillUtils.handleAbilitySpeedDecrease(player);
|
||||
SkillUtils.removeAbilityBoostsFromInventory(player);
|
||||
salvageManager.handleSalvage(clickedBlock.getLocation(), heldItem);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class AbilityDisableTask extends BukkitRunnable {
|
||||
switch (ability) {
|
||||
case SUPER_BREAKER:
|
||||
case GIGA_DRILL_BREAKER:
|
||||
SkillUtils.handleAbilitySpeedDecrease(player);
|
||||
SkillUtils.removeAbilityBoostsFromInventory(player);
|
||||
// Fallthrough
|
||||
|
||||
case BERSERK:
|
||||
|
@ -188,6 +188,9 @@ public class BleedTimerTask extends BukkitRunnable {
|
||||
if(toolTier < 4)
|
||||
ticks = Math.max(1, (ticks / 3));
|
||||
|
||||
ticks+=1;
|
||||
|
||||
|
||||
BleedContainer newBleedContainer = new BleedContainer(entity, ticks, bleedRank, toolTier, attacker);
|
||||
bleedList.put(entity, newBleedContainer);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class SmeltingManager extends SkillManager {
|
||||
applyXpGain(Smelting.getResourceXp(smelting), XPGainReason.PVE, XPGainSource.PASSIVE);
|
||||
|
||||
if (Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.SMELTING, result.getType())
|
||||
&& isSecondSmeltSuccessful()) {
|
||||
&& isSecondSmeltSuccessful() && result.getAmount() < 64) {
|
||||
ItemStack newResult = result.clone();
|
||||
|
||||
newResult.setAmount(result.getAmount() + 1);
|
||||
|
@ -35,10 +35,10 @@ public class UnarmedManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canUseIronArm() {
|
||||
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE))
|
||||
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE))
|
||||
return false;
|
||||
|
||||
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE);
|
||||
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE);
|
||||
}
|
||||
|
||||
public boolean canUseBerserk() {
|
||||
@ -145,23 +145,22 @@ public class UnarmedManager extends SkillManager {
|
||||
/**
|
||||
* Handle the effects of the Iron Arm ability
|
||||
*/
|
||||
public double calculateIronArmDamage() {
|
||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.UNARMED_IRON_ARM_STYLE, getPlayer())) {
|
||||
public double calculateSteelArmStyleDamage() {
|
||||
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.ALWAYS_FIRES, SubSkillType.UNARMED_STEEL_ARM_STYLE, getPlayer())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return getIronArmDamage();
|
||||
return getSteelArmStyleDamage();
|
||||
}
|
||||
|
||||
public double getIronArmDamage() {
|
||||
int rank = RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE);
|
||||
public double getSteelArmStyleDamage() {
|
||||
double rank = RankUtils.getRank(getPlayer(), SubSkillType.UNARMED_STEEL_ARM_STYLE);
|
||||
double bonus = 0;
|
||||
|
||||
if(rank == 1)
|
||||
{
|
||||
return 1.5;
|
||||
} else {
|
||||
return 3 + (rank * 2);
|
||||
}
|
||||
if(rank >= 18)
|
||||
bonus = 1 + rank - 18;
|
||||
|
||||
return bonus + 0.5 + (rank / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,16 +1,21 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.bukkit.Material.AIR;
|
||||
|
||||
@ -23,29 +28,28 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a bow, false otherwise
|
||||
*/
|
||||
public static boolean isBow(ItemStack item) {
|
||||
public static boolean isBow(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isBow(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
public static boolean isCrossbow(ItemStack itemStack) {
|
||||
public static boolean isCrossbow(@NotNull ItemStack itemStack) {
|
||||
return mcMMO.getMaterialMapStore().isCrossbow(itemStack.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasItemInEitherHand(Player player, Material material) {
|
||||
public static boolean hasItemInEitherHand(@NotNull Player player, @NotNull Material material) {
|
||||
return hasItemInEitherHand(player, material.getKey().getKey());
|
||||
}
|
||||
|
||||
public static boolean hasItemInEitherHand(Player player, String id) {
|
||||
public static boolean hasItemInEitherHand(@NotNull Player player, @NotNull String id) {
|
||||
return player.getInventory().getItemInMainHand().getType().getKey().getKey().equalsIgnoreCase(id)
|
||||
|| player.getInventory().getItemInOffHand().getType().getKey().getKey().equalsIgnoreCase(id);
|
||||
}
|
||||
|
||||
public static boolean hasItemInMainHand(Player player, String id) {
|
||||
public static boolean hasItemInMainHand(@NotNull Player player, @NotNull String id) {
|
||||
return player.getInventory().getItemInMainHand().getType().getKey().getKey().equalsIgnoreCase(id);
|
||||
}
|
||||
|
||||
public static boolean hasItemInOffHand(Player player, String id) {
|
||||
public static boolean hasItemInOffHand(@NotNull Player player, @NotNull String id) {
|
||||
return player.getInventory().getItemInOffHand().getType().getKey().getKey().equalsIgnoreCase(id);
|
||||
}
|
||||
|
||||
@ -56,11 +60,11 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a sword, false otherwise
|
||||
*/
|
||||
public static boolean isSword(ItemStack item) {
|
||||
public static boolean isSword(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isSword(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
public static boolean isTrident(ItemStack itemStack) {
|
||||
public static boolean isTrident(@NotNull ItemStack itemStack) {
|
||||
return mcMMO.getMaterialMapStore().isTrident(itemStack.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -89,7 +93,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a hoe, false otherwise
|
||||
*/
|
||||
public static boolean isHoe(ItemStack item) {
|
||||
public static boolean isHoe(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isHoe(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -99,7 +103,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a shovel, false otherwise
|
||||
*/
|
||||
public static boolean isShovel(ItemStack item) {
|
||||
public static boolean isShovel(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isShovel(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -109,7 +113,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is an axe, false otherwise
|
||||
*/
|
||||
public static boolean isAxe(ItemStack item) {
|
||||
public static boolean isAxe(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isAxe(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -119,7 +123,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a pickaxe, false otherwise
|
||||
*/
|
||||
public static boolean isPickaxe(ItemStack item) {
|
||||
public static boolean isPickaxe(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isPickAxe(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -129,7 +133,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item counts as unarmed, false otherwise
|
||||
*/
|
||||
public static boolean isUnarmed(ItemStack item) {
|
||||
public static boolean isUnarmed(@NotNull ItemStack item) {
|
||||
if (Config.getInstance().getUnarmedItemsAsUnarmed()) {
|
||||
return !isMinecraftTool(item);
|
||||
}
|
||||
@ -143,7 +147,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is armor, false otherwise
|
||||
*/
|
||||
public static boolean isArmor(ItemStack item) {
|
||||
public static boolean isArmor(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isArmor(item.getType());
|
||||
}
|
||||
|
||||
@ -153,7 +157,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is leather armor, false otherwise
|
||||
*/
|
||||
public static boolean isLeatherArmor(ItemStack item) {
|
||||
public static boolean isLeatherArmor(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isLeatherArmor(item.getType());
|
||||
}
|
||||
|
||||
@ -163,7 +167,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is gold armor, false otherwise
|
||||
*/
|
||||
public static boolean isGoldArmor(ItemStack item) {
|
||||
public static boolean isGoldArmor(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isGoldArmor(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -173,7 +177,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is iron armor, false otherwise
|
||||
*/
|
||||
public static boolean isIronArmor(ItemStack item) {
|
||||
public static boolean isIronArmor(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isIronArmor(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -183,7 +187,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is diamond armor, false otherwise
|
||||
*/
|
||||
public static boolean isDiamondArmor(ItemStack item) {
|
||||
public static boolean isDiamondArmor(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isDiamondArmor(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -201,7 +205,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is chainmail armor, false otherwise
|
||||
*/
|
||||
public static boolean isChainmailArmor(ItemStack item) {
|
||||
public static boolean isChainmailArmor(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isChainmailArmor(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -211,7 +215,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a tool, false otherwise
|
||||
*/
|
||||
public static boolean isMinecraftTool(ItemStack item) {
|
||||
public static boolean isMinecraftTool(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isTool(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -221,7 +225,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a stone tool, false otherwise
|
||||
*/
|
||||
public static boolean isStoneTool(ItemStack item) {
|
||||
public static boolean isStoneTool(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isStoneTool(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -231,7 +235,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a wooden tool, false otherwise
|
||||
*/
|
||||
public static boolean isWoodTool(ItemStack item) {
|
||||
public static boolean isWoodTool(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isWoodTool(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -241,7 +245,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a string tool, false otherwise
|
||||
*/
|
||||
public static boolean isStringTool(ItemStack item) {
|
||||
public static boolean isStringTool(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isStringTool(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -251,7 +255,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a stone tool, false otherwise
|
||||
*/
|
||||
public static boolean isGoldTool(ItemStack item) {
|
||||
public static boolean isGoldTool(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isGoldTool(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -261,7 +265,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is an iron tool, false otherwise
|
||||
*/
|
||||
public static boolean isIronTool(ItemStack item) {
|
||||
public static boolean isIronTool(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isIronTool(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -271,7 +275,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a diamond tool, false otherwise
|
||||
*/
|
||||
public static boolean isDiamondTool(ItemStack item) {
|
||||
public static boolean isDiamondTool(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isDiamondTool(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
@ -281,15 +285,15 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is enchantable, false otherwise
|
||||
*/
|
||||
public static boolean isEnchantable(ItemStack item) {
|
||||
public static boolean isEnchantable(@NotNull ItemStack item) {
|
||||
return mcMMO.getMaterialMapStore().isEnchantable(item.getType().getKey().getKey());
|
||||
}
|
||||
|
||||
public static boolean isSmeltable(ItemStack item) {
|
||||
public static boolean isSmeltable(@NotNull ItemStack item) {
|
||||
return item != null && item.getType().isBlock() && MaterialUtils.isOre(item.getType());
|
||||
}
|
||||
|
||||
public static boolean isSmelted(ItemStack item) {
|
||||
public static boolean isSmelted(@NotNull ItemStack item) {
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
@ -311,7 +315,7 @@ public final class ItemUtils {
|
||||
* @param item Item that will get shared
|
||||
* @return True if the item can be shared.
|
||||
*/
|
||||
public static boolean isSharable(ItemStack item) {
|
||||
public static boolean isSharable(@NotNull ItemStack item) {
|
||||
if (item == null || item.getType() == AIR) {
|
||||
return false;
|
||||
}
|
||||
@ -325,7 +329,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a mining drop, false otherwise
|
||||
*/
|
||||
public static boolean isMiningDrop(ItemStack item) {
|
||||
public static boolean isMiningDrop(@NotNull ItemStack item) {
|
||||
//TODO: 1.14 This needs to be updated
|
||||
switch (item.getType()) {
|
||||
case COAL:
|
||||
@ -356,7 +360,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a herbalism drop, false otherwise
|
||||
*/
|
||||
public static boolean isHerbalismDrop(ItemStack item) {
|
||||
public static boolean isHerbalismDrop(@NotNull ItemStack item) {
|
||||
//TODO: 1.14 This needs to be updated
|
||||
switch (item.getType()) {
|
||||
case WHEAT:
|
||||
@ -395,7 +399,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a mob drop, false otherwise
|
||||
*/
|
||||
public static boolean isMobDrop(ItemStack item) {
|
||||
public static boolean isMobDrop(@NotNull ItemStack item) {
|
||||
//TODO: 1.14 This needs to be updated
|
||||
switch (item.getType()) {
|
||||
case STRING:
|
||||
@ -453,7 +457,7 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a woodcutting drop, false otherwise
|
||||
*/
|
||||
public static boolean isWoodcuttingDrop(ItemStack item) {
|
||||
public static boolean isWoodcuttingDrop(@NotNull ItemStack item) {
|
||||
switch (item.getType()) {
|
||||
case ACACIA_LOG:
|
||||
case BIRCH_LOG:
|
||||
@ -493,11 +497,11 @@ public final class ItemUtils {
|
||||
* @param item Item to check
|
||||
* @return true if the item is a miscellaneous drop, false otherwise
|
||||
*/
|
||||
public static boolean isMiscDrop(ItemStack item) {
|
||||
public static boolean isMiscDrop(@NotNull ItemStack item) {
|
||||
return ItemWeightConfig.getInstance().getMiscItems().contains(item.getType());
|
||||
}
|
||||
|
||||
public static boolean isMcMMOItem(ItemStack item) {
|
||||
public static boolean isMcMMOItem(@NotNull ItemStack item) {
|
||||
if (!item.hasItemMeta()) {
|
||||
return false;
|
||||
}
|
||||
@ -511,7 +515,7 @@ public final class ItemUtils {
|
||||
&& itemMeta.getLore().contains("mcMMO Item");
|
||||
}
|
||||
|
||||
public static boolean isChimaeraWing(ItemStack item) {
|
||||
public static boolean isChimaeraWing(@NotNull ItemStack item) {
|
||||
if (!isMcMMOItem(item)) {
|
||||
return false;
|
||||
}
|
||||
@ -523,4 +527,54 @@ 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 removeAbilityLore(@NotNull ItemStack itemStack) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta == null)
|
||||
return;
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
List<String> itemLore = itemMeta.getLore();
|
||||
|
||||
if(itemLore == null)
|
||||
return;
|
||||
|
||||
if (itemLore.remove("mcMMO Ability Tool")) {
|
||||
itemMeta.setLore(itemLore);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addDigSpeedToItem(@NotNull ItemStack itemStack, int existingEnchantLevel) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta == null)
|
||||
return;
|
||||
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, existingEnchantLevel + AdvancedConfig.getInstance().getEnchantBuff(), true);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
public static boolean canBeSuperAbilityDigBoosted(@NotNull ItemStack itemStack) {
|
||||
return isShovel(itemStack) || isPickaxe(itemStack);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,59 @@
|
||||
package com.gmail.nossr50.util.compat.layers.persistentdata;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
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";
|
||||
|
||||
public AbstractPersistentDataLayer() {
|
||||
superAbilityBoosted = getNamespacedKey(SUPER_ABILITY_BOOSTED);
|
||||
initializeLayer();
|
||||
}
|
||||
|
||||
public abstract @Nullable UUID getFurnaceOwner(Furnace furnace);
|
||||
public @NotNull NamespacedKey getNamespacedKey(@NotNull String key) {
|
||||
return new NamespacedKey(mcMMO.p, key);
|
||||
}
|
||||
|
||||
public abstract void setFurnaceOwner(Furnace furnace, UUID uuid);
|
||||
public abstract @Nullable UUID getFurnaceOwner(@NotNull Furnace furnace);
|
||||
|
||||
public abstract void setFurnaceOwner(@NotNull Furnace furnace, @NotNull UUID uuid);
|
||||
|
||||
public abstract void setSuperAbilityBoostedItem(@NotNull ItemStack itemStack, int originalDigSpeed);
|
||||
|
||||
public abstract boolean isSuperAbilityBoosted(@NotNull ItemStack itemStack);
|
||||
|
||||
public abstract int getSuperAbilityToolOriginalDigSpeed(@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);
|
||||
}
|
||||
|
||||
public static String getLegacyAbilityToolLore() {
|
||||
return LEGACY_ABILITY_TOOL_LORE;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package com.gmail.nossr50.util.compat.layers.persistentdata;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataHolder;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
@ -13,6 +16,12 @@ import java.util.UUID;
|
||||
|
||||
public class SpigotPersistentDataLayer extends AbstractPersistentDataLayer {
|
||||
|
||||
/*
|
||||
* Don't modify these keys
|
||||
*/
|
||||
public static final String FURNACE_UUID_MOST_SIG = "furnace_uuid_most_sig";
|
||||
public static final String FURNACE_UUID_LEAST_SIG = "furnace_uuid_least_sig";
|
||||
|
||||
private NamespacedKey furnaceOwner_MostSig_Key;
|
||||
private NamespacedKey furnaceOwner_LeastSig_Key;
|
||||
|
||||
@ -23,17 +32,12 @@ public class SpigotPersistentDataLayer extends AbstractPersistentDataLayer {
|
||||
}
|
||||
|
||||
private void initNamespacedKeys() {
|
||||
furnaceOwner_MostSig_Key = getNamespacedKey("furnace_uuid_most_sig");
|
||||
furnaceOwner_LeastSig_Key = getNamespacedKey("furnace_uuid_least_sig");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public NamespacedKey getNamespacedKey(String key) {
|
||||
return new NamespacedKey(mcMMO.p, key);
|
||||
furnaceOwner_MostSig_Key = getNamespacedKey(FURNACE_UUID_MOST_SIG);
|
||||
furnaceOwner_LeastSig_Key = getNamespacedKey(FURNACE_UUID_LEAST_SIG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UUID getFurnaceOwner(Furnace furnace) {
|
||||
public @Nullable UUID getFurnaceOwner(@NotNull Furnace furnace) {
|
||||
//Get container from entity
|
||||
PersistentDataContainer dataContainer = ((PersistentDataHolder) furnace).getPersistentDataContainer();
|
||||
|
||||
@ -49,7 +53,7 @@ public class SpigotPersistentDataLayer extends AbstractPersistentDataLayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFurnaceOwner(Furnace furnace, UUID uuid) {
|
||||
public void setFurnaceOwner(@NotNull Furnace furnace, @NotNull UUID uuid) {
|
||||
PersistentDataContainer dataContainer = ((PersistentDataHolder) furnace).getPersistentDataContainer();
|
||||
|
||||
dataContainer.set(furnaceOwner_MostSig_Key, PersistentDataType.LONG, uuid.getMostSignificantBits());
|
||||
@ -57,4 +61,75 @@ public class SpigotPersistentDataLayer extends AbstractPersistentDataLayer {
|
||||
|
||||
furnace.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSuperAbilityBoostedItem(@NotNull ItemStack itemStack, int originalDigSpeed) {
|
||||
if(itemStack.getItemMeta() == null) {
|
||||
mcMMO.p.getLogger().severe("Can not assign persistent data to an item with null item metadata");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
|
||||
dataContainer.set(superAbilityBoosted, PersistentDataType.INTEGER, originalDigSpeed);
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuperAbilityBoosted(@NotNull ItemStack itemStack) {
|
||||
if(itemStack.getItemMeta() == null)
|
||||
return false;
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
//Get container from entity
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
|
||||
//If this value isn't null, then the tool can be considered dig speed boosted
|
||||
Integer boostValue = dataContainer.get(superAbilityBoosted, PersistentDataType.INTEGER);
|
||||
|
||||
return boostValue != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSuperAbilityToolOriginalDigSpeed(@NotNull ItemStack itemStack) {
|
||||
//Get container from entity
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta == null)
|
||||
return 0;
|
||||
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
|
||||
if(dataContainer.get(superAbilityBoosted, PersistentDataType.INTEGER) == null) {
|
||||
mcMMO.p.getLogger().severe("Value should never be null for a boosted item");
|
||||
return 0;
|
||||
} else {
|
||||
//Too lazy to make a custom data type for this stuff
|
||||
Integer boostValue = dataContainer.get(superAbilityBoosted, PersistentDataType.INTEGER);
|
||||
return Math.max(boostValue, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBonusDigSpeedOnSuperAbilityTool(@NotNull ItemStack itemStack) {
|
||||
int originalSpeed = getSuperAbilityToolOriginalDigSpeed(itemStack);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
//TODO: can be optimized
|
||||
if(itemMeta.hasEnchant(Enchantment.DIG_SPEED)) {
|
||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||
}
|
||||
|
||||
if(originalSpeed > 0) {
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, originalSpeed, true);
|
||||
}
|
||||
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
dataContainer.remove(superAbilityBoosted); //Remove persistent data
|
||||
|
||||
//TODO: needed?
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,13 @@ package com.gmail.nossr50.util.compat.layers.persistentdata;
|
||||
import com.gmail.nossr50.datatypes.meta.UUIDMeta;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.tags.CustomItemTagContainer;
|
||||
import org.bukkit.inventory.meta.tags.ItemTagType;
|
||||
import org.bukkit.metadata.Metadatable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -20,7 +26,7 @@ public class SpigotTemporaryDataLayer extends AbstractPersistentDataLayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getFurnaceOwner(Furnace furnace) {
|
||||
public UUID getFurnaceOwner(@NotNull Furnace furnace) {
|
||||
Metadatable metadatable = (Metadatable) furnace;
|
||||
|
||||
if(metadatable.getMetadata(FURNACE_OWNER_METADATA_KEY).size() > 0) {
|
||||
@ -32,7 +38,7 @@ public class SpigotTemporaryDataLayer extends AbstractPersistentDataLayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFurnaceOwner(Furnace furnace, UUID uuid) {
|
||||
public void setFurnaceOwner(@NotNull Furnace furnace, @NotNull UUID uuid) {
|
||||
Metadatable metadatable = (Metadatable) furnace;
|
||||
|
||||
if(metadatable.getMetadata(FURNACE_OWNER_METADATA_KEY).size() > 0) {
|
||||
@ -41,4 +47,65 @@ public class SpigotTemporaryDataLayer extends AbstractPersistentDataLayer {
|
||||
|
||||
metadatable.setMetadata(FURNACE_OWNER_METADATA_KEY, new UUIDMeta(mcMMO.p, uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSuperAbilityBoostedItem(@NotNull ItemStack itemStack, int originalDigSpeed) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta == null) {
|
||||
mcMMO.p.getLogger().severe("Item meta should never be null for a super boosted item!");
|
||||
return;
|
||||
}
|
||||
|
||||
itemMeta.getCustomTagContainer().setCustomTag(superAbilityBoosted, ItemTagType.INTEGER, originalDigSpeed);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuperAbilityBoosted(@NotNull ItemStack itemStack) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta == null)
|
||||
return false;
|
||||
|
||||
CustomItemTagContainer tagContainer = itemMeta.getCustomTagContainer();
|
||||
return tagContainer.hasCustomTag(superAbilityBoosted, ItemTagType.INTEGER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSuperAbilityToolOriginalDigSpeed(@NotNull ItemStack itemStack) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta == null)
|
||||
return 0;
|
||||
|
||||
CustomItemTagContainer tagContainer = itemMeta.getCustomTagContainer();
|
||||
|
||||
if(tagContainer.hasCustomTag(superAbilityBoosted , ItemTagType.INTEGER)) {
|
||||
return tagContainer.getCustomTag(superAbilityBoosted, ItemTagType.INTEGER);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBonusDigSpeedOnSuperAbilityTool(@NotNull ItemStack itemStack) {
|
||||
int originalSpeed = getSuperAbilityToolOriginalDigSpeed(itemStack);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta == null)
|
||||
return;
|
||||
|
||||
if(itemMeta.hasEnchant(Enchantment.DIG_SPEED)) {
|
||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||
}
|
||||
|
||||
|
||||
if(originalSpeed > 0) {
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, originalSpeed, true);
|
||||
}
|
||||
|
||||
//TODO: needed?
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public final class CombatUtils {
|
||||
|
||||
//Only execute bonuses if the player is not spamming
|
||||
if (unarmedManager.canUseIronArm()) {
|
||||
finalDamage+=(unarmedManager.calculateIronArmDamage() * mmoPlayer.getAttackStrength());
|
||||
finalDamage+=(unarmedManager.calculateSteelArmStyleDamage() * mmoPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
if (unarmedManager.canUseBerserk()) {
|
||||
|
@ -16,6 +16,7 @@ import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.AbstractPersistentDataLayer;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -29,10 +30,10 @@ 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;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class SkillUtils {
|
||||
|
||||
@ -147,23 +148,24 @@ public class SkillUtils {
|
||||
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (heldItem == null || heldItem.getType() == Material.AIR) {
|
||||
if(heldItem == null)
|
||||
return;
|
||||
|
||||
if (!ItemUtils.canBeSuperAbilityDigBoosted(heldItem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||
ItemMeta itemMeta = heldItem.getItemMeta();
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
int originalDigSpeed = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
itemLore = itemMeta.getLore();
|
||||
}
|
||||
//Add dig speed
|
||||
|
||||
itemLore.add("mcMMO Ability Tool");
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + AdvancedConfig.getInstance().getEnchantBuff(), true);
|
||||
//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));
|
||||
|
||||
itemMeta.setLore(itemLore);
|
||||
heldItem.setItemMeta(itemMeta);
|
||||
//1.13.2+ will have persistent metadata for this item
|
||||
AbstractPersistentDataLayer compatLayer = mcMMO.getCompatibilityManager().getPersistentDataLayer();
|
||||
compatLayer.setSuperAbilityBoostedItem(heldItem, originalDigSpeed);
|
||||
}
|
||||
else {
|
||||
int duration = 0;
|
||||
@ -206,39 +208,41 @@ public class SkillUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleAbilitySpeedDecrease(Player player) {
|
||||
public static void removeAbilityBoostsFromInventory(@NotNull Player player) {
|
||||
if (!HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ItemStack item : player.getInventory().getContents()) {
|
||||
removeAbilityBuff(item);
|
||||
for (ItemStack itemStack : player.getInventory().getContents()) {
|
||||
removeAbilityBuff(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAbilityBuff(ItemStack item) {
|
||||
if (item == null || item.getType() == Material.AIR || (!ItemUtils.isPickaxe(item) && !ItemUtils.isShovel(item)) || !item.containsEnchantment(Enchantment.DIG_SPEED)) {
|
||||
public static void removeAbilityBuff(@Nullable ItemStack itemStack) {
|
||||
if(itemStack == null)
|
||||
return;
|
||||
|
||||
if(!ItemUtils.canBeSuperAbilityDigBoosted(itemStack))
|
||||
return;
|
||||
|
||||
|
||||
//1.13.2+ will have persistent metadata for this itemStack
|
||||
AbstractPersistentDataLayer compatLayer = mcMMO.getCompatibilityManager().getPersistentDataLayer();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
List<String> itemLore = itemMeta.getLore();
|
||||
|
||||
if (itemLore.remove("mcMMO Ability Tool")) {
|
||||
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||
|
||||
if (efficiencyLevel <= AdvancedConfig.getInstance().getEnchantBuff()) {
|
||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||
}
|
||||
else {
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - AdvancedConfig.getInstance().getEnchantBuff(), true);
|
||||
}
|
||||
|
||||
itemMeta.setLore(itemLore);
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
if(compatLayer.isSuperAbilityBoosted(itemStack)) {
|
||||
compatLayer.removeBonusDigSpeedOnSuperAbilityTool(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user