Always Show Option For Protocol Name Custom Motd

This commit is contained in:
LinsaFTW 2023-01-25 17:17:07 -03:00
parent 8e47ac2731
commit 3a5d644206
6 changed files with 45 additions and 39 deletions

View File

@ -1,4 +1,4 @@
From 6b240a4dfee02eb3762994affbce94c84c829a8f Mon Sep 17 00:00:00 2001
From 40db55725460874e6f2129bdbfa60478bba3fb69 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 7 Oct 2021 21:37:24 -0300
Subject: [PATCH] Custom motd system
@ -20,10 +20,10 @@ index 5589ce1b..1e928197 100644
return (boolean) setIfUnexistant(arg1, (Object) arg2, configuration);
}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index edecc1e5..b920cf63 100644
index edecc1e5..ab33e071 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -3,15 +3,92 @@ package dev._2lstudios.flamecord.configuration;
@@ -3,15 +3,94 @@ package dev._2lstudios.flamecord.configuration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@ -99,6 +99,8 @@ index edecc1e5..b920cf63 100644
+ private boolean protocolEnabled = false;
+ @Getter
+ private String protocolName = "&c&lMaintenance";
+ @Getter
+ private boolean protocolAlwaysShow = false;
+
+ @Getter
+ private boolean maxPlayersEnabled = false;
@ -116,7 +118,7 @@ index edecc1e5..b920cf63 100644
@Getter
private boolean loggerInitialhandler = false;
@Getter
@@ -36,6 +113,21 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -36,6 +115,22 @@ public class FlameCordConfiguration extends FlameConfig {
configuration = configurationProvider.load(configurationFile);
}
@ -128,6 +130,7 @@ index edecc1e5..b920cf63 100644
+ this.samples = ColorUtil.hexColor(new ArrayList<>(setIfUnexistant("custom-motd.sample.samples", this.samples, configuration)), 734);
+ this.protocolEnabled = setIfUnexistant("custom-motd.protocol.enabled", this.protocolEnabled, configuration);
+ this.protocolName = ColorUtil.hexColor(setIfUnexistant("custom-motd.protocol.name", this.protocolName, configuration), 735);
+ this.protocolAlwaysShow = setIfUnexistant("custom-motd.protocol.always-show", this.protocolAlwaysShow, configuration);
+ this.maxPlayersEnabled = setIfUnexistant("custom-motd.maxplayers.enabled", this.maxPlayersEnabled, configuration);
+ this.maxPlayersAmount = setIfUnexistant("custom-motd.maxplayers.amount", this.maxPlayersAmount, configuration);
+ this.maxPlayersOneMore = setIfUnexistant("custom-motd.maxplayers.justonemore", this.maxPlayersOneMore, configuration);
@ -605,7 +608,7 @@ index 00000000..0b039c79
+
+}
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index 66a34754..23b488d1 100644
index 66a34754..58be68b0 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -23,6 +23,8 @@ import javax.crypto.spec.SecretKeySpec;
@ -625,7 +628,7 @@ index 66a34754..23b488d1 100644
final int protocol = ( ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion();
Callback<ServerPing> pingBack = new Callback<ServerPing>()
@@ -338,7 +339,53 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -338,7 +339,56 @@ public class InitialHandler extends PacketHandler implements PendingConnection
( (BungeeServerInfo) forced ).ping( pingBack, handshake.getProtocolVersion() );
} else
{
@ -662,6 +665,8 @@ index 66a34754..23b488d1 100644
+ protocolName = bungee.getName() + " " + bungee.getGameVersion();
+ }
+
+ int customProtocol = config.isProtocolEnabled() && config.isProtocolAlwaysShow() ? -1 : protocol;
+
+ if (config.isSampleEnabled()) {
+ final UUID fakeUuid = new UUID(0, 0);
+ final String[] sampleString = config.getSample(maxPlayers, onlinePlayers, protocol);
@ -671,12 +676,13 @@ index 66a34754..23b488d1 100644
+ for (int i = 0; i < sampleString.length; i++) {
+ sample[i] = new ServerPing.PlayerInfo(sampleString[i], fakeUuid);
+ }
+ }
+ }
+
+ pingBack.done( new ServerPing(
+ new ServerPing.Protocol( protocolName, config.isProtocolEnabled() ? -1 : protocol ),
+ new ServerPing.Protocol( protocolName, customProtocol ),
+ new ServerPing.Players( maxPlayers, onlinePlayers, sample ),
+ motd, BungeeCord.getInstance().config.getFaviconObject() ), null );
+ // FlameCord end - Custom motd system
}
thisState = State.PING;

View File

