From adc81d56d267c9bd816774df37d6085d1f01f6e4 Mon Sep 17 00:00:00 2001 From: Sen Date: Mon, 26 May 2025 13:27:03 +0200 Subject: [PATCH] change port, config and version mechanisms --- client/src/client/Client.java | 17 +++++---- client/src/client/gui/GuiConnect.java | 5 +-- client/src/client/gui/GuiInfo.java | 8 ++-- client/src/client/gui/GuiMenu.java | 4 +- client/src/client/gui/GuiServer.java | 22 +++++++---- common/src/common/Version.java | 11 ++++++ common/src/common/init/Config.java | 24 ++++++------ common/src/common/util/ReleaseType.java | 24 ++++++++++++ common/src/common/util/Util.java | 13 ++++++- server/src/server/Server.java | 37 +++++++++++++------ .../server/command/CommandEnvironment.java | 2 - .../command/commands/CommandRebind.java | 17 --------- .../src/server/network/HandshakeHandler.java | 10 ++--- server/src/server/network/Player.java | 2 +- 14 files changed, 122 insertions(+), 74 deletions(-) create mode 100644 common/src/common/Version.java create mode 100644 common/src/common/util/ReleaseType.java delete mode 100644 server/src/server/command/commands/CommandRebind.java diff --git a/client/src/client/Client.java b/client/src/client/Client.java index 7dcb511..5df3f6d 100755 --- a/client/src/client/Client.java +++ b/client/src/client/Client.java @@ -100,6 +100,7 @@ import client.window.Window; import client.window.WindowEvent; import client.world.ChunkClient; import client.world.WorldClient; +import common.Version; import common.biome.Biome; import common.block.Block; import common.collect.Lists; @@ -116,7 +117,6 @@ import common.future.ListenableFutureTask; import common.future.ThreadFactoryBuilder; import common.init.BlockRegistry; import common.init.Blocks; -import common.init.Config; import common.init.EntityRegistry; import common.init.ItemRegistry; import common.init.Items; @@ -259,7 +259,8 @@ public class Client implements IThreadListener { this.help = help; } } - + + public static final String VERSION = Version.NAME + " Client " + Util.VERSION; public static final int LOG_BUFFER = 32768; private static final LazyLoadBase CLIENT_NIO_EVENTLOOP = new LazyLoadBase() { @@ -520,7 +521,7 @@ public class Client implements IThreadListener { { connection = createNetworkManagerAndConnect(address == null ? InetAddress.getLoopbackAddress() : InetAddress.getByName(IDN.toASCII(address)), port); connection.setNetHandler(new ClientLoginHandler(connection, this, user, access, pass)); - connection.sendPacket(new HPacketHandshake(Config.PROTOCOL), new GenericFutureListener>() { + connection.sendPacket(new HPacketHandshake(Util.PROTOCOL), new GenericFutureListener>() { public void operationComplete(Future u) throws Exception { connection.setConnectionState(PacketRegistry.LOGIN); } @@ -1248,14 +1249,14 @@ public class Client implements IThreadListener { // SKC.setGuiMenu(); // else // SKC.setGuiAny(); - Window.setTitle(String.format("%s - %s", Config.CLIENT_VERSION, gui.getTitle())); + Window.setTitle(String.format("%s - %s", VERSION, gui.getTitle())); } else { this.menu(false); this.leftClickCounter = 10000; 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(); } } @@ -2173,8 +2174,8 @@ public class Client implements IThreadListener { public void run() { Log.SYSTEM.info("Java " + System.getProperty("java.version")); - Log.SYSTEM.info(Config.CLIENT_VERSION); - if(!Window.createWindow(Config.CLIENT_VERSION, System.getProperty("opengl.debug") != null)) + Log.SYSTEM.info(VERSION + " (Protokoll #" + Util.PROTOCOL + ")"); + if(!Window.createWindow(VERSION, System.getProperty("opengl.debug") != null)) System.exit(1); Log.SYSTEM.info("OpenGL %s", GL11.glGetString(GL11.GL_VERSION)); Log.SYSTEM.info("GL_VENDOR: %s", GL11.glGetString(GL11.GL_VENDOR)); @@ -2972,7 +2973,7 @@ public class Client implements IThreadListener { } public void reset() { - this.buffer = TextColor.NEON + "*** " + Config.CLIENT_VERSION + " ***"; + this.buffer = TextColor.NEON + "*** " + VERSION + " ***"; this.console.clear(); this.chat.clear(); this.feed.clear(); diff --git a/client/src/client/gui/GuiConnect.java b/client/src/client/gui/GuiConnect.java index 67135c0..8cabda8 100644 --- a/client/src/client/gui/GuiConnect.java +++ b/client/src/client/gui/GuiConnect.java @@ -14,7 +14,6 @@ import client.gui.element.PressType; import client.renderer.Drawing; import client.util.FileUtils; import common.color.TextColor; -import common.init.Config; import common.log.Log; import common.network.IPlayer; import common.util.Tuple; @@ -133,7 +132,7 @@ public class GuiConnect extends GuiList implements Button for(int z = 0; z <= lines.length; z++) { String line = z == lines.length ? null : lines[z]; 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)); if(line != null) { address = ""; @@ -250,7 +249,7 @@ public class GuiConnect extends GuiList implements Button } else if(button == this.createButton) { 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) { ServerInfo server = this.getSelected(); diff --git a/client/src/client/gui/GuiInfo.java b/client/src/client/gui/GuiInfo.java index 8fe7c30..97819dd 100644 --- a/client/src/client/gui/GuiInfo.java +++ b/client/src/client/gui/GuiInfo.java @@ -1,15 +1,17 @@ package client.gui; +import client.Client; import client.gui.element.NavButton; import client.gui.element.TransparentArea; +import common.Version; import common.color.TextColor; -import common.init.Config; import common.log.Log; +import common.util.Util; public class GuiInfo extends Gui { private static final String VER = - TextColor.GREEN + "" + TextColor.BUG + "" + TextColor.BUG + "" + TextColor.BUG + " " + TextColor.VIOLET + "" + Config.CLIENT_VERSION + "" + - TextColor.GREEN + " " + TextColor.BUG + "" + TextColor.BUG + "" + TextColor.BUG; + TextColor.GREEN + "" + Util.repeatString(TextColor.BUG, Version.RELEASE.getId()) + TextColor.DVIOLET + "|-| " + TextColor.VIOLET + Client.VERSION + TextColor.DVIOLET + " |-|" + + 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" + "Optimiert für Geschwindigkeit, Stabilität und" + TextColor.UNKNOWN + "" + TextColor.UNKNOWN + " [Speicherzugriffsfehler]"; diff --git a/client/src/client/gui/GuiMenu.java b/client/src/client/gui/GuiMenu.java index 398d962..cea6cff 100644 --- a/client/src/client/gui/GuiMenu.java +++ b/client/src/client/gui/GuiMenu.java @@ -1,5 +1,6 @@ package client.gui; +import client.Client; import client.gui.character.GuiChar; import client.gui.character.GuiCharacters; import client.gui.element.ActButton; @@ -11,7 +12,6 @@ import client.gui.options.GuiOptions; import client.renderer.Drawing; import client.window.Keysym; import common.color.TextColor; -import common.init.Config; import common.rng.Random; import common.util.ExtMath; @@ -100,7 +100,7 @@ public class GuiMenu extends Gui { } }, "Client schließen")); 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.pickSplash(); } diff --git a/client/src/client/gui/GuiServer.java b/client/src/client/gui/GuiServer.java index 3cb509e..7502470 100644 --- a/client/src/client/gui/GuiServer.java +++ b/client/src/client/gui/GuiServer.java @@ -12,7 +12,6 @@ import client.gui.element.FieldCallback; import client.vars.CVarCategory; import client.vars.Variable; import common.color.TextColor; -import common.init.Config; import common.network.IPlayer; public class GuiServer extends Gui implements FieldCallback { @@ -29,6 +28,7 @@ public class GuiServer extends Gui implements FieldCallback { private Label nameLabel; private Label addrLabel; private Label portLabel; + private Label rangeLabel; private Label userLabel; private Label passLabel; 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") private String lastAddr = ""; - @Variable(name = "srv_last_port", category = CVarCategory.SYSTEM, min = 0, max = 65535, display = "Letzter Server-Port") - private int lastPort = Config.PORT; + @Variable(name = "srv_last_port", category = CVarCategory.SYSTEM, min = 1024, max = 32767, display = "Letzter Server-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) private String lastUser = ""; @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) 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.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.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())); @@ -65,7 +66,8 @@ public class GuiServer extends Gui implements FieldCallback { if(this.server != null) 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.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.passLabel = this.add(new Label(0, 100, 480, 20, "Passwort", 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()); } catch(NumberFormatException e) { + this.rangeLabel.setText("[" + TextColor.RED + "1024..32767" + TextColor.RESET + "]"); + return; } - if(port < 0 || port > 65535) { - this.portLabel.setText(TextColor.RED + "Port"); + if(port < 1024 || port > 32767) { + this.rangeLabel.setText("[" + (port < 1024 ? TextColor.RED + "1024" + TextColor.RESET + "..32767" : "1024.." + TextColor.RED + "32767" + TextColor.RESET) + "]"); return; } } @@ -138,8 +142,10 @@ public class GuiServer extends Gui implements FieldCallback { else if(value == FieldAction.FOCUS) { if(elem == this.addrBox) this.addrLabel.setText("Adresse"); - else if(elem == this.portBox) + else if(elem == this.portBox) { this.portLabel.setText("Port"); + this.rangeLabel.setText("[1024..32767]"); + } else if(elem == this.userBox) this.userLabel.setText("Nutzer"); else if(this.server != null && elem == this.nameBox) diff --git a/common/src/common/Version.java b/common/src/common/Version.java new file mode 100644 index 0000000..daf86da --- /dev/null +++ b/common/src/common/Version.java @@ -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; +} diff --git a/common/src/common/init/Config.java b/common/src/common/init/Config.java index c50fd3f..457d847 100755 --- a/common/src/common/init/Config.java +++ b/common/src/common/init/Config.java @@ -23,11 +23,13 @@ public abstract class Config { String name(); float min() default (float)Integer.MIN_VALUE; float max() default (float)Integer.MAX_VALUE; + boolean nonDefault() default false; } public static class Value { public final ValueType type; public final String def; + public final boolean noDef; private final Field field; private final float min; private final float max; @@ -41,6 +43,7 @@ public abstract class Config { throw new IllegalArgumentException(value.name() + ": Unbekannter Variablen-Typ - " + field.getType()); this.field = field; this.def = this.getValue(); + this.noDef = value.nonDefault(); // Clamped clamp = this.field.getAnnotation(Clamped.class); this.min = (this.type == ValueType.INTEGER || this.type == ValueType.FLOAT) ? value.min() : 0; @@ -59,7 +62,7 @@ public abstract class Config { // throw new RuntimeException(e); // } // } - this.setValue(this.def); + this.setValue(this.def, this.noDef); } public String getValue() { @@ -82,7 +85,7 @@ public abstract class Config { } } - private void setValue(String value) { + private void setValue(String value, boolean noClamp) { try { switch(this.type) { case STRING: @@ -98,7 +101,7 @@ public abstract class Config { } 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; case FLOAT: float fnum = 0.0f; @@ -107,7 +110,8 @@ public abstract class Config { } catch(NumberFormatException e) { } - fnum = ExtMath.clampf(fnum, this.min, this.max); + if(!noClamp) + fnum = ExtMath.clampf(fnum, this.min, this.max); int round = (int)(fnum * 1000.0f); this.field.setFloat(null, (float)round / 1000.0f); break; @@ -118,12 +122,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 VARS = new TreeMap(); @@ -439,6 +437,8 @@ public abstract class Config { public static int timeout = 30; @Var(name = "passwordMinLength", min = 1, max = 32) 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) // public static int spawnX = 0; @@ -479,7 +479,7 @@ public abstract class Config { public static void clear() { 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) { Config.Value vl = VARS.get(key); if(vl != null) { - vl.setValue(value); + vl.setValue(value, false); if(update && vl.callback != null) vl.callback.run(); } diff --git a/common/src/common/util/ReleaseType.java b/common/src/common/util/ReleaseType.java new file mode 100644 index 0000000..be367f8 --- /dev/null +++ b/common/src/common/util/ReleaseType.java @@ -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; + } +} diff --git a/common/src/common/util/Util.java b/common/src/common/util/Util.java index 629ef96..230fdfc 100644 --- a/common/src/common/util/Util.java +++ b/common/src/common/util/Util.java @@ -7,13 +7,16 @@ import java.util.function.Function; import javax.swing.JOptionPane; +import common.Version; import common.collect.Lists; import common.collect.Maps; import common.log.Log; public abstract class Util { - public static final boolean WINDOWS = System.getProperty("os.name").startsWith("Windows"); 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) { StringBuilder sb = new StringBuilder(); @@ -397,4 +400,12 @@ int utf_len(const char *str) { 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); } + + 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(); + } } diff --git a/server/src/server/Server.java b/server/src/server/Server.java index 5d0b5cb..055d6ef 100755 --- a/server/src/server/Server.java +++ b/server/src/server/Server.java @@ -24,6 +24,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.FutureTask; +import common.Version; import common.collect.Lists; import common.collect.Maps; import common.color.TextColor; @@ -153,20 +154,19 @@ public final class Server implements IThreadListener { long time = System.currentTimeMillis(); Util.checkOs(); 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(); UniverseRegistry.register(); RotationRegistry.register(); ReorderRegistry.register(); boolean debug = System.getProperty("server.debug", null) != null; - int port = Integer.parseInt(System.getProperty("server.port", "" + Config.PORT)); final Server server = new Server(debug); Registry.addShutdownHook(new Runnable() { public void run() { server.stopServer(); } }); - server.run(time, port); + server.run(time); Region.killIO(); Log.flushLog(); } @@ -175,10 +175,12 @@ public final class Server implements IThreadListener { NBTTagCompound data = new NBTTagCompound(); data.setLong("Time", time); data.setLong("LastAccess", System.currentTimeMillis()); - data.setString("Version", Config.VERSION); + data.setString("Version", Util.VERSION); NBTTagCompound cfg = new NBTTagCompound(); 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("Universe", UniverseRegistry.saveNbt()); @@ -245,6 +247,11 @@ public final class Server implements IThreadListener { } } }, "viewDistance"); + Config.setCallback(new Runnable() { + public void run() { + Server.this.bind(Config.port); + } + }, "port"); this.keyPair = EncryptUtil.generateKeyPair(); } @@ -356,14 +363,16 @@ public final class Server implements IThreadListener { Config.Value cvar = entry.getValue(); String v = cvar.getValue(); 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 + "'****'"; else if(cvar.type == ValueType.STRING) comp += TextColor.NEON + "'" + v + "'"; else comp += ((cvar.type == ValueType.BOOLEAN ? (v.equals("true") ? TextColor.GREEN : TextColor.RED) : TextColor.BLUE)) + 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); } @@ -381,12 +390,14 @@ public final class Server implements IThreadListener { return false; String v = cfg.getValue(); 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 + "'"; else comp += ((cfg.type == ValueType.BOOLEAN ? (v.equals("true") ? TextColor.GREEN : TextColor.RED) : TextColor.BLUE)) + 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); // break; // default: @@ -434,7 +445,7 @@ public final class Server implements IThreadListener { return true; } - public void run(long time, int port) { + public void run(long time) { if(!this.debug) { Converter.convert(); long wtime = loadServerConfig(); @@ -489,8 +500,10 @@ public final class Server implements IThreadListener { WorldServer.loadWarps(dim, this.warps); } } - if(port >= 0) - this.bind(port); + if(Config.port >= 0) + 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() { private final BufferedReader reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(System.in))); diff --git a/server/src/server/command/CommandEnvironment.java b/server/src/server/command/CommandEnvironment.java index bb85367..5a437b2 100644 --- a/server/src/server/command/CommandEnvironment.java +++ b/server/src/server/command/CommandEnvironment.java @@ -22,7 +22,6 @@ import server.command.commands.CommandOfflinetp; import server.command.commands.CommandPasswd; import server.command.commands.CommandPlayers; import server.command.commands.CommandPotion; -import server.command.commands.CommandRebind; import server.command.commands.CommandRegister; import server.command.commands.CommandRemove; import server.command.commands.CommandRevoke; @@ -276,7 +275,6 @@ public class CommandEnvironment { this.registerExecutable(new CommandKick()); this.registerExecutable(new CommandMessage()); this.registerExecutable(new CommandShutdown()); - this.registerExecutable(new CommandRebind()); this.registerExecutable(new CommandPasswd()); this.registerExecutable(new CommandPlayers()); this.registerExecutable(new CommandSave()); diff --git a/server/src/server/command/commands/CommandRebind.java b/server/src/server/command/commands/CommandRebind.java deleted file mode 100644 index ad45c0e..0000000 --- a/server/src/server/command/commands/CommandRebind.java +++ /dev/null @@ -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); - } -} diff --git a/server/src/server/network/HandshakeHandler.java b/server/src/server/network/HandshakeHandler.java index 718e66f..54d51cf 100755 --- a/server/src/server/network/HandshakeHandler.java +++ b/server/src/server/network/HandshakeHandler.java @@ -1,12 +1,12 @@ package server.network; -import common.init.Config; import common.network.IHandshakeHandler; import common.network.NetConnection; import common.network.NetHandler; import common.network.PacketRegistry; import common.packet.HPacketHandshake; import common.packet.RPacketDisconnect; +import common.util.Util; import server.Server; public class HandshakeHandler extends NetHandler implements IHandshakeHandler @@ -31,13 +31,13 @@ public class HandshakeHandler extends NetHandler implements IHandshakeHandler return; } this.networkManager.setConnectionState(PacketRegistry.LOGIN); - if (packetIn.getProtocolVersion() != Config.PROTOCOL) + if (packetIn.getProtocolVersion() != Util.PROTOCOL) { String comp; - if(packetIn.getProtocolVersion() < Config.PROTOCOL) - comp = "Der Server nutzt eine neuere Version: " + Config.VERSION; + if(packetIn.getProtocolVersion() < Util.PROTOCOL) + comp = "Der Server nutzt eine neuere Version: " + Util.VERSION; 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.closeChannel(comp); } diff --git a/server/src/server/network/Player.java b/server/src/server/network/Player.java index f45fafb..1e299fa 100755 --- a/server/src/server/network/Player.java +++ b/server/src/server/network/Player.java @@ -2044,7 +2044,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer return Lists.newArrayList(); if(v.type == ValueType.BOOLEAN) 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(); }