mirror of https://github.com/LOOHP/Limbo.git
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>
|
||||
<artifactId>Limbo</artifactId>
|
||||
<name>Limbo</name>
|
||||
<version>0.6.14-ALPHA</version>
|
||||
<version>0.6.15-ALPHA</version>
|
||||
|
||||
<description>Standalone Limbo Minecraft Server.</description>
|
||||
<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.tag.CompoundTag;
|
||||
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
public class Limbo {
|
||||
|
||||
public static final String LIMBO_BRAND = "Limbo";
|
||||
|
|
@ -110,12 +112,13 @@ public class Limbo {
|
|||
}
|
||||
if (!noGui) {
|
||||
System.out.println("Launching Server GUI.. Add \"--nogui\" in launch arguments to disable");
|
||||
Thread t1 = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GUI.main();
|
||||
}
|
||||
});
|
||||
Thread t1 = new Thread(() -> {
|
||||
try {
|
||||
GUI.main();
|
||||
} catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
t1.start();
|
||||
}
|
||||
|
||||
|
|
@ -128,9 +131,9 @@ public class Limbo {
|
|||
|
||||
//===========================
|
||||
|
||||
public final String serverImplementationVersion = "1.18.2";
|
||||
public final int serverImplementationProtocol = 758;
|
||||
public final String limboImplementationVersion;
|
||||
public final String SERVER_IMPLEMENTATION_VERSION = "1.18.2";
|
||||
public final int SERVER_IMPLEMENTATION_PROTOCOL = 758;
|
||||
public final String LIMBO_IMPLEMENTATION_VERSION;
|
||||
|
||||
private AtomicBoolean isRunning;
|
||||
|
||||
|
|
@ -176,8 +179,8 @@ public class Limbo {
|
|||
console = new Console(System.in, System.out, System.err);
|
||||
}
|
||||
|
||||
limboImplementationVersion = getLimboVersion();
|
||||
console.sendMessage("Loading Limbo Version " + limboImplementationVersion + " on Minecraft " + serverImplementationVersion);
|
||||
LIMBO_IMPLEMENTATION_VERSION = getLimboVersion();
|
||||
console.sendMessage("Loading Limbo Version " + LIMBO_IMPLEMENTATION_VERSION + " on Minecraft " + SERVER_IMPLEMENTATION_VERSION);
|
||||
|
||||
String spName = "server.properties";
|
||||
File sp = new File(spName);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,16 @@ public class DefaultCommands implements CommandExecutor, TabCompletor {
|
|||
if (args.length == 0) {
|
||||
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 (sender.hasPermission("limboserver.spawn")) {
|
||||
if (args.length == 1 && sender instanceof Player) {
|
||||
|
|
@ -78,12 +88,10 @@ public class DefaultCommands implements CommandExecutor, TabCompletor {
|
|||
if (args.length > 1) {
|
||||
Player player = Limbo.getInstance().getPlayer(args[1]);
|
||||
if (player != null) {
|
||||
if (args.length >= 2) {
|
||||
String reasonRaw = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
||||
if (reasonRaw.trim().length() > 0) {
|
||||
reason = LegacyComponentSerializer.legacySection().deserialize(reasonRaw);
|
||||
customReason = true;
|
||||
}
|
||||
String reasonRaw = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
||||
if (reasonRaw.trim().length() > 0) {
|
||||
reason = LegacyComponentSerializer.legacySection().deserialize(reasonRaw);
|
||||
customReason = true;
|
||||
}
|
||||
player.disconnect(reason);
|
||||
if (customReason) {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ import javax.swing.JPanel;
|
|||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.loohp.limbo.Limbo;
|
||||
|
|
@ -67,7 +69,8 @@ public class GUI extends JFrame {
|
|||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main() {
|
||||
public static void main() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
GUI frame = new GUI();
|
||||
frame.setVisible(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ public class SystemInfo {
|
|||
long allocatedMemory = runtime.totalMemory();
|
||||
long freeMemory = runtime.freeMemory();
|
||||
|
||||
sb.append("Free Memory: " + format.format(freeMemory / 1024 / 1024) + " MB\n");
|
||||
sb.append("Allocated Memory: " + format.format(allocatedMemory / 1024 / 1024) + " MB\n");
|
||||
sb.append("Max Memory: " + format.format(maxMemory / 1024 / 1024) + " 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("Free Memory: ").append(format.format(freeMemory / 1024 / 1024)).append(" MB\n");
|
||||
sb.append("Allocated Memory: ").append(format.format(allocatedMemory / 1024 / 1024)).append(" MB\n");
|
||||
sb.append("Max Memory: ").append(format.format(maxMemory / 1024 / 1024)).append(" MB\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");
|
||||
|
||||
try {
|
||||
|
|
@ -54,13 +54,16 @@ public class SystemInfo {
|
|||
double systemLoad = operatingSystemMXBean.getSystemCpuLoad();
|
||||
int processors = runtime.availableProcessors();
|
||||
|
||||
sb.append("Available Processors: " + processors + "\n");
|
||||
sb.append("Process CPU Load: " + Math.round(processLoad * 100) + "%\n");
|
||||
sb.append("System CPU Load: " + Math.round(systemLoad * 100) + "%\n");
|
||||
sb.append("Available Processors: ").append(processors).append("\n");
|
||||
sb.append("Process CPU Load: ").append(Math.round(processLoad * 100)).append("%\n");
|
||||
sb.append("System CPU Load: ").append(Math.round(systemLoad * 100)).append("%\n");
|
||||
GUI.sysText.setText(sb.toString());
|
||||
} catch (Exception ignore) {}
|
||||
|
||||
try {TimeUnit.MILLISECONDS.sleep(1000);} catch (InterruptedException e) {}
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,17 +23,12 @@ import com.loohp.limbo.network.protocol.packets.PacketPlayInResourcePackStatus.E
|
|||
import com.loohp.limbo.player.Player;
|
||||
|
||||
public class PlayerResourcePackStatusEvent extends PlayerEvent {
|
||||
|
||||
private Player player;
|
||||
|
||||
private EnumResourcePackStatus status;
|
||||
|
||||
public PlayerResourcePackStatusEvent(Player player, EnumResourcePackStatus status) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
super(player);
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public EnumResourcePackStatus getStatus() {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
package com.loohp.limbo.events.player;
|
||||
|
||||
import com.loohp.limbo.player.Player;
|
||||
import com.loohp.limbo.utils.NamespacedKey;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class ServerProperties {
|
|||
prop.store(pw, COMMENT);
|
||||
pw.close();
|
||||
|
||||
protocol = Limbo.getInstance().serverImplementationProtocol;
|
||||
protocol = Limbo.getInstance().SERVER_IMPLEMENTATION_PROTOCOL;
|
||||
|
||||
maxPlayers = Integer.parseInt(prop.getProperty("max-players"));
|
||||
serverPort = Integer.parseInt(prop.getProperty("server-port"));
|
||||
|
|
@ -186,7 +186,7 @@ public class ServerProperties {
|
|||
}
|
||||
|
||||
public String getServerImplementationVersion() {
|
||||
return Limbo.getInstance().serverImplementationVersion;
|
||||
return Limbo.getInstance().SERVER_IMPLEMENTATION_VERSION;
|
||||
}
|
||||
|
||||
public String getServerModName() {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class Metrics {
|
|||
}
|
||||
}
|
||||
|
||||
limboVersion = Limbo.getInstance().limboImplementationVersion;
|
||||
limboVersion = Limbo.getInstance().LIMBO_IMPLEMENTATION_VERSION;
|
||||
|
||||
// Load the data
|
||||
serverUUID = config.get("serverUuid", String.class);
|
||||
|
|
@ -137,7 +137,7 @@ public class Metrics {
|
|||
addCustomChart(new Metrics.SimplePie("minecraftVersion", new Callable<String>() {
|
||||
@Override
|
||||
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 {
|
||||
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);
|
||||
data = new byte[dataLength];
|
||||
in.readFully(data);
|
||||
this.data = new byte[dataLength];
|
||||
in.readFully(this.data);
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ groups:
|
|||
default:
|
||||
- limboserver.spawn
|
||||
- limboserver.chat
|
||||
- limboserver.version
|
||||
|
||||
players:
|
||||
LOOHP:
|
||||
|
|
|
|||
Loading…
Reference in New Issue