@ -1,11 +1,11 @@
From 35bab2c97710ecdb12d8d46b216702b833dcfb12 Mon Sep 17 00:00:00 2001
From 6fbdfc541f535fb0b4d18d09f7fb7bd15f0c91d8 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 24 Feb 2022 23:41:57 -0300
Subject: [PATCH] TCP Fast Open
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index b920cf63..38e40429 100644
index ab33e071..9a3c78e2 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -16,6 +16,10 @@ import net.md_5.bungee.config.Configuration;
@ -19,7 +19,7 @@ index b920cf63..38e40429 100644
public String getMOTD(int maxPlayers, int onlinePlayers, int protocol) {
String motd;
@@ -127,6 +131,7 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -130,6 +134,7 @@ public class FlameCordConfiguration extends FlameConfig {
this.fakePlayersEnabled = setIfUnexistant("custom-motd.fakeplayers.enabled", this.fakePlayersEnabled, configuration);
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);

View File

@ -1,4 +1,4 @@
From 495e5daadc5dd7bb0a10540acea0a721e233aa0d Mon Sep 17 00:00:00 2001
From 59fcde54dc18fe434a0782545337603cf6c9305d Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 4 Mar 2022 13:35:53 -0300
Subject: [PATCH] Antibot System
@ -1267,7 +1267,7 @@ index 00000000..44d773ab
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index 38e40429..49f831cc 100644
index 9a3c78e2..8acfb6eb 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -16,6 +16,184 @@ import net.md_5.bungee.config.Configuration;
@ -1455,7 +1455,7 @@ index 38e40429..49f831cc 100644
// FlameCord - TCP Fast Open
@Getter
private int tcpFastOpen = 3;
@@ -131,6 +309,7 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -134,6 +312,7 @@ public class FlameCordConfiguration extends FlameConfig {
this.fakePlayersEnabled = setIfUnexistant("custom-motd.fakeplayers.enabled", this.fakePlayersEnabled, configuration);
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);
@ -1463,7 +1463,7 @@ index 38e40429..49f831cc 100644
this.tcpFastOpen = setIfUnexistant("tcp-fast-open", this.tcpFastOpen, configuration);
this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration);
@@ -139,6 +318,9 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -142,6 +321,9 @@ public class FlameCordConfiguration extends FlameConfig {
this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration);
this.loggerDetailedConnection = setIfUnexistant("logger.detailed-connect-errors", this.loggerDetailedConnection, configuration);
@ -1716,7 +1716,7 @@ index 8d56997e..d892c23c 100644
// Need to close loggers after last message!
org.apache.logging.log4j.LogManager.shutdown(); // Waterfall
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index 23b488d1..e41e94e4 100644
index 58be68b0..b88e6452 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -22,8 +22,8 @@ import javax.crypto.SecretKey;
@ -1730,7 +1730,7 @@ index 23b488d1..e41e94e4 100644
import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -409,6 +409,22 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -412,6 +412,22 @@ public class InitialHandler extends PacketHandler implements PendingConnection
public void handle(Handshake handshake) throws Exception
{
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
@ -1753,7 +1753,7 @@ index 23b488d1..e41e94e4 100644
this.handshake = handshake;
ch.setVersion( handshake.getProtocolVersion() );
ch.getHandle().pipeline().remove( PipelineUtils.LEGACY_KICKER );
@@ -439,6 +455,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -442,6 +458,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
return;
}
@ -1765,7 +1765,7 @@ index 23b488d1..e41e94e4 100644
switch ( handshake.getRequestedProtocol() )
{
case 1:
@@ -450,6 +471,17 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -453,6 +474,17 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
thisState = State.STATUS;
ch.setProtocol( Protocol.STATUS );
@ -1783,7 +1783,7 @@ index 23b488d1..e41e94e4 100644
break;
case 2:
// Login
@@ -461,6 +493,16 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -464,6 +496,16 @@ public class InitialHandler extends PacketHandler implements PendingConnection
thisState = State.USERNAME;
ch.setProtocol( Protocol.LOGIN );
@ -1800,7 +1800,7 @@ index 23b488d1..e41e94e4 100644
if ( !ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) )
{
if ( handshake.getProtocolVersion() > bungee.getProtocolVersion() )
@@ -524,6 +566,38 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -527,6 +569,38 @@ public class InitialHandler extends PacketHandler implements PendingConnection
return;
}

View File

