diff --git a/core/pom.xml b/core/pom.xml index 033f786c9..fe54bb80a 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -76,7 +76,7 @@ org.spigotmc spigot-api - 1.13.2-R0.1-SNAPSHOT + 1.19.4-R0.1-SNAPSHOT provided @@ -166,7 +166,7 @@ com.github.PikaMug LocaleLib - 3.9 + 60b38e1fbe de.tr7zw @@ -285,6 +285,12 @@ plugin.yml + + de.tr7zw:item-nbt-api-plugin + + plugin.yml + + diff --git a/core/src/main/java/me/pikamug/quests/listeners/BukkitBlockListener.java b/core/src/main/java/me/pikamug/quests/listeners/BukkitBlockListener.java index c4c131a87..374d4c390 100644 --- a/core/src/main/java/me/pikamug/quests/listeners/BukkitBlockListener.java +++ b/core/src/main/java/me/pikamug/quests/listeners/BukkitBlockListener.java @@ -402,6 +402,11 @@ public class BukkitBlockListener implements Listener { } catch (final IllegalArgumentException e) { // https://github.com/PikaMug/Quests/issues/2243 } + try { + return new ItemStack(block.getBlockData().getPlacementMaterial(), 1, durability); + } catch (Exception e) { + // https://github.com/PikaMug/Quests/issues/2256 + } return null; } } diff --git a/core/src/main/java/me/pikamug/quests/util/BukkitItemUtil.java b/core/src/main/java/me/pikamug/quests/util/BukkitItemUtil.java index d58d99ddb..6626df2d6 100644 --- a/core/src/main/java/me/pikamug/quests/util/BukkitItemUtil.java +++ b/core/src/main/java/me/pikamug/quests/util/BukkitItemUtil.java @@ -223,10 +223,14 @@ public class BukkitItemUtil { return null; } try { - final Material mat = Material.getMaterial(material.toUpperCase()); + Material mat = Material.getMaterial(material.toUpperCase()); if (mat == null) { return null; } + if (mat.isBlock() && Material.getMaterial("CRAFTER") != null) { + // Paper 1.21+ does not allow ItemStack from unobtainable blocks (i.e. CARROTS block) + mat = mat.createBlockData().getPlacementMaterial(); + } return new ItemStack(mat, amount, durability); } catch (final Exception e) { try { diff --git a/core/src/main/java/me/pikamug/quests/util/BukkitLang.java b/core/src/main/java/me/pikamug/quests/util/BukkitLang.java index 510e7e33d..80785a3da 100644 --- a/core/src/main/java/me/pikamug/quests/util/BukkitLang.java +++ b/core/src/main/java/me/pikamug/quests/util/BukkitLang.java @@ -10,8 +10,8 @@ package me.pikamug.quests.util; -import me.pikamug.quests.Quests; import me.clip.placeholderapi.PlaceholderAPI; +import me.pikamug.quests.Quests; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -25,6 +25,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.lang.reflect.Method; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.Collection; @@ -59,7 +60,6 @@ public class BukkitLang { * @param key label as it appears in lang file, such as "journalNoQuests" * @return formatted string, plus processing through PlaceholderAPI by clip */ - @SuppressWarnings("deprecation") public static String get(final Player player, final String key) { if (key == null) { return null; @@ -71,7 +71,15 @@ public class BukkitLang { try { locale = player.getLocale(); } catch (final NoSuchMethodError e) { - locale = player.spigot().getLocale(); + try { + final Method m = player.spigot().getClass().getDeclaredMethod("getLocale"); + m.setAccessible(true); + locale = (String) m.invoke(player.spigot()); + } catch (final Exception e2) { + plugin.getPluginLogger().severe("Legacy player locale reflection failed, defaulting to en_US"); + e2.printStackTrace(); + locale = "en_US"; + } } final int separator = locale.indexOf("_"); if (separator == -1) {