Skip to content

Commit

Permalink
Added #nmsClass that can get from spigot/mojang name
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominilk01 authored Jul 5, 2024
1 parent 4aafc61 commit dd6179a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/fr/mrmicky/fastboard/FastReflection.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ public static Class<?> nmsClass(String post1_17package, String className) throws
return Class.forName(nmsClassName(post1_17package, className));
}

public static Class<?> nmsClass(String post1_17package, String spigotClassName, String mojangClassName) throws ClassNotFoundException {
Class<?> clazz;
try {
clazz = Class.forName(nmsClassName(post1_17package, spigotClassName));
} catch (ClassNotFoundException spigotNotFound) {
try {
clazz = Class.forName(nmsClassName(post1_17package, mojangClassName));
} catch (ClassNotFoundException mojangNotFound) {
throw new ClassNotFoundException("Class : " + spigotClassName + " / " + mojangClassName + " could not be found");
}
}
return clazz;
}

public static Optional<Class<?>> nmsOptionalClass(String post1_17package, String className) {
return optionalClass(nmsClassName(post1_17package, className));
}
Expand Down

0 comments on commit dd6179a

Please sign in to comment.