diff --git a/pom.xml b/pom.xml
index 6fe53e2..863093c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,9 +2,23 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.loohp
+ com.loohp.limbo
Limbo
- 0.4.0-ALPHA
+ Limbo
+ 0.4.1-ALPHA
+
+ Standalone Limbo Minecraft Server.
+ https://github.com/LOOHP/Limbo
+ jar
+
+
+ UTF-8
+
+ ${project.version}
+ 1.8
+ 1.8
+
+
src/main/java
@@ -50,10 +64,98 @@
ISO-8859-1
+
+
+ maven-javadoc-plugin
+ 3.2.0
+
+ false
+ ISO-8859-1
+ Limbo JavaDocs
+ Limbo JavaDocs
+
+ -Xdoclint:none
+
+
+
+
+ install
+
+ aggregate
+
+
+
+
${project.artifactId}-${project.version}-1.16.5
+
+
+ jenkins
+
+
+ env.BUILD_NUMBER
+
+
+
+ -b${env.BUILD_NUMBER}
+
+ ${project.version}
+
+
+
+
+ release-sign-artifacts
+
+
+ performRelease
+ true
+
+
+
+ ${project.version}
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.2.1
+
+ ${project.build.sourceEncoding}
+
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.2.0
+
+ ${project.build.sourceEncoding}
+
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+
+
+
+
jitpack.io
@@ -117,9 +219,4 @@
-
- 1.8
- 1.8
-
-
\ No newline at end of file
diff --git a/src/main/java/com/loohp/limbo/Console.java b/src/main/java/com/loohp/limbo/Console.java
index 676bc2f..bffa3e0 100644
--- a/src/main/java/com/loohp/limbo/Console.java
+++ b/src/main/java/com/loohp/limbo/Console.java
@@ -20,10 +20,12 @@ import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.Ansi.Attribute;
import org.jline.reader.Candidate;
import org.jline.reader.Completer;
+import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader;
import org.jline.reader.LineReader.SuggestionType;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.ParsedLine;
+import org.jline.reader.UserInterruptException;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
@@ -85,7 +87,7 @@ public class Console implements CommandSender {
reader = new ConsoleReader(in, out);
reader.setExpandEvents(false);
-
+ reader.setHandleUserInterrupt(false);
terminal = TerminalBuilder.builder().streams(in, out).system(true).jansi(true).build();
tabReader = LineReaderBuilder.builder().terminal(terminal).completer(new Completer() {
@@ -152,10 +154,16 @@ public class Console implements CommandSender {
return;
}
while (true) {
- String command = tabReader.readLine(PROMPT).trim();
- if (command.length() > 0) {
- String[] input = CustomStringUtils.splitStringToArgs(command);
- new Thread(() -> Limbo.getInstance().dispatchCommand(this, input)).start();
+ try {
+ String command = tabReader.readLine(PROMPT).trim();
+ if (command.length() > 0) {
+ String[] input = CustomStringUtils.splitStringToArgs(command);
+ new Thread(() -> Limbo.getInstance().dispatchCommand(this, input)).start();
+ }
+ } catch (UserInterruptException e) {
+ System.exit(0);
+ } catch (EndOfFileException e) {
+ break;
}
}
}
diff --git a/src/main/java/com/loohp/limbo/Limbo.java b/src/main/java/com/loohp/limbo/Limbo.java
index 67d1703..0f48cab 100644
--- a/src/main/java/com/loohp/limbo/Limbo.java
+++ b/src/main/java/com/loohp/limbo/Limbo.java
@@ -321,6 +321,10 @@ public class Limbo {
metrics = new Metrics();
+ Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+ Limbo.getInstance().terminate();
+ }));
+
console.run();
}
@@ -496,7 +500,7 @@ public class Limbo {
return String.join("\00", begin, "127", version, String.join("", Arrays.asList(motd).stream().map(each -> each.toLegacyText()).collect(Collectors.toList())), String.valueOf(playersOnline), String.valueOf(maxPlayers));
}
- public void stopServer() {
+ protected void terminate() {
isRunning.set(false);
console.sendMessage("Stopping Server...");
@@ -520,6 +524,9 @@ public class Limbo {
console.sendMessage("Server closed");
console.logs.close();
+ }
+
+ public void stopServer() {
System.exit(0);
}
diff --git a/src/main/java/com/loohp/limbo/Server/ClientConnection.java b/src/main/java/com/loohp/limbo/Server/ClientConnection.java
index 6bd1535..b2c3a0f 100644
--- a/src/main/java/com/loohp/limbo/Server/ClientConnection.java
+++ b/src/main/java/com/loohp/limbo/Server/ClientConnection.java
@@ -293,37 +293,26 @@ public class ClientConnection extends Thread {
TimeUnit.MILLISECONDS.sleep(500);
- ServerProperties p = Limbo.getInstance().getServerProperties();
- Location s = p.getWorldSpawn();
-
- PlayerJoinEvent evt = new PlayerJoinEvent(player, s);
- Limbo.getInstance().getEventsManager().callEvent(evt);
- s = evt.getSpawnLocation();
-
- PacketPlayOutLogin join = new PacketPlayOutLogin(player.getEntityId(), false, p.getDefaultGamemode(), Limbo.getInstance().getWorlds().stream().map(each -> new NamespacedKey(each.getName()).toString()).collect(Collectors.toList()).toArray(new String[Limbo.getInstance().getWorlds().size()]), Limbo.getInstance().getDimensionRegistry().getCodec(), p.getWorldSpawn().getWorld(), 0, (byte) p.getMaxPlayers(), 8, p.isReducedDebugInfo(), true, false, true);
- sendPacket(join);
- Limbo.getInstance().getUnsafe().setPlayerGameModeSilently(player, p.getDefaultGamemode());
-
- //PacketPlayOutKeepAlive alive = new PacketPlayOutKeepAlive((long) (Math.random() * Long.MAX_VALUE));
+ ServerProperties properties = Limbo.getInstance().getServerProperties();
+ Location worldSpawn = properties.getWorldSpawn();
- World world = s.getWorld();
+ PlayerJoinEvent joinEvent = Limbo.getInstance().getEventsManager().callEvent(new PlayerJoinEvent(player, worldSpawn));
+ worldSpawn = joinEvent.getSpawnLocation();
+ World world = worldSpawn.getWorld();
+
+ PacketPlayOutLogin join = new PacketPlayOutLogin(player.getEntityId(), false, properties.getDefaultGamemode(), Limbo.getInstance().getWorlds().stream().map(each -> new NamespacedKey(each.getName()).toString()).collect(Collectors.toList()).toArray(new String[Limbo.getInstance().getWorlds().size()]), Limbo.getInstance().getDimensionRegistry().getCodec(), world, 0, (byte) properties.getMaxPlayers(), 8, properties.isReducedDebugInfo(), true, false, true);
+ sendPacket(join);
+ Limbo.getInstance().getUnsafe().setPlayerGameModeSilently(player, properties.getDefaultGamemode());
player.playerInteractManager.update();
SkinResponse skinresponce = isBungeecord && bungeeSkin != null ? bungeeSkin : MojangAPIUtils.getSkinFromMojangServer(player.getName());
PlayerSkinProperty skin = skinresponce != null ? new PlayerSkinProperty(skinresponce.getSkin(), skinresponce.getSignature()) : null;
- PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PlayerInfoAction.ADD_PLAYER, player.getUniqueId(), new PlayerInfoData.PlayerInfoDataAddPlayer(player.getName(), Optional.ofNullable(skin), p.getDefaultGamemode(), 0, false, Optional.empty()));
+ PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PlayerInfoAction.ADD_PLAYER, player.getUniqueId(), new PlayerInfoData.PlayerInfoDataAddPlayer(player.getName(), Optional.ofNullable(skin), properties.getDefaultGamemode(), 0, false, Optional.empty()));
sendPacket(info);
- /*
- for (ClientConnection client : Limbo.getInstance().getServerConnection().getClients()) {
- DataOutputStream other = new DataOutputStream(client.getSocket().getOutputStream());
- DataTypeIO.writeVarInt(other, packetByte.length);
- other.write(packetByte);
- }
- */
Set flags = new HashSet<>();
- if (p.isAllowFlight()) {
+ if (properties.isAllowFlight()) {
flags.add(PlayerAbilityFlags.FLY);
}
if (player.getGamemode().equals(GameMode.CREATIVE)) {
@@ -340,11 +329,11 @@ public class ClientConnection extends Thread {
sendPacket(declare);
}
- PacketPlayOutSpawnPosition spawnPos = new PacketPlayOutSpawnPosition(BlockPosition.from(s));
+ PacketPlayOutSpawnPosition spawnPos = new PacketPlayOutSpawnPosition(BlockPosition.from(worldSpawn));
sendPacket(spawnPos);
- PacketPlayOutPositionAndLook positionLook = new PacketPlayOutPositionAndLook(s.getX(), s.getY(), s.getZ(), s.getYaw(), s.getPitch(), 1);
- Limbo.getInstance().getUnsafe().setPlayerLocationSilently(player, new Location(world, s.getX(), s.getY(), s.getZ(), s.getYaw(), s.getPitch()));
+ PacketPlayOutPositionAndLook positionLook = new PacketPlayOutPositionAndLook(worldSpawn.getX(), worldSpawn.getY(), worldSpawn.getZ(), worldSpawn.getYaw(), worldSpawn.getPitch(), 1);
+ Limbo.getInstance().getUnsafe().setPlayerLocationSilently(player, new Location(world, worldSpawn.getX(), worldSpawn.getY(), worldSpawn.getZ(), worldSpawn.getYaw(), worldSpawn.getPitch()));
sendPacket(positionLook);
player.getDataWatcher().update();