mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 02:25:42 +01:00
Remove unused method and NBT usage
This commit is contained in:
parent
3a94526373
commit
7f1adc37e1
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
package me.pikamug.quests.listeners;
|
package me.pikamug.quests.listeners;
|
||||||
|
|
||||||
import de.tr7zw.changeme.nbtapi.NBT;
|
|
||||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||||
import me.pikamug.quests.enums.ObjectiveType;
|
import me.pikamug.quests.enums.ObjectiveType;
|
||||||
import me.pikamug.quests.events.quester.BukkitQuesterPostUpdateObjectiveEvent;
|
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.Quest;
|
||||||
import me.pikamug.quests.quests.components.BukkitObjective;
|
import me.pikamug.quests.quests.components.BukkitObjective;
|
||||||
import me.pikamug.quests.quests.components.BukkitStage;
|
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.BukkitLang;
|
||||||
|
import me.pikamug.quests.util.stack.BlockItemStack;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.data.Ageable;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
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.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1858,7 +1858,7 @@ public class BukkitQuester implements Quester {
|
|||||||
}
|
}
|
||||||
} */ else if (Material.getMaterial("CRAFTER") != null && broken.getType().isEdible()) {
|
} */ else if (Material.getMaterial("CRAFTER") != null && broken.getType().isEdible()) {
|
||||||
// Paper 1.21+ is special case
|
// 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();
|
final short brokenAge = broken.getDurability();
|
||||||
if (toBreakAge > 0) {
|
if (toBreakAge > 0) {
|
||||||
// Age toBreak specified so check for durability
|
// Age toBreak specified so check for durability
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
package me.pikamug.quests.util;
|
package me.pikamug.quests.util;
|
||||||
|
|
||||||
import de.tr7zw.changeme.nbtapi.NBT;
|
|
||||||
import me.pikamug.quests.util.stack.BlockItemStack;
|
import me.pikamug.quests.util.stack.BlockItemStack;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -233,9 +232,6 @@ public class BukkitItemUtil {
|
|||||||
if (mat.isBlock() && Material.getMaterial("CRAFTER") != null) {
|
if (mat.isBlock() && Material.getMaterial("CRAFTER") != null) {
|
||||||
// Paper 1.21+ does not allow ItemStack from unobtainable blocks (i.e. CARROTS block)
|
// Paper 1.21+ does not allow ItemStack from unobtainable blocks (i.e. CARROTS block)
|
||||||
item = new ItemStack(mat.createBlockData().getPlacementMaterial(), amount);
|
item = new ItemStack(mat.createBlockData().getPlacementMaterial(), amount);
|
||||||
NBT.modify(item, nbt -> {
|
|
||||||
nbt.setShort("quests_age", durability);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
item = new ItemStack(mat, amount, durability);
|
item = new ItemStack(mat, amount, durability);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user