Skip to content

Commit

Permalink
Removed usage of deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartGecko44 committed Jun 27, 2024
1 parent 7c29345 commit a039d07
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 29 deletions.
8 changes: 5 additions & 3 deletions src/main/java/org/gecko/spigotadmintoys/gui/ConfigGUI.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gecko.spigotadmintoys.gui;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadableItemNBT;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand All @@ -14,6 +15,8 @@
import org.gecko.spigotadmintoys.data.ConfigurationManager;
import org.gecko.spigotadmintoys.logic.SetAndGet;

import java.util.function.Function;

public class ConfigGUI implements Listener {

public static final String ENABLE_BUCKET = "Enable Bucket";
Expand Down Expand Up @@ -131,8 +134,7 @@ private boolean isClickEventValid(InventoryClickEvent event) {

private void handleItemClick(Player player, ItemStack clickedItem) {
if (clickedItem != null && (clickedItem.getType() == Material.INK_SACK || clickedItem.getType() == Material.PAPER || clickedItem.getType() == Material.CONCRETE || clickedItem.getType() == Material.ARROW)) {
NBTItem nbtItem = new NBTItem(clickedItem);
String identifier = nbtItem.getString("Ident");
String identifier = NBT.get(clickedItem, (Function<ReadableItemNBT, String>) nbt -> nbt.getString("Ident"));
short data = clickedItem.getDurability();

if (handleButtonFeatures(player, identifier, data)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.gecko.spigotadmintoys.gui.logic;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadWriteItemNBT;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;

public class CreateButtonItem {

Expand All @@ -28,9 +30,8 @@ public ItemStack createButtonItem(Material material, String name, short data, St
meta.setLore(loreToString);
item.setItemMeta(meta);

NBTItem nbtItem = new NBTItem(item);
nbtItem.setString("Ident", ident);
NBT.modify(item, (Consumer<ReadWriteItemNBT>) nbt -> nbt.setString("Ident", ident));

return nbtItem.getItem();
return item;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.gecko.spigotadmintoys.items;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadWriteItemNBT;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;

public class TriggerItems {

Expand All @@ -21,9 +23,8 @@ public ItemStack createCustomItem(Material material, String name, short data, St
meta.setLore(loreToList);
item.setItemMeta(meta);

NBTItem nbtItem = new NBTItem(item);
nbtItem.setString("Ident", ident);
NBT.modify(item, (Consumer<ReadWriteItemNBT>) nbt -> nbt.setString("Ident", ident));

return nbtItem.getItem();
return item;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gecko.spigotadmintoys.items.weapons;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadableItemNBT;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Arrow;
Expand All @@ -12,6 +13,8 @@
import org.gecko.spigotadmintoys.enchantments.enchants.weapons.bows.BowListener;
import org.gecko.spigotadmintoys.items.TriggerItems;

import java.util.function.Function;

public class Shortbow implements Listener {

public static final String SHORTBOWCONST = "Shortbow";
Expand All @@ -31,8 +34,7 @@ public void onPlayerBowClick(PlayerInteractEvent event) {
return;
}

NBTItem nbtItem = new NBTItem(event.getPlayer().getInventory().getItemInMainHand());
String identifier = nbtItem.getString("Ident");
String identifier = NBT.get(event.getPlayer().getInventory().getItemInMainHand(), (Function<ReadableItemNBT, String>) nbt -> nbt.getString("Ident"));

if (!identifier.equals(SHORTBOWCONST)) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gecko.spigotadmintoys.listeners;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadableItemNBT;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
Expand All @@ -20,6 +21,7 @@
import org.gecko.spigotadmintoys.logic.SetAndGet;

import java.util.*;
import java.util.function.Function;

public class BarrierListener implements Listener {

Expand Down Expand Up @@ -61,8 +63,7 @@ public void barrierBreakEventHandler(BlockBreakEvent event) {
BucketListener bucketListener = setAndGet.getBucketListener();
BedrockListener bedrockListener = setAndGet.getBedrockListener();
WaterBucketListener waterBucketListener = setAndGet.getWaterBucketListener();
NBTItem nbtItem = new NBTItem(event.getPlayer().getInventory().getItemInMainHand());
String identifier = nbtItem.getString("Ident");
String identifier = NBT.get(event.getPlayer().getInventory().getItemInMainHand(), (Function<ReadableItemNBT, String>) nbt -> nbt.getString("Ident"));
radiusLimit = setAndGet.getRadiusLimit();
realRadiusLimit = radiusLimit - 2;
showRemoval = setAndGet.getShowRemoval();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gecko.spigotadmintoys.listeners;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadableItemNBT;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
Expand All @@ -24,6 +25,7 @@
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;

public class BedrockListener implements Listener {

Expand Down Expand Up @@ -168,8 +170,7 @@ private void bedrockPlayerSource(BlockBreakEvent event) {
return;
}
Player player = event.getPlayer();
NBTItem nbtItem = new NBTItem(event.getPlayer().getInventory().getItemInMainHand());
String identifier = nbtItem.getString("Ident");
String identifier = NBT.get(event.getPlayer().getInventory().getItemInMainHand(), (Function<ReadableItemNBT, String>) nbt -> nbt.getString("Ident"));
// Check if the bucket is filling with water
if (player.getInventory().getItemInMainHand().getType() == Material.BEDROCK && identifier.equalsIgnoreCase("Custom Bedrock") && (!IMMUTABLE_MATERIALS.contains(event.getBlock().getType()))) {
allRemovalActive = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gecko.spigotadmintoys.listeners;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadableItemNBT;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
Expand All @@ -20,6 +21,7 @@
import org.gecko.spigotadmintoys.logic.SetAndGet;

import java.util.*;
import java.util.function.Function;

public class BucketListener implements Listener {

Expand Down Expand Up @@ -63,8 +65,7 @@ public void onBucketFill(PlayerBucketFillEvent event) {
BarrierListener barrierListener = setAndGet.getBarrierListener();
BedrockListener bedrockListener = setAndGet.getBedrockListener();
WaterBucketListener waterBucketListener = setAndGet.getWaterBucketListener();
NBTItem nbtItem = new NBTItem(event.getPlayer().getInventory().getItemInMainHand());
String identifier = nbtItem.getString("Ident");
String identifier = NBT.get(event.getPlayer().getInventory().getItemInMainHand(), (Function<ReadableItemNBT, String>) nbt -> nbt.getString("Ident"));
radiusLimit = setAndGet.getRadiusLimit();
realRadiusLimit = radiusLimit - 2;
showRemoval = setAndGet.getShowRemoval();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gecko.spigotadmintoys.listeners;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadableItemNBT;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
Expand All @@ -22,6 +23,7 @@
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;

public class SphereMaker implements Listener {

Expand Down Expand Up @@ -64,8 +66,7 @@ public void onBlockBreak(BlockBreakEvent event) {
BedrockListener bedrockListener = setAndGet.getBedrockListener();
BucketListener bucketListener = setAndGet.getBucketListener();
WaterBucketListener waterBucketListener = setAndGet.getWaterBucketListener();
NBTItem nbtItem = new NBTItem(event.getPlayer().getInventory().getItemInMainHand());
String identifier = nbtItem.getString("Ident");
String identifier = NBT.get(event.getPlayer().getInventory().getItemInMainHand(), (Function<ReadableItemNBT, String>) nbt -> nbt.getString("Ident"));
radiusLimit = setAndGet.getRadiusLimit();
realradiusLimit = setAndGet.getRadiusLimit() - 2;
if (realradiusLimit > 1 && !barrierListener.isBlockRemovalActive() && !bedrockListener.isAllRemovalActive() && !bucketListener.isWauhRemovalActive() && !waterBucketListener.isTsunamiActive() && !IMMUTABLE_MATERIALS.contains(event.getBlock().getType()) && identifier.equals("SphereMaker")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gecko.spigotadmintoys.listeners;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadableItemNBT;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
Expand All @@ -20,6 +21,7 @@
import org.gecko.spigotadmintoys.logic.SetAndGet;

import java.util.*;
import java.util.function.Function;

public class WaterBucketListener implements Listener {

Expand Down Expand Up @@ -60,8 +62,7 @@ public void tsunamiClick(PlayerBucketEmptyEvent event) {
BucketListener bucketListener = setAndGet.getBucketListener();
BarrierListener barrierListener = setAndGet.getBarrierListener();
BedrockListener bedrockListener = setAndGet.getBedrockListener();
NBTItem nbtItem = new NBTItem(event.getPlayer().getInventory().getItemInMainHand());
String identifier = nbtItem.getString("Ident");
String identifier = NBT.get(event.getPlayer().getInventory().getItemInMainHand(), (Function<ReadableItemNBT, String>) nbt -> nbt.getString("Ident"));
radiusLimit = setAndGet.getRadiusLimit();
realRadiusLimit = radiusLimit - 2;
showRemoval = setAndGet.getShowRemoval();
Expand Down

0 comments on commit a039d07

Please sign in to comment.