forked from BLOCKFANTASY/LOOHP-Limbo
Fixed PacketPlayInPluginMessaging & Added default command /version
This commit is contained in:
parent
0ac9810554
commit
effcbab3e4
2
pom.xml
2
pom.xml
|
|
@ -24,7 +24,7 @@
|
||||||
<groupId>com.loohp</groupId>
|
<groupId>com.loohp</groupId>
|
||||||
<artifactId>Limbo</artifactId>
|
<artifactId>Limbo</artifactId>
|
||||||
<name>Limbo</name>
|
<name>Limbo</name>
|
||||||
<version>0.6.14-ALPHA</version>
|
<version>0.6.15-ALPHA</version>
|
||||||
|
|
||||||
<description>Standalone Limbo Minecraft Server.</description>
|
<description>Standalone Limbo Minecraft Server.</description>
|
||||||
<url>https://github.com/LOOHP/Limbo</url>
|
<url>https://github.com/LOOHP/Limbo</url>
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,8 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.querz.nbt.io.NBTUtil;
|
import net.querz.nbt.io.NBTUtil;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
|
||||||
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
|
||||||
public class Limbo {
|
public class Limbo {
|
||||||
|
|
||||||
public static final String LIMBO_BRAND = "Limbo";
|
public static final String LIMBO_BRAND = "Limbo";
|
||||||
|
|
@ -110,10 +112,11 @@ public class Limbo {
|
||||||
}
|
}
|
||||||
if (!noGui) {
|
if (!noGui) {
|
||||||
System.out.println("Launching Server GUI.. Add \"--nogui\" in launch arguments to disable");
|
System.out.println("Launching Server GUI.. Add \"--nogui\" in launch arguments to disable");
|
||||||
Thread t1 = new Thread(new Runnable() {
|
Thread t1 = new Thread(() -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
|
||||||
GUI.main();
|
GUI.main();
|
||||||
|
} catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
t1.start();
|
t1.start();
|
||||||
|
|
@ -128,9 +131,9 @@ public class Limbo {
|
||||||
|
|
||||||
//===========================
|
//===========================
|
||||||
|
|
||||||
public final String serverImplementationVersion = "1.18.2";
|
public final String SERVER_IMPLEMENTATION_VERSION = "1.18.2";
|
||||||
public final int serverImplementationProtocol = 758;
|
public final int SERVER_IMPLEMENTATION_PROTOCOL = 758;
|
||||||
public final String limboImplementationVersion;
|
public final String LIMBO_IMPLEMENTATION_VERSION;
|
||||||
|
|
||||||
private AtomicBoolean isRunning;
|
private AtomicBoolean isRunning;
|
||||||
|
|
||||||
|
|
@ -176,8 +179,8 @@ public class Limbo {
|
||||||
console = new Console(System.in, System.out, System.err);
|
console = new Console(System.in, System.out, System.err);
|
||||||
}
|
}
|
||||||
|
|
||||||
limboImplementationVersion = getLimboVersion();
|
LIMBO_IMPLEMENTATION_VERSION = getLimboVersion();
|
||||||
console.sendMessage("Loading Limbo Version " + limboImplementationVersion + " on Minecraft " + serverImplementationVersion);
|
console.sendMessage("Loading Limbo Version " + LIMBO_IMPLEMENTATION_VERSION + " on Minecraft " + SERVER_IMPLEMENTATION_VERSION);
|
||||||
|
|
||||||
String spName = "server.properties";
|
String spName = "server.properties";
|
||||||
File sp = new File(spName);
|
File sp = new File(spName);
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,16 @@ public class DefaultCommands implements CommandExecutor, TabCompletor {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("version")) {
|
||||||
|
if (sender.hasPermission("limboserver.version")) {
|
||||||
|
sender.sendMessage(ChatColor.DARK_GRAY + "This server is running Limbo version " + Limbo.getInstance().LIMBO_IMPLEMENTATION_VERSION + " (MC: " + Limbo.getInstance().SERVER_IMPLEMENTATION_VERSION + ")");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You do not have permission to use that command!");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("spawn")) {
|
if (args[0].equalsIgnoreCase("spawn")) {
|
||||||
if (sender.hasPermission("limboserver.spawn")) {
|
if (sender.hasPermission("limboserver.spawn")) {
|
||||||
if (args.length == 1 && sender instanceof Player) {
|
if (args.length == 1 && sender instanceof Player) {
|
||||||
|
|
@ -78,13 +88,11 @@ public class DefaultCommands implements CommandExecutor, TabCompletor {
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
Player player = Limbo.getInstance().getPlayer(args[1]);
|
Player player = Limbo.getInstance().getPlayer(args[1]);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (args.length >= 2) {
|
|
||||||
String reasonRaw = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
String reasonRaw = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
||||||
if (reasonRaw.trim().length() > 0) {
|
if (reasonRaw.trim().length() > 0) {
|
||||||
reason = LegacyComponentSerializer.legacySection().deserialize(reasonRaw);
|
reason = LegacyComponentSerializer.legacySection().deserialize(reasonRaw);
|
||||||
customReason = true;
|
customReason = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
player.disconnect(reason);
|
player.disconnect(reason);
|
||||||
if (customReason) {
|
if (customReason) {
|
||||||
sender.sendMessage(ChatColor.RED + "Kicked the player " + player.getName() + " for the reason: " + LegacyComponentSerializer.legacySection().serialize(reason));
|
sender.sendMessage(ChatColor.RED + "Kicked the player " + player.getName() + " for the reason: " + LegacyComponentSerializer.legacySection().serialize(reason));
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JTextPane;
|
import javax.swing.JTextPane;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
|
|
@ -67,7 +69,8 @@ public class GUI extends JFrame {
|
||||||
/**
|
/**
|
||||||
* Launch the application.
|
* Launch the application.
|
||||||
*/
|
*/
|
||||||
public static void main() {
|
public static void main() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
GUI frame = new GUI();
|
GUI frame = new GUI();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@ public class SystemInfo {
|
||||||
long allocatedMemory = runtime.totalMemory();
|
long allocatedMemory = runtime.totalMemory();
|
||||||
long freeMemory = runtime.freeMemory();
|
long freeMemory = runtime.freeMemory();
|
||||||
|
|
||||||
sb.append("Free Memory: " + format.format(freeMemory / 1024 / 1024) + " MB\n");
|
sb.append("Free Memory: ").append(format.format(freeMemory / 1024 / 1024)).append(" MB\n");
|
||||||
sb.append("Allocated Memory: " + format.format(allocatedMemory / 1024 / 1024) + " MB\n");
|
sb.append("Allocated Memory: ").append(format.format(allocatedMemory / 1024 / 1024)).append(" MB\n");
|
||||||
sb.append("Max Memory: " + format.format(maxMemory / 1024 / 1024) + " MB\n");
|
sb.append("Max Memory: ").append(format.format(maxMemory / 1024 / 1024)).append(" MB\n");
|
||||||
sb.append("Memory Usage: " + format.format((allocatedMemory - freeMemory) / 1024 / 1024) + "/" + format.format(maxMemory / 1024 / 1024) + " MB (" + Math.round((double) (allocatedMemory - freeMemory) / (double) (maxMemory) * 100) + "%)\n");
|
sb.append("Memory Usage: ").append(format.format((allocatedMemory - freeMemory) / 1024 / 1024)).append("/").append(format.format(maxMemory / 1024 / 1024)).append(" MB (").append(Math.round((double) (allocatedMemory - freeMemory) / (double) (maxMemory) * 100)).append("%)\n");
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -54,13 +54,16 @@ public class SystemInfo {
|
||||||
double systemLoad = operatingSystemMXBean.getSystemCpuLoad();
|
double systemLoad = operatingSystemMXBean.getSystemCpuLoad();
|
||||||
int processors = runtime.availableProcessors();
|
int processors = runtime.availableProcessors();
|
||||||
|
|
||||||
sb.append("Available Processors: " + processors + "\n");
|
sb.append("Available Processors: ").append(processors).append("\n");
|
||||||
sb.append("Process CPU Load: " + Math.round(processLoad * 100) + "%\n");
|
sb.append("Process CPU Load: ").append(Math.round(processLoad * 100)).append("%\n");
|
||||||
sb.append("System CPU Load: " + Math.round(systemLoad * 100) + "%\n");
|
sb.append("System CPU Load: ").append(Math.round(systemLoad * 100)).append("%\n");
|
||||||
GUI.sysText.setText(sb.toString());
|
GUI.sysText.setText(sb.toString());
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {}
|
||||||
|
|
||||||
try {TimeUnit.MILLISECONDS.sleep(1000);} catch (InterruptedException e) {}
|
try {
|
||||||
|
TimeUnit.MILLISECONDS.sleep(1000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,16 +24,11 @@ import com.loohp.limbo.player.Player;
|
||||||
|
|
||||||
public class PlayerResourcePackStatusEvent extends PlayerEvent {
|
public class PlayerResourcePackStatusEvent extends PlayerEvent {
|
||||||
|
|
||||||
private Player player;
|
|
||||||
private EnumResourcePackStatus status;
|
private EnumResourcePackStatus status;
|
||||||
|
|
||||||
public PlayerResourcePackStatusEvent(Player player, EnumResourcePackStatus status) {
|
public PlayerResourcePackStatusEvent(Player player, EnumResourcePackStatus status) {
|
||||||
super(player);
|
super(player);
|
||||||
}
|
this.status = status;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumResourcePackStatus getStatus() {
|
public EnumResourcePackStatus getStatus() {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
package com.loohp.limbo.events.player;
|
package com.loohp.limbo.events.player;
|
||||||
|
|
||||||
import com.loohp.limbo.player.Player;
|
import com.loohp.limbo.player.Player;
|
||||||
import com.loohp.limbo.utils.NamespacedKey;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ public class ServerProperties {
|
||||||
prop.store(pw, COMMENT);
|
prop.store(pw, COMMENT);
|
||||||
pw.close();
|
pw.close();
|
||||||
|
|
||||||
protocol = Limbo.getInstance().serverImplementationProtocol;
|
protocol = Limbo.getInstance().SERVER_IMPLEMENTATION_PROTOCOL;
|
||||||
|
|
||||||
maxPlayers = Integer.parseInt(prop.getProperty("max-players"));
|
maxPlayers = Integer.parseInt(prop.getProperty("max-players"));
|
||||||
serverPort = Integer.parseInt(prop.getProperty("server-port"));
|
serverPort = Integer.parseInt(prop.getProperty("server-port"));
|
||||||
|
|
@ -186,7 +186,7 @@ public class ServerProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerImplementationVersion() {
|
public String getServerImplementationVersion() {
|
||||||
return Limbo.getInstance().serverImplementationVersion;
|
return Limbo.getInstance().SERVER_IMPLEMENTATION_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerModName() {
|
public String getServerModName() {
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public class Metrics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
limboVersion = Limbo.getInstance().limboImplementationVersion;
|
limboVersion = Limbo.getInstance().LIMBO_IMPLEMENTATION_VERSION;
|
||||||
|
|
||||||
// Load the data
|
// Load the data
|
||||||
serverUUID = config.get("serverUuid", String.class);
|
serverUUID = config.get("serverUuid", String.class);
|
||||||
|
|
@ -137,7 +137,7 @@ public class Metrics {
|
||||||
addCustomChart(new Metrics.SimplePie("minecraftVersion", new Callable<String>() {
|
addCustomChart(new Metrics.SimplePie("minecraftVersion", new Callable<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String call() throws Exception {
|
public String call() throws Exception {
|
||||||
return Limbo.getInstance().serverImplementationVersion;
|
return Limbo.getInstance().SERVER_IMPLEMENTATION_VERSION;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,10 @@ public class PacketPlayInPluginMessaging extends PacketIn {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketPlayInPluginMessaging(DataInputStream in, int packetLength, int packetId) throws IOException {
|
public PacketPlayInPluginMessaging(DataInputStream in, int packetLength, int packetId) throws IOException {
|
||||||
String channel = DataTypeIO.readString(in, StandardCharsets.UTF_8);
|
this.channel = DataTypeIO.readString(in, StandardCharsets.UTF_8);
|
||||||
int dataLength = packetLength - DataTypeIO.getVarIntLength(packetId) - DataTypeIO.getStringLength(channel, StandardCharsets.UTF_8);
|
int dataLength = packetLength - DataTypeIO.getVarIntLength(packetId) - DataTypeIO.getStringLength(channel, StandardCharsets.UTF_8);
|
||||||
data = new byte[dataLength];
|
this.data = new byte[dataLength];
|
||||||
in.readFully(data);
|
in.readFully(this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChannel() {
|
public String getChannel() {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ groups:
|
||||||
default:
|
default:
|
||||||
- limboserver.spawn
|
- limboserver.spawn
|
||||||
- limboserver.chat
|
- limboserver.chat
|
||||||
|
- limboserver.version
|
||||||
|
|
||||||
players:
|
players:
|
||||||
LOOHP:
|
LOOHP:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue