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:
GrizzlT
2021-08-17 11:19:14 +02:00
parent 7be0b5f9da
commit c7378beb2b
6 changed files with 87 additions and 36 deletions
@@ -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;
}