fix(stats): skip registry entries without keys
This commit is contained in:
@@ -7,7 +7,11 @@ final class BukkitRegistryKeys {
|
||||
private BukkitRegistryKeys() {}
|
||||
|
||||
static NamespacedKey get(Keyed value) {
|
||||
return value.getKey();
|
||||
try {
|
||||
return value.getKey();
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static String format(Keyed value, String fallback) {
|
||||
|
||||
@@ -21,4 +21,13 @@ class BukkitRegistryKeysTest {
|
||||
|
||||
assertNull(BukkitRegistryKeys.get(keyed));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reportsAKeyThatBukkitRejectsAsUnavailable() {
|
||||
Keyed keyed = () -> {
|
||||
throw new IllegalArgumentException("Registry entry does not have a key");
|
||||
};
|
||||
|
||||
assertNull(BukkitRegistryKeys.get(keyed));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user