change port, config and version mechanisms
This commit is contained in:
parent
f879b060e8
commit
adc81d56d2
14 changed files with 122 additions and 74 deletions
|
@ -100,6 +100,7 @@ import client.window.Window;
|
||||||
import client.window.WindowEvent;
|
import client.window.WindowEvent;
|
||||||
import client.world.ChunkClient;
|
import client.world.ChunkClient;
|
||||||
import client.world.WorldClient;
|
import client.world.WorldClient;
|
||||||
|
import common.Version;
|
||||||
import common.biome.Biome;
|
import common.biome.Biome;
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
|
@ -116,7 +117,6 @@ import common.future.ListenableFutureTask;
|
||||||
import common.future.ThreadFactoryBuilder;
|
import common.future.ThreadFactoryBuilder;
|
||||||
import common.init.BlockRegistry;
|
import common.init.BlockRegistry;
|
||||||
import common.init.Blocks;
|
import common.init.Blocks;
|
||||||
import common.init.Config;
|
|
||||||
import common.init.EntityRegistry;
|
import common.init.EntityRegistry;
|
||||||
import common.init.ItemRegistry;
|
import common.init.ItemRegistry;
|
||||||
import common.init.Items;
|
import common.init.Items;
|
||||||
|
@ -260,6 +260,7 @@ public class Client implements IThreadListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String VERSION = Version.NAME + " Client " + Util.VERSION;
|
||||||
public static final int LOG_BUFFER = 32768;
|
public static final int LOG_BUFFER = 32768;
|
||||||
private static final LazyLoadBase<NioEventLoopGroup> CLIENT_NIO_EVENTLOOP = new LazyLoadBase<NioEventLoopGroup>()
|
private static final LazyLoadBase<NioEventLoopGroup> CLIENT_NIO_EVENTLOOP = new LazyLoadBase<NioEventLoopGroup>()
|
||||||
{
|
{
|
||||||
|
@ -520,7 +521,7 @@ public class Client implements IThreadListener {
|
||||||
{
|
{
|
||||||
connection = createNetworkManagerAndConnect(address == null ? InetAddress.getLoopbackAddress() : InetAddress.getByName(IDN.toASCII(address)), port);
|
connection = createNetworkManagerAndConnect(address == null ? InetAddress.getLoopbackAddress() : InetAddress.getByName(IDN.toASCII(address)), port);
|
||||||
connection.setNetHandler(new ClientLoginHandler(connection, this, user, access, pass));
|
connection.setNetHandler(new ClientLoginHandler(connection, this, user, access, pass));
|
||||||
connection.sendPacket(new HPacketHandshake(Config.PROTOCOL), new GenericFutureListener<Future<? super Void>>() {
|
connection.sendPacket(new HPacketHandshake(Util.PROTOCOL), new GenericFutureListener<Future<? super Void>>() {
|
||||||
public void operationComplete(Future<? super Void> u) throws Exception {
|
public void operationComplete(Future<? super Void> u) throws Exception {
|
||||||
connection.setConnectionState(PacketRegistry.LOGIN);
|
connection.setConnectionState(PacketRegistry.LOGIN);
|
||||||
}
|
}
|
||||||
|
@ -1248,14 +1249,14 @@ public class Client implements IThreadListener {
|
||||||
// SKC.setGuiMenu();
|
// SKC.setGuiMenu();
|
||||||
// else
|
// else
|
||||||
// SKC.setGuiAny();
|
// SKC.setGuiAny();
|
||||||
Window.setTitle(String.format("%s - %s", Config.CLIENT_VERSION, gui.getTitle()));
|
Window.setTitle(String.format("%s - %s", VERSION, gui.getTitle()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.menu(false);
|
this.menu(false);
|
||||||
this.leftClickCounter = 10000;
|
this.leftClickCounter = 10000;
|
||||||
Bind.disableMouse();
|
Bind.disableMouse();
|
||||||
Window.setTitle(String.format("%s - %s%s", Config.CLIENT_VERSION, "Welt / Render", this.nograb ? "" : " (Maus gefangen)"));
|
Window.setTitle(String.format("%s - %s%s", VERSION, "Welt / Render", this.nograb ? "" : " (Maus gefangen)"));
|
||||||
// SKC.setGuiNone();
|
// SKC.setGuiNone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2173,8 +2174,8 @@ public class Client implements IThreadListener {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.SYSTEM.info("Java " + System.getProperty("java.version"));
|
Log.SYSTEM.info("Java " + System.getProperty("java.version"));
|
||||||
Log.SYSTEM.info(Config.CLIENT_VERSION);
|
Log.SYSTEM.info(VERSION + " (Protokoll #" + Util.PROTOCOL + ")");
|
||||||
if(!Window.createWindow(Config.CLIENT_VERSION, System.getProperty("opengl.debug") != null))
|
if(!Window.createWindow(VERSION, System.getProperty("opengl.debug") != null))
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
Log.SYSTEM.info("OpenGL %s", GL11.glGetString(GL11.GL_VERSION));
|
Log.SYSTEM.info("OpenGL %s", GL11.glGetString(GL11.GL_VERSION));
|
||||||
Log.SYSTEM.info("GL_VENDOR: %s", GL11.glGetString(GL11.GL_VENDOR));
|
Log.SYSTEM.info("GL_VENDOR: %s", GL11.glGetString(GL11.GL_VENDOR));
|
||||||
|
@ -2972,7 +2973,7 @@ public class Client implements IThreadListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
this.buffer = TextColor.NEON + "*** " + Config.CLIENT_VERSION + " ***";
|
this.buffer = TextColor.NEON + "*** " + VERSION + " ***";
|
||||||
this.console.clear();
|
this.console.clear();
|
||||||
this.chat.clear();
|
this.chat.clear();
|
||||||
this.feed.clear();
|
this.feed.clear();
|
||||||
|
|
|
@ -14,7 +14,6 @@ import client.gui.element.PressType;
|
||||||
import client.renderer.Drawing;
|
import client.renderer.Drawing;
|
||||||
import client.util.FileUtils;
|
import client.util.FileUtils;
|
||||||
import common.color.TextColor;
|
import common.color.TextColor;
|
||||||
import common.init.Config;
|
|
||||||
import common.log.Log;
|
import common.log.Log;
|
||||||
import common.network.IPlayer;
|
import common.network.IPlayer;
|
||||||
import common.util.Tuple;
|
import common.util.Tuple;
|
||||||
|
@ -133,7 +132,7 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
|
||||||
for(int z = 0; z <= lines.length; z++) {
|
for(int z = 0; z <= lines.length; z++) {
|
||||||
String line = z == lines.length ? null : lines[z];
|
String line = z == lines.length ? null : lines[z];
|
||||||
if(line == null || (line.startsWith("[") && line.endsWith("]"))) {
|
if(line == null || (line.startsWith("[") && line.endsWith("]"))) {
|
||||||
if(!name.isEmpty() && !address.isEmpty() && !user.isEmpty() && user.length() < IPlayer.MAX_USER_LENGTH && IPlayer.isValidUser(user) && password.length() < IPlayer.MAX_PASS_LENGTH && access.length() < IPlayer.MAX_PASS_LENGTH && address.length() < 128 && name.length() < 128 && port >= 0 && port < 65536)
|
if(!name.isEmpty() && !address.isEmpty() && !user.isEmpty() && user.length() < IPlayer.MAX_USER_LENGTH && IPlayer.isValidUser(user) && password.length() < IPlayer.MAX_PASS_LENGTH && access.length() < IPlayer.MAX_PASS_LENGTH && address.length() < 128 && name.length() < 128 && port >= 1024 && port <= 32767)
|
||||||
this.elements.add(new ServerInfo(name, address, port, user, password, access, time));
|
this.elements.add(new ServerInfo(name, address, port, user, password, access, time));
|
||||||
if(line != null) {
|
if(line != null) {
|
||||||
address = "";
|
address = "";
|
||||||
|
@ -250,7 +249,7 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
|
||||||
}
|
}
|
||||||
else if(button == this.createButton) {
|
else if(button == this.createButton) {
|
||||||
this.setSelected(-1);
|
this.setSelected(-1);
|
||||||
this.gm.displayGuiScreen(new GuiServer(new ServerInfo("", "", Config.PORT, "", "", "", -1L)));
|
this.gm.displayGuiScreen(new GuiServer(new ServerInfo("", "", -1, "", "", "", -1L)));
|
||||||
}
|
}
|
||||||
else if(button == this.editButton) {
|
else if(button == this.editButton) {
|
||||||
ServerInfo server = this.getSelected();
|
ServerInfo server = this.getSelected();
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
package client.gui;
|
package client.gui;
|
||||||
|
|
||||||
|
import client.Client;
|
||||||
import client.gui.element.NavButton;
|
import client.gui.element.NavButton;
|
||||||
import client.gui.element.TransparentArea;
|
import client.gui.element.TransparentArea;
|
||||||
|
import common.Version;
|
||||||
import common.color.TextColor;
|
import common.color.TextColor;
|
||||||
import common.init.Config;
|
|
||||||
import common.log.Log;
|
import common.log.Log;
|
||||||
|
import common.util.Util;
|
||||||
|
|
||||||
public class GuiInfo extends Gui {
|
public class GuiInfo extends Gui {
|
||||||
private static final String VER =
|
private static final String VER =
|
||||||
TextColor.GREEN + "" + TextColor.BUG + "" + TextColor.BUG + "" + TextColor.BUG + " " + TextColor.VIOLET + "" + Config.CLIENT_VERSION + "" +
|
TextColor.GREEN + "" + Util.repeatString(TextColor.BUG, Version.RELEASE.getId()) + TextColor.DVIOLET + "|-| " + TextColor.VIOLET + Client.VERSION + TextColor.DVIOLET + " |-|" +
|
||||||
TextColor.GREEN + " " + TextColor.BUG + "" + TextColor.BUG + "" + TextColor.BUG;
|
TextColor.GREEN + Util.repeatString(TextColor.BUG, Version.RELEASE.getId());
|
||||||
|
|
||||||
private static final String INFO = "Ein Spiel zur Simulation, zum Testen, für Rollenspiele, Mehrspieler und vieles mehr." + "\n" +
|
private static final String INFO = "Ein Spiel zur Simulation, zum Testen, für Rollenspiele, Mehrspieler und vieles mehr." + "\n" +
|
||||||
"Optimiert für Geschwindigkeit, Stabilität und" + TextColor.UNKNOWN + "" + TextColor.UNKNOWN + " [Speicherzugriffsfehler]";
|
"Optimiert für Geschwindigkeit, Stabilität und" + TextColor.UNKNOWN + "" + TextColor.UNKNOWN + " [Speicherzugriffsfehler]";
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package client.gui;
|
package client.gui;
|
||||||
|
|
||||||
|
import client.Client;
|
||||||
import client.gui.character.GuiChar;
|
import client.gui.character.GuiChar;
|
||||||
import client.gui.character.GuiCharacters;
|
import client.gui.character.GuiCharacters;
|
||||||
import client.gui.element.ActButton;
|
import client.gui.element.ActButton;
|
||||||
|
@ -11,7 +12,6 @@ import client.gui.options.GuiOptions;
|
||||||
import client.renderer.Drawing;
|
import client.renderer.Drawing;
|
||||||
import client.window.Keysym;
|
import client.window.Keysym;
|
||||||
import common.color.TextColor;
|
import common.color.TextColor;
|
||||||
import common.init.Config;
|
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public class GuiMenu extends Gui {
|
||||||
}
|
}
|
||||||
}, "Client schließen"));
|
}, "Client schließen"));
|
||||||
this.shift();
|
this.shift();
|
||||||
this.add(new Label(4, /* this.gm.fb_y - 2 */ 0, 200, 20, TextColor.VIOLET + Config.CLIENT_VERSION, true));
|
this.add(new Label(4, /* this.gm.fb_y - 2 */ 0, 200, 20, TextColor.VIOLET + Client.VERSION, true));
|
||||||
this.splashLabel = this.add(new Label(0, 160, width, 24, ""));
|
this.splashLabel = this.add(new Label(0, 160, width, 24, ""));
|
||||||
this.pickSplash();
|
this.pickSplash();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import client.gui.element.FieldCallback;
|
||||||
import client.vars.CVarCategory;
|
import client.vars.CVarCategory;
|
||||||
import client.vars.Variable;
|
import client.vars.Variable;
|
||||||
import common.color.TextColor;
|
import common.color.TextColor;
|
||||||
import common.init.Config;
|
|
||||||
import common.network.IPlayer;
|
import common.network.IPlayer;
|
||||||
|
|
||||||
public class GuiServer extends Gui implements FieldCallback {
|
public class GuiServer extends Gui implements FieldCallback {
|
||||||
|
@ -29,6 +28,7 @@ public class GuiServer extends Gui implements FieldCallback {
|
||||||
private Label nameLabel;
|
private Label nameLabel;
|
||||||
private Label addrLabel;
|
private Label addrLabel;
|
||||||
private Label portLabel;
|
private Label portLabel;
|
||||||
|
private Label rangeLabel;
|
||||||
private Label userLabel;
|
private Label userLabel;
|
||||||
private Label passLabel;
|
private Label passLabel;
|
||||||
private Label accLabel;
|
private Label accLabel;
|
||||||
|
@ -39,8 +39,8 @@ public class GuiServer extends Gui implements FieldCallback {
|
||||||
|
|
||||||
@Variable(name = "srv_last_address", category = CVarCategory.SYSTEM, min = 1, max = 128, display = "Letzte Server-Adresse")
|
@Variable(name = "srv_last_address", category = CVarCategory.SYSTEM, min = 1, max = 128, display = "Letzte Server-Adresse")
|
||||||
private String lastAddr = "";
|
private String lastAddr = "";
|
||||||
@Variable(name = "srv_last_port", category = CVarCategory.SYSTEM, min = 0, max = 65535, display = "Letzter Server-Port")
|
@Variable(name = "srv_last_port", category = CVarCategory.SYSTEM, min = 1024, max = 32767, display = "Letzter Server-Port")
|
||||||
private int lastPort = Config.PORT;
|
private int lastPort = -1;
|
||||||
@Variable(name = "srv_last_user", category = CVarCategory.SYSTEM, max = IPlayer.MAX_USER_LENGTH, display = "Letzter Server-Nutzer", validator = IPlayer.UserValidator.class)
|
@Variable(name = "srv_last_user", category = CVarCategory.SYSTEM, max = IPlayer.MAX_USER_LENGTH, display = "Letzter Server-Nutzer", validator = IPlayer.UserValidator.class)
|
||||||
private String lastUser = "";
|
private String lastUser = "";
|
||||||
@Variable(name = "srv_last_password", category = CVarCategory.SYSTEM, max = IPlayer.MAX_PASS_LENGTH, display = "Letztes Server-Passwort")
|
@Variable(name = "srv_last_password", category = CVarCategory.SYSTEM, max = IPlayer.MAX_PASS_LENGTH, display = "Letztes Server-Passwort")
|
||||||
|
@ -52,7 +52,8 @@ public class GuiServer extends Gui implements FieldCallback {
|
||||||
if(this.server != null)
|
if(this.server != null)
|
||||||
this.nameBox = this.add(new Field(0, -50, 400, 24, 128, this, this.server.getName()));
|
this.nameBox = this.add(new Field(0, -50, 400, 24, 128, this, this.server.getName()));
|
||||||
this.addrBox = this.add(new Field(0, 20, 400, 24, 128, this, this.server == null ? this.lastAddr : this.server.getAddress()));
|
this.addrBox = this.add(new Field(0, 20, 400, 24, 128, this, this.server == null ? this.lastAddr : this.server.getAddress()));
|
||||||
this.portBox = this.add(new Field(404, 20, 76, 24, 5, this, "" + (this.server == null ? this.lastPort : this.server.getPort())));
|
int port = this.server == null ? this.lastPort : this.server.getPort();
|
||||||
|
this.portBox = this.add(new Field(404, 20, 76, 24, 5, this, port < 0 ? "" : "" + port));
|
||||||
this.userBox = this.add(new Field(0, 70, 220, 24, IPlayer.MAX_USER_LENGTH, this, IPlayer.VALID_USER, this.server == null ? this.lastUser : this.server.getUser()));
|
this.userBox = this.add(new Field(0, 70, 220, 24, IPlayer.MAX_USER_LENGTH, this, IPlayer.VALID_USER, this.server == null ? this.lastUser : this.server.getUser()));
|
||||||
this.passBox = this.add(new Field(0, 120, 480, 24, IPlayer.MAX_PASS_LENGTH, this, this.server == null ? this.lastPass : this.server.getPassword()));
|
this.passBox = this.add(new Field(0, 120, 480, 24, IPlayer.MAX_PASS_LENGTH, this, this.server == null ? this.lastPass : this.server.getPassword()));
|
||||||
this.accBox = this.add(new Field(0, 170, 480, 24, IPlayer.MAX_PASS_LENGTH, this, this.server == null ? this.lastAcc : this.server.getAccess()));
|
this.accBox = this.add(new Field(0, 170, 480, 24, IPlayer.MAX_PASS_LENGTH, this, this.server == null ? this.lastAcc : this.server.getAccess()));
|
||||||
|
@ -65,7 +66,8 @@ public class GuiServer extends Gui implements FieldCallback {
|
||||||
if(this.server != null)
|
if(this.server != null)
|
||||||
this.nameLabel = this.add(new Label(0, -70, 410, 20, "Name", true));
|
this.nameLabel = this.add(new Label(0, -70, 410, 20, "Name", true));
|
||||||
this.addrLabel = this.add(new Label(0, 0, 410, 20, "Adresse", true));
|
this.addrLabel = this.add(new Label(0, 0, 410, 20, "Adresse", true));
|
||||||
this.portLabel = this.add(new Label(414, 0, 66, 20, "Port", true));
|
this.portLabel = this.add(new Label(404, 0, 76, 20, "Port", true));
|
||||||
|
this.rangeLabel = this.add(new Label(370, 44, 110, 20, "[1024..32767]", true));
|
||||||
this.userLabel = this.add(new Label(0, 50, 220, 20, "Nutzer", true));
|
this.userLabel = this.add(new Label(0, 50, 220, 20, "Nutzer", true));
|
||||||
this.passLabel = this.add(new Label(0, 100, 480, 20, "Passwort", true));
|
this.passLabel = this.add(new Label(0, 100, 480, 20, "Passwort", true));
|
||||||
this.accLabel = this.add(new Label(0, 150, 480, 20, "Zugang", true));
|
this.accLabel = this.add(new Label(0, 150, 480, 20, "Zugang", true));
|
||||||
|
@ -102,9 +104,11 @@ public class GuiServer extends Gui implements FieldCallback {
|
||||||
port = Integer.parseInt(this.portBox.getText());
|
port = Integer.parseInt(this.portBox.getText());
|
||||||
}
|
}
|
||||||
catch(NumberFormatException e) {
|
catch(NumberFormatException e) {
|
||||||
|
this.rangeLabel.setText("[" + TextColor.RED + "1024..32767" + TextColor.RESET + "]");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(port < 0 || port > 65535) {
|
if(port < 1024 || port > 32767) {
|
||||||
this.portLabel.setText(TextColor.RED + "Port");
|
this.rangeLabel.setText("[" + (port < 1024 ? TextColor.RED + "1024" + TextColor.RESET + "..32767" : "1024.." + TextColor.RED + "32767" + TextColor.RESET) + "]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,8 +142,10 @@ public class GuiServer extends Gui implements FieldCallback {
|
||||||
else if(value == FieldAction.FOCUS) {
|
else if(value == FieldAction.FOCUS) {
|
||||||
if(elem == this.addrBox)
|
if(elem == this.addrBox)
|
||||||
this.addrLabel.setText("Adresse");
|
this.addrLabel.setText("Adresse");
|
||||||
else if(elem == this.portBox)
|
else if(elem == this.portBox) {
|
||||||
this.portLabel.setText("Port");
|
this.portLabel.setText("Port");
|
||||||
|
this.rangeLabel.setText("[1024..32767]");
|
||||||
|
}
|
||||||
else if(elem == this.userBox)
|
else if(elem == this.userBox)
|
||||||
this.userLabel.setText("Nutzer");
|
this.userLabel.setText("Nutzer");
|
||||||
else if(this.server != null && elem == this.nameBox)
|
else if(this.server != null && elem == this.nameBox)
|
||||||
|
|
11
common/src/common/Version.java
Normal file
11
common/src/common/Version.java
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package common;
|
||||||
|
|
||||||
|
import common.util.ReleaseType;
|
||||||
|
|
||||||
|
public abstract class Version {
|
||||||
|
public static final String NAME = "TCR";
|
||||||
|
public static final ReleaseType RELEASE = ReleaseType.DEV;
|
||||||
|
public static final int MAJOR = 2;
|
||||||
|
public static final int MINOR = 2;
|
||||||
|
public static final int PATCH = 1;
|
||||||
|
}
|
|
@ -23,11 +23,13 @@ public abstract class Config {
|
||||||
String name();
|
String name();
|
||||||
float min() default (float)Integer.MIN_VALUE;
|
float min() default (float)Integer.MIN_VALUE;
|
||||||
float max() default (float)Integer.MAX_VALUE;
|
float max() default (float)Integer.MAX_VALUE;
|
||||||
|
boolean nonDefault() default false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Value {
|
public static class Value {
|
||||||
public final ValueType type;
|
public final ValueType type;
|
||||||
public final String def;
|
public final String def;
|
||||||
|
public final boolean noDef;
|
||||||
private final Field field;
|
private final Field field;
|
||||||
private final float min;
|
private final float min;
|
||||||
private final float max;
|
private final float max;
|
||||||
|
@ -41,6 +43,7 @@ public abstract class Config {
|
||||||
throw new IllegalArgumentException(value.name() + ": Unbekannter Variablen-Typ - " + field.getType());
|
throw new IllegalArgumentException(value.name() + ": Unbekannter Variablen-Typ - " + field.getType());
|
||||||
this.field = field;
|
this.field = field;
|
||||||
this.def = this.getValue();
|
this.def = this.getValue();
|
||||||
|
this.noDef = value.nonDefault();
|
||||||
// Clamped clamp = this.field.getAnnotation(Clamped.class);
|
// Clamped clamp = this.field.getAnnotation(Clamped.class);
|
||||||
this.min = (this.type == ValueType.INTEGER || this.type == ValueType.FLOAT)
|
this.min = (this.type == ValueType.INTEGER || this.type == ValueType.FLOAT)
|
||||||
? value.min() : 0;
|
? value.min() : 0;
|
||||||
|
@ -59,7 +62,7 @@ public abstract class Config {
|
||||||
// throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
this.setValue(this.def);
|
this.setValue(this.def, this.noDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
@ -82,7 +85,7 @@ public abstract class Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setValue(String value) {
|
private void setValue(String value, boolean noClamp) {
|
||||||
try {
|
try {
|
||||||
switch(this.type) {
|
switch(this.type) {
|
||||||
case STRING:
|
case STRING:
|
||||||
|
@ -98,7 +101,7 @@ public abstract class Config {
|
||||||
}
|
}
|
||||||
catch(NumberFormatException e) {
|
catch(NumberFormatException e) {
|
||||||
}
|
}
|
||||||
this.field.setInt(null, ExtMath.clampi(inum, (int)this.min, (int)this.max));
|
this.field.setInt(null, noClamp ? inum : ExtMath.clampi(inum, (int)this.min, (int)this.max));
|
||||||
break;
|
break;
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
float fnum = 0.0f;
|
float fnum = 0.0f;
|
||||||
|
@ -107,6 +110,7 @@ public abstract class Config {
|
||||||
}
|
}
|
||||||
catch(NumberFormatException e) {
|
catch(NumberFormatException e) {
|
||||||
}
|
}
|
||||||
|
if(!noClamp)
|
||||||
fnum = ExtMath.clampf(fnum, this.min, this.max);
|
fnum = ExtMath.clampf(fnum, this.min, this.max);
|
||||||
int round = (int)(fnum * 1000.0f);
|
int round = (int)(fnum * 1000.0f);
|
||||||
this.field.setFloat(null, (float)round / 1000.0f);
|
this.field.setFloat(null, (float)round / 1000.0f);
|
||||||
|
@ -119,12 +123,6 @@ public abstract class Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int PROTOCOL = 666;
|
|
||||||
public static final int PORT = 26666;
|
|
||||||
public static final String NAME = "TCR";
|
|
||||||
public static final String VERSION = "v2.2.1-alpha";
|
|
||||||
public static final String CLIENT_VERSION = NAME + " Client " + VERSION;
|
|
||||||
|
|
||||||
public static final Map<String, Config.Value> VARS = new TreeMap();
|
public static final Map<String, Config.Value> VARS = new TreeMap();
|
||||||
|
|
||||||
@Var(name = "fireTick")
|
@Var(name = "fireTick")
|
||||||
|
@ -439,6 +437,8 @@ public abstract class Config {
|
||||||
public static int timeout = 30;
|
public static int timeout = 30;
|
||||||
@Var(name = "passwordMinLength", min = 1, max = 32)
|
@Var(name = "passwordMinLength", min = 1, max = 32)
|
||||||
public static int minPassLength = 8;
|
public static int minPassLength = 8;
|
||||||
|
@Var(name = "port", min = 1024, max = 32767, nonDefault = true)
|
||||||
|
public static int port = -1;
|
||||||
|
|
||||||
// @Var(name = "spawnX", min = -World.MAX_SIZE + 1, max = World.MAX_SIZE - 1)
|
// @Var(name = "spawnX", min = -World.MAX_SIZE + 1, max = World.MAX_SIZE - 1)
|
||||||
// public static int spawnX = 0;
|
// public static int spawnX = 0;
|
||||||
|
@ -479,7 +479,7 @@ public abstract class Config {
|
||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
for(Config.Value value : VARS.values()) {
|
for(Config.Value value : VARS.values()) {
|
||||||
value.setValue(value.def);
|
value.setValue(value.def, value.noDef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ public abstract class Config {
|
||||||
public static void set(String key, String value, boolean update) {
|
public static void set(String key, String value, boolean update) {
|
||||||
Config.Value vl = VARS.get(key);
|
Config.Value vl = VARS.get(key);
|
||||||
if(vl != null) {
|
if(vl != null) {
|
||||||
vl.setValue(value);
|
vl.setValue(value, false);
|
||||||
if(update && vl.callback != null)
|
if(update && vl.callback != null)
|
||||||
vl.callback.run();
|
vl.callback.run();
|
||||||
}
|
}
|
||||||
|
|
24
common/src/common/util/ReleaseType.java
Normal file
24
common/src/common/util/ReleaseType.java
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package common.util;
|
||||||
|
|
||||||
|
public enum ReleaseType {
|
||||||
|
DEV("dev", 3),
|
||||||
|
ALPHA("alpha", 2),
|
||||||
|
BETA("beta", 1),
|
||||||
|
STABLE(null, 0);
|
||||||
|
|
||||||
|
private final String suffix;
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
private ReleaseType(String suffix, int id) {
|
||||||
|
this.suffix = suffix == null ? "" : "-" + suffix;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return this.suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,13 +7,16 @@ import java.util.function.Function;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import common.Version;
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
import common.collect.Maps;
|
import common.collect.Maps;
|
||||||
import common.log.Log;
|
import common.log.Log;
|
||||||
|
|
||||||
public abstract class Util {
|
public abstract class Util {
|
||||||
public static final boolean WINDOWS = System.getProperty("os.name").startsWith("Windows");
|
|
||||||
private static final long START = getTime();
|
private static final long START = getTime();
|
||||||
|
public static final boolean WINDOWS = System.getProperty("os.name").startsWith("Windows");
|
||||||
|
public static final int PROTOCOL = Version.MAJOR << 16 | Version.MINOR << 8 | Version.PATCH;
|
||||||
|
public static final String VERSION = "v" + Version.MAJOR + "." + Version.MINOR + "." + Version.PATCH + Version.RELEASE;
|
||||||
|
|
||||||
public static String strip(String str, int offset, int len, char newl, char tab, char unk) {
|
public static String strip(String str, int offset, int len, char newl, char tab, char unk) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -397,4 +400,12 @@ int utf_len(const char *str) {
|
||||||
public static String getRegionName(int x, int z) {
|
public static String getRegionName(int x, int z) {
|
||||||
return String.format("r.%c%X%c%X.rgn", x < 0 ? 'n' : 'p', ((x < 0) ? -x : x) >> 3, z < 0 ? 'n' : 'p', ((z < 0) ? -z : z) >> 3);
|
return String.format("r.%c%X%c%X.rgn", x < 0 ? 'n' : 'p', ((x < 0) ? -x : x) >> 3, z < 0 ? 'n' : 'p', ((z < 0) ? -z : z) >> 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String repeatString(Object obj, int count) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for(int z = 0; z < count; z++) {
|
||||||
|
sb.append(obj);
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
|
|
||||||
|
import common.Version;
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
import common.collect.Maps;
|
import common.collect.Maps;
|
||||||
import common.color.TextColor;
|
import common.color.TextColor;
|
||||||
|
@ -153,20 +154,19 @@ public final class Server implements IThreadListener {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
Util.checkOs();
|
Util.checkOs();
|
||||||
Registry.setup("Server thread");
|
Registry.setup("Server thread");
|
||||||
Log.SYSTEM.info("Starte " + Config.NAME + " Server Version " + Config.VERSION);
|
Log.SYSTEM.info("Starte " + Version.NAME + " Server Version " + Util.VERSION + " (Protokoll #" + Util.PROTOCOL + ")");
|
||||||
GenBiome.setAsProvider();
|
GenBiome.setAsProvider();
|
||||||
UniverseRegistry.register();
|
UniverseRegistry.register();
|
||||||
RotationRegistry.register();
|
RotationRegistry.register();
|
||||||
ReorderRegistry.register();
|
ReorderRegistry.register();
|
||||||
boolean debug = System.getProperty("server.debug", null) != null;
|
boolean debug = System.getProperty("server.debug", null) != null;
|
||||||
int port = Integer.parseInt(System.getProperty("server.port", "" + Config.PORT));
|
|
||||||
final Server server = new Server(debug);
|
final Server server = new Server(debug);
|
||||||
Registry.addShutdownHook(new Runnable() {
|
Registry.addShutdownHook(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
server.stopServer();
|
server.stopServer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
server.run(time, port);
|
server.run(time);
|
||||||
Region.killIO();
|
Region.killIO();
|
||||||
Log.flushLog();
|
Log.flushLog();
|
||||||
}
|
}
|
||||||
|
@ -175,10 +175,12 @@ public final class Server implements IThreadListener {
|
||||||
NBTTagCompound data = new NBTTagCompound();
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
data.setLong("Time", time);
|
data.setLong("Time", time);
|
||||||
data.setLong("LastAccess", System.currentTimeMillis());
|
data.setLong("LastAccess", System.currentTimeMillis());
|
||||||
data.setString("Version", Config.VERSION);
|
data.setString("Version", Util.VERSION);
|
||||||
NBTTagCompound cfg = new NBTTagCompound();
|
NBTTagCompound cfg = new NBTTagCompound();
|
||||||
for(String cvar : Config.VARS.keySet()) {
|
for(String cvar : Config.VARS.keySet()) {
|
||||||
cfg.setString(cvar, Config.VARS.get(cvar).getValue());
|
Config.Value value = Config.VARS.get(cvar);
|
||||||
|
if(!value.noDef || !value.def.equals(value.getValue()))
|
||||||
|
cfg.setString(cvar, value.getValue());
|
||||||
}
|
}
|
||||||
data.setTag("Config", cfg);
|
data.setTag("Config", cfg);
|
||||||
data.setTag("Universe", UniverseRegistry.saveNbt());
|
data.setTag("Universe", UniverseRegistry.saveNbt());
|
||||||
|
@ -245,6 +247,11 @@ public final class Server implements IThreadListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "viewDistance");
|
}, "viewDistance");
|
||||||
|
Config.setCallback(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
Server.this.bind(Config.port);
|
||||||
|
}
|
||||||
|
}, "port");
|
||||||
this.keyPair = EncryptUtil.generateKeyPair();
|
this.keyPair = EncryptUtil.generateKeyPair();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,14 +363,16 @@ public final class Server implements IThreadListener {
|
||||||
Config.Value cvar = entry.getValue();
|
Config.Value cvar = entry.getValue();
|
||||||
String v = cvar.getValue();
|
String v = cvar.getValue();
|
||||||
String comp = TextColor.YELLOW + entry.getKey() + TextColor.GRAY + " = ";
|
String comp = TextColor.YELLOW + entry.getKey() + TextColor.GRAY + " = ";
|
||||||
if(entry.getKey().equals("password") && !v.isEmpty())
|
if(cvar.noDef && cvar.def.equals(v))
|
||||||
|
comp += TextColor.DGRAY + "[ - ]";
|
||||||
|
else if(entry.getKey().equals("password") && !v.isEmpty())
|
||||||
comp += TextColor.NEON + "'****'";
|
comp += TextColor.NEON + "'****'";
|
||||||
else if(cvar.type == ValueType.STRING)
|
else if(cvar.type == ValueType.STRING)
|
||||||
comp += TextColor.NEON + "'" + v + "'";
|
comp += TextColor.NEON + "'" + v + "'";
|
||||||
else
|
else
|
||||||
comp += ((cvar.type == ValueType.BOOLEAN ? (v.equals("true") ? TextColor.GREEN : TextColor.RED) : TextColor.BLUE)) + v;
|
comp += ((cvar.type == ValueType.BOOLEAN ? (v.equals("true") ? TextColor.GREEN : TextColor.RED) : TextColor.BLUE)) + v;
|
||||||
if(!cvar.def.equals(v)) {
|
if(!cvar.def.equals(v)) {
|
||||||
comp += TextColor.GRAY + " (" + TextColor.BROWN + cvar.def + TextColor.GRAY + ")";
|
comp += TextColor.GRAY + " (" + (cvar.noDef ? TextColor.DGRAY + "[ - ]" : TextColor.BROWN + cvar.def) + TextColor.GRAY + ")";
|
||||||
}
|
}
|
||||||
exec.logConsole(comp);
|
exec.logConsole(comp);
|
||||||
}
|
}
|
||||||
|
@ -381,12 +390,14 @@ public final class Server implements IThreadListener {
|
||||||
return false;
|
return false;
|
||||||
String v = cfg.getValue();
|
String v = cfg.getValue();
|
||||||
String comp = TextColor.YELLOW + args[0] + TextColor.GRAY + " = ";
|
String comp = TextColor.YELLOW + args[0] + TextColor.GRAY + " = ";
|
||||||
if(cfg.type == ValueType.STRING)
|
if(cfg.noDef && cfg.def.equals(v))
|
||||||
|
comp += TextColor.DGRAY + "[ - ]";
|
||||||
|
else if(cfg.type == ValueType.STRING)
|
||||||
comp += TextColor.NEON + "'" + v + "'";
|
comp += TextColor.NEON + "'" + v + "'";
|
||||||
else
|
else
|
||||||
comp += ((cfg.type == ValueType.BOOLEAN ? (v.equals("true") ? TextColor.GREEN : TextColor.RED) : TextColor.BLUE)) + v;
|
comp += ((cfg.type == ValueType.BOOLEAN ? (v.equals("true") ? TextColor.GREEN : TextColor.RED) : TextColor.BLUE)) + v;
|
||||||
if(!cfg.def.equals(v))
|
if(!cfg.def.equals(v))
|
||||||
comp += TextColor.GRAY + " (" + TextColor.BROWN + cfg.def + TextColor.GRAY + ")";
|
comp += TextColor.GRAY + " (" + (cfg.noDef ? TextColor.DGRAY + "[ - ]" : TextColor.BROWN + cfg.def) + TextColor.GRAY + ")";
|
||||||
exec.logConsole(comp);
|
exec.logConsole(comp);
|
||||||
// break;
|
// break;
|
||||||
// default:
|
// default:
|
||||||
|
@ -434,7 +445,7 @@ public final class Server implements IThreadListener {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(long time, int port) {
|
public void run(long time) {
|
||||||
if(!this.debug) {
|
if(!this.debug) {
|
||||||
Converter.convert();
|
Converter.convert();
|
||||||
long wtime = loadServerConfig();
|
long wtime = loadServerConfig();
|
||||||
|
@ -489,8 +500,10 @@ public final class Server implements IThreadListener {
|
||||||
WorldServer.loadWarps(dim, this.warps);
|
WorldServer.loadWarps(dim, this.warps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(port >= 0)
|
if(Config.port >= 0)
|
||||||
this.bind(port);
|
this.bind(Config.port);
|
||||||
|
else
|
||||||
|
Log.SYSTEM.warn("Kein Port definiert, verwende 'port <1024-32767>' um einen Hosting-Port festzulegen");
|
||||||
Thread con = new Thread(new Runnable() {
|
Thread con = new Thread(new Runnable() {
|
||||||
private final BufferedReader reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(System.in)));
|
private final BufferedReader reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(System.in)));
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import server.command.commands.CommandOfflinetp;
|
||||||
import server.command.commands.CommandPasswd;
|
import server.command.commands.CommandPasswd;
|
||||||
import server.command.commands.CommandPlayers;
|
import server.command.commands.CommandPlayers;
|
||||||
import server.command.commands.CommandPotion;
|
import server.command.commands.CommandPotion;
|
||||||
import server.command.commands.CommandRebind;
|
|
||||||
import server.command.commands.CommandRegister;
|
import server.command.commands.CommandRegister;
|
||||||
import server.command.commands.CommandRemove;
|
import server.command.commands.CommandRemove;
|
||||||
import server.command.commands.CommandRevoke;
|
import server.command.commands.CommandRevoke;
|
||||||
|
@ -276,7 +275,6 @@ public class CommandEnvironment {
|
||||||
this.registerExecutable(new CommandKick());
|
this.registerExecutable(new CommandKick());
|
||||||
this.registerExecutable(new CommandMessage());
|
this.registerExecutable(new CommandMessage());
|
||||||
this.registerExecutable(new CommandShutdown());
|
this.registerExecutable(new CommandShutdown());
|
||||||
this.registerExecutable(new CommandRebind());
|
|
||||||
this.registerExecutable(new CommandPasswd());
|
this.registerExecutable(new CommandPasswd());
|
||||||
this.registerExecutable(new CommandPlayers());
|
this.registerExecutable(new CommandPlayers());
|
||||||
this.registerExecutable(new CommandSave());
|
this.registerExecutable(new CommandSave());
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package server.command.commands;
|
|
||||||
|
|
||||||
import server.command.Command;
|
|
||||||
import server.command.CommandEnvironment;
|
|
||||||
import server.command.Executor;
|
|
||||||
|
|
||||||
public class CommandRebind extends Command {
|
|
||||||
public CommandRebind() {
|
|
||||||
super("rebind");
|
|
||||||
|
|
||||||
this.addInt("port", 1024, 65535);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void exec(CommandEnvironment env, Executor exec, int port) {
|
|
||||||
env.getServer().bind(port);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +1,12 @@
|
||||||
package server.network;
|
package server.network;
|
||||||
|
|
||||||
import common.init.Config;
|
|
||||||
import common.network.IHandshakeHandler;
|
import common.network.IHandshakeHandler;
|
||||||
import common.network.NetConnection;
|
import common.network.NetConnection;
|
||||||
import common.network.NetHandler;
|
import common.network.NetHandler;
|
||||||
import common.network.PacketRegistry;
|
import common.network.PacketRegistry;
|
||||||
import common.packet.HPacketHandshake;
|
import common.packet.HPacketHandshake;
|
||||||
import common.packet.RPacketDisconnect;
|
import common.packet.RPacketDisconnect;
|
||||||
|
import common.util.Util;
|
||||||
import server.Server;
|
import server.Server;
|
||||||
|
|
||||||
public class HandshakeHandler extends NetHandler implements IHandshakeHandler
|
public class HandshakeHandler extends NetHandler implements IHandshakeHandler
|
||||||
|
@ -31,13 +31,13 @@ public class HandshakeHandler extends NetHandler implements IHandshakeHandler
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.networkManager.setConnectionState(PacketRegistry.LOGIN);
|
this.networkManager.setConnectionState(PacketRegistry.LOGIN);
|
||||||
if (packetIn.getProtocolVersion() != Config.PROTOCOL)
|
if (packetIn.getProtocolVersion() != Util.PROTOCOL)
|
||||||
{
|
{
|
||||||
String comp;
|
String comp;
|
||||||
if(packetIn.getProtocolVersion() < Config.PROTOCOL)
|
if(packetIn.getProtocolVersion() < Util.PROTOCOL)
|
||||||
comp = "Der Server nutzt eine neuere Version: " + Config.VERSION;
|
comp = "Der Server nutzt eine neuere Version: " + Util.VERSION;
|
||||||
else
|
else
|
||||||
comp = "Der Server nutzt eine ältere Version: " + Config.VERSION;
|
comp = "Der Server nutzt eine ältere Version: " + Util.VERSION;
|
||||||
this.networkManager.sendPacket(new RPacketDisconnect(comp));
|
this.networkManager.sendPacket(new RPacketDisconnect(comp));
|
||||||
this.networkManager.closeChannel(comp);
|
this.networkManager.closeChannel(comp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2044,7 +2044,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
if(v.type == ValueType.BOOLEAN)
|
if(v.type == ValueType.BOOLEAN)
|
||||||
return Boolean.parseBoolean(v.getValue()) ? Lists.newArrayList("false", "true") : Lists.newArrayList("true", "false");
|
return Boolean.parseBoolean(v.getValue()) ? Lists.newArrayList("false", "true") : Lists.newArrayList("true", "false");
|
||||||
else if(v.type == ValueType.INTEGER || v.type == ValueType.FLOAT)
|
else if(!v.noDef && (v.type == ValueType.INTEGER || v.type == ValueType.FLOAT))
|
||||||
return Lists.newArrayList(v.def);
|
return Lists.newArrayList(v.def);
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue