Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/main/java/me/pikamug/localelib/LocaleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public LocaleManager() {
isPost1dot18 = true;
}
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
final String bukkitVersion = Bukkit.getBukkitVersion();
try {
if (packageName.equals("org.bukkit.craftbukkit")) {
// Bukkit version is 1.20.5+
Expand All @@ -92,7 +93,13 @@ public LocaleManager() {
}
}
} catch (final ClassNotFoundException e) {
e.printStackTrace();
Bukkit.getLogger().severe("[LocaleLib] Unable to resolve NMS/CraftBukkit classes for this server "
+ "version (" + bukkitVersion + "): " + e.getMessage());
}
if (!oldVersion && (craftMagicNumbers == null || itemClazz == null)) {
Bukkit.getLogger().severe("[LocaleLib] This server version (" + bukkitVersion + ") does not appear to "
+ "be supported. Material name translation will not work; entity and enchantment translation "
+ "are unaffected.");
}
try {
englishTranslations = LocaleKeys.loadTranslations();
Expand Down Expand Up @@ -446,6 +453,11 @@ public String queryMaterial(final Material material, final short durability, fin
if (material.isBlock() && material.createBlockData() instanceof Ageable) {
matKey = "block.minecraft." + material.name().toLowerCase();
} else {
if (craftMagicNumbers == null || itemClazz == null) {
throw new IllegalArgumentException("[LocaleLib] Cannot query material '" + material.name()
+ "': NMS/CraftBukkit classes were not resolved for this server version ("
+ Bukkit.getBukkitVersion() + ") at startup.");
}
try {
final Method itemMethod = craftMagicNumbers.getDeclaredMethod("getItem", material.getClass());
itemMethod.setAccessible(true);
Expand Down