SteamWar/BungeeCore
Archiviert
13
2

JDK11 support for 1.15.2-server

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-09-22 17:06:49 +02:00
Ursprung ca149e5245
Commit 3cdcc77a41
3 geänderte Dateien mit 73 neuen und 77 gelöschten Zeilen

Datei anzeigen

@ -32,23 +32,13 @@ import java.util.*;
public class SubserverSystem { public class SubserverSystem {
private SubserverSystem(){} private SubserverSystem(){}
private static final String BACKBONE = "/home/minecraft/backbone/"; private static final String BACKBONE = "/home/minecraft/backbone/";
private static final List<String> JVM_ARGS = Arrays.asList("-Dlog4j.configurationFile=log4j2.xml", "-server", "-Xms128M", "-XX:ThreadPriorityPolicy=42", "-XX:+TieredCompilation", "-XX:TargetSurvivorRatio=90", "-XX:SurvivorRatio=8", "-XX:MaxTenuringThreshold=15", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseBiasedLocking", "-XX:UseSSE=3", "-XX:+UseCodeCacheFlushing", "-XX:+UseThreadPriorities", "-XX:+UseFastAccessorMethods", "-XX:+AggressiveOpts", "-XX:+ReduceSignalUsage", "-XX:+UseInterpreter", "-XX:+UseFastEmptyMethods", "-XX:+UseSharedSpaces", "-XX:AllocatePrefetchStyle=1", "-XX:+AlwaysCompileLoopMethods", "-XX:SharedReadOnlySize=30m", "-XX:+UseConcMarkSweepGC", "-XX:+RewriteFrequentPairs", "-XX:+OptimizeStringConcat", "-XX:+CMSCleanOnEnter", "-XX:+UseInlineCaches"); private static final List<String> JVM_ARGS = Arrays.asList("-Dlog4j.configurationFile=log4j2.xml", "-server", "-Xms128M", "-XX:+CompressedOops", "-XX:+TieredCompilation", "-XX:TargetSurvivorRatio=90", "-XX:SurvivorRatio=8", "-XX:MaxTenuringThreshold=15", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseBiasedLocking", "-XX:UseSSE=3", "-XX:+UseCodeCacheFlushing", "-XX:+UseThreadPriorities", "-XX:+AggressiveOpts", "-XX:+ReduceSignalUsage", "-XX:+UseInterpreter", "-XX:+UseSharedSpaces", "-XX:AllocatePrefetchStyle=1", "-XX:+AlwaysCompileLoopMethods", "-XX:+UseConcMarkSweepGC", "-XX:+RewriteFrequentPairs", "-XX:+OptimizeStringConcat", "-XX:+CMSCleanOnEnter", "-XX:+UseInlineCaches");
private static final List<String> JVM8_ARGS = Arrays.asList("-XX:ThreadPriorityPolicy=42", "-XX:SharedReadOnlySize=30m", "-XX:+UseFastEmptyMethods", "-XX:+UseFastAccessorMethods");
private static final String ARENA_PATH = BACKBONE + "arenaserver/"; private static final String ARENA_PATH = BACKBONE + "arenaserver/";
private static final String SERVER_PATH = BACKBONE + "server/"; private static final String SERVER_PATH = BACKBONE + "server/";
private static final String EVENT_PATH = BACKBONE + "event/"; private static final String EVENT_PATH = BACKBONE + "event/";
private static final String BINARY_PATH = "/binarys/";
public static void sendDeniedMessage(ProxiedPlayer p, UUID owner){
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
if(o == null)
return;
BungeeCore.send(o, BungeeCore.CHAT_PREFIX + "§e" + p.getName() + " §7möchte auf deine Bauwelt.");
BungeeCore.send(o, "§7Klicke §ehier§7, wenn du das erlauben möchtest.",
"§e/bau addmember " + p.getName(),
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.getName()));
}
/** /**
* This function starts every arena (even test- and eventarenas). * This function starts every arena (even test- and eventarenas).
@ -109,30 +99,18 @@ public class SubserverSystem {
throw new SecurityException("Could not copy folder", e); throw new SecurityException("Could not copy folder", e);
} }
//Generate launch command List<String> cmd = serverStartCommand(
List<String> cmd = new LinkedList<>(); modus.serverJar(),
cmd.add("java"); worldDir,
cmd.add("-DlogPath=" + mapName); mapName,
cmd.add("-DfightID=" + eventFightID); port,
if(player1 != null && eventFightID != -1) "2G",
cmd.add("-DblueLeader=" + player1.toString()); "logPath=" + mapName,
if(player2 != null) "fightID=" + eventFightID,
cmd.add("-DredLeader=" + player2.toString()); "ranked=" + ranked,
if(checkSchemID != 0) "checkSchemID=" + checkSchemID,
cmd.add("-DcheckSchemID=" + checkSchemID); player1 != null && eventFightID != -1 ? "blueLeader=" + player1.toString() : null,
if(ranked) player2 != null ? "redLeader=" + player2.toString() : null);
cmd.add("-Dranked=true");
cmd.add("-Xmx2G");
cmd.addAll(JVM_ARGS);
cmd.add("-jar");
cmd.add(BINARY_PATH + modus.serverJar());
cmd.add("--log-strip-color");
cmd.add("--world-dir");
cmd.add(worldDir);
cmd.add("--level-name");
cmd.add(mapName);
cmd.add("--port");
cmd.add(String.valueOf(port));
//Start server //Start server
ProcessBuilder process = new ProcessBuilder(cmd); ProcessBuilder process = new ProcessBuilder(cmd);
@ -164,10 +142,6 @@ public class SubserverSystem {
return startArena(modus, map, eventFightID, checkSchemID, serverName, mapName, player1, player2, false); return startArena(modus, map, eventFightID, checkSchemID, serverName, mapName, player1, player2, false);
} }
public static Subserver startArena(ArenaMode modus, String map){
return startArena(modus, map, 0, 0, null, null, null, null);
}
public static Subserver startEventArena(EventFight eventFight, String serverName){ public static Subserver startEventArena(EventFight eventFight, String serverName){
return startArena( return startArena(
eventFight.getSpielmodus(), eventFight.getSpielmodus(),
@ -180,7 +154,7 @@ public class SubserverSystem {
null); null);
} }
public static void sendToTestServer(ProxiedPlayer p, ArenaMode m, String map, int checkSchemId){ public static void startTestServer(ProxiedPlayer p, ArenaMode m, String map, int checkSchemId){
startArena(m, map, -1, checkSchemId, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null).sendPlayer(p); startArena(m, map, -1, checkSchemId, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null).sendPlayer(p);
} }
@ -189,24 +163,16 @@ public class SubserverSystem {
return; return;
SteamwarUser user = SteamwarUser.get(owner); SteamwarUser user = SteamwarUser.get(owner);
copyBauwelt(p, BungeeCore.BAUWELT_PROTOTYP, BungeeCore.WORLD_FOLDER + owner.toString()); copyBauweltIfRequired(p, BungeeCore.BAUWELT_PROTOTYP, BungeeCore.WORLD_FOLDER + owner.toString());
int port = freePort(4000); int port = freePort(4000);
//Generate launch command List<String> cmd = serverStartCommand(
List<String> cmd = new LinkedList<>(); "spigot-1.12.2.jar",
cmd.add("java"); "/home/minecraft/userworlds",
cmd.add("-DlogPath=" + owner.toString()); owner.toString(),
cmd.add("-Xmx256M"); port,
cmd.addAll(JVM_ARGS); "256M",
cmd.add("-jar"); "logPath=" + owner.toString());
cmd.add(BINARY_PATH + "spigot-1.12.2.jar");
cmd.add("--log-strip-color");
cmd.add("--world-dir");
cmd.add("/home/minecraft/userworlds");
cmd.add("--level-name");
cmd.add(owner.toString());
cmd.add("--port");
cmd.add(String.valueOf(port));
//Start server //Start server
ProcessBuilder process = new ProcessBuilder(cmd); ProcessBuilder process = new ProcessBuilder(cmd);
@ -220,24 +186,16 @@ public class SubserverSystem {
return; return;
SteamwarUser user = SteamwarUser.get(owner); SteamwarUser user = SteamwarUser.get(owner);
copyBauwelt(p, BungeeCore.BAUWELT15, BungeeCore.USERWORLDS15 + user.getId()); copyBauweltIfRequired(p, BungeeCore.BAUWELT15, BungeeCore.USERWORLDS15 + user.getId());
int port = freePort(4000); int port = freePort(4000);
//Generate launch command List<String> cmd = serverStartCommand(
List<String> cmd = new LinkedList<>(); "spigot-1.15.2.jar",
cmd.add("java"); "/home/minecraft/userworlds15",
cmd.add("-DlogPath=" + user.getId()); String.valueOf(user.getId()),
cmd.add("-Xmx512M"); port,
cmd.addAll(JVM_ARGS); "512M",
cmd.add("-jar"); "logPath=" + owner.toString());
cmd.add(BINARY_PATH + "spigot-1.15.2.jar");
cmd.add("--log-strip-color");
cmd.add("--world-dir");
cmd.add("/home/minecraft/userworlds15");
cmd.add("--level-name");
cmd.add(String.valueOf(user.getId()));
cmd.add("--port");
cmd.add(String.valueOf(port));
//Start server //Start server
ProcessBuilder process = new ProcessBuilder(cmd); ProcessBuilder process = new ProcessBuilder(cmd);
@ -246,6 +204,44 @@ public class SubserverSystem {
new Bauserver(user.getUserName() + "s Bau", owner, port, process, () -> {}).sendPlayer(p); new Bauserver(user.getUserName() + "s Bau", owner, port, process, () -> {}).sendPlayer(p);
} }
public static void sendDeniedMessage(ProxiedPlayer p, UUID owner){
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
if(o == null)
return;
BungeeCore.send(o, BungeeCore.CHAT_PREFIX + "§e" + p.getName() + " §7möchte auf deine Bauwelt.");
BungeeCore.send(o, "§7Klicke §ehier§7, wenn du das erlauben möchtest.",
"§e/bau addmember " + p.getName(),
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.getName()));
}
private static List<String> serverStartCommand(String serverJar, String worldDir, String levelName, int port, String xmx, String... dParams){
List<String> cmd = new ArrayList<>();
boolean jdk11 = serverJar.contains("1.15.2");
if(jdk11)
cmd.add("/usr/lib/jvm/java-11-openjdk-amd64/bin/java");
else
cmd.add("java");
for(String param : dParams){
cmd.add("-D" + param);
}
cmd.add("-Xmx" + xmx);
cmd.addAll(JVM_ARGS);
if(!jdk11)
cmd.addAll(JVM8_ARGS);
cmd.add("-jar");
cmd.add("/binarys/" + serverJar);
cmd.add("--log-strip-color");
cmd.add("--world-dir");
cmd.add(worldDir);
cmd.add("--level-name");
cmd.add(levelName);
cmd.add("--port");
cmd.add(String.valueOf(port));
return cmd;
}
private static boolean bauRunning(ProxiedPlayer p, UUID owner){ private static boolean bauRunning(ProxiedPlayer p, UUID owner){
for(Subserver subserver : Subserver.getServerList()){ for(Subserver subserver : Subserver.getServerList()){
if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)){ if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)){
@ -256,7 +252,7 @@ public class SubserverSystem {
return false; return false;
} }
private static void copyBauwelt(ProxiedPlayer p, String sourcePath, String targetPath){ private static void copyBauweltIfRequired(ProxiedPlayer p, String sourcePath, String targetPath){
File w = new File(targetPath); File w = new File(targetPath);
if (!w.exists() || !w.isDirectory()){ if (!w.exists() || !w.isDirectory()){
try { try {

Datei anzeigen

@ -271,7 +271,7 @@ public class BauCommand {
break; break;
} }
} }
SubserverSystem.sendToTestServer(p, mode, map, 0); SubserverSystem.startTestServer(p, mode, map, 0);
})); }));
} }

Datei anzeigen

@ -232,7 +232,7 @@ public class CheckCommand extends BasicCommand {
} }
ArenaMode mode = ArenaMode.getByCheckSchemType(schematic.getSchemType().toDB()); ArenaMode mode = ArenaMode.getByCheckSchemType(schematic.getSchemType().toDB());
SubserverSystem.sendToTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID()); SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID());
currentCheckers.put(checker.getUniqueId(), this); currentCheckers.put(checker.getUniqueId(), this);
currentSchems.put(schematic.getSchemID(), this); currentSchems.put(schematic.getSchemID(), this);
next(0); next(0);