try fix
This commit is contained in:
parent
76ecfb39ab
commit
b0dc368ef7
6 changed files with 99 additions and 23 deletions
|
@ -107,6 +107,8 @@ public final class Server implements IThreadListener {
|
||||||
private final Map<String, Position> warps = Maps.<String, Position>newTreeMap();
|
private final Map<String, Position> warps = Maps.<String, Position>newTreeMap();
|
||||||
private final CommandEnvironment scriptEnv = new CommandEnvironment(this);
|
private final CommandEnvironment scriptEnv = new CommandEnvironment(this);
|
||||||
private final boolean debug;
|
private final boolean debug;
|
||||||
|
private final boolean ipcpipe;
|
||||||
|
private final String token;
|
||||||
|
|
||||||
private WorldServer space;
|
private WorldServer space;
|
||||||
private ChannelFuture endpoint;
|
private ChannelFuture endpoint;
|
||||||
|
@ -135,17 +137,24 @@ public final class Server implements IThreadListener {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Util.checkOs();
|
Util.checkOs();
|
||||||
Registry.setup("Server thread");
|
Registry.setup("Server thread");
|
||||||
final Server server = new Server(false);
|
boolean debug = Boolean.parseBoolean(System.getProperty("server.debug", "false"));
|
||||||
|
boolean ipc = debug || Boolean.parseBoolean(System.getProperty("server.pipe", "false"));;
|
||||||
|
String token = System.getProperty("server.token", null);
|
||||||
|
int port = Integer.parseInt(System.getProperty("server.port", "" + Config.PORT));
|
||||||
|
int distance = Integer.parseInt(System.getProperty("server.distance", "" + 0));
|
||||||
|
final Server server = new Server(debug, ipc, token);
|
||||||
Registry.addShutdownHook(new Runnable() {
|
Registry.addShutdownHook(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
server.stopServer();
|
server.stopServer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
server.run();
|
server.run(port, distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Server(boolean debug) {
|
private Server(boolean debug, boolean ipc, String token) {
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
|
this.ipcpipe = ipc;
|
||||||
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandEnvironment getScriptEnvironment() {
|
public CommandEnvironment getScriptEnvironment() {
|
||||||
|
@ -245,12 +254,14 @@ public final class Server implements IThreadListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run(int port, int distance) {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
Log.JNI.info("Starte Server Version " + Config.VERSION);
|
Log.JNI.info("Starte Server Version " + Config.VERSION);
|
||||||
if(!this.debug) {
|
if(!this.debug) {
|
||||||
this.setMessage("Welt wird erstellt und geladen");
|
this.setMessage("Welt wird erstellt und geladen");
|
||||||
FolderInfo info = Region.loadWorldInfo(null);
|
FolderInfo info = Region.loadWorldInfo(null);
|
||||||
|
if(distance > 0)
|
||||||
|
Config.set("viewDistance", "" + distance, null);
|
||||||
// if(dtime == -1L) // {
|
// if(dtime == -1L) // {
|
||||||
// dtime = World.START_TIME;
|
// dtime = World.START_TIME;
|
||||||
//// Config.set("spawnDim", "1", null);
|
//// Config.set("spawnDim", "1", null);
|
||||||
|
@ -289,6 +300,8 @@ public final class Server implements IThreadListener {
|
||||||
Config.set("weatherChanges", "false", null);
|
Config.set("weatherChanges", "false", null);
|
||||||
Config.set("mobSpawning", "false", null);
|
Config.set("mobSpawning", "false", null);
|
||||||
Config.set("spawnRadius", "0", null);
|
Config.set("spawnRadius", "0", null);
|
||||||
|
if(distance > 0)
|
||||||
|
Config.set("viewDistance", "" + distance, null);
|
||||||
this.worlds.add(this.space = new WorldServer(this, World.START_TIME,
|
this.worlds.add(this.space = new WorldServer(this, World.START_TIME,
|
||||||
Space.INSTANCE, true));
|
Space.INSTANCE, true));
|
||||||
this.dimensions.put(this.space.dimension.getDimensionId(), this.space);
|
this.dimensions.put(this.space.dimension.getDimensionId(), this.space);
|
||||||
|
@ -301,7 +314,8 @@ public final class Server implements IThreadListener {
|
||||||
}
|
}
|
||||||
WorldServer.loadWarps(dim, this.warps);
|
WorldServer.loadWarps(dim, this.warps);
|
||||||
}
|
}
|
||||||
// this.openLAN();
|
if(port >= 0)
|
||||||
|
this.bind(port);
|
||||||
}
|
}
|
||||||
Log.JNI.info("Server gestartet in " + String.format("%.1f", (double)(System.currentTimeMillis() - time) / 1000.0) + " Sekunden");
|
Log.JNI.info("Server gestartet in " + String.format("%.1f", (double)(System.currentTimeMillis() - time) / 1000.0) + " Sekunden");
|
||||||
while(this.running) {
|
while(this.running) {
|
||||||
|
@ -1105,8 +1119,8 @@ public final class Server implements IThreadListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind(int port) {
|
public void bind(int port) {
|
||||||
this.schedule(new Runnable() {
|
// this.schedule(new Runnable() {
|
||||||
public void run() {
|
// public void run() {
|
||||||
if(port >= 0) {
|
if(port >= 0) {
|
||||||
try {
|
try {
|
||||||
Server.this.setLanEndpoint(port);
|
Server.this.setLanEndpoint(port);
|
||||||
|
@ -1118,8 +1132,8 @@ public final class Server implements IThreadListener {
|
||||||
else {
|
else {
|
||||||
Server.this.unsetLanEndpoint();
|
Server.this.unsetLanEndpoint();
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
|
|
@ -28,8 +28,10 @@ public class ServerProcess {
|
||||||
for(int z = 0; z < key.length; z++) {
|
for(int z = 0; z < key.length; z++) {
|
||||||
sb.append(String.format("%02x", key[z] & 255));
|
sb.append(String.format("%02x", key[z] & 255));
|
||||||
}
|
}
|
||||||
this.builder = new ProcessBuilder("java", "-Xms", minMem + "M", "-Xmx", maxMem + "M", "-jar", "game.jar", "game.Server",
|
File jar = new File("game.jar");
|
||||||
"-p", "" + port, "-d", "" + distance, "-t", sb.toString()).directory(dir).redirectErrorStream(true);
|
this.builder = new ProcessBuilder("java", "-Xms" + minMem + "M", "-Xmx" + maxMem + "M", "-cp", jar.exists() ? jar.getAbsolutePath() : new File("../bin").getAbsolutePath(),
|
||||||
|
"-Dserver.port=" + port, "-Dserver.distance=" + distance, "-Dserver.token=" + sb.toString(), dir == null ? "-Dserver.debug" : "-Dserver.pipe", "game.Server")
|
||||||
|
.directory(dir).redirectErrorStream(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
@ -69,9 +71,10 @@ public class ServerProcess {
|
||||||
ServerProcess.this.total = Integer.parseInt(data.second);
|
ServerProcess.this.total = Integer.parseInt(data.second);
|
||||||
if(data.first.equals("progress"))
|
if(data.first.equals("progress"))
|
||||||
ServerProcess.this.progress = Integer.parseInt(data.second);
|
ServerProcess.this.progress = Integer.parseInt(data.second);
|
||||||
|
Log.SYSTEM.info("server cmd %s -- %s", data.first, data.second);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Log.SYSTEM.info("==SERVER== %s", line);
|
System.err.println(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "Server console listener");
|
}, "Server console listener");
|
||||||
|
|
|
@ -95,6 +95,7 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
comp = "Interner Fehler: " + p_exceptionCaught_2_;
|
comp = "Interner Fehler: " + p_exceptionCaught_2_;
|
||||||
|
Log.SYSTEM.error(p_exceptionCaught_2_, "Fehler in der Verbindung mit %s", this.getCutAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.closeChannel(comp);
|
this.closeChannel(comp);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Map.Entry;
|
||||||
import game.collect.Maps;
|
import game.collect.Maps;
|
||||||
import game.entity.npc.Alignment;
|
import game.entity.npc.Alignment;
|
||||||
import game.entity.npc.PlayerCharacter;
|
import game.entity.npc.PlayerCharacter;
|
||||||
|
import game.log.Log;
|
||||||
import game.network.ClientPlayer;
|
import game.network.ClientPlayer;
|
||||||
import game.network.Player;
|
import game.network.Player;
|
||||||
import game.world.BlockPos;
|
import game.world.BlockPos;
|
||||||
|
@ -24,17 +25,21 @@ public class SPacketCharacterList implements Packet<ClientPlayer> {
|
||||||
|
|
||||||
public SPacketCharacterList(int selected) {
|
public SPacketCharacterList(int selected) {
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
|
Log.SYSTEM.info("PPPPPPPPPPPPPPPPP selected" + selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPacketCharacterList(int selected, int index, PlayerCharacter conns) {
|
public SPacketCharacterList(int selected, int index, PlayerCharacter conns) {
|
||||||
this.players.put(index, conns);
|
this.players.put(index, conns);
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
|
Log.SYSTEM.info("PPPPPPPPPPPPPPPPP selected " + selected + " @ " + index + " : " + (conns == null ? "[null]" : conns.name + " - " + conns.dim));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPacketCharacterList(int selected, Iterable<PlayerCharacter> conns) {
|
public SPacketCharacterList(int selected, Iterable<PlayerCharacter> conns) {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
Log.SYSTEM.info("PPPPPPPPPPPPPPPPP list selected" + selected);
|
||||||
for(PlayerCharacter conn : conns) {
|
for(PlayerCharacter conn : conns) {
|
||||||
this.players.put(pos++, conn);
|
this.players.put(pos++, conn);
|
||||||
|
Log.SYSTEM.info("PPPPPPPPPPPPPPPPP list : " + conn.name + " - " + conn.dim);
|
||||||
}
|
}
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package game.util;
|
package game.util;
|
||||||
|
|
||||||
import java.awt.GraphicsEnvironment;
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import game.collect.Lists;
|
||||||
|
import game.collect.Maps;
|
||||||
import game.log.Log;
|
import game.log.Log;
|
||||||
import game.properties.IStringSerializable;
|
import game.properties.IStringSerializable;
|
||||||
|
|
||||||
|
@ -322,4 +326,53 @@ int utf_len(const char *str) {
|
||||||
public static Tuple<String, String> getKeyValue(String text) {
|
public static Tuple<String, String> getKeyValue(String text) {
|
||||||
return getKeyValue(text, ' ');
|
return getKeyValue(text, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Object parseObject(String arg) {
|
||||||
|
try {
|
||||||
|
return Float.parseFloat(arg);
|
||||||
|
}
|
||||||
|
catch(NumberFormatException e) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(arg);
|
||||||
|
}
|
||||||
|
catch(NumberFormatException e) {
|
||||||
|
}
|
||||||
|
return arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, Object> parseArgsSimple(String[] args) {
|
||||||
|
Map<String, Object> map = Maps.newHashMap();
|
||||||
|
List<Object> list = Lists.newArrayList();
|
||||||
|
String option = null;
|
||||||
|
boolean parse = true;
|
||||||
|
for(int z = 0; z < args.length; z++) {
|
||||||
|
String arg = args[z];
|
||||||
|
if(arg.startsWith("--")) {
|
||||||
|
if(arg.length() == 2) {
|
||||||
|
parse = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(option != null)
|
||||||
|
map.put(option, null);
|
||||||
|
option = arg.substring(2);
|
||||||
|
}
|
||||||
|
else if(arg.startsWith("-") && arg.length() == 2) {
|
||||||
|
if(option != null)
|
||||||
|
map.put(option, null);
|
||||||
|
option = arg.substring(1);
|
||||||
|
}
|
||||||
|
else if(option != null) {
|
||||||
|
map.put(option, parseObject(arg));
|
||||||
|
option = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
list.add(parseObject(arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(option != null)
|
||||||
|
map.put(option, null);
|
||||||
|
map.put("__pos", list);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import game.log.Log;
|
||||||
|
|
||||||
public abstract class Window {
|
public abstract class Window {
|
||||||
public static long getTime() {
|
public static long getTime() {
|
||||||
return glfwGetTimerValue() / (glfwGetTimerFrequency() / 1000000L);
|
return System.nanoTime() / 1000L; // glfwGetTimerValue() / (glfwGetTimerFrequency() / 1000000L);
|
||||||
}
|
}
|
||||||
public static void setWindowed(int xpos, int ypos, int xsize, int ysize) {
|
public static void setWindowed(int xpos, int ypos, int xsize, int ysize) {
|
||||||
if(window != NULL)
|
if(window != NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue