mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-21 18:15:32 +01:00
Use block placement material on 1.21+, fixes #2256
This commit is contained in:
parent
f5b3dc8614
commit
ba078ea7f8
10
core/pom.xml
10
core/pom.xml
@ -76,7 +76,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -166,7 +166,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.PikaMug</groupId>
|
||||
<artifactId>LocaleLib</artifactId>
|
||||
<version>3.9</version>
|
||||
<version>60b38e1fbe</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.tr7zw</groupId>
|
||||
@ -285,6 +285,12 @@
|
||||
<exclude>plugin.yml</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>de.tr7zw:item-nbt-api-plugin</artifact>
|
||||
<excludes>
|
||||
<exclude>plugin.yml</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user