@ -1,11 +1,11 @@
From ef413893bd49dbd42542cd7aeeaa5426d99cbf86 Mon Sep 17 00:00:00 2001
From 80933081e2983627c9f8488cf034316c1571f512 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 4 Mar 2022 14:09:35 -0300
Subject: [PATCH] Allow Invalid Names
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index 49f831cc..b76adb32 100644
index 8acfb6eb..05f7da1d 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -16,6 +16,10 @@ import net.md_5.bungee.config.Configuration;
@ -19,7 +19,7 @@ index 49f831cc..b76adb32 100644
// Antibot accounts
@Getter
private boolean antibotAccountsEnabled = true;
@@ -318,6 +322,9 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -321,6 +325,9 @@ public class FlameCordConfiguration extends FlameConfig {
this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration);
this.loggerDetailedConnection = setIfUnexistant("logger.detailed-connect-errors", this.loggerDetailedConnection, configuration);
@ -30,10 +30,10 @@ index 49f831cc..b76adb32 100644
loadAntibot(configuration, whitelistedAddresses);
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index e41e94e4..e478ab9e 100644
index b88e6452..e8c14c55 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -525,7 +525,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -528,7 +528,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" );

View File

@ -1,4 +1,4 @@
From 90ffabd55d91789d1b92d98c7f19fc01ac4141c3 Mon Sep 17 00:00:00 2001
From ab1e5d100f2d678f1471fa83226dc9a5af2d370b Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Tue, 10 Jan 2023 16:37:13 -0300
Subject: [PATCH] Dont Process Links For Kick Messages
@ -117,10 +117,10 @@ index 4371374a..2bb27e67 100644
* The text of the component that will be displayed to the client
*/
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index d485dff0..7efed17f 100644
index e8c14c55..6d0719a0 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -830,7 +830,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -833,7 +833,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
if ( canSendKickMessage() )
{

View File

@ -1,11 +1,11 @@
From d5ab702a2db2b7c1b0868f5c4a4cd37514420e28 Mon Sep 17 00:00:00 2001
From 477817bdc183b430c925b7b3841e5b51ac632852 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Sun, 22 Jan 2023 09:41:36 -0300
Subject: [PATCH] InitialHandler Processing State
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index 7efed17f..a2a11e81 100644
index 6d0719a0..8beed72f 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -135,6 +135,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@ -30,7 +30,7 @@ index 7efed17f..a2a11e81 100644
ServerInfo forced = AbstractReconnectHandler.getForcedHost( this );
final int protocol = ( ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion();
@@ -389,6 +397,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -392,6 +400,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
thisState = State.PING;
@ -40,7 +40,7 @@ index 7efed17f..a2a11e81 100644
}
private static final boolean ACCEPT_INVALID_PACKETS = Boolean.parseBoolean(System.getProperty("waterfall.acceptInvalidPackets", "false"));
@@ -398,6 +409,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -401,6 +412,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
// FlameCord - Never accept invalid packets
Preconditions.checkState( thisState == State.PING, "Not expecting PING" );
@ -51,7 +51,7 @@ index 7efed17f..a2a11e81 100644
unsafe.sendPacket( ping );
@@ -409,7 +424,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -412,7 +427,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
public void handle(Handshake handshake) throws Exception
{
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
@ -64,7 +64,7 @@ index 7efed17f..a2a11e81 100644
// FlameCord start - Antibot System
// Close and firewall on invalid protocol
int protocol = handshake.getRequestedProtocol();
@@ -482,6 +501,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -485,6 +504,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
// FlameCord end - Antibot System
@ -75,7 +75,7 @@ index 7efed17f..a2a11e81 100644
break;
case 2:
// Login
@@ -514,6 +537,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -517,6 +540,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
return;
}
@ -87,7 +87,7 @@ index 7efed17f..a2a11e81 100644
break;
default:
throw new QuietException( "Cannot request protocol " + handshake.getRequestedProtocol() );
@@ -524,6 +552,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -527,6 +555,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
public void handle(LoginRequest loginRequest) throws Exception
{
Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" );
@ -98,7 +98,7 @@ index 7efed17f..a2a11e81 100644
if ( !FlameCord.getInstance().getFlameCordConfiguration().isAllowInvalidNames() && !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) )
{
@@ -631,6 +663,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -634,6 +666,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
thisState = State.FINISHING;
finish();
}
@ -108,7 +108,7 @@ index 7efed17f..a2a11e81 100644
}
};
@@ -644,6 +679,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@@ -647,6 +682,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
Preconditions.checkState( thisState == State.ENCRYPT, "Not expecting ENCRYPT" );
Preconditions.checkState( EncryptionUtil.check( loginRequest.getPublicKey(), encryptResponse, request ), "Invalid verification" );
thisState = State.FINISHING; // Waterfall - move earlier - There is no verification of this later (and this is not API)