forked from BLOCKFANTASY/LOOHP-Limbo
Added new Server Properties and cleaned up Login Plugin Packets
- Added option for Modern Forwarding and BungeeGuard (for proxies that are connected to older servers) - Made Modern, Bungeecord and Bungeeguard mutually exclusive - Fixed PacketLoginInPluginMessaging, structure was incorrect - Added `readUUID` in DataTypeIO
This commit is contained in:
parent
7be0b5f9da
commit
c7378beb2b
|
|
@ -1,26 +1,19 @@
|
|||
package com.loohp.limbo.file;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.loohp.limbo.Limbo;
|
||||
import com.loohp.limbo.location.Location;
|
||||
import com.loohp.limbo.utils.GameMode;
|
||||
import com.loohp.limbo.utils.NamespacedKey;
|
||||
import com.loohp.limbo.world.World;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ServerProperties {
|
||||
|
||||
public static final String COMMENT = "For explaination of what each of the options does, please visit:\nhttps://github.com/LOOHP/Limbo/blob/master/src/main/resources/server.properties";
|
||||
|
|
@ -40,6 +33,9 @@ public class ServerProperties {
|
|||
private String versionString;
|
||||
private int protocol;
|
||||
private boolean bungeecord;
|
||||
private boolean velocityModern;
|
||||
private boolean bungeeGuard;
|
||||
private String[] forwardingSecrets;
|
||||
private int viewDistance;
|
||||
private double ticksPerSecond;
|
||||
private boolean handshakeVerbose;
|
||||
|
|
@ -91,6 +87,27 @@ public class ServerProperties {
|
|||
motdJson = prop.getProperty("motd");
|
||||
versionString = prop.getProperty("version");
|
||||
bungeecord = Boolean.parseBoolean(prop.getProperty("bungeecord"));
|
||||
velocityModern = Boolean.parseBoolean(prop.getProperty("velocity-modern"));
|
||||
bungeeGuard = Boolean.parseBoolean(prop.getProperty("bungee-guard"));
|
||||
if (velocityModern || bungeeGuard) {
|
||||
String forwardingSecretsStr = prop.getProperty("forwarding-secrets");
|
||||
if (forwardingSecretsStr == null || forwardingSecretsStr.equals("")) {
|
||||
Limbo.getInstance().getConsole().sendMessage("Velocity Modern Forwarding or BungeeGuard is enabled but no forwarding-secret was found!");
|
||||
Limbo.getInstance().getConsole().sendMessage("Server will exit!");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
this.forwardingSecrets = forwardingSecretsStr.split(";");
|
||||
if (bungeecord) {
|
||||
Limbo.getInstance().getConsole().sendMessage("BungeeCord is enabled but so is Velocity Modern Forwarding or BungeeGuard, We will automatically disable BungeeCord forwarding because of this");
|
||||
bungeecord = false;
|
||||
}
|
||||
if (velocityModern && bungeeGuard) {
|
||||
Limbo.getInstance().getConsole().sendMessage("Both Velocity Modern Forwarding and BungeeGuard are enabled! Because of this we always prefer Modern Forwarding, disabling BungeeGuard");
|
||||
bungeeGuard = false;
|
||||
}
|
||||
}
|
||||
|
||||
viewDistance = Integer.parseInt(prop.getProperty("view-distance"));
|
||||
ticksPerSecond = Double.parseDouble(prop.getProperty("ticks-per-second"));
|
||||
handshakeVerbose = Boolean.parseBoolean(prop.getProperty("handshake-verbose"));
|
||||
|
|
@ -123,6 +140,18 @@ public class ServerProperties {
|
|||
return bungeecord;
|
||||
}
|
||||
|
||||
public boolean isVelocityModern() {
|
||||
return velocityModern;
|
||||
}
|
||||
|
||||
public boolean isBungeeGuard() {
|
||||
return bungeeGuard;
|
||||
}
|
||||
|
||||
public String[] getForwardingSecrets() {
|
||||
return forwardingSecrets;
|
||||
}
|
||||
|
||||
public Optional<BufferedImage> getFavicon() {
|
||||
return favicon;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
package com.loohp.limbo.server.packets;
|
||||
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.utils.NamespacedKey;
|
||||
|
||||
public class PacketLoginInPluginMessaging extends PacketIn {
|
||||
|
||||
private int messageId;
|
||||
private NamespacedKey channel;
|
||||
private byte[] data;
|
||||
private boolean successful;
|
||||
private byte[] data = null;
|
||||
|
||||
public PacketLoginInPluginMessaging(int messageId, NamespacedKey channel, byte[] data) {
|
||||
public PacketLoginInPluginMessaging(int messageId, boolean successful, byte[] data) {
|
||||
this.messageId = messageId;
|
||||
this.channel = channel;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public PacketLoginInPluginMessaging(DataInputStream in, int packetLength, int packetId) throws IOException {
|
||||
messageId = DataTypeIO.readVarInt(in);
|
||||
String rawChannel = DataTypeIO.readString(in, StandardCharsets.UTF_8);
|
||||
channel = new NamespacedKey(rawChannel);
|
||||
int dataLength = packetLength - DataTypeIO.getVarIntLength(packetId) - DataTypeIO.getVarIntLength(messageId) - DataTypeIO.getStringLength(rawChannel, StandardCharsets.UTF_8);
|
||||
data = new byte[dataLength];
|
||||
in.read(data);
|
||||
successful = in.readBoolean();
|
||||
if (successful) {
|
||||
int dataLength = packetLength - DataTypeIO.getVarIntLength(packetId) - DataTypeIO.getVarIntLength(messageId) - 1;
|
||||
if (dataLength != 0) {
|
||||
data = new byte[dataLength];
|
||||
in.readFully(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public NamespacedKey getChannel() {
|
||||
return channel;
|
||||
public boolean isSuccessful() {
|
||||
return successful;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
package com.loohp.limbo.server.packets;
|
||||
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.utils.NamespacedKey;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.utils.NamespacedKey;
|
||||
|
||||
public class PacketLoginOutPluginMessaging extends PacketOut {
|
||||
|
||||
private int messageId;
|
||||
private NamespacedKey channel;
|
||||
private byte[] data;
|
||||
|
||||
public PacketLoginOutPluginMessaging(int messageId, NamespacedKey channel) {
|
||||
this(messageId, channel, null);
|
||||
}
|
||||
|
||||
public PacketLoginOutPluginMessaging(int messageId, NamespacedKey channel, byte[] data) {
|
||||
this.messageId = messageId;
|
||||
this.channel = channel;
|
||||
|
|
@ -40,7 +44,9 @@ public class PacketLoginOutPluginMessaging extends PacketOut {
|
|||
output.writeByte(Packet.getLoginOut().get(getClass()));
|
||||
DataTypeIO.writeVarInt(output, messageId);
|
||||
DataTypeIO.writeString(output, channel.toString(), StandardCharsets.UTF_8);
|
||||
output.write(data);
|
||||
if (data != null) {
|
||||
output.write(data);
|
||||
}
|
||||
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public class DataTypeIO {
|
|||
out.writeLong(uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
public static UUID readUUID(DataInputStream in) throws IOException {
|
||||
return new UUID(in.readLong(), in.readLong());
|
||||
}
|
||||
|
||||
public static void writeCompoundTag(DataOutputStream out, CompoundTag tag) throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
"LoginOut": {
|
||||
"PacketLoginOutLoginSuccess": "0x02",
|
||||
"PacketLoginOutDisconnect": "0x00",
|
||||
"PacketLoginOutPluginMessaging": "0x04",
|
||||
"PacketLoginOutPluginMessaging": "0x04"
|
||||
},
|
||||
"PlayIn": {
|
||||
"0x0F": "PacketPlayInKeepAlive",
|
||||
|
|
|
|||
|
|
@ -7,9 +7,21 @@ server-port=30000
|
|||
#Server ip, localhost for local access only
|
||||
server-ip=0.0.0.0
|
||||
|
||||
#Whether this is server is behind a bungeecord proxy
|
||||
#Whether this server is behind a bungeecord proxy
|
||||
#Mutually exclusive with velocity-modern and bungee-guard
|
||||
bungeecord=false
|
||||
|
||||
#Whether this server is behind a velocity proxy with modern player forwarding
|
||||
#Mutually exclusive with bungeecord and bungee-guard
|
||||
velocity-modern=false
|
||||
|
||||
#Whether this server is behind a bungeecord proxy with BungeeGuard installed (velocity can do this too for <1.13)
|
||||
#Mutually exclusive with bungeecord and velocity-modern
|
||||
bungee-guard=false
|
||||
|
||||
#For Velocity Modern Forwarding or BungeeGuard a list (separated by `;`) of valid secrets
|
||||
forwarding-secrets=
|
||||
|
||||
#World Name and the Schematic file containing map
|
||||
level-name=world;spawn.schem
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue