Mixin versions
This commit is contained in:
@@ -23,8 +23,8 @@ fi
|
||||
echo "[Akarin] Ready to build"
|
||||
(
|
||||
echo "[Akarin] Touch sources.."
|
||||
yes|cp -rf "$basedir/sources/server/src" "$paperbasedir/Paper-Server/"
|
||||
yes|cp -rf "$basedir/sources/server/pom.xml" "$paperbasedir/Paper-Server/"
|
||||
yes|cp -rf "$basedir/sources/src" "$paperbasedir/Paper-Server/"
|
||||
yes|cp -rf "$basedir/sources/pom.xml" "$paperbasedir/Paper-Server/"
|
||||
|
||||
cd "$paperbasedir"
|
||||
if [ "$2" == "--fast" ] || [ "$3" == "--fast" ] || [ "$4" == "--fast" ]; then
|
||||
@@ -35,7 +35,7 @@ echo "[Akarin] Ready to build"
|
||||
fi
|
||||
|
||||
minecraftversion=$(cat "$paperworkdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
||||
rawjar="$paperbasedir/Paper-Server/target/paper-$minecraftversion.jar"
|
||||
rawjar="$paperbasedir/Paper-Server/target/akarin-$minecraftversion.jar"
|
||||
yes|cp -rf "$rawjar" "$basedir/akarin-$minecraftversion.jar"
|
||||
|
||||
echo ""
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package io.akarin.api.mixin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.defaults.VersionCommand;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = VersionCommand.class, remap = false)
|
||||
public class MixinVersionCommand {
|
||||
@Shadow private static int getFromRepo(String repo, String hash) { return 0; }
|
||||
|
||||
/**
|
||||
* Match current version with repository and calculate the distance
|
||||
* @param repo
|
||||
* @param verInfo
|
||||
* @return Version distance from lastest
|
||||
*/
|
||||
@Overwrite
|
||||
private static int getDistance(String repo, String verInfo) {
|
||||
verInfo = verInfo.replace("\"", "");
|
||||
return getFromRepo("Akarin-project/Akarin", verInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* A workaround for unexpected calling
|
||||
* @param currentVer
|
||||
* @return Version distance from lastest
|
||||
*/
|
||||
@Overwrite
|
||||
private static int getFromJenkins(int currentVer) {
|
||||
String[] parts = Bukkit.getVersion().substring("git-Akarin-".length()).split("[-\\s]");
|
||||
return getFromRepo("Akarin-project/Akarin", parts[0]);
|
||||
}
|
||||
|
||||
@Shadow private void setVersionMessage(String msg) {}
|
||||
private static boolean customVersion;
|
||||
|
||||
@Overwrite
|
||||
private void obtainVersion() {
|
||||
// Skipping if detected
|
||||
if (customVersion) return;
|
||||
|
||||
String version = Bukkit.getVersion();
|
||||
if (version == null) version = "Unique"; // Custom - > Unique
|
||||
|
||||
if (version.startsWith("git-Akarin-")) {
|
||||
String[] parts = version.substring("git-Akarin-".length()).split("[-\\s]");
|
||||
int distance = getDistance(null, parts[0]);
|
||||
switch (distance) {
|
||||
case -1:
|
||||
setVersionMessage("Error obtaining version information");
|
||||
break;
|
||||
case 0:
|
||||
setVersionMessage("You are running the latest version");
|
||||
break;
|
||||
case -2:
|
||||
setVersionMessage("Unknown version");
|
||||
break;
|
||||
default:
|
||||
setVersionMessage("You are " + distance + " version(s) behind");
|
||||
}
|
||||
} else {
|
||||
customVersion = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class Bootstrap {
|
||||
}
|
||||
|
||||
/*
|
||||
* Notify message
|
||||
* Redirect notify message
|
||||
*/
|
||||
@Redirect(method = "main", at = @At(
|
||||
value = "INVOKE_STRING",
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package io.akarin.server.mixin.core.network;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerConnection;
|
||||
|
||||
@Mixin(value = ServerConnection.class, remap = false)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"DummyEula",
|
||||
"Watchcat",
|
||||
|
||||
"MixinVersionCommand",
|
||||
"MixinMinecraftServer"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user