Add option legacy-versioning-compat
This commit is contained in:
@@ -109,7 +109,7 @@ public class AkarinGlobalConfig {
|
||||
return time;
|
||||
}
|
||||
|
||||
private static void set(String path, Object val) {
|
||||
public static void set(String path, Object val) {
|
||||
config.set(path, val);
|
||||
}
|
||||
|
||||
@@ -148,4 +148,8 @@ public class AkarinGlobalConfig {
|
||||
extraAddress = getList("network.extra-local-address", Lists.newArrayList());
|
||||
}
|
||||
|
||||
public static boolean legacyVersioningCompat;
|
||||
private static void legacyVersioningCompat() {
|
||||
legacyVersioningCompat = getBoolean("bonus.legacy-versioning-compat", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,15 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
@Mixin(value = CraftServer.class, remap = false)
|
||||
public class MixinCraftServer {
|
||||
@Shadow @Final @Mutable private String serverName;
|
||||
private boolean unhookServerName = true;
|
||||
private boolean needApplyServerName = true;
|
||||
|
||||
@Overwrite
|
||||
public String getName() {
|
||||
// We cannot apply the name modification in <init> method,
|
||||
// cause the initializer will be added to the tail
|
||||
if (unhookServerName) {
|
||||
if (needApplyServerName) {
|
||||
serverName = "Akarin";
|
||||
unhookServerName = false;
|
||||
needApplyServerName = false;
|
||||
}
|
||||
return serverName;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import io.akarin.api.LogWrapper;
|
||||
import io.akarin.server.core.AkarinGlobalConfig;
|
||||
import net.minecraft.server.MCUtil;
|
||||
|
||||
@Mixin(value = VersionCommand.class, remap = false)
|
||||
@@ -79,19 +80,19 @@ public class MixinVersionCommand {
|
||||
}
|
||||
if (!hasVersion) {
|
||||
obtainVersion(sender);
|
||||
/* TODO Option: legacy-versioning-compat */ currentSender = sender;
|
||||
if (AkarinGlobalConfig.legacyVersioningCompat) currentSender = sender;
|
||||
}
|
||||
}
|
||||
|
||||
@Overwrite
|
||||
private void obtainVersion() {
|
||||
if (false /* TODO Option: legacy-versioning-compat */) {
|
||||
/* TODO Option: legacy-versioning-compat = true */
|
||||
LogWrapper.logger.warn("A legacy version lookup caught, legacy-versioning-compat enabled forcely!");
|
||||
throw new UnsupportedOperationException();
|
||||
} else {
|
||||
if (AkarinGlobalConfig.legacyVersioningCompat) {
|
||||
obtainVersion(currentSender);
|
||||
currentSender = null;
|
||||
currentSender = null; // try release
|
||||
} else {
|
||||
LogWrapper.logger.warn("A legacy version lookup was caught, legacy-versioning-compat enabled forcely!");
|
||||
AkarinGlobalConfig.legacyVersioningCompat = true;
|
||||
AkarinGlobalConfig.set("bonus.legacy-versioning-compat", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,6 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.akarin.api.LocalAddress;
|
||||
import io.akarin.api.WrappedCollections;
|
||||
|
||||
Reference in New Issue
Block a user