Dieser Commit ist enthalten in:
Ursprung
cd8706b67f
Commit
ac8c277846
@ -38,21 +38,21 @@ public class Bauserver extends Subserver {
|
||||
private final UUID owner;
|
||||
|
||||
public Bauserver(String serverName, UUID owner, int port, ProcessBuilder processBuilder, Runnable shutdownCallback){
|
||||
super(Servertype.BAUSERVER, serverName, port, processBuilder, shutdownCallback, null);
|
||||
this.owner = owner;
|
||||
this(serverName, owner, port, processBuilder, shutdownCallback, null);
|
||||
}
|
||||
|
||||
public Bauserver(String serverName, UUID owner, int port, ProcessBuilder processBuilder, Runnable shutdownCallback, Consumer<Exception> failureCallback){
|
||||
super(Servertype.BAUSERVER, serverName, port, processBuilder, shutdownCallback, failureCallback);
|
||||
this.owner = owner;
|
||||
|
||||
synchronized (servers) {
|
||||
servers.put(owner, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void register() {
|
||||
super.register();
|
||||
synchronized (servers) {
|
||||
servers.put(owner, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,21 +37,21 @@ public class Builderserver extends Subserver {
|
||||
|
||||
private final String map;
|
||||
public Builderserver(String serverName, String map, int port, ProcessBuilder processBuilder, Runnable shutdownCallback){
|
||||
super(Servertype.BUILDER, serverName, port, processBuilder, shutdownCallback, null);
|
||||
this.map = map;
|
||||
this(serverName, map, port, processBuilder, shutdownCallback, null);
|
||||
}
|
||||
|
||||
public Builderserver(String serverName, String map, int port, ProcessBuilder processBuilder, Runnable shutdownCallback, Consumer<Exception> failureCallback){
|
||||
super(Servertype.BUILDER, serverName, port, processBuilder, shutdownCallback, failureCallback);
|
||||
this.map = map;
|
||||
|
||||
synchronized (servers) {
|
||||
servers.put(map, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void register() {
|
||||
super.register();
|
||||
synchronized (servers) {
|
||||
servers.put(map, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,14 +40,11 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Subserver {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final Map<String, ServerInfo> servers = ProxyServer.getInstance().getServers();
|
||||
private static final Logger logger = ProxyServer.getInstance().getLogger();
|
||||
|
||||
@Getter
|
||||
private static final List<Subserver> serverList = new LinkedList<>();
|
||||
private static final Map<String, Subserver> infoToServer = new HashMap<>();
|
||||
private static final Map<ServerInfo, Subserver> infoToServer = new HashMap<>();
|
||||
|
||||
public static Subserver getSubserver(ProxiedPlayer p) {
|
||||
synchronized (serverList) {
|
||||
@ -61,7 +58,7 @@ public class Subserver {
|
||||
|
||||
public static Subserver getSubserver(ServerInfo server) {
|
||||
synchronized (serverList) {
|
||||
return infoToServer.get(server.getName());
|
||||
return infoToServer.get(server);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,24 +178,29 @@ public class Subserver {
|
||||
}
|
||||
|
||||
protected void register() {
|
||||
servers.put(serverName, server);
|
||||
synchronized (serverList) {
|
||||
if(ProxyServer.getInstance().getServers().containsKey(serverName)) {
|
||||
throw new SecurityException("Server already registered: " + serverName);
|
||||
}
|
||||
|
||||
ProxyServer.getInstance().getServers().put(serverName, server);
|
||||
serverList.add(this);
|
||||
infoToServer.put(serverName, this);
|
||||
infoToServer.put(server, this);
|
||||
}
|
||||
}
|
||||
|
||||
protected void unregister() {
|
||||
synchronized (serverList){
|
||||
infoToServer.remove(serverName);
|
||||
infoToServer.remove(server);
|
||||
serverList.remove(this);
|
||||
ProxyServer.getInstance().getServers().remove(serverName);
|
||||
}
|
||||
servers.remove(serverName);
|
||||
}
|
||||
|
||||
private void run() {
|
||||
register();
|
||||
|
||||
Exception ex = null;
|
||||
try {
|
||||
if(checkpoint) {
|
||||
start(process.getErrorStream(), line -> line.contains("Restore finished successfully."));
|
||||
@ -229,13 +231,15 @@ public class Subserver {
|
||||
|
||||
process.waitFor();
|
||||
} catch(IOException e) {
|
||||
failureCallback.accept(e);
|
||||
ex = e;
|
||||
} catch(InterruptedException e) {
|
||||
failureCallback.accept(e);
|
||||
ex = e;
|
||||
Thread.currentThread().interrupt();
|
||||
} finally {
|
||||
shutdownCallback.run();
|
||||
unregister();
|
||||
shutdownCallback.run();
|
||||
if(ex != null)
|
||||
failureCallback.accept(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren