Skip to content

Commit 0f3ed61

Browse files
committed
Items - change PDC methods
1 parent 95fe343 commit 0f3ed61

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

src/main/java/com/shanebeestudios/hg/api/util/ItemUtils.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ public static boolean isCursed(ItemStack itemStack) {
3333

3434
public static ItemStack getTrackingStick() {
3535
ItemStack itemStack = ItemType.STICK.createItemStack();
36-
ItemMeta itemMeta = itemStack.getItemMeta();
37-
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer();
38-
pdc.set(Constants.TRACKING_STICK_KEY, PersistentDataType.BOOLEAN, true);
39-
itemStack.setItemMeta(itemMeta);
36+
itemStack.editPersistentDataContainer(pdc ->
37+
pdc.set(Constants.TRACKING_STICK_KEY, PersistentDataType.BOOLEAN, true));
4038

4139
itemStack.setData(DataComponentTypes.ITEM_NAME, Util.getMini(LANG.item_tracking_stick_name));
4240
itemStack.setData(DataComponentTypes.MAX_STACK_SIZE, 1);

src/main/java/com/shanebeestudios/hg/plugin/listeners/GameCompassListener.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.shanebeestudios.hg.api.gui.SpectatorGUI;
55
import com.shanebeestudios.hg.api.util.Constants;
66
import com.shanebeestudios.hg.plugin.HungerGames;
7+
import io.papermc.paper.persistence.PersistentDataContainerView;
78
import org.bukkit.Material;
89
import org.bukkit.entity.Player;
910
import org.bukkit.event.EventHandler;
@@ -12,8 +13,6 @@
1213
import org.bukkit.event.player.PlayerInteractEvent;
1314
import org.bukkit.inventory.Inventory;
1415
import org.bukkit.inventory.ItemStack;
15-
import org.bukkit.inventory.meta.ItemMeta;
16-
import org.bukkit.persistence.PersistentDataContainer;
1716
import org.bukkit.persistence.PersistentDataType;
1817

1918
public class GameCompassListener extends GameListenerBase {
@@ -57,10 +56,8 @@ private boolean isSpectatorCompass(PlayerInteractEvent event) {
5756

5857
ItemStack item = event.getItem();
5958
if (item == null || item.getType() != Material.COMPASS) return false;
60-
ItemMeta itemMeta = item.getItemMeta();
61-
if (itemMeta == null) return false;
6259

63-
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer();
60+
PersistentDataContainerView pdc = item.getPersistentDataContainer();
6461
return pdc.has(Constants.SPECTATOR_COMPASS_KEY, PersistentDataType.BOOLEAN);
6562
}
6663

src/main/java/com/shanebeestudios/hg/plugin/managers/ItemManager.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.bukkit.configuration.ConfigurationSection;
1414
import org.bukkit.configuration.file.YamlConfiguration;
1515
import org.bukkit.inventory.ItemStack;
16-
import org.bukkit.persistence.PersistentDataContainer;
1716
import org.bukkit.persistence.PersistentDataType;
1817
import org.jetbrains.annotations.Nullable;
1918

@@ -116,10 +115,8 @@ public List<ItemStack> loadItems(ConfigurationSection config) {
116115
public ItemStack getSpectatorCompass() {
117116
ItemStack compass = new ItemStack(Material.COMPASS);
118117
compass.setData(DataComponentTypes.ITEM_NAME, Util.getMini(this.lang.spectate_compass_name));
119-
compass.editMeta(itemMeta -> {
120-
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer();
121-
pdc.set(Constants.SPECTATOR_COMPASS_KEY, PersistentDataType.BOOLEAN, true);
122-
});
118+
compass.editPersistentDataContainer(pdc ->
119+
pdc.set(Constants.SPECTATOR_COMPASS_KEY, PersistentDataType.BOOLEAN, true));
123120
return compass;
124121
}
125122

0 commit comments

Comments
 (0)