Skip to content

Commit

Permalink
fix(MinecraftUtils): Reflection
Browse files Browse the repository at this point in the history
Fixed MinecraftUtils Reflection
  • Loading branch information
GeorgeV220 committed Apr 30, 2022
1 parent cc31cd7 commit e1aefd2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/georgev22/api/minecraft/MinecraftUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,12 @@ public static MinecraftVersion getCurrentVersion() {
return currentVersion.name();
}

@Contract(pure = true)
public static @NotNull String getCurrentVersionNameVtoLowerCase() {
return currentVersion.name().replace("V", "v");
}


static {
try {
currentVersion = MinecraftVersion.valueOf(Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].toUpperCase());
Expand All @@ -635,7 +641,7 @@ public static boolean isRepackaged() {

@Contract(pure = true)
public static @NotNull String getNMSClassName(String className) {
return NET_MINECRAFT_SERVER_PACKAGE + '.' + MinecraftVersion.getCurrentVersionName() + '.' + className;
return NET_MINECRAFT_SERVER_PACKAGE + '.' + MinecraftVersion.getCurrentVersionNameVtoLowerCase() + '.' + className;
}

public static @NotNull Class<?> getNMSClass(String className) throws ClassNotFoundException {
Expand All @@ -648,7 +654,7 @@ public static Optional<Class<?>> getNMSOptionalClass(String className) {

@Contract(pure = true)
public static @NotNull String getOBCClassName(String className) {
return ORG_BUKKIT_CRAFTBUKKIT_PACKAGE + '.' + MinecraftVersion.getCurrentVersionName() + '.' + className;
return ORG_BUKKIT_CRAFTBUKKIT_PACKAGE + '.' + MinecraftVersion.getCurrentVersionNameVtoLowerCase() + '.' + className;
}

public static @NotNull Class<?> getOBCClass(String className) throws ClassNotFoundException {
Expand Down

0 comments on commit e1aefd2

Please sign in to comment.