Fixes plugin versioning #12

This commit is contained in:
Sotr
2018-06-24 21:02:02 +08:00
parent 8db031c856
commit 4c622207e1
3 changed files with 18 additions and 1 deletions

View File

@@ -81,6 +81,12 @@ public abstract class Akari {
}
}
private static final String serverVersion = Akari.class.getPackage().getImplementationVersion();
public static String getServerVersion() {
return serverVersion + " (MC: " + MinecraftServer.getServer().getVersion() + ")";
}
/*
* Timings
*/

View File

@@ -14,8 +14,10 @@ import net.minecraft.server.MinecraftServer;
@Mixin(value = CraftServer.class, remap = false)
public abstract class MixinCraftServer {
@Shadow @Final @Mutable private String serverName;
@Shadow @Final @Mutable private String serverVersion;
@Shadow @Final protected MinecraftServer console;
private boolean needApplyServerName = true;
private boolean needApplyServerVersion = true;
@Overwrite
public String getName() {
@@ -28,6 +30,15 @@ public abstract class MixinCraftServer {
return serverName;
}
@Overwrite
public String getVersion() {
if (needApplyServerVersion) {
serverVersion = AkarinGlobalConfig.serverBrandName.equals(Akari.EMPTY_STRING) ? serverVersion : serverVersion.replace("Akarin", AkarinGlobalConfig.serverBrandName);
needApplyServerVersion = false;
}
return serverVersion + " (MC: " + console.getVersion() + ")";
}
@Overwrite
public boolean isPrimaryThread() {
return Akari.isPrimaryThread();

View File

@@ -104,7 +104,7 @@ public abstract class MixinVersionCommand {
versionWaiters.add(sender);
sender.sendMessage("Checking version, please wait...");
String version = Bukkit.getVersion();
String version = Akari.getServerVersion();
if (version == null) {
version = "Unique"; // Custom - > Unique
customVersion = true;