Remove unused method and NBT usage

This commit is contained in:
PikaMug 2024-08-08 05:13:57 -04:00
parent 3a94526373
commit 7f1adc37e1
3 changed files with 2 additions and 45 deletions

View File

@ -10,7 +10,6 @@
package me.pikamug.quests.listeners;
import de.tr7zw.changeme.nbtapi.NBT;
import me.pikamug.quests.BukkitQuestsPlugin;
import me.pikamug.quests.enums.ObjectiveType;
import me.pikamug.quests.events.quester.BukkitQuesterPostUpdateObjectiveEvent;
@ -22,12 +21,10 @@ import me.pikamug.quests.player.Quester;
import me.pikamug.quests.quests.Quest;
import me.pikamug.quests.quests.components.BukkitObjective;
import me.pikamug.quests.quests.components.BukkitStage;
import me.pikamug.quests.util.stack.BlockItemStack;
import me.pikamug.quests.util.BukkitLang;
import me.pikamug.quests.util.stack.BlockItemStack;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.Ageable;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -39,7 +36,6 @@ import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.LinkedList;
@ -375,39 +371,4 @@ public class BukkitBlockListener implements Listener {
}
}
}
/**
* Gets item equivalent of Block, unless server is on certain builds of Paper
* server software, in which case may return null
*
* @param block Block to convert
* @return item or null
*/
@SuppressWarnings("deprecation")
private ItemStack getItemEquivalent(final Block block) {
short durability = 0;
try {
durability = block.getState().getData().toItemStack().getDurability();
} catch (final IllegalArgumentException e) {
// https://github.com/PikaMug/Quests/issues/2236
}
try {
return new ItemStack(block.getType(), 1, durability);
} catch (final IllegalArgumentException e) {
// https://github.com/PikaMug/Quests/issues/2243
}
try {
// Should only happen on Paper 1.21+
final ItemStack item = new ItemStack(block.getBlockData().getPlacementMaterial());
if (block.getBlockData() instanceof Ageable) {
NBT.modify(item, nbt -> {
nbt.setShort("quests_age", (short) ((Ageable)block.getBlockData()).getAge());
});
}
return item;
} catch (Exception e) {
// https://github.com/PikaMug/Quests/issues/2256
}
return null;
}
}

View File

@ -1858,7 +1858,7 @@ public class BukkitQuester implements Quester {
}
} */ else if (Material.getMaterial("CRAFTER") != null && broken.getType().isEdible()) {
// Paper 1.21+ is special case
final short toBreakAge = /* NBT.get(toBreak, nbt -> (short) nbt.getShort("quests_age")); */ 0;
final short toBreakAge = 0;
final short brokenAge = broken.getDurability();
if (toBreakAge > 0) {
// Age toBreak specified so check for durability

View File

@ -10,7 +10,6 @@
package me.pikamug.quests.util;
import de.tr7zw.changeme.nbtapi.NBT;
import me.pikamug.quests.util.stack.BlockItemStack;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -233,9 +232,6 @@ public class BukkitItemUtil {
if (mat.isBlock() && Material.getMaterial("CRAFTER") != null) {
// Paper 1.21+ does not allow ItemStack from unobtainable blocks (i.e. CARROTS block)
item = new ItemStack(mat.createBlockData().getPlacementMaterial(), amount);
NBT.modify(item, nbt -> {
nbt.setShort("quests_age", durability);
});
} else {
item = new ItemStack(mat, amount, durability);
}