Skip to content

Commit

Permalink
Get ready for Paper no longer relocating CB under MC ver (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalshyDev authored Feb 14, 2024
1 parent 6a47ff9 commit 6e05a2e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
15 changes: 15 additions & 0 deletions dough-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,19 @@
<artifactId>dough-common</artifactId>
<packaging>jar</packaging>

<repositories>
<repository>
<id>papermc-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.7</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import io.github.bakedlibs.dough.versions.MinecraftVersion;
import io.github.bakedlibs.dough.versions.UnknownServerVersionException;
import io.papermc.lib.PaperLib;

/**
* This class provides some useful static methods to perform reflection.
Expand Down Expand Up @@ -53,10 +54,18 @@ private ReflectionUtils() {}

if (versionSpecificPackage == null) {
String packageName = Bukkit.getServer().getClass().getPackage().getName();
versionSpecificPackage = packageName.substring(packageName.lastIndexOf('.') + 1);

// Paper are no longer relocating CB to live under the version in the package name
// This means org.bukkit.craftbukkit.v1_20_R1.CraftWorld is now org.bukkit.craftbukkit.CraftWorld
// So we check that it is Paper and does NOT have the _v1 in the package name and just return an empty string
if (PaperLib.isPaper() && !packageName.contains(".v1_")) {
return (versionSpecificPackage = "");
}

versionSpecificPackage = packageName.substring(packageName.lastIndexOf('.') + 1) + '.';
}

return versionSpecificPackage + '.';
return versionSpecificPackage;
}

/**
Expand Down

0 comments on commit 6e05a2e

Please sign in to comment.