From 134a361fa6e880118b40b2a9696b392987174c8b Mon Sep 17 00:00:00 2001 From: Yenil <85287520+ImYenil@users.noreply.github.com> Date: Sun, 4 Feb 2024 01:15:45 +0900 Subject: [PATCH] Fixed NullPointerException (#967) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add 1.20.4 support (#949) add 1.20.4 support * Fixed NullPointerException Fixed NullPointerException Error Log: https://pastebin.com/DCWeqQKQ --------- Co-authored-by: Andrei Dascălu --- .../andrei1058/bedwars/support/version/v1_12_R1/v1_12_R1.java | 3 +++ .../andrei1058/bedwars/support/version/v1_8_R3/v1_8_R3.java | 3 +++ .../andrei1058/bedwars/support/version/v1_16_R3/v1_16_R3.java | 3 +++ .../andrei1058/bedwars/support/version/v1_17_R1/v1_17_R1.java | 3 +++ .../andrei1058/bedwars/support/version/v1_18_R2/v1_18_R2.java | 3 +++ 5 files changed, 15 insertions(+) diff --git a/versionsupport_1_12_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_12_R1/v1_12_R1.java b/versionsupport_1_12_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_12_R1/v1_12_R1.java index 4c1ca7fc1..bae30a535 100644 --- a/versionsupport_1_12_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_12_R1/v1_12_R1.java +++ b/versionsupport_1_12_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_12_R1/v1_12_R1.java @@ -74,6 +74,9 @@ public v1_12_R1(Plugin plugin, String name) { @Override public String getTag(org.bukkit.inventory.ItemStack itemStack, String key) { net.minecraft.server.v1_12_R1.ItemStack i = CraftItemStack.asNMSCopy(itemStack); + if (i == null) { + return null; + } NBTTagCompound tag = i.getTag(); return tag == null ? null : tag.hasKey(key) ? tag.getString(key) : null; } diff --git a/versionsupport_1_8_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_8_R3/v1_8_R3.java b/versionsupport_1_8_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_8_R3/v1_8_R3.java index 470bd67c1..d5ec519ca 100644 --- a/versionsupport_1_8_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_8_R3/v1_8_R3.java +++ b/versionsupport_1_8_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_8_R3/v1_8_R3.java @@ -441,6 +441,9 @@ public ItemStack setTag(ItemStack itemStack, String key, String value) { @Override public String getTag(ItemStack itemStack, String key) { net.minecraft.server.v1_8_R3.ItemStack i = CraftItemStack.asNMSCopy(itemStack); + if (i == null) { + return null; + } NBTTagCompound tag = i.getTag(); return tag == null ? null : tag.hasKey(key) ? tag.getString(key) : null; } diff --git a/versionsupport_v1_16_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_16_R3/v1_16_R3.java b/versionsupport_v1_16_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_16_R3/v1_16_R3.java index c4505029d..abaefe746 100644 --- a/versionsupport_v1_16_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_16_R3/v1_16_R3.java +++ b/versionsupport_v1_16_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_16_R3/v1_16_R3.java @@ -90,6 +90,9 @@ public void registerCommand(String name, Command clasa) { @Override public String getTag(org.bukkit.inventory.ItemStack itemStack, String key) { net.minecraft.server.v1_16_R3.ItemStack i = CraftItemStack.asNMSCopy(itemStack); + if (i == null) { + return null; + } NBTTagCompound tag = i.getTag(); return tag == null ? null : tag.hasKey(key) ? tag.getString(key) : null; } diff --git a/versionsupport_v1_17_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_17_R1/v1_17_R1.java b/versionsupport_v1_17_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_17_R1/v1_17_R1.java index 90dd24449..517776844 100644 --- a/versionsupport_v1_17_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_17_R1/v1_17_R1.java +++ b/versionsupport_v1_17_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_17_R1/v1_17_R1.java @@ -116,6 +116,9 @@ public void registerCommand(String name, Command clasa) { @Override public String getTag(org.bukkit.inventory.ItemStack itemStack, String key) { ItemStack i = CraftItemStack.asNMSCopy(itemStack); + if (i == null) { + return null; + } NBTTagCompound tag = i.getTag(); return tag == null ? null : tag.hasKey(key) ? tag.getString(key) : null; } diff --git a/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/v1_18_R2.java b/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/v1_18_R2.java index ac7d044db..c8539da7d 100644 --- a/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/v1_18_R2.java +++ b/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/v1_18_R2.java @@ -106,6 +106,9 @@ public void registerCommand(String name, Command clasa) { @Override public String getTag(org.bukkit.inventory.ItemStack itemStack, String key) { ItemStack i = CraftItemStack.asNMSCopy(itemStack); + if (i == null) { + return null; + } NBTTagCompound tag = i.t(); return tag == null ? null : tag.e(key) ? tag.l(key) : null; }