Use full implementation version as subplatform name

This commit is contained in:
RaphiMC 2023-08-15 01:49:41 +02:00
parent 0e02ecf818
commit 99e8fa7b83
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
3 changed files with 12 additions and 1 deletions

View File

@ -30,6 +30,7 @@ dependencies {
blossom { blossom {
replaceToken("\${version}", project.version, "src/main/java/net/raphimc/vialegacy/ViaLegacy.java") replaceToken("\${version}", project.version, "src/main/java/net/raphimc/vialegacy/ViaLegacy.java")
replaceToken("\${impl_version}", "git-${project.archivesBaseName}-${project.version}:${latestCommitHash()}", "src/main/java/net/raphimc/vialegacy/ViaLegacy.java")
} }
java { java {
@ -87,3 +88,12 @@ publishing {
} }
} }
} }
String latestCommitHash() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "--short", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim()
}

View File

@ -23,6 +23,7 @@ import net.raphimc.vialegacy.platform.ViaLegacyPlatform;
public class ViaLegacy { public class ViaLegacy {
public static final String VERSION = "${version}"; public static final String VERSION = "${version}";
public static final String IMPL_VERSION = "${impl_version}";
private static ViaLegacyPlatform platform; private static ViaLegacyPlatform platform;
private static ViaLegacyConfig config; private static ViaLegacyConfig config;

View File

@ -74,7 +74,7 @@ public interface ViaLegacyPlatform {
final ViaLegacyConfig config = new ViaLegacyConfig(new File(dataFolder, "vialegacy.yml")); final ViaLegacyConfig config = new ViaLegacyConfig(new File(dataFolder, "vialegacy.yml"));
config.reloadConfig(); config.reloadConfig();
ViaLegacy.init(this, config); ViaLegacy.init(this, config);
Via.getManager().getSubPlatforms().add("ViaLegacy-" + ViaLegacy.VERSION); Via.getManager().getSubPlatforms().add(ViaLegacy.IMPL_VERSION);
final ProtocolManager protocolManager = Via.getManager().getProtocolManager(); final ProtocolManager protocolManager = Via.getManager().getProtocolManager();
protocolManager.registerProtocol(new Protocol1_8to1_7_6_10(), ProtocolVersion.v1_8, ProtocolVersion.v1_7_6); protocolManager.registerProtocol(new Protocol1_8to1_7_6_10(), ProtocolVersion.v1_8, ProtocolVersion.v1_7_6);