Added BungeeGuard support

This commit is contained in:
Nanit
2021-11-13 11:45:45 +02:00
parent ebd6baf7b5
commit 14fd8f094c
5 changed files with 73 additions and 1 deletions

View File

@@ -6,11 +6,13 @@ import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.serialize.TypeSerializer;
import java.nio.charset.StandardCharsets;
import java.util.List;
public class InfoForwarding {
private Type type;
private byte[] secretKey;
private List<String> tokens;
public Type getType() {
return type;
@@ -20,6 +22,14 @@ public class InfoForwarding {
return secretKey;
}
public List<String> getTokens() {
return tokens;
}
public boolean hasToken(String token) {
return tokens != null && token != null && tokens.contains(token);
}
public boolean isNone() {
return type == Type.NONE;
}
@@ -32,10 +42,15 @@ public class InfoForwarding {
return type == Type.MODERN;
}
public boolean isBungeeGuard() {
return type == Type.BUNGEE_GUARD;
}
public enum Type {
NONE,
LEGACY,
MODERN
MODERN,
BUNGEE_GUARD
}
public static class Serializer implements TypeSerializer<InfoForwarding> {
@@ -54,6 +69,10 @@ public class InfoForwarding {
forwarding.secretKey = node.node("secret").getString("").getBytes(StandardCharsets.UTF_8);
}
if (forwarding.type == Type.BUNGEE_GUARD) {
forwarding.tokens = node.node("tokens").getList(String.class);
}
return forwarding;
}