Make compilable again

This commit is contained in:
LinsaFTW 2023-02-23 17:51:32 -03:00
parent d387b6fb3f
commit 4bb4066ad4
42 changed files with 12990 additions and 5 deletions

6
.gitignore vendored
View File

@ -8,8 +8,4 @@ FlameCord-Proxy
out/
.project
.settings
pom.xml
Waterfall-Proxy-Patches
.settings

View File

@ -0,0 +1,146 @@
From 01758bf18170f703930757151d86c9440e8793da Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 17:59:15 +0800
Subject: [PATCH] FlameCord POM Changes
diff --git a/flamecord/pom.xml b/flamecord/pom.xml
new file mode 100644
index 00000000..20edd900
--- /dev/null
+++ b/flamecord/pom.xml
@@ -0,0 +1,44 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>io.github.waterfallmc</groupId>
+ <artifactId>waterfall-parent</artifactId>
+ <version>1.19-R0.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>dev._2lstudios</groupId>
+ <artifactId>waterfall-flamecord</artifactId>
+ <version>1.19-R0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Waterfall-FlameCord</name>
+ <description>FlameCord adds security essentials and new configuration options</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.github.waterfallmc</groupId>
+ <artifactId>waterfall-config</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.github.waterfallmc</groupId>
+ <artifactId>waterfall-chat</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${project.name}</finalName>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>${basedir}/src/main/resources</directory>
+ </resource>
+ </resources>
+ </build>
+</project>
diff --git a/pom.xml b/pom.xml
index 2b544c23..d940b21c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,6 +63,7 @@
<module>query</module>
<!--<module>slf4j</module>-->
<module>native</module>
+ <module>flamecord</module> <!-- FlameCord - POM Changes -->
</modules>
<scm>
diff --git a/protocol/pom.xml b/protocol/pom.xml
index 93ae5952..d6222d16 100644
--- a/protocol/pom.xml
+++ b/protocol/pom.xml
@@ -64,5 +64,14 @@
<version>1.3.0</version>
<scope>compile</scope>
</dependency>
+
+ <!-- FlameCord start - Add our dependencies -->
+ <dependency>
+ <groupId>dev._2lstudios</groupId>
+ <artifactId>waterfall-flamecord</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- FlameCord end -->
</dependencies>
</project>
diff --git a/proxy/pom.xml b/proxy/pom.xml
index 1036a2e7..10fe411d 100644
--- a/proxy/pom.xml
+++ b/proxy/pom.xml
@@ -157,6 +157,51 @@
<scope>runtime</scope>
</dependency>
<!-- Waterfall end -->
+
+ <!-- FlameCord start - Add our dependencies -->
+ <dependency>
+ <groupId>dev._2lstudios</groupId>
+ <artifactId>waterfall-flamecord</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.github.waterfallmc</groupId>
+ <artifactId>waterfall-module-cmd-alert</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.github.waterfallmc</groupId>
+ <artifactId>waterfall-module-cmd-find</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.github.waterfallmc</groupId>
+ <artifactId>waterfall-module-cmd-list</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.github.waterfallmc</groupId>
+ <artifactId>waterfall-module-cmd-send</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.github.waterfallmc</groupId>
+ <artifactId>waterfall-module-cmd-server</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.md-5</groupId>
+ <artifactId>bungeecord-module-reconnect-yaml</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- FlameCord end -->
</dependencies>
<!-- Waterfall start - copy license files into jar -->
--
2.37.0.windows.1

View File

@ -0,0 +1,122 @@
From 5b40e2e22fb37fb5aa2b34d3a6b14bd91e7e72fa Mon Sep 17 00:00:00 2001
From: Techcable <Techcable@techcable.net>
Date: Mon, 6 Jun 2016 13:47:46 -0600
Subject: [PATCH] Rename references from Waterfall to FlameCord
diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml
index 688f1b995..b0b0d33eb 100644
--- a/bootstrap/pom.xml
+++ b/bootstrap/pom.xml
@@ -37,7 +37,7 @@
</dependencies>
<build>
- <finalName>Waterfall</finalName>
+ <finalName>FlameCord</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/bootstrap/src/main/java/net/md_5/bungee/Bootstrap.java b/bootstrap/src/main/java/net/md_5/bungee/Bootstrap.java
index a4516ed96..9838f5c55 100644
--- a/bootstrap/src/main/java/net/md_5/bungee/Bootstrap.java
+++ b/bootstrap/src/main/java/net/md_5/bungee/Bootstrap.java
@@ -7,7 +7,7 @@ public class Bootstrap
{
if ( Float.parseFloat( System.getProperty( "java.class.version" ) ) < 52.0 )
{
- System.err.println( "*** ERROR *** Waterfall requires Java 8 or above to function! Please download and install it!" );
+ System.err.println( "*** ERROR *** FlameCord requires Java 8 or above to function! Please download and install it!" );
System.out.println( "You can check your Java version with the command: java -version" );
return;
}
diff --git a/log/src/main/java/net/md_5/bungee/log/LogDispatcher.java b/log/src/main/java/net/md_5/bungee/log/LogDispatcher.java
index d703d6d24..49dce84ba 100644
--- a/log/src/main/java/net/md_5/bungee/log/LogDispatcher.java
+++ b/log/src/main/java/net/md_5/bungee/log/LogDispatcher.java
@@ -12,7 +12,7 @@ public class LogDispatcher extends Thread
public LogDispatcher(BungeeLogger logger)
{
- super( "Waterfall Logger Thread" );
+ super( "FlameCord Logger Thread" );
this.logger = logger;
}
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index e0fcd8fbe..8617cdc7a 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -189,7 +189,7 @@ public class BungeeCord extends ProxyServer
public BungeeCord() throws IOException
{
// Java uses ! to indicate a resource inside of a jar/zip/other container. Running Bungee from within a directory that has a ! will cause this to muck up.
- Preconditions.checkState( new File( "." ).getAbsolutePath().indexOf( '!' ) == -1, "Cannot use Waterfall in directory with ! in path." );
+ Preconditions.checkState( new File( "." ).getAbsolutePath().indexOf( '!' ) == -1, "Cannot use FlameCord in directory with ! in path." );
reloadMessages();
@@ -545,7 +545,7 @@ public class BungeeCord extends ProxyServer
@Override
public String getName()
{
- return "Waterfall";
+ return "FlameCord";
}
@Override
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCordLauncher.java b/proxy/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
index 96a9998d1..463bc3d53 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
@@ -63,7 +63,7 @@ public class BungeeCordLauncher
BungeeCord bungee = new BungeeCord();
ProxyServer.setInstance( bungee );
- bungee.getLogger().info( "Enabled Waterfall version " + bungee.getVersion() );
+ bungee.getLogger().info( "Enabled FlameCord version " + bungee.getVersion() );
bungee.start();
if ( !options.has( "noconsole" ) )
diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandBungee.java b/proxy/src/main/java/net/md_5/bungee/command/CommandBungee.java
index b26035cf9..820f7b03c 100644
--- a/proxy/src/main/java/net/md_5/bungee/command/CommandBungee.java
+++ b/proxy/src/main/java/net/md_5/bungee/command/CommandBungee.java
@@ -16,6 +16,6 @@ public class CommandBungee extends Command
@Override
public void execute(CommandSender sender, String[] args)
{
- sender.sendMessage( ChatColor.BLUE + "This server is running Waterfall version " + ProxyServer.getInstance().getVersion() + " by md_5" );
+ sender.sendMessage( ChatColor.BLUE + "This server is running FlameCord version " + ProxyServer.getInstance().getVersion() + " by md_5" );
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandReload.java b/proxy/src/main/java/net/md_5/bungee/command/CommandReload.java
index 720d0c3b5..5ab4db189 100644
--- a/proxy/src/main/java/net/md_5/bungee/command/CommandReload.java
+++ b/proxy/src/main/java/net/md_5/bungee/command/CommandReload.java
@@ -23,7 +23,7 @@ public class CommandReload extends Command
BungeeCord.getInstance().startListeners();
BungeeCord.getInstance().getPluginManager().callEvent( new ProxyReloadEvent( sender ) );
- sender.sendMessage( ChatColor.BOLD.toString() + ChatColor.RED.toString() + "Waterfall has been reloaded."
- + " This is NOT advisable and you will not be supported with any issues that arise! Please restart Waterfall ASAP." );
+ sender.sendMessage( ChatColor.BOLD.toString() + ChatColor.RED.toString() + "FlameCord has been reloaded."
+ + " This is NOT advisable and you will not be supported with any issues that arise! Please restart FlameCord ASAP." );
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java b/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java
index 0dd69778b..9abae0b61 100644
--- a/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java
+++ b/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java
@@ -227,7 +227,7 @@ public class YamlConfig implements ConfigurationAdapter
Map<String, Object> val = entry.getValue();
String name = entry.getKey();
String addr = get( "address", "localhost:25565", val );
- String motd = ChatColor.translateAlternateColorCodes( '&', get( "motd", "&1Just another Waterfall - Forced Host", val ) );
+ String motd = ChatColor.translateAlternateColorCodes( '&', get( "motd", "&1Just another FlameCord - Forced Host", val ) );
boolean restricted = get( "restricted", false, val );
SocketAddress address = Util.getAddr( addr );
ServerInfo info = ProxyServer.getInstance().constructServerInfo( name, address, motd, restricted );
--
2.37.3.windows.1

View File

@ -0,0 +1,63 @@
From 84cae2e73501b000c7f15d260d4ec736d7025ea3 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Tue, 8 Jun 2021 22:24:27 -0300
Subject: [PATCH] FlameCord rebrand
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
index da0efa36f..966d2442b 100644
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
@@ -68,7 +68,8 @@ public class WaterfallConfiguration extends Configuration {
YamlConfig config = new YamlConfig(new File("waterfall.yml"));
config.load(false); // Load, but no permissions
logInitialHandlerConnections = config.getBoolean( "log_initial_handler_connections", logInitialHandlerConnections );
- gameVersion = config.getString("game_version", "").isEmpty() ? Joiner.on(", ").join(ProtocolConstants.SUPPORTED_VERSIONS) : config.getString("game_version", "");
+ // FlameCord - Make the version look better
+ gameVersion = config.getString("game_version", "").isEmpty() ? ProtocolConstants.SUPPORTED_VERSIONS.get(0) + "-" + ProtocolConstants.SUPPORTED_VERSIONS.get(ProtocolConstants.SUPPORTED_VERSIONS.size() - 1) : config.getString("game_version", "");
useNettyDnsResolver = config.getBoolean("use_netty_dns_resolver", useNettyDnsResolver);
// Throttling options
tabThrottle = config.getInt("throttling.tab_complete", tabThrottle);
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index 8617cdc7a..0ed479c8d 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -551,7 +551,7 @@ public class BungeeCord extends ProxyServer
@Override
public String getVersion()
{
- return ( BungeeCord.class.getPackage().getImplementationVersion() == null ) ? "unknown" : BungeeCord.class.getPackage().getImplementationVersion();
+ return "1.3.6";
}
public final void reloadMessages()
diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandBungee.java b/proxy/src/main/java/net/md_5/bungee/command/CommandBungee.java
index 820f7b03c..aeda79639 100644
--- a/proxy/src/main/java/net/md_5/bungee/command/CommandBungee.java
+++ b/proxy/src/main/java/net/md_5/bungee/command/CommandBungee.java
@@ -16,6 +16,7 @@ public class CommandBungee extends Command
@Override
public void execute(CommandSender sender, String[] args)
{
- sender.sendMessage( ChatColor.BLUE + "This server is running FlameCord version " + ProxyServer.getInstance().getVersion() + " by md_5" );
+ // FlameCord - Use custom version message
+ sender.sendMessage( ChatColor.translateAlternateColorCodes( '&', "&eThis server is running &c" + ProxyServer.getInstance().getName() + "&e version &a" + ProxyServer.getInstance().getVersion() + "&e by &bLinsaFTW & Sammwy&e." ) );
}
}
diff --git a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java b/query/src/main/java/net/md_5/bungee/query/QueryHandler.java
index 0c1ecfb8e..b2b199969 100644
--- a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java
+++ b/query/src/main/java/net/md_5/bungee/query/QueryHandler.java
@@ -103,7 +103,8 @@ public class QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
// Waterfall start
List<String> players = bungee.getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList());
- ProxyQueryEvent event = new ProxyQueryEvent(listener, new QueryResult(listener.getMotd(), "SMP", "Waterfall_Proxy",
+ // FlameCord - Rebrand
+ ProxyQueryEvent event = new ProxyQueryEvent(listener, new QueryResult(listener.getMotd(), "SMP", "FlameCord_Proxy",
bungee.getOnlineCount(), listener.getMaxPlayers(), listener.getHost().getPort(),
listener.getHost().getHostString(), "MINECRAFT", players, bungee.getGameVersion()));
QueryResult result = bungee.getPluginManager().callEvent(event).getResult();
--
2.37.3.windows.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,56 @@
From 2a6878cb7a8c16bb76b79012db51d81f112636c9 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 17:57:23 +0800
Subject: [PATCH] Make PlayerHandshakeEvent cancellable
diff --git a/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java b/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java
index 2f7b38d9e..e29b0ed35 100644
--- a/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java
+++ b/api/src/main/java/net/md_5/bungee/api/event/PlayerHandshakeEvent.java
@@ -2,8 +2,11 @@ package net.md_5.bungee.api.event;
import lombok.Data;
import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
import lombok.ToString;
import net.md_5.bungee.api.connection.PendingConnection;
+import net.md_5.bungee.api.plugin.Cancellable;
import net.md_5.bungee.api.plugin.Event;
import net.md_5.bungee.protocol.packet.Handshake;
@@ -14,8 +17,11 @@ import net.md_5.bungee.protocol.packet.Handshake;
@Data
@ToString(callSuper = false)
@EqualsAndHashCode(callSuper = false)
-public class PlayerHandshakeEvent extends Event
-{
+// FlameCord - Implement cancellable
+public class PlayerHandshakeEvent extends Event implements Cancellable {
+ @Getter
+ @Setter
+ private boolean cancelled = false;
/**
* Connection attempting to login.
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 de417ecae..c3543a18d 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
@@ -362,7 +362,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
this.virtualHost = InetSocketAddress.createUnresolved( handshake.getHost(), handshake.getPort() );
- bungee.getPluginManager().callEvent( new PlayerHandshakeEvent( InitialHandler.this, handshake ) );
+ // FlameCord - Make PlayerHandshakeEvent cancellable
+ if (bungee.getPluginManager().callEvent(new PlayerHandshakeEvent(InitialHandler.this, handshake)).isCancelled()) {
+ ch.close();
+ return;
+ }
switch ( handshake.getRequestedProtocol() )
{
--
2.37.3.windows.1

View File

@ -0,0 +1,23 @@
From c44b23dcab5a544424e6835060638e1bbf053ae2 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 17:58:18 +0800
Subject: [PATCH] Make a getter for the callback
diff --git a/api/src/main/java/net/md_5/bungee/api/event/AsyncEvent.java b/api/src/main/java/net/md_5/bungee/api/event/AsyncEvent.java
index cf85ca06..8a945a99 100644
--- a/api/src/main/java/net/md_5/bungee/api/event/AsyncEvent.java
+++ b/api/src/main/java/net/md_5/bungee/api/event/AsyncEvent.java
@@ -25,7 +25,8 @@ import net.md_5.bungee.api.plugin.Plugin;
@EqualsAndHashCode(callSuper = true)
public class AsyncEvent<T> extends Event
{
-
+ // FlameCord - Make a getter for the callback
+ @Getter
private final Callback<T> done;
private final Map<Plugin, AtomicInteger> intents = new ConcurrentHashMap<>();
private final AtomicBoolean fired = new AtomicBoolean();
--
2.32.0

View File

@ -0,0 +1,73 @@
From 2edaf016d49ec4c769eebaf7383f3a7e6dccc19c Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:00:49 +0800
Subject: [PATCH] Disable update checker & Use bungee name
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCordLauncher.java b/proxy/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
index 463bc3d53..00243fdb9 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
@@ -45,25 +45,10 @@ public class BungeeCordLauncher
return;
}
- if ( BungeeCord.class.getPackage().getSpecificationVersion() != null && System.getProperty( "IReallyKnowWhatIAmDoingISwear" ) == null )
- {
- Date buildDate = new SimpleDateFormat( "yyyyMMdd" ).parse( BungeeCord.class.getPackage().getSpecificationVersion() );
-
- Calendar deadline = Calendar.getInstance();
- deadline.add( Calendar.WEEK_OF_YEAR, -8 );
- if ( buildDate.before( deadline.getTime() ) )
- {
- System.err.println( "*** Hey! This build is potentially outdated :( ***" );
- System.err.println( "*** Please check for a new build from https://papermc.io/downloads ***" );
- System.err.println( "*** Should this build be outdated, you will get NO support for it. ***" );
- //System.err.println( "*** Server will start in 10 seconds ***" );
- //Thread.sleep( TimeUnit.SECONDS.toMillis( 10 ) );
- }
- }
-
BungeeCord bungee = new BungeeCord();
ProxyServer.setInstance( bungee );
- bungee.getLogger().info( "Enabled FlameCord version " + bungee.getVersion() );
+ // FlameCord - Use BungeeCord name
+ bungee.getLogger().info( "Enabled " + bungee.getName() + " version " + bungee.getVersion() );
bungee.start();
if ( !options.has( "noconsole" ) )
diff --git a/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java b/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java
index 9abae0b61..e8232c0bd 100644
--- a/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java
+++ b/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java
@@ -22,6 +22,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import lombok.RequiredArgsConstructor;
+import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.Util;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ProxyServer;
@@ -227,7 +228,8 @@ public class YamlConfig implements ConfigurationAdapter
Map<String, Object> val = entry.getValue();
String name = entry.getKey();
String addr = get( "address", "localhost:25565", val );
- String motd = ChatColor.translateAlternateColorCodes( '&', get( "motd", "&1Just another FlameCord - Forced Host", val ) );
+ // FlameCord - Use Bungee name instead
+ String motd = ChatColor.translateAlternateColorCodes( '&', get( "motd", "&1Just another " + BungeeCord.getInstance().getName() + " - Forced Host", val ) );
boolean restricted = get( "restricted", false, val );
SocketAddress address = Util.getAddr( addr );
ServerInfo info = ProxyServer.getInstance().constructServerInfo( name, address, motd, restricted );
@@ -253,7 +255,8 @@ public class YamlConfig implements ConfigurationAdapter
for ( Map<String, Object> val : base )
{
- String motd = get( "motd", "&1Another Bungee server", val );
+ // FlameCord - Use Bungee name instead
+ String motd = get( "motd", "&1Another " + BungeeCord.getInstance().getName() + " server", val );
motd = ChatColor.translateAlternateColorCodes( '&', motd );
int maxPlayers = get( "max_players", 1, val );
--
2.37.3.windows.1

View File

@ -0,0 +1,23 @@
From dca52858df4acbd78c9128f6e40e447b86824150 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:01:37 +0800
Subject: [PATCH] Change replaceAll() to replace()
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
index d672c8ef..9067b806 100644
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
@@ -129,7 +129,8 @@ public class ServerConnector extends PacketHandler
newp[newp.length - 2] = new net.md_5.bungee.protocol.Property( ForgeConstants.FML_LOGIN_PROFILE, "true", null );
// If we do not perform the replacement, then the IP Forwarding code in Spigot et. al. will try to split on this prematurely.
- newp[newp.length - 1] = new net.md_5.bungee.protocol.Property( ForgeConstants.EXTRA_DATA, user.getExtraDataInHandshake().replaceAll( "\0", "\1"), "" );
+ // FlameCord - Change replaceAll() to replace()
+ newp[newp.length - 1] = new net.md_5.bungee.protocol.Property( ForgeConstants.EXTRA_DATA, user.getExtraDataInHandshake().replace( "\0", "\1"), "" );
// All done.
properties = newp;
--
2.36.1.windows.1

View File

@ -0,0 +1,32 @@
From 510085f25ef21678828f5b3026662f51a94c1137 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Wed, 21 Dec 2022 21:43:05 -0300
Subject: [PATCH] Use duplicate() for MinecraftDecoder
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
index ac83e3253..c31ec1ce7 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
@@ -38,7 +38,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
}
Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT;
- ByteBuf slice = in.copy(); // Can't slice this one due to EntityMap :(
+ ByteBuf slice = in.duplicate(); // FlameCord - Duplicate buf instead of Copy
Object packetTypeInfo = null;
try
@@ -73,7 +73,8 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
in.skipBytes( in.readableBytes() );
}
- out.add( new PacketWrapper( packet, slice ) );
+ // FlameCord - Duplicate buf instead of Copy
+ out.add( new PacketWrapper( packet, slice.retain() ) );
slice = null;
} catch (BadPacketException | IndexOutOfBoundsException e) {
// Waterfall start: Additional DoS mitigations
--
2.37.3.windows.1

View File

@ -0,0 +1,131 @@
From 9c6dd2dc6ee18d5429d098b5a5d1963cfd404856 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:06:17 +0800
Subject: [PATCH] Close connections & Don't flush if not necessary
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 c3543a18..8ed26e5c 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
@@ -208,6 +208,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
ServerPing legacy = result.getResponse();
+
+ // FlameCord - Close and return if legacy == null
+ if (legacy == null) {
+ ch.close();
+ return;
+ }
+
String kickMessage;
if ( v1_5 )
@@ -283,6 +290,17 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@Override
public void done(ProxyPingEvent pingResult, Throwable error)
{
+ // FlameCord - Close if response is null
+ if (pingResult.getResponse() == null) {
+ ch.close();
+ return;
+ }
+
+ // FlameCord - Return if connection is closed
+ if (ch.isClosed()) {
+ return;
+ }
+
// FlameCord start - 1.7.x support
Gson gson = handshake.getProtocolVersion() == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy : BungeeCord.getInstance().gson;
if ( ProtocolConstants.isBeforeOrEq( handshake.getProtocolVersion() , ProtocolConstants.MINECRAFT_1_8 ) )
@@ -327,11 +345,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@Override
public void handle(PingPacket ping) throws Exception
{
- if (!ACCEPT_INVALID_PACKETS) {
- Preconditions.checkState(thisState == State.PING, "Not expecting PING");
- }
+ // FlameCord - Never accept invalid packets
+ Preconditions.checkState( thisState == State.PING, "Not expecting PING" );
+
unsafe.sendPacket( ping );
- disconnect( "" );
+
+ // FlameCord - Close instead of disconnect
+ ch.close();
}
@Override
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
index 6dc5633f..8b0fac0a 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
@@ -80,10 +80,11 @@ public class ChannelWrapper
if ( packet != null && ch.isActive() )
{
- ch.writeAndFlush( packet ).addListeners( ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE, ChannelFutureListener.CLOSE );
+ // FlameCord - Remove the firing of exceptions on failure
+ ch.writeAndFlush( packet ).addListeners( ChannelFutureListener.CLOSE );
} else
{
- ch.flush();
+ // FlameCord - Don't flush just close
ch.close();
}
}
@@ -113,7 +114,7 @@ public class ChannelWrapper
public void addBefore(String baseName, String name, ChannelHandler handler)
{
Preconditions.checkState( ch.eventLoop().inEventLoop(), "cannot add handler outside of event loop" );
- ch.pipeline().flush();
+ // FlameCord - Don't flush if not necessary
ch.pipeline().addBefore( baseName, name, handler );
}
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
index 2a21243b..a95193ba 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
@@ -5,6 +5,7 @@ import io.github.waterfallmc.waterfall.event.ConnectionInitEvent;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.ChannelException;
+import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
@@ -98,6 +99,14 @@ public class PipelineUtils
BungeeCord.getInstance().getPluginManager().callEvent(connectionInitEvent);
}
+
+ // FlameCord - Close on exception caught
+ @Override
+ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
+ cause.printStackTrace();
+
+ ctx.close();
+ }
};
public static final Base BASE = new Base();
private static final KickStringWriter legacyKicker = new KickStringWriter();
@@ -192,5 +201,13 @@ public class PipelineUtils
ch.pipeline().addLast( BOSS_HANDLER, new HandlerBoss() );
}
+
+ // FlameCord - Close on exception caught
+ @Override
+ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
+ cause.printStackTrace();
+
+ ctx.close();
+ }
}
}
--
2.37.3.windows.1

View File

@ -0,0 +1,53 @@
From cf87130274644325adbf7fabb7b95d95e976ee57 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:10:30 +0800
Subject: [PATCH] Packet Checks
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
index c31ec1ce7..640f0ea26 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
@@ -38,6 +38,19 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
}
Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT;
+
+ // FlameCord - Check size before decoding
+ if (prot == protocol.TO_SERVER) {
+ final int readableBytes = in.readableBytes();
+ final int capacity = in.capacity();
+
+ if (readableBytes > 2097152) {
+ throw new FastDecoderException("Error decoding packet with too many readableBytes: " + readableBytes);
+ } else if (capacity > 2097152) {
+ throw new FastDecoderException("Error decoding packet with too big capacity: " + capacity);
+ }
+ }
+
ByteBuf slice = in.duplicate(); // FlameCord - Duplicate buf instead of Copy
Object packetTypeInfo = null;
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
index 29cf4b4fc..4820267b3 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
@@ -78,6 +78,15 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
{
+ // FlameCord - Return if channel isn't active
+ if (!ctx.channel().isActive()) {
+ if (msg instanceof PacketWrapper) {
+ ((PacketWrapper) msg).trySingleRelease();
+ }
+
+ return;
+ }
+
if ( msg instanceof HAProxyMessage )
{
HAProxyMessage proxy = (HAProxyMessage) msg;
--
2.37.3.windows.1

View File

@ -0,0 +1,23 @@
From f790d57423c57a21d642db20b6de9d3515fd3e93 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:14:02 +0800
Subject: [PATCH] Change default timeout
diff --git a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
index 8911bee85..b67195ec8 100644
--- a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
+++ b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
@@ -35,7 +35,8 @@ public abstract class Configuration implements ProxyConfig
/**
* Time before users are disconnected due to no network activity.
*/
- private int timeout = 30000;
+ // FlameCord - Modify default timeout
+ private int timeout = 17000;
/**
* UUID used for metrics.
*/
--
2.37.3.windows.1

View File

@ -0,0 +1,23 @@
From cbec17576f5c5472cf0037f9962ca5c806133200 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:25:51 +0800
Subject: [PATCH] Don't allow name containing dot
diff --git a/proxy/src/main/java/net/md_5/bungee/util/AllowedCharacters.java b/proxy/src/main/java/net/md_5/bungee/util/AllowedCharacters.java
index 1a4242a2e..d947fad7d 100644
--- a/proxy/src/main/java/net/md_5/bungee/util/AllowedCharacters.java
+++ b/proxy/src/main/java/net/md_5/bungee/util/AllowedCharacters.java
@@ -21,7 +21,8 @@ public final class AllowedCharacters
} else
{
// Don't allow spaces, Yaml config doesn't support them
- return isChatAllowedCharacter( c ) && c != ' ';
+ // FlameCord - Don't allow dots
+ return isChatAllowedCharacter( c ) && c != ' ' && c != '.';
}
}
--
2.37.3.windows.1

View File

@ -0,0 +1,78 @@
From 33c937b0b20e6ad8994c21258841d5330443c2fe Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:30:07 +0800
Subject: [PATCH] Use pipeline to reduce redundancy
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
index 8b0fac0a..b3fa4835 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
@@ -5,6 +5,8 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelPipeline;
+
import java.net.SocketAddress;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
@@ -37,14 +39,18 @@ public class ChannelWrapper
public void setProtocol(Protocol protocol)
{
- ch.pipeline().get( MinecraftDecoder.class ).setProtocol( protocol );
- ch.pipeline().get( MinecraftEncoder.class ).setProtocol( protocol );
+ // FlameCord - Use pipeline to reduce redundancy
+ final ChannelPipeline pipeline = ch.pipeline();
+ pipeline.get( MinecraftDecoder.class ).setProtocol( protocol );
+ pipeline.get( MinecraftEncoder.class ).setProtocol( protocol );
}
public void setVersion(int protocol)
{
- ch.pipeline().get( MinecraftDecoder.class ).setProtocolVersion( protocol );
- ch.pipeline().get( MinecraftEncoder.class ).setProtocolVersion( protocol );
+ // FlameCord - Use pipeline to reduce redundancy
+ final ChannelPipeline pipeline = ch.pipeline();
+ pipeline.get( MinecraftDecoder.class ).setProtocolVersion( protocol );
+ pipeline.get( MinecraftEncoder.class ).setProtocolVersion( protocol );
}
public void write(Object packet)
@@ -125,25 +131,27 @@ public class ChannelWrapper
public void setCompressionThreshold(int compressionThreshold)
{
- if ( ch.pipeline().get( PacketCompressor.class ) == null && compressionThreshold != -1 )
+ // FlameCord - Use pipeline to reduce redundancy
+ final ChannelPipeline pipeline = ch.pipeline();
+ if ( pipeline.get( PacketCompressor.class ) == null && compressionThreshold != -1 )
{
addBefore( PipelineUtils.PACKET_ENCODER, "compress", new PacketCompressor() );
}
if ( compressionThreshold != -1 )
{
- ch.pipeline().get( PacketCompressor.class ).setThreshold( compressionThreshold );
+ pipeline.get( PacketCompressor.class ).setThreshold( compressionThreshold );
} else
{
- ch.pipeline().remove( "compress" );
+ pipeline.remove( "compress" );
}
- if ( ch.pipeline().get( PacketDecompressor.class ) == null && compressionThreshold != -1 )
+ if ( pipeline.get( PacketDecompressor.class ) == null && compressionThreshold != -1 )
{
addBefore( PipelineUtils.PACKET_DECODER, "decompress", new PacketDecompressor(compressionThreshold) );
}
if ( compressionThreshold == -1 )
{
- ch.pipeline().remove( "decompress" );
+ pipeline.remove( "decompress" );
}
}
}
--
2.37.3.windows.1

View File

@ -0,0 +1,22 @@
From 047ea04ae1cf8277e6c2eed87dc0d5fd901efe91 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:35:33 +0800
Subject: [PATCH] Allow custom uuids even if onlineMode is true
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 8ed26e5c..4242b9c8 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
@@ -769,7 +769,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
public void setUniqueId(UUID uuid)
{
Preconditions.checkState( thisState == State.USERNAME, "Can only set uuid while state is username" );
- Preconditions.checkState( !onlineMode, "Can only set uuid when online mode is false" );
+ // FlameCord - Allow custom uuids even if onlineMode is true
this.uniqueId = uuid;
}
--
2.37.3.windows.1

View File

@ -0,0 +1,24 @@
From 0f07c38f3d16849626c28ae710616788f30b00fc Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:40:55 +0800
Subject: [PATCH] Change IllegalStateException to QuietException and explain
that is a plugin
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
index 2d72e26ea..94702434d 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -313,7 +313,8 @@ public final class UserConnection implements ProxiedPlayer
if ( getServer() == null && !ch.isClosing() )
{
- throw new IllegalStateException( "Cancelled ServerConnectEvent with no server or disconnect." );
+ // FlameCord - Change IllegalStateException to QuietException and explain that is a plugin
+ throw new QuietException("A plugin cancelled ServerConnectEvent with no server or disconnect.");
}
return;
}
--
2.37.3.windows.1

View File

@ -0,0 +1,25 @@
From ac09d06618510ed85aadc83a5a6bb812bf109218 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Wed, 16 Dec 2020 18:43:17 +0800
Subject: [PATCH] Don't declare uuid unless it's null
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 8715821fe..1c10b5a93 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
@@ -559,7 +559,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
loginProfile = obj;
name = obj.getName();
- uniqueId = Util.getUUID( obj.getId() );
+ // FlameCord - Don't declare uuid unless it's null
+ if (uniqueId == null) {
+ uniqueId = Util.getUUID(obj.getId());
+ }
finish();
return;
}
--
2.37.3.windows.1

View File

@ -0,0 +1,377 @@
From f4ab4a93d462da9ff8375c432ea7824a189ca59a Mon Sep 17 00:00:00 2001
From: Juan Cruz Linsalata <LinsaFTW@users.noreply.github.com>
Date: Mon, 12 Oct 2020 15:40:53 -0300
Subject: [PATCH] FlameCord General Patch
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
new file mode 100644
index 000000000..f3d5c0290
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
@@ -0,0 +1,31 @@
+package dev._2lstudios.flamecord;
+
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
+import lombok.Getter;
+import net.md_5.bungee.config.ConfigurationProvider;
+import net.md_5.bungee.config.YamlConfiguration;
+
+public class FlameCord {
+ @Getter
+ private static FlameCord instance;
+
+ public static void initialize(final Logger logger, final Collection<String> whitelistedAddresses) {
+ if (FlameCord.instance == null) {
+ FlameCord.instance = new FlameCord();
+ }
+
+ instance.reload(logger, whitelistedAddresses);
+ }
+
+ @Getter
+ private FlameCordConfiguration flameCordConfiguration;
+
+ public void reload(final Logger logger, final Collection<String> whitelistedAddresses) {
+ final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
+
+ this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider, whitelistedAddresses);
+ }
+}
\ No newline at end of file
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
new file mode 100644
index 000000000..e6c660d15
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
@@ -0,0 +1,74 @@
+package dev._2lstudios.flamecord.configuration;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+import net.md_5.bungee.config.Configuration;
+import net.md_5.bungee.config.ConfigurationProvider;
+import net.md_5.bungee.config.YamlConfiguration;
+
+public class FlameConfig {
+ Configuration load(File file) {
+ ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
+
+ if (file.exists() && file.isFile()) {
+ try {
+ return configurationProvider.load(file);
+ } catch (IOException ex) {
+ // Failed to load, do nothing
+ }
+ }
+
+ return new Configuration();
+ }
+
+ void save(Configuration config, File file) {
+ ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
+
+ try {
+ configurationProvider.save(config, file);
+ } catch (IOException ex) {
+ // Failed to save, do nothing
+ }
+ }
+
+ double setIfUnexistant(final String arg1, final double arg2, final Configuration configuration) {
+ return (double) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ int setIfUnexistant(final String arg1, final int arg2, final Configuration configuration) {
+ return (int) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ String setIfUnexistant(final String arg1, final String arg2, final Configuration configuration) {
+ return (String) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ boolean setIfUnexistant(final String arg1, final boolean arg2, final Configuration configuration) {
+ return (boolean) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ Object setIfUnexistant(final String arg1, final Object arg2, final Configuration configuration) {
+ if (!configuration.contains(arg1)) {
+ configuration.set(arg1, arg2);
+
+ return arg2;
+ } else {
+ return configuration.get(arg1);
+ }
+ }
+
+ Collection<String> setIfUnexistant(final String arg1, final Collection<String> arg2,
+ final Configuration configuration) {
+ if (!configuration.contains(arg1)) {
+ configuration.set(arg1, new ArrayList<>(arg2));
+
+ return arg2;
+ } else {
+ return new HashSet<>(configuration.getStringList(arg1));
+ }
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
new file mode 100644
index 000000000..241e8ed9c
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -0,0 +1,20 @@
+package dev._2lstudios.flamecord.configuration;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+
+import lombok.Getter;
+import net.md_5.bungee.config.Configuration;
+import net.md_5.bungee.config.ConfigurationProvider;
+
+public class FlameCordConfiguration extends FlameConfig {
+ public FlameCordConfiguration(final ConfigurationProvider configurationProvider, final Collection<String> whitelistedAddresses) {
+ final File configurationFile = new File("./flamecord.yml");
+ final Configuration configuration = load(configurationFile);
+
+ save(configuration, configurationFile);
+ }
+}
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
index 640f0ea26..70a1192e7 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
@@ -1,5 +1,6 @@
package net.md_5.bungee.protocol;
+import dev._2lstudios.flamecord.FlameCord;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
diff --git a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
new file mode 100644
index 000000000..021b38d43
--- /dev/null
+++ b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
@@ -0,0 +1,58 @@
+package dev._2lstudios.flamecord.commands;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import dev._2lstudios.flamecord.FlameCord;
+import net.md_5.bungee.BungeeCord;
+import net.md_5.bungee.api.CommandSender;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.config.ServerInfo;
+import net.md_5.bungee.api.plugin.Command;
+
+public class FlameCordCommand extends Command {
+private final BungeeCord bungeeCord;
+
+ public FlameCordCommand(final BungeeCord bungeeCord) {
+ super("flamecord");
+
+ this.bungeeCord = bungeeCord;
+ }
+
+ @Override
+ public void execute(final CommandSender sender, final String[] args) {
+ final FlameCord flameCord = FlameCord.getInstance();
+
+ if (sender.hasPermission("flamecord.usage")) {
+ if (args.length > 0) {
+ final String arg0 = args[0];
+
+ switch (arg0) {
+ case "reload": {
+ // FlameCord - Collect ips from servers
+ final Collection<String> whitelistedAddresses = new HashSet<>();
+
+ for (final ServerInfo serverInfo : bungeeCord.getServers().values()) {
+ whitelistedAddresses.add(serverInfo.getSocketAddress().toString());
+ }
+
+ FlameCord.initialize(bungeeCord.getLogger(), whitelistedAddresses);
+ sender.sendMessage(TextComponent
+ .fromLegacyText("flamecord_reload"));
+ break;
+ }
+ default: {
+ sender.sendMessage(TextComponent.fromLegacyText("flamecord_help"));
+ break;
+ }
+ }
+ } else {
+ sender.sendMessage(TextComponent
+ .fromLegacyText("flamecord_help"));
+ }
+ } else {
+ sender.sendMessage(TextComponent
+ .fromLegacyText("flamecord_nopermission"));
+ }
+ }
+}
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index 27d41dd00..0d8f02d25 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -9,6 +9,8 @@ import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+
+import dev._2lstudios.flamecord.FlameCord;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.github.waterfallmc.waterfall.conf.WaterfallConfiguration;
import io.github.waterfallmc.waterfall.event.ProxyExceptionEvent;
@@ -295,6 +297,15 @@ public class BungeeCord extends ProxyServer
pluginManager.loadPlugins();
config.load();
+ // FlameCord - Renew and register modules
+ final Collection<String> whitelistedAddresses = new HashSet<>();
+
+ for (final ServerInfo serverInfo : getServers().values()) {
+ whitelistedAddresses.add(serverInfo.getSocketAddress().toString());
+ }
+
+ FlameCord.initialize(logger, whitelistedAddresses);
+
if ( config.isForgeSupport() )
{
registerChannel( ForgeConstants.FML_TAG );
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
index da688839c..3a07c7c8a 100644
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
@@ -2,6 +2,8 @@ package net.md_5.bungee;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
+
+import dev._2lstudios.flamecord.FlameCord;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import java.net.InetSocketAddress;
@@ -165,7 +167,9 @@ public class ServerConnector extends PacketHandler
{
if ( packet.packet == null )
{
- throw new QuietException( "Unexpected packet received during server login process!\n" + BufUtil.dump( packet.buf, 16 ) );
+ // FlameCord - FlameCord General Patch
+ // More specific invalid packet exceptions
+ throw new QuietException( "Unexpected packet received during server connector process!\n" + BufUtil.dump(packet.buf, 16) );
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
index 94702434d..e48f77131 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -35,6 +35,7 @@ import net.md_5.bungee.api.SkinConfiguration;
import net.md_5.bungee.api.Title;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.config.ListenerInfo;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PermissionCheckEvent;
@@ -66,6 +67,7 @@ import net.md_5.bungee.tab.ServerUnique;
import net.md_5.bungee.tab.TabList;
import net.md_5.bungee.util.CaseInsensitiveSet;
import net.md_5.bungee.util.ChatComponentTransformer;
+import net.md_5.bungee.util.QuietException;
@RequiredArgsConstructor
public final class UserConnection implements ProxiedPlayer
@@ -393,9 +395,11 @@ public final class UserConnection implements ProxiedPlayer
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, request.getConnectTimeout() )
.remoteAddress( target.getAddress() );
// Windows is bugged, multi homed users will just have to live with random connecting IPs
- if ( getPendingConnection().getListener().isSetLocalAddress() && !PlatformDependent.isWindows() && getPendingConnection().getListener().getSocketAddress() instanceof InetSocketAddress )
+ // FlameCord - Use listenerInfo
+ final ListenerInfo listenerInfo = getPendingConnection().getListener();
+ if ( listenerInfo.isSetLocalAddress() && !PlatformDependent.isWindows() && listenerInfo.getSocketAddress() instanceof InetSocketAddress )
{
- b.localAddress( getPendingConnection().getListener().getHost().getHostString(), 0 );
+ b.localAddress( listenerInfo.getHost().getHostString(), 0 );
}
b.connect().addListener( listener );
}
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 3b1bffe6c..22688a045 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
@@ -21,6 +21,8 @@ import java.util.logging.Level;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import dev._2lstudios.flamecord.FlameCord;
+
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.BungeeCord;
@@ -159,7 +161,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
if ( packet.packet == null )
{
- throw new QuietException( "Unexpected packet received during login process! " + BufUtil.dump( packet.buf, 16 ) );
+ // FlameCord - FlameCord General Patch
+ // More specific invalid packet exceptions
+ throw new QuietException( "Unexpected packet received during initial handler process!\n" + BufUtil.dump(packet.buf, 16) );
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
index a409d440b..3503c089d 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
@@ -1,6 +1,7 @@
package net.md_5.bungee.connection;
import com.google.gson.Gson;
+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.BungeeCord;
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
index 4820267b3..694ecdb01 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
@@ -1,6 +1,8 @@
package net.md_5.bungee.netty;
import com.google.common.base.Preconditions;
+
+import dev._2lstudios.flamecord.FlameCord;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.CorruptedFrameException;
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
index a95193ba7..a4c3bd710 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
@@ -1,6 +1,8 @@
package net.md_5.bungee.netty;
import com.google.common.base.Preconditions;
+
+import dev._2lstudios.flamecord.FlameCord;
import io.github.waterfallmc.waterfall.event.ConnectionInitEvent;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.Channel;
--
2.37.3.windows.1

View File

@ -0,0 +1,194 @@
From 681805834a7f83cccb8de7878b8ffacbdb4b6d0d Mon Sep 17 00:00:00 2001
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
Date: Sat, 1 May 2021 14:17:48 -0300
Subject: [PATCH] FlameCord module system
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
index f3d5c0290..fb3d8ca2e 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
@@ -4,6 +4,7 @@ import java.util.Collection;
import java.util.logging.Logger;
import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
+import dev._2lstudios.flamecord.configuration.ModulesConfiguration;
import lombok.Getter;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
@@ -23,9 +24,16 @@ public class FlameCord {
@Getter
private FlameCordConfiguration flameCordConfiguration;
+ // FlameCord - Module System
+ @Getter
+ private ModulesConfiguration modulesConfiguration;
+
public void reload(final Logger logger, final Collection<String> whitelistedAddresses) {
final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider, whitelistedAddresses);
+
+ // FlameCord - Module System
+ this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
}
}
\ No newline at end of file
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/ModulesConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/ModulesConfiguration.java
new file mode 100644
index 000000000..a6cb2638f
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/ModulesConfiguration.java
@@ -0,0 +1,35 @@
+package dev._2lstudios.flamecord.configuration;
+
+import java.io.File;
+
+import net.md_5.bungee.config.Configuration;
+import net.md_5.bungee.config.ConfigurationProvider;
+
+public class ModulesConfiguration extends FlameConfig {
+ public boolean reconnectEnabled = false;
+ public boolean alertEnabled = true;
+ public boolean findEnabled = true;
+ public boolean ipEnabled = true;
+ public boolean listEnabled = true;
+ public boolean permsEnabled = true;
+ public boolean reloadEnabled = true;
+ public boolean sendEnabled = true;
+ public boolean serverEnabled = true;
+
+ public ModulesConfiguration(final ConfigurationProvider configurationProvider) {
+ final File configurationFile = new File("./modules.yml");
+ final Configuration configuration = load(configurationFile);
+
+ this.alertEnabled = setIfUnexistant("alert.enabled", this.alertEnabled, configuration);
+ this.findEnabled = setIfUnexistant("find.enabled", this.findEnabled, configuration);
+ this.ipEnabled = setIfUnexistant("ip.enabled", this.ipEnabled, configuration);
+ this.listEnabled = setIfUnexistant("list.enabled", this.listEnabled, configuration);
+ this.permsEnabled = setIfUnexistant("perms.enabled", this.permsEnabled, configuration);
+ this.reloadEnabled = setIfUnexistant("reload.enabled", this.reloadEnabled, configuration);
+ this.sendEnabled = setIfUnexistant("send.enabled", this.sendEnabled, configuration);
+ this.serverEnabled = setIfUnexistant("server.enabled", this.serverEnabled, configuration);
+ this.reconnectEnabled = setIfUnexistant("reconnect.enabled", this.reconnectEnabled, configuration);
+
+ save(configuration, configurationFile);
+ }
+}
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index 0d8f02d25..d58227fd9 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -11,6 +11,8 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.commands.FlameCordCommand;
+import dev._2lstudios.flamecord.configuration.ModulesConfiguration;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.github.waterfallmc.waterfall.conf.WaterfallConfiguration;
import io.github.waterfallmc.waterfall.event.ProxyExceptionEvent;
@@ -90,6 +92,13 @@ import net.md_5.bungee.conf.Configuration;
import net.md_5.bungee.conf.YamlConfig;
import net.md_5.bungee.forge.ForgeConstants;
import net.md_5.bungee.module.ModuleManager;
+import net.md_5.bungee.module.cmd.alert.CommandAlert;
+import net.md_5.bungee.module.cmd.alert.CommandAlertRaw;
+import net.md_5.bungee.module.cmd.find.CommandFind;
+import net.md_5.bungee.module.cmd.list.CommandList;
+import net.md_5.bungee.module.cmd.send.CommandSend;
+import net.md_5.bungee.module.cmd.server.CommandServer;
+import net.md_5.bungee.module.reconnect.yaml.YamlReconnectHandler;
import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.ProtocolConstants;
@@ -244,11 +253,6 @@ public class BungeeCord extends ProxyServer
// Waterfall end
pluginManager = new PluginManager( this );
- getPluginManager().registerCommand( null, new CommandReload() );
- getPluginManager().registerCommand( null, new CommandEnd() );
- getPluginManager().registerCommand( null, new CommandIP() );
- getPluginManager().registerCommand( null, new CommandBungee() );
- getPluginManager().registerCommand( null, new CommandPerms() );
if ( !Boolean.getBoolean( "net.md_5.bungee.native.disable" ) )
{
@@ -287,9 +291,10 @@ public class BungeeCord extends ProxyServer
bossEventLoopGroup = PipelineUtils.newEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty Boss IO Thread #%1$d" ).build() );
workerEventLoopGroup = PipelineUtils.newEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty Worker IO Thread #%1$d" ).build() );
- File moduleDirectory = new File( "modules" );
+ // FlameCord - Use own module system
+ /* File moduleDirectory = new File( "modules" );
moduleManager.load( this, moduleDirectory );
- pluginManager.detectPlugins( moduleDirectory );
+ pluginManager.detectPlugins( moduleDirectory ); */
pluginsFolder.mkdir();
pluginManager.detectPlugins( pluginsFolder );
@@ -315,6 +320,7 @@ public class BungeeCord extends ProxyServer
isRunning = true;
+ loadModules();
pluginManager.enablePlugins();
if ( config.getThrottle() > 0 )
@@ -853,4 +859,53 @@ public class BungeeCord extends ProxyServer
{
return new BungeeTitle();
}
+
+ // FlameCord - FlameCord Module System
+ public void loadModules() {
+ final ModulesConfiguration modulesConfiguration = FlameCord.getInstance().getModulesConfiguration();
+
+ // Bungeecord Commands
+ pluginManager.registerCommand(null, new CommandEnd());
+ pluginManager.registerCommand(null, new CommandBungee());
+
+ if (modulesConfiguration.reloadEnabled) {
+ pluginManager.registerCommand(null, new CommandReload());
+ }
+ if (modulesConfiguration.ipEnabled) {
+ pluginManager.registerCommand(null, new CommandIP());
+ }
+ if (modulesConfiguration.permsEnabled) {
+ pluginManager.registerCommand(null, new CommandPerms());
+ }
+
+ // Modules Commands
+ if (modulesConfiguration.alertEnabled) {
+ pluginManager.registerCommand(null, new CommandAlert());
+ pluginManager.registerCommand(null, new CommandAlertRaw());
+ }
+ if (modulesConfiguration.findEnabled) {
+ pluginManager.registerCommand(null, new CommandFind());
+ }
+ if (modulesConfiguration.listEnabled) {
+ pluginManager.registerCommand(null, new CommandList());
+ }
+ if (modulesConfiguration.sendEnabled) {
+ pluginManager.registerCommand(null, new CommandSend());
+ }
+ if (modulesConfiguration.serverEnabled) {
+ pluginManager.registerCommand(null, new CommandServer());
+ }
+
+ if (modulesConfiguration.reconnectEnabled) {
+ for (ListenerInfo info : getConfig().getListeners()) {
+ if (!info.isForceDefault() && getReconnectHandler() == null) {
+ setReconnectHandler(new YamlReconnectHandler());
+ break;
+ }
+ }
+ }
+
+ // Flamecord Command
+ pluginManager.registerCommand(null, new FlameCordCommand(this));
+ }
}
--
2.37.3.windows.1

View File

@ -0,0 +1,224 @@
From 168e63822c7f19251ff48a96fb341b230d662143 Mon Sep 17 00:00:00 2001
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
Date: Sat, 1 May 2021 13:40:39 -0300
Subject: [PATCH] FlameCord message configuration
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
index fb3d8ca2e..676ba95b9 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
@@ -4,6 +4,7 @@ import java.util.Collection;
import java.util.logging.Logger;
import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
+import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
import dev._2lstudios.flamecord.configuration.ModulesConfiguration;
import lombok.Getter;
import net.md_5.bungee.config.ConfigurationProvider;
@@ -27,6 +28,8 @@ public class FlameCord {
// FlameCord - Module System
@Getter
private ModulesConfiguration modulesConfiguration;
+ @Getter
+ private MessagesConfiguration messagesConfiguration;
public void reload(final Logger logger, final Collection<String> whitelistedAddresses) {
final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
@@ -35,5 +38,6 @@ public class FlameCord {
// FlameCord - Module System
this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
+ this.messagesConfiguration = new MessagesConfiguration(logger, configurationProvider);
}
}
\ No newline at end of file
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
new file mode 100644
index 000000000..ae1794385
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
@@ -0,0 +1,102 @@
+package dev._2lstudios.flamecord.configuration;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import net.md_5.bungee.api.ChatColor;
+import net.md_5.bungee.config.Configuration;
+import net.md_5.bungee.config.ConfigurationProvider;
+
+public class MessagesConfiguration extends FlameConfig {
+ private final Logger logger;
+ private final Map<String, String> messages = new HashMap<>();
+
+ public MessagesConfiguration(final Logger logger, final ConfigurationProvider configurationProvider) {
+ this.logger = logger;
+
+ final File configurationFile = new File("./messages.yml");
+ final Configuration configuration = load(configurationFile);
+
+ // FlameCord
+ setIfUnexistant("flamecord_reload", "&aAll files had been successfully reloaded!", configuration);
+ setIfUnexistant("flamecord_help",
+ "&aFlameCord&b {0}&a by&b LinsaFTW\n&e /flamecord reload&7 >&b Reloads FlameCord files!\n&e /flamecord firewall <add/remove> <ip>&7 >&b Firewall certain ips!\n&e /bplugins&7 >&b Show the plugin list!\n&e /bip <player>&7 >&b Show the ip and info of a player!\n&e /flamecord help&7 >&b Shows this message!",
+ configuration);
+ setIfUnexistant("flamecord_nopermission", "&cYou don't have permission to do this!", configuration);
+
+ // BungeeCord
+ setIfUnexistant("alert", "&8[&4Alert&8]&r ", configuration);
+ setIfUnexistant("already_connected", "&cYou are already connected to this server!", configuration);
+ setIfUnexistant("already_connected_proxy", "&cYou are already connected to this proxy!", configuration);
+ setIfUnexistant("already_connecting", "&cAlready connecting to this server!", configuration);
+ setIfUnexistant("command_list", "&a[{0}] &e({1}): &r{2}", configuration);
+ setIfUnexistant("connect_kick", "&cKicked whilst connecting to {0}: {1}", configuration);
+ setIfUnexistant("current_server", "&6You are currently connected to {0}.", configuration);
+ setIfUnexistant("fallback_kick",
+ "&cCould not connect to a default or fallback server, please try again later: {0}", configuration);
+ setIfUnexistant("fallback_lobby",
+ "&cCould not connect to target server, you have been moved to a fallback server.", configuration);
+ setIfUnexistant("lost_connection", "[Proxy] Lost connection to server.", configuration);
+ setIfUnexistant("mojang_fail", "Error occurred while contacting login servers, are they down?",
+ configuration);
+ setIfUnexistant("no_permission", "&cYou do not have permission to execute this command!", configuration);
+ setIfUnexistant("no_server", "&cThe specified server does not exist.", configuration);
+ setIfUnexistant("no_server_permission", "&cYou don't have permission to access this server.",
+ configuration);
+ setIfUnexistant("outdated_client", "Outdated client! Please use {0}", configuration);
+ setIfUnexistant("outdated_server", "Outdated server! I'm still on {0}", configuration);
+ setIfUnexistant("proxy_full", "Server is full!", configuration);
+ setIfUnexistant("restart", "[Proxy] Proxy restarting.", configuration);
+ setIfUnexistant("server_list", "&6You may connect to the following servers at this time: ", configuration);
+ setIfUnexistant("server_went_down",
+ "&cThe server you were previously on went down, you have been connected to a fallback server",
+ configuration);
+ setIfUnexistant("total_players", "Total players online: {0}", configuration);
+ setIfUnexistant("name_invalid", "Username contains invalid characters.", configuration);
+ setIfUnexistant("ping_cannot_connect", "&c[Bungee] Can't connect to server.", configuration);
+ setIfUnexistant("offline_mode_player", "Not authenticated with Minecraft.net", configuration);
+ setIfUnexistant("secure_profile_required", "A secure profile is required to join this server.", configuration);
+ setIfUnexistant("secure_profile_expired", "Secure profile expired.", configuration);
+ setIfUnexistant("secure_profile_invalid", "Secure profile invalid.", configuration);
+ setIfUnexistant("message_needed", "&cYou must supply a message.", configuration);
+ setIfUnexistant("error_occurred_player",
+ "&cAn error occurred while parsing your message. (Hover for details)", configuration);
+ setIfUnexistant("error_occurred_console", "&cAn error occurred while parsing your message: {0}",
+ configuration);
+ setIfUnexistant("server_command_hover_players", "{0} players", configuration);
+ setIfUnexistant("click_to_connect", "Click to connect to the server", configuration);
+ setIfUnexistant("username_needed", "&cPlease follow this command by a user name.", configuration);
+ setIfUnexistant("user_not_online", "&cThat user is not online.", configuration);
+ setIfUnexistant("user_online_at", "&a{0} &ris online at {1}", configuration);
+ setIfUnexistant("send_cmd_usage",
+ "&cNot enough arguments, usage: /send <server|player|all|current> <target>", configuration);
+ setIfUnexistant("player_only", "&cOnly in game players can use this command", configuration);
+ setIfUnexistant("you_got_summoned", "&6Summoned to {0} by {1}", configuration);
+ setIfUnexistant("command_perms_groups", "&6You have the following groups: {0}", configuration);
+ setIfUnexistant("command_perms_permission", "&9- {0}", configuration);
+ setIfUnexistant("command_ip", "&9IP of {0} is {1}", configuration);
+ setIfUnexistant("illegal_chat_characters", "&cIllegal characters in chat ({0})", configuration);
+
+ for (final String key : configuration.getKeys()) {
+ final Object value = configuration.get(key);
+
+ if (value instanceof String) {
+ this.messages.put(key, ChatColor.translateAlternateColorCodes('&', (String) value));
+ }
+ }
+
+ save(configuration, configurationFile);
+ }
+
+ public String getTranslation(final String name, final Object... args) {
+ if (!messages.containsKey(name)) {
+ logger.warning("[FlameCord] Tried to get translation '" + name
+ + "' from messages.yml file but wasn't found. Please try resetting this file or report to a developer.");
+ }
+
+ return MessageFormat.format(messages.getOrDefault(name, "<translation '" + name + "' missing>"), args);
+ }
+}
\ No newline at end of file
diff --git a/module/cmd-server/src/main/java/net/md_5/bungee/module/cmd/server/CommandServer.java b/module/cmd-server/src/main/java/net/md_5/bungee/module/cmd/server/CommandServer.java
index 698b420f4..e4ad7e389 100644
--- a/module/cmd-server/src/main/java/net/md_5/bungee/module/cmd/server/CommandServer.java
+++ b/module/cmd-server/src/main/java/net/md_5/bungee/module/cmd/server/CommandServer.java
@@ -50,7 +50,9 @@ public class CommandServer extends Command implements TabExecutor
int count = server.getPlayers().size();
serverTextComponent.setHoverEvent( new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
- new ComponentBuilder( count + ( count == 1 ? " player" : " players" ) + "\n" ).appendLegacy( ProxyServer.getInstance().getTranslation( "click_to_connect" ) ).create() )
+ // FlameCord - FlameCord messages configuration
+ // Make player count customizable
+ new ComponentBuilder( ProxyServer.getInstance().getTranslation( "server_command_hover_players", count ) + "\n" ).appendLegacy( ProxyServer.getInstance().getTranslation( "click_to_connect" ) ).create() )
);
serverTextComponent.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) );
serverList.append( serverTextComponent );
diff --git a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
index 021b38d43..fb81adee0 100644
--- a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
+++ b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
@@ -4,6 +4,7 @@ import java.util.Collection;
import java.util.HashSet;
import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
@@ -22,6 +23,7 @@ private final BungeeCord bungeeCord;
@Override
public void execute(final CommandSender sender, final String[] args) {
final FlameCord flameCord = FlameCord.getInstance();
+ final MessagesConfiguration messagesConfiguration = flameCord.getMessagesConfiguration();
if (sender.hasPermission("flamecord.usage")) {
if (args.length > 0) {
@@ -38,21 +40,22 @@ private final BungeeCord bungeeCord;
FlameCord.initialize(bungeeCord.getLogger(), whitelistedAddresses);
sender.sendMessage(TextComponent
- .fromLegacyText("flamecord_reload"));
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_reload")));
break;
}
default: {
- sender.sendMessage(TextComponent.fromLegacyText("flamecord_help"));
+ sender.sendMessage(TextComponent.fromLegacyText(
+ messagesConfiguration.getTranslation("flamecord_help", bungeeCord.getVersion())));
break;
}
}
} else {
sender.sendMessage(TextComponent
- .fromLegacyText("flamecord_help"));
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_help", bungeeCord.getVersion())));
}
} else {
sender.sendMessage(TextComponent
- .fromLegacyText("flamecord_nopermission"));
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_nopermission")));
}
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index d58227fd9..8994454c7 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -620,8 +620,8 @@ public class BungeeCord extends ProxyServer
@Override
public String getTranslation(String name, Object... args)
{
- Format format = messageFormats.get( name );
- return ( format != null ) ? format.format( args ) : "<translation '" + name + "' missing>";
+ // FlameCord - Use own translation system
+ return FlameCord.getInstance().getMessagesConfiguration().getTranslation(name, args);
}
@Override
--
2.37.3.windows.1

View File

@ -0,0 +1,68 @@
From 4121bc5ef2215f0621d449c5cf2073c47ed93947 Mon Sep 17 00:00:00 2001
From: linsaftw <linsaftw@users.noreply.github.com>
Date: Sat, 20 Mar 2021 12:36:25 -0300
Subject: [PATCH] Fix ByteBuf memory leaks
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
index 68916db79..688ff72d2 100644
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
@@ -155,11 +155,15 @@ public abstract class EntityMap
if ( readId == oldId || readId == newId )
{
ByteBuf data = packet.copy();
- packet.readerIndex( offset );
- packet.writerIndex( offset );
- DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet );
- packet.writeBytes( data );
- data.release();
+
+ try {
+ packet.readerIndex( offset );
+ packet.writerIndex( offset );
+ DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet );
+ packet.writeBytes( data );
+ } finally {
+ data.release();
+ }
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java
index cefa0206e..8d4439ab8 100644
--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java
+++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java
@@ -38,16 +38,22 @@ public class ForgeUtils
{
Map<String, String> modTags = new HashMap<>();
ByteBuf payload = Unpooled.wrappedBuffer( pluginMessage.getData() );
- byte discriminator = payload.readByte();
- if ( discriminator == 2 ) // ModList
- {
- ByteBuf buffer = payload.slice();
- int modCount = DefinedPacket.readVarInt( buffer, 2 );
- for ( int i = 0; i < modCount; i++ )
+
+ try {
+ byte discriminator = payload.readByte();
+ if ( discriminator == 2 ) // ModList
{
- modTags.put( DefinedPacket.readString( buffer ), DefinedPacket.readString( buffer ) );
+ ByteBuf buffer = payload.slice();
+ int modCount = DefinedPacket.readVarInt( buffer, 2 );
+ for ( int i = 0; i < modCount; i++ )
+ {
+ modTags.put( DefinedPacket.readString( buffer ), DefinedPacket.readString( buffer ) );
+ }
}
+ } finally {
+ payload.release();
}
+
return modTags;
}
--
2.37.3.windows.1

View File

@ -0,0 +1,27 @@
From 7e20c899237e194fbda629aa6be4444fbe293b7d Mon Sep 17 00:00:00 2001
From: PermisosDev <55111245+PermisosDev@users.noreply.github.com>
Date: Thu, 15 Apr 2021 08:34:57 -0300
Subject: [PATCH] Check if packetID is invalid.
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
index 70a1192e7..6316143f7 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
@@ -65,7 +65,12 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
int packetId = DefinedPacket.readVarInt( in );
packetTypeInfo = packetId;
-
+ // FlameCord Start - Check if packetId is invalid.
+ if (packetId < 0 || packetId > Protocol.MAX_PACKET_ID)
+ {
+ throw new FastDecoderException( "[" + ctx.channel().remoteAddress() + "] <-> MinecraftDecoder received invalid packet #1, id " + packetId );
+ }
+ // Flamecord End
DefinedPacket packet = prot.createPacket( packetId, protocolVersion, supportsForge );
if ( packet != null )
{
--
2.37.3.windows.1

View File

@ -0,0 +1,140 @@
From 1d9ee842e043c343a64b8fe7ef6962ee0fb53041 Mon Sep 17 00:00:00 2001
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 30 Apr 2021 23:51:51 -0300
Subject: [PATCH] FlameCord logger options
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 241e8ed9c..b563cbced 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -11,10 +11,27 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration extends FlameConfig {
+ @Getter
+ private boolean loggerInitialhandler = false;
+ @Getter
+ private boolean loggerExceptions = false;
+ @Getter
+ private boolean loggerDump = false;
+ @Getter
+ private boolean loggerHaProxy = false;
+ @Getter
+ private boolean loggerDetailedConnection = true;
+
public FlameCordConfiguration(final ConfigurationProvider configurationProvider, final Collection<String> whitelistedAddresses) {
final File configurationFile = new File("./flamecord.yml");
final Configuration configuration = load(configurationFile);
+ this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration);
+ this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
+ this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, configuration);
+ this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration);
+ this.loggerDetailedConnection = setIfUnexistant("logger.detailed-connect-errors", this.loggerDetailedConnection, configuration);
+
save(configuration, configurationFile);
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
index e48f77131..909227970 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap;
+import dev._2lstudios.flamecord.FlameCord;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
@@ -406,7 +407,10 @@ public final class UserConnection implements ProxiedPlayer
private String connectionFailMessage(Throwable cause)
{
- bungee.getLogger().log(Level.WARNING, "Error occurred processing connection for " + this.name + " " + Util.exception( cause, false )); // Waterfall
+ // FlameCord - Allow for toggle the logging of connection failures
+ if(FlameCord.getInstance().getFlameCordConfiguration().isLoggerDetailedConnection()) {
+ bungee.getLogger().log(Level.WARNING, "Error occurred processing connection for " + this.name + " " + Util.exception(cause, false)); // Waterfall
+ }
return ""; // 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 22688a045..66a347542 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
@@ -396,7 +396,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
case 1:
// Ping
- if ( bungee.getConfig().isLogPings() )
+ // FlameCord - Option to log initialhandler
+ if ( bungee.getConfig().isLogPings() && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() )
{
bungee.getLogger().log( Level.INFO, "{0} has pinged", this );
}
@@ -405,7 +406,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
break;
case 2:
// Login
- if (BungeeCord.getInstance().getConfig().isLogInitialHandlerConnections() ) // Waterfall
+ // FlameCord - Option to log initialhandler
+ if (BungeeCord.getInstance().getConfig().isLogInitialHandlerConnections() && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() ) // Waterfall
{
bungee.getLogger().log( Level.INFO, "{0} has connected", this );
}
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
index 694ecdb01..14e3004fc 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
@@ -46,7 +46,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
channel = new ChannelWrapper( ctx );
handler.connected( channel );
- if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
+ // FlameCord - Option to log initialhandler
+ if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler );
}
@@ -61,7 +62,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
channel.markClosed();
handler.disconnected( channel );
- if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
+ // FlameCord - Option to log initialhandler
+ if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler );
}
@@ -98,10 +100,12 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{
InetSocketAddress newAddress = new InetSocketAddress( proxy.sourceAddress(), proxy.sourcePort() );
- ProxyServer.getInstance().getLogger().log( Level.FINE, "Set remote address via PROXY {0} -> {1}", new Object[]
- {
- channel.getRemoteAddress(), newAddress
- } );
+ // FlameCord - Option to log haproxy
+ if ( FlameCord.getInstance().getFlameCordConfiguration().isLoggerHaProxy() )
+ ProxyServer.getInstance().getLogger().log( Level.FINE, "Set remote address via PROXY {0} -> {1}", new Object[]
+ {
+ channel.getRemoteAddress(), newAddress
+ } );
channel.setRemoteAddress( newAddress );
}
@@ -146,6 +150,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{
boolean logExceptions = !( handler instanceof PingHandler );
+ // FlameCord - Option to log exceptions
+ logExceptions = FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions() ? logExceptions : false;
+
if ( logExceptions )
{
if ( cause instanceof ReadTimeoutException )
--
2.37.3.windows.1

View File

@ -0,0 +1,86 @@
From 664f35c5a6155c5e41aa10d1cd15cf590cc011a0 Mon Sep 17 00:00:00 2001
From: abhiram <abhithegamer2019@gmail.com>
Date: Thu, 13 May 2021 01:05:03 +0530
Subject: [PATCH] Added an api method to unload Plugins
Format Code to Bungee's code style
diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
index 90031156f..a190dfae8 100644
--- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
+++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
@@ -25,6 +25,7 @@ import java.util.Set;
import java.util.Stack;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
+import java.util.logging.Handler;
import java.util.logging.Level;
import io.github.waterfallmc.waterfall.event.ProxyExceptionEvent; // Waterfall
import io.github.waterfallmc.waterfall.exception.ProxyCommandException; // Waterfall
@@ -63,6 +64,7 @@ public final class PluginManager
private Map<String, PluginDescription> toLoad = new HashMap<>();
private final Multimap<Plugin, Command> commandsByPlugin = ArrayListMultimap.create();
private final Multimap<Plugin, Listener> listenersByPlugin = ArrayListMultimap.create();
+ private final HashMap<String,URLClassLoader> pluginloaders = new HashMap<>();
@SuppressWarnings("unchecked")
public PluginManager(ProxyServer proxy)
@@ -291,6 +293,45 @@ public final class PluginManager
return plugins.get( name );
}
+
+ /**
+ * This will Unload the given plugin
+ *
+ * @param plugin to unload
+ */
+ // FlameCord start - Adds a method to unload plugin from proxy
+ public void unloadPlugin(Plugin plugin)
+ {
+ plugin.onDisable();
+ this.unregisterListeners( plugin );
+ this.unregisterCommands( plugin );
+ this.proxy.getScheduler().cancel( plugin );
+
+ for ( Handler handler : plugin.getLogger().getHandlers() )
+ {
+ handler.close();
+ }
+
+ try
+ {
+ pluginloaders.get( plugin.getDescription().getName() ).close();
+ }catch (Exception exception)
+ {
+ exception.printStackTrace();
+ }
+
+ if( this.plugins.containsKey( plugin.getDescription().getName() ) )
+ {
+ this.plugins.remove( plugin.getDescription().getName() );
+ }
+
+ if( this.pluginloaders.containsKey( plugin.getDescription().getName() ) )
+ {
+ this.pluginloaders.remove( plugin.getDescription().getName() );
+ }
+ }
+ // FlameCord end
+
public void loadPlugins()
{
Map<PluginDescription, Boolean> pluginStatuses = new HashMap<>();
@@ -395,6 +436,9 @@ public final class PluginManager
Plugin clazz = (Plugin) main.getDeclaredConstructor().newInstance();
plugins.put( plugin.getName(), clazz );
+ // FlameCord start - cache url classloaders to unload plugins
+ pluginloaders.put( plugin.getName(),loader );
+ // FlameCord end
clazz.onLoad();
ProxyServer.getInstance().getLogger().log( Level.INFO, "Loaded plugin {0} version {1} by {2}", new Object[]
{
--
2.37.3.windows.1

View File

@ -0,0 +1,69 @@
From 2caae71d8c0bdc5a325610ef1c77775f9ba4ee69 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 10 Jun 2021 11:30:19 -0300
Subject: [PATCH] Apply packet limits
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java
index e78519964..222285cc1 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java
@@ -61,4 +61,14 @@ public class EncryptionRequest extends DefinedPacket
{
handler.handle( this );
}
+
+ @Override
+ public int expectedMaxLength(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
+ return 20 + 256 + 256; // FlameCord - Apply packet limits
+ }
+
+ @Override
+ public int expectedMinLength(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
+ return 20 + 1 + 1; // FlameCord - Apply packet limits
+ }
}
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java
index 7dbbfd3cd..b78420556 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Handshake.java
@@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.DefinedPacket;
+import net.md_5.bungee.protocol.ProtocolConstants;
@Data
@NoArgsConstructor
@@ -43,4 +44,14 @@ public class Handshake extends DefinedPacket
{
handler.handle( this );
}
+
+ @Override
+ public int expectedMaxLength(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
+ return 1036 + 256; // FlameCord - Apply packet limits
+ }
+
+ @Override
+ public int expectedMinLength(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
+ return 5; // FlameCord - Apply packet limits
+ }
}
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java
index 3224b0d2b..763d34c2f 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java
@@ -70,7 +70,8 @@ public class LoginRequest extends DefinedPacket
public int expectedMaxLength(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
// Accommodate the rare (but likely malicious) use of UTF-8 usernames, since it is technically
// legal on the protocol level.
- if (protocolVersion >= ProtocolConstants.MINECRAFT_1_19) return -1;
+ // FlameCord - Apply packet limits
+ if (protocolVersion >= ProtocolConstants.MINECRAFT_1_19) return 1 + (16 * 4) + 1024;
return 1 + (16 * 4);
}
// Waterfall end
--
2.37.3.windows.1

View File

@ -0,0 +1,676 @@
From 2072d8d33f059abfdb95c16158792887f3f701d3 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
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 b563cbced..b41ee92cc 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -2,15 +2,94 @@ package dev._2lstudios.flamecord.configuration;
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import dev._2lstudios.flamecord.utils.ColorUtil;
import lombok.Getter;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration extends FlameConfig {
+ public String getMOTD(int maxPlayers, int onlinePlayers, int protocol) {
+ String motd;
+
+ if (protocol >= 735) {
+ motd = hexMotds.get(new Random().nextInt(hexMotds.size()));
+ } else {
+ motd = motds.get(new Random().nextInt(motds.size()));
+ }
+
+ motd = motd.replace("%maxplayers%", String.valueOf(maxPlayers)).replace("%onlineplayers%", String.valueOf(onlinePlayers));
+
+ return motd;
+ }
+
+ public String[] getSample(int maxPlayers, int onlinePlayers, int protocol) {
+ String sample;
+
+ if (protocol >= 735) {
+ sample = hexSamples.get(new Random().nextInt(hexSamples.size()));
+ } else {
+ sample = samples.get(new Random().nextInt(samples.size()));
+ }
+
+ sample = sample.replace("%maxplayers%", String.valueOf(maxPlayers)).replace("%onlineplayers%", String.valueOf(onlinePlayers));
+
+ return sample.split("\n");
+ }
+
+ public String getProtocolName(int maxPlayers, int onlinePlayers) {
+ return protocolName.replace("%maxplayers%", String.valueOf(maxPlayers)).replace("%onlineplayers%", String.valueOf(onlinePlayers));
+ }
+
+ public int getFakePlayersAmount(final int players) {
+ switch (fakePlayersMode) {
+ case "STATIC":
+ return fakePlayersAmount;
+ case "RANDOM":
+ return (int) (Math.floor(Math.random() * fakePlayersAmount) + 1);
+ case "DIVISION":
+ return players / fakePlayersAmount;
+ default:
+ return 0;
+ }
+ }
+
+ @Getter
+ private boolean motdEnabled = false;
+ private List<String> motds = Collections.singletonList("&eDefault &cFlameCord&e server &7(%onlineplayers%/%maxplayers%)\n&eEdit on &cflamecord.yml&7 (IridiumColorAPI HEX)");
+ private List<String> hexMotds;
+
+ @Getter
+ private boolean sampleEnabled = false;
+ private List<String> samples = Collections.singletonList("&eDefault &cFlameCord&e server &7(%onlineplayers%/%maxplayers%)\n&eEdit on &cflamecord.yml&7 (IridiumColorAPI HEX)");
+ private List<String> hexSamples;
+
+ @Getter
+ private boolean protocolEnabled = false;
+ @Getter
+ private String protocolName = "&c&lMaintenance";
+ @Getter
+ private boolean protocolAlwaysShow = false;
+
+ @Getter
+ private boolean maxPlayersEnabled = false;
+ @Getter
+ private int maxPlayersAmount = 1000;
+ @Getter
+ private boolean maxPlayersOneMore = false;
+
+ @Getter
+ private boolean fakePlayersEnabled = false;
+ @Getter
+ private int fakePlayersAmount = 3;
+ private String fakePlayersMode = "DIVISION";
+
@Getter
private boolean loggerInitialhandler = false;
@Getter
@@ -32,6 +111,22 @@ public class FlameCordConfiguration extends FlameConfig {
this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration);
this.loggerDetailedConnection = setIfUnexistant("logger.detailed-connect-errors", this.loggerDetailedConnection, configuration);
+ this.motdEnabled = setIfUnexistant("custom-motd.motd.enabled", this.motdEnabled, configuration);
+ this.hexMotds = ColorUtil.hexColor(new ArrayList<>(setIfUnexistant("custom-motd.motd.motds", this.motds, configuration)), 735);
+ this.motds = ColorUtil.hexColor(new ArrayList<>(setIfUnexistant("custom-motd.motd.motds", this.motds, configuration)), 734);
+ this.sampleEnabled = setIfUnexistant("custom-motd.sample.enabled", this.sampleEnabled, configuration);
+ this.hexSamples = ColorUtil.hexColor(new ArrayList<>(setIfUnexistant("custom-motd.sample.samples", this.samples, configuration)), 735);
+ 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);
+ 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);
+
save(configuration, configurationFile);
}
}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/ColorUtil.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/ColorUtil.java
new file mode 100644
index 000000000..9587bccda
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/ColorUtil.java
@@ -0,0 +1,48 @@
+package dev._2lstudios.flamecord.utils;
+
+import java.util.List;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.IridiumColorAPI;
+import net.md_5.bungee.api.ChatColor;
+
+public class ColorUtil {
+ public static String color(String text) {
+ return ChatColor.translateAlternateColorCodes('&', text);
+ }
+
+ public static List<String> color(final List<String> texts) {
+ for (int i = 0; i < texts.size(); i++) {
+ texts.set(i, color(texts.get(i)));
+ }
+
+ return texts;
+ }
+
+ public static String hex(String text, int protocol) {
+ if (text == null) {
+ return text;
+ }
+
+ return IridiumColorAPI.process(text, protocol);
+ }
+
+ public static String hexColor(String text, int protocol) {
+ if (text != null) {
+ text = color(text);
+
+ if (text != null) {
+ text = hex(text, protocol);
+ }
+ }
+
+ return text;
+ }
+
+ public static List<String> hexColor(final List<String> texts, int protocol) {
+ for (int i = 0; i < texts.size(); i++) {
+ texts.set(i, hexColor(texts.get(i), protocol));
+ }
+
+ return texts;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/IridiumColorAPI.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/IridiumColorAPI.java
new file mode 100644
index 000000000..6c386e16f
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/IridiumColorAPI.java
@@ -0,0 +1,275 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi;
+
+import java.awt.Color;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import javax.annotation.Nonnull;
+
+import com.google.common.collect.ImmutableMap;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns.GradientPattern;
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns.Pattern;
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns.RainbowPattern;
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns.SolidPattern;
+import net.md_5.bungee.api.ChatColor;
+
+public class IridiumColorAPI {
+
+ /**
+ * Cached result if the server version is after the v1.16 RGB update.
+ *
+ * @since 1.0.0
+ */
+ private static final boolean SUPPORTS_RGB(int protocol) {
+ return protocol >= 735;
+ }
+
+ private static final List<String> SPECIAL_COLORS = Arrays.asList("&l", "&n", "&o", "&k", "&m", "§l", "§n", "§o", "§k", "§m");
+
+ /**
+ * Cached result of all legacy colors.
+ *
+ * @since 1.0.0
+ */
+ private static final Map<Color, ChatColor> COLORS = ImmutableMap.<Color, ChatColor>builder()
+ .put(new Color(0), ChatColor.getByChar('0'))
+ .put(new Color(170), ChatColor.getByChar('1'))
+ .put(new Color(43520), ChatColor.getByChar('2'))
+ .put(new Color(43690), ChatColor.getByChar('3'))
+ .put(new Color(11141120), ChatColor.getByChar('4'))
+ .put(new Color(11141290), ChatColor.getByChar('5'))
+ .put(new Color(16755200), ChatColor.getByChar('6'))
+ .put(new Color(11184810), ChatColor.getByChar('7'))
+ .put(new Color(5592405), ChatColor.getByChar('8'))
+ .put(new Color(5592575), ChatColor.getByChar('9'))
+ .put(new Color(5635925), ChatColor.getByChar('a'))
+ .put(new Color(5636095), ChatColor.getByChar('b'))
+ .put(new Color(16733525), ChatColor.getByChar('c'))
+ .put(new Color(16733695), ChatColor.getByChar('d'))
+ .put(new Color(16777045), ChatColor.getByChar('e'))
+ .put(new Color(16777215), ChatColor.getByChar('f')).build();
+
+ /**
+ * Cached result of patterns.
+ *
+ * @since 1.0.2
+ */
+ private static final List<Pattern> PATTERNS = Arrays.asList(new GradientPattern(), new SolidPattern(), new RainbowPattern());
+
+ /**
+ * Processes a string to add color to it.
+ * Thanks to Distressing for helping with the regex <3
+ *
+ * @param string The string we want to process
+ * @since 1.0.0
+ */
+ @Nonnull
+ public static String process(@Nonnull String string, int protocol) {
+ for (Pattern pattern : PATTERNS) {
+ string = pattern.process(string, protocol);
+ }
+
+ string = ChatColor.translateAlternateColorCodes('&', string);
+ return string;
+ }
+
+ /**
+ * Processes multiple strings in a collection.
+ *
+ * @param strings The collection of the strings we are processing
+ * @return The list of processed strings
+ * @since 1.0.3
+ */
+ @Nonnull
+ public static List<String> process(@Nonnull Collection<String> strings, int protocol) {
+ return strings.stream()
+ .map(s -> IridiumColorAPI.process(s, protocol))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Colors a String.
+ *
+ * @param string The string we want to color
+ * @param color The color we want to set it to
+ * @since 1.0.0
+ */
+ @Nonnull
+ public static String color(@Nonnull String string, @Nonnull Color color, int protocol) {
+ return (SUPPORTS_RGB(protocol) ? ChatColor.of(color) : getClosestColor(color)) + string;
+ }
+
+ /**
+ * Colors a String with a gradiant.
+ *
+ * @param string The string we want to color
+ * @param start The starting gradiant
+ * @param end The ending gradiant
+ * @since 1.0.0
+ */
+ @Nonnull
+ public static String color(@Nonnull String string, @Nonnull Color start, @Nonnull Color end, int protocol) {
+ String originalString = string;
+
+ ChatColor[] colors = createGradient(start, end, withoutSpecialChar(string).length(), protocol);
+ return apply(originalString, colors);
+ }
+
+ /**
+ * Colors a String with rainbow colors.
+ *
+ * @param string The string which should have rainbow colors
+ * @param saturation The saturation of the rainbow colors
+ * @since 1.0.3
+ */
+ @Nonnull
+ public static String rainbow(@Nonnull String string, float saturation, int protocol) {
+ String originalString = string;
+
+ ChatColor[] colors = createRainbow(withoutSpecialChar(string).length(), saturation, protocol);
+ return apply(originalString, colors);
+ }
+
+ /**
+ * Gets a color from hex code.
+ *
+ * @param string The hex code of the color
+ * @since 1.0.0
+ */
+ @Nonnull
+ public static ChatColor getColor(@Nonnull String string, int protocol) {
+ return SUPPORTS_RGB(protocol) ? ChatColor.of(new Color(Integer.parseInt(string, 16)))
+ : getClosestColor(new Color(Integer.parseInt(string, 16)));
+ }
+
+ /**
+ * Removes all color codes from the provided String, including IridiumColorAPI
+ * patterns.
+ *
+ * @param string The String which should be stripped
+ * @return The stripped string without color codes
+ * @since 1.0.5
+ */
+ @Nonnull
+ public static String stripColorFormatting(@Nonnull String string) {
+ return string.replaceAll("<#[0-9A-F]{6}>|[&§][a-f0-9lnokm]|<[/]?[A-Z]{5,8}(:[0-9A-F]{6})?[0-9]*>", "");
+ }
+
+ @Nonnull
+ private static String apply(@Nonnull String source, ChatColor[] colors) {
+ StringBuilder specialColors = new StringBuilder();
+ StringBuilder stringBuilder = new StringBuilder();
+ String[] characters = source.split("");
+ int outIndex = 0;
+ for (int i = 0; i < characters.length; i++) {
+ if (characters[i].equals("&") || characters[i].equals("§")) {
+ if (i + 1 < characters.length) {
+ if (characters[i + 1].equals("r")) {
+ specialColors.setLength(0);
+ } else {
+ specialColors.append(characters[i]);
+ specialColors.append(characters[i + 1]);
+ }
+ i++;
+ } else
+ stringBuilder.append(colors[outIndex++]).append(specialColors).append(characters[i]);
+ } else
+ stringBuilder.append(colors[outIndex++]).append(specialColors).append(characters[i]);
+ }
+ return stringBuilder.toString();
+ }
+
+ @Nonnull
+ private static String withoutSpecialChar(@Nonnull String source) {
+ String workingString = source;
+ for (String color : SPECIAL_COLORS) {
+ if (workingString.contains(color)) {
+ workingString = workingString.replace(color, "");
+ }
+ }
+ return workingString;
+ }
+
+ /**
+ * Returns a rainbow array of chat colors.
+ *
+ * @param step How many colors we return
+ * @param saturation The saturation of the rainbow
+ * @return The array of colors
+ * @since 1.0.3
+ */
+ @Nonnull
+ private static ChatColor[] createRainbow(int step, float saturation, int protocol) {
+ ChatColor[] colors = new ChatColor[step];
+ double colorStep = (1.00 / step);
+
+ for (int i = 0; i < step; i++) {
+ Color color = Color.getHSBColor((float) (colorStep * i), saturation, saturation);
+ if (SUPPORTS_RGB(protocol)) {
+ colors[i] = ChatColor.of(color);
+ } else {
+ colors[i] = getClosestColor(color);
+ }
+ }
+
+ return colors;
+ }
+
+ /**
+ * Returns a gradient array of chat colors.
+ *
+ * @param start The starting color.
+ * @param end The ending color.
+ * @param step How many colors we return.
+ * @author TheViperShow
+ * @since 1.0.0
+ */
+ @Nonnull
+ private static ChatColor[] createGradient(@Nonnull Color start, @Nonnull Color end, int step, int protocol) {
+ ChatColor[] colors = new ChatColor[step];
+ int stepR = Math.abs(start.getRed() - end.getRed()) / (step - 1);
+ int stepG = Math.abs(start.getGreen() - end.getGreen()) / (step - 1);
+ int stepB = Math.abs(start.getBlue() - end.getBlue()) / (step - 1);
+ int[] direction = new int[] {
+ start.getRed() < end.getRed() ? +1 : -1,
+ start.getGreen() < end.getGreen() ? +1 : -1,
+ start.getBlue() < end.getBlue() ? +1 : -1
+ };
+
+ for (int i = 0; i < step; i++) {
+ Color color = new Color(start.getRed() + ((stepR * i) * direction[0]), start.getGreen() + ((stepG * i) * direction[1]), start.getBlue() + ((stepB * i) * direction[2]));
+ if (SUPPORTS_RGB(protocol)) {
+ colors[i] = ChatColor.of(color);
+ } else {
+ colors[i] = getClosestColor(color);
+ }
+ }
+
+ return colors;
+ }
+
+ /**
+ * Returns the closest legacy color from an rgb color
+ *
+ * @param color The color we want to transform
+ * @since 1.0.0
+ */
+ @Nonnull
+ private static ChatColor getClosestColor(Color color) {
+ Color nearestColor = null;
+ double nearestDistance = Integer.MAX_VALUE;
+
+ for (Color constantColor : COLORS.keySet()) {
+ double distance = Math.pow(color.getRed() - constantColor.getRed(), 2) + Math.pow(color.getGreen() - constantColor.getGreen(), 2) + Math.pow(color.getBlue() - constantColor.getBlue(), 2);
+ if (nearestDistance > distance) {
+ nearestColor = constantColor;
+ nearestDistance = distance;
+ }
+ }
+ return COLORS.get(nearestColor);
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/GradientPattern.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/GradientPattern.java
new file mode 100644
index 000000000..c1f05cd0a
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/GradientPattern.java
@@ -0,0 +1,33 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns;
+
+import java.awt.*;
+import java.util.regex.Matcher;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.IridiumColorAPI;
+
+/**
+ * Represents a gradient color pattern which can be applied to a String.
+ */
+public class GradientPattern implements Pattern {
+
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("<GRADIENT:([0-9A-Fa-f]{6})>(.*?)</GRADIENT:([0-9A-Fa-f]{6})>");
+
+ /**
+ * Applies a gradient pattern to the provided String.
+ * Output might me the same as the input if this pattern is not present.
+ *
+ * @param string The String to which this pattern should be applied to
+ * @return The new String with applied pattern
+ */
+ public String process(String string, int protocol) {
+ Matcher matcher = pattern.matcher(string);
+ while (matcher.find()) {
+ String start = matcher.group(1);
+ String end = matcher.group(3);
+ String content = matcher.group(2);
+ string = string.replace(matcher.group(), IridiumColorAPI.color(content, new Color(Integer.parseInt(start, 16)), new Color(Integer.parseInt(end, 16)), protocol));
+ }
+ return string;
+ }
+
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/Pattern.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/Pattern.java
new file mode 100644
index 000000000..5457ead64
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/Pattern.java
@@ -0,0 +1,17 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns;
+
+/**
+ * Represents a color pattern which can be applied to a String.
+ */
+public interface Pattern {
+
+ /**
+ * Applies this pattern to the provided String.
+ * Output might me the same as the input if this pattern is not present.
+ *
+ * @param string The String to which this pattern should be applied to
+ * @return The new String with applied pattern
+ */
+ String process(String string, int protocol);
+
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/RainbowPattern.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/RainbowPattern.java
new file mode 100644
index 000000000..792e9f987
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/RainbowPattern.java
@@ -0,0 +1,28 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns;
+
+import java.util.regex.Matcher;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.IridiumColorAPI;
+
+public class RainbowPattern implements Pattern {
+
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("<RAINBOW([0-9]{1,3})>(.*?)</RAINBOW>");
+
+ /**
+ * Applies a rainbow pattern to the provided String.
+ * Output might me the same as the input if this pattern is not present.
+ *
+ * @param string The String to which this pattern should be applied to
+ * @return The new String with applied pattern
+ */
+ public String process(String string, int protocol) {
+ Matcher matcher = pattern.matcher(string);
+ while (matcher.find()) {
+ String saturation = matcher.group(1);
+ String content = matcher.group(2);
+ string = string.replace(matcher.group(), IridiumColorAPI.rainbow(content, Float.parseFloat(saturation), protocol));
+ }
+ return string;
+ }
+
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/SolidPattern.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/SolidPattern.java
new file mode 100644
index 000000000..0b039c797
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/SolidPattern.java
@@ -0,0 +1,29 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns;
+
+import java.util.regex.Matcher;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.IridiumColorAPI;
+
+public class SolidPattern implements Pattern {
+
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("<SOLID:([0-9A-Fa-f]{6})>|#\\{([0-9A-Fa-f]{6})}");
+
+ /**
+ * Applies a solid RGB color to the provided String.
+ * Output might me the same as the input if this pattern is not present.
+ *
+ * @param string The String to which this pattern should be applied to
+ * @return The new String with applied pattern
+ */
+ public String process(String string, int protocol) {
+ Matcher matcher = pattern.matcher(string);
+ while (matcher.find()) {
+ String color = matcher.group(1);
+ if (color == null) color = matcher.group(2);
+
+ string = string.replace(matcher.group(), IridiumColorAPI.getColor(color, protocol) + "");
+ }
+ return string;
+ }
+
+}
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 66a347542..58be68b02 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;
import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.configuration.FlameConfig;
+import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.BungeeCord;
@@ -275,7 +277,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
Preconditions.checkState( thisState == State.STATUS, "Not expecting STATUS" );
ServerInfo forced = AbstractReconnectHandler.getForcedHost( this );
- final String motd = ( forced != null ) ? forced.getMotd() : listener.getMotd();
final int protocol = ( ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion();
Callback<ServerPing> pingBack = new Callback<ServerPing>()
@@ -338,7 +339,56 @@ public class InitialHandler extends PacketHandler implements PendingConnection
( (BungeeServerInfo) forced ).ping( pingBack, handshake.getProtocolVersion() );
} else
{
- pingBack.done( getPingInfo( motd, protocol ), null );
+ // FlameCord - Custom motd system
+ // Get the configuration
+ final FlameCordConfiguration config = FlameCord.getInstance().getFlameCordConfiguration();
+
+ String motd;
+ String protocolName;
+
+ ServerPing.PlayerInfo[] sample = null;
+
+ int maxPlayers = listener.getMaxPlayers();
+ int onlinePlayers = bungee.getOnlineCount();
+
+ if (config.isFakePlayersEnabled()) {
+ onlinePlayers += config.getFakePlayersAmount(onlinePlayers);
+ }
+
+ if (config.isMaxPlayersEnabled()) {
+ maxPlayers = config.isMaxPlayersOneMore() ? onlinePlayers + 1 : config.getMaxPlayersAmount();
+ }
+
+ if (config.isMotdEnabled()) {
+ motd = config.getMOTD(maxPlayers, onlinePlayers, protocol);
+ } else {
+ motd = ( forced != null ) ? forced.getMotd() : listener.getMotd();
+ }
+
+ if (config.isProtocolEnabled()) {
+ protocolName = config.getProtocolName(maxPlayers, onlinePlayers);
+ } else {
+ 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);
+
+ sample = new ServerPing.PlayerInfo[sampleString.length];
+
+ for (int i = 0; i < sampleString.length; i++) {
+ sample[i] = new ServerPing.PlayerInfo(sampleString[i], fakeUuid);
+ }
+ }
+
+ pingBack.done( new ServerPing(
+ 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;
--
2.37.3.windows.1

View File

@ -0,0 +1,46 @@
From 62bf8051431b5035171c900d729a1c175fcda639 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 b41ee92cc..14665b1f6 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -15,6 +15,10 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration extends FlameConfig {
+ // FlameCord - TCP Fast Open
+ @Getter
+ private int tcpFastOpen = 3;
+
public String getMOTD(int maxPlayers, int onlinePlayers, int protocol) {
String motd;
@@ -127,6 +131,8 @@ public class FlameCordConfiguration extends FlameConfig {
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);
+ this.tcpFastOpen = setIfUnexistant("tcp-fast-open", this.tcpFastOpen, configuration);
+
save(configuration, configurationFile);
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
index a4c3bd710..ffea15992 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
@@ -194,6 +194,8 @@ public class PipelineUtils
// IP_TOS is not supported (Windows XP / Windows Server 2003)
}
ch.config().setOption( ChannelOption.TCP_NODELAY, true );
+ // FlameCord - TCP Fast Open
+ ch.config().setOption( ChannelOption.TCP_FASTOPEN, FlameCord.getInstance().getFlameCordConfiguration().getTcpFastOpen() );
ch.config().setAllocator( PooledByteBufAllocator.DEFAULT );
ch.config().setWriteBufferWaterMark( MARK );
--
2.37.3.windows.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
From 1e3a2975964623026cc90326efc27ccafb47ae51 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 0f12f4ae6..6f463b9c6 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -15,6 +15,10 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration extends FlameConfig {
+ // FlameCord - Allow Invalid Names
+ @Getter
+ private boolean allowInvalidNames = false;
+
// Antibot accounts
@Getter
private boolean antibotAccountsEnabled = true;
@@ -317,6 +321,9 @@ public class FlameCordConfiguration extends FlameConfig {
// FlameCord - Antibot System
loadAntibot(configuration, whitelistedAddresses);
+ // FlameCord - Allow Invalid Names
+ this.allowInvalidNames = setIfUnexistant("allow-invalid-names", this.allowInvalidNames, configuration);
+
save(configuration, configurationFile);
}
}
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 b88e64526..e8c14c552 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
@@ -528,7 +528,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" );
- if ( !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) )
+ if ( !FlameCord.getInstance().getFlameCordConfiguration().isAllowInvalidNames() && !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) )
{
disconnect( bungee.getTranslation( "name_invalid" ) );
return;
--
2.37.3.windows.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
From c3a0de08b9d4d728fe488f5d3b83e19e2766f6ae Mon Sep 17 00:00:00 2001
From: xIsm4 <minelatinsoporte@gmail.com>
Date: Thu, 4 Aug 2022 23:27:43 +0200
Subject: [PATCH] Dont frame unreadable connections
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
index aa538f74..99d203c7 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
@@ -33,7 +33,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
{
// See Varint21FrameDecoder for the general reasoning. We add this here as ByteToMessageDecoder#handlerRemoved()
// will fire any cumulated data through the pipeline, so we want to try and stop it here.
- if ( !ctx.channel().isActive() )
+ if ( !ctx.channel().isActive() || !in.isReadable() ) // FlameCord - Check if connection is readable
{
return;
}
--
2.37.3.windows.1

View File

@ -0,0 +1,23 @@
From 8a2c6364c6c2e36eaa918195ca370382a37debee Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Tue, 13 Sep 2022 20:41:48 -0300
Subject: [PATCH] Avoid throwing IOOB on login
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java
index 763d34c2..57e50a8b 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginRequest.java
@@ -32,7 +32,8 @@ public class LoginRequest extends DefinedPacket
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
{
- if ( buf.readBoolean() )
+ // FlameCord - Avoid throwing IOOB on login
+ if ( buf.isReadable() && buf.readBoolean() )
{
uuid = readUUID( buf );
}
--
2.37.3.windows.1

View File

@ -0,0 +1,26 @@
From 981d25c1f3b03e1c2f10427811c7690c64c2e967 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Tue, 15 Nov 2022 18:07:27 +0100
Subject: [PATCH] Only show connection fail reason when detailed logger is
enabled
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
index f3d60253..021fe839 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -405,8 +405,10 @@ public final class UserConnection implements ProxiedPlayer
// FlameCord - Allow for toggle the logging of connection failures
if(FlameCord.getInstance().getFlameCordConfiguration().isLoggerDetailedConnection()) {
bungee.getLogger().log(Level.WARNING, "Error occurred processing connection for " + this.name + " " + Util.exception(cause, false)); // Waterfall
+ // FlameCord - Show connection fail reason
+ return groups.contains( "admin" ) ? cause.getMessage() : cause.getClass().getName();
}
- return ""; // Waterfall
+ return cause.getClass().getName(); // FlameCord
}
@Override
--
2.37.3.windows.1

View File

@ -0,0 +1,60 @@
From 69f3e68d5a12bcaf0423d2c18da6b51a8d38d998 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Wed, 28 Dec 2022 14:23:54 -0300
Subject: [PATCH] Optimize Decoder/Encoder Getter
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
index 6f1d8336..b98ee6a7 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
@@ -31,26 +31,42 @@ public class ChannelWrapper
@Getter
private volatile boolean closing;
+ // FlameCord start - Optimize Decoder/Encoder Getter
+ MinecraftDecoder decoder;
+ MinecraftEncoder encoder;
+ // FlameCord end - Optimize Decoder/Encoder Getter
+
public ChannelWrapper(ChannelHandlerContext ctx)
{
this.ch = ctx.channel();
this.remoteAddress = ( this.ch.remoteAddress() == null ) ? this.ch.parent().localAddress() : this.ch.remoteAddress();
+
+ // FlameCord start - Optimize Decoder/Encoder Getter
+ this.decoder = (MinecraftDecoder) ch.pipeline().get( PipelineUtils.PACKET_DECODER );
+ this.encoder = (MinecraftEncoder) ch.pipeline().get( PipelineUtils.PACKET_ENCODER );
+ // FlameCord end - Optimize Decoder/Encoder Getter
}
public void setProtocol(Protocol protocol)
{
// FlameCord - Use pipeline to reduce redundancy
final ChannelPipeline pipeline = ch.pipeline();
- pipeline.get( MinecraftDecoder.class ).setProtocol( protocol );
- pipeline.get( MinecraftEncoder.class ).setProtocol( protocol );
+
+ // FlameCord start - Optimize Decoder/Encoder Getter
+ decoder.setProtocol( protocol );
+ encoder.setProtocol( protocol );
+ // FlameCord end - Optimize Decoder/Encoder Getter
}
public void setVersion(int protocol)
{
// FlameCord - Use pipeline to reduce redundancy
final ChannelPipeline pipeline = ch.pipeline();
- pipeline.get( MinecraftDecoder.class ).setProtocolVersion( protocol );
- pipeline.get( MinecraftEncoder.class ).setProtocolVersion( protocol );
+
+ // FlameCord start - Optimize Decoder/Encoder Getter
+ decoder.setProtocolVersion( protocol );
+ encoder.setProtocolVersion( protocol );
+ // FlameCord end - Optimize Decoder/Encoder Getter
}
public void write(Object packet)
--
2.37.3.windows.1

View File

@ -0,0 +1,134 @@
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
diff --git a/chat/src/main/java/net/md_5/bungee/api/chat/TextComponent.java b/chat/src/main/java/net/md_5/bungee/api/chat/TextComponent.java
index 4371374a..2bb27e67 100644
--- a/chat/src/main/java/net/md_5/bungee/api/chat/TextComponent.java
+++ b/chat/src/main/java/net/md_5/bungee/api/chat/TextComponent.java
@@ -160,6 +160,107 @@ public final class TextComponent extends BaseComponent
return components.toArray( new BaseComponent[ 0 ] );
}
+ // FlameCord start - Dont Process Links For Kick Messages
+ public static BaseComponent[] fromLegacyTextFast(String message)
+ {
+ return fromLegacyTextFast( message, ChatColor.WHITE );
+ }
+
+ public static BaseComponent[] fromLegacyTextFast(String message, ChatColor defaultColor)
+ {
+ ArrayList<BaseComponent> components = new ArrayList<>();
+ StringBuilder builder = new StringBuilder();
+ TextComponent component = new TextComponent();
+
+ for ( int i = 0; i < message.length(); i++ )
+ {
+ char c = message.charAt( i );
+ if ( c == ChatColor.COLOR_CHAR )
+ {
+ if ( ++i >= message.length() )
+ {
+ break;
+ }
+ c = message.charAt( i );
+ if ( c >= 'A' && c <= 'Z' )
+ {
+ c += 32;
+ }
+ ChatColor format;
+ if ( c == 'x' && i + 12 < message.length() )
+ {
+ StringBuilder hex = new StringBuilder( "#" );
+ for ( int j = 0; j < 6; j++ )
+ {
+ hex.append( message.charAt( i + 2 + ( j * 2 ) ) );
+ }
+ try
+ {
+ format = ChatColor.of( hex.toString() );
+ } catch ( IllegalArgumentException ex )
+ {
+ format = null;
+ }
+
+ i += 12;
+ } else
+ {
+ format = ChatColor.getByChar( c );
+ }
+ if ( format == null )
+ {
+ continue;
+ }
+ if ( builder.length() > 0 )
+ {
+ TextComponent old = component;
+ component = new TextComponent( old );
+ old.setText( builder.toString() );
+ builder = new StringBuilder();
+ components.add( old );
+ }
+ if ( format == ChatColor.BOLD )
+ {
+ component.setBold( true );
+ } else if ( format == ChatColor.ITALIC )
+ {
+ component.setItalic( true );
+ } else if ( format == ChatColor.UNDERLINE )
+ {
+ component.setUnderlined( true );
+ } else if ( format == ChatColor.STRIKETHROUGH )
+ {
+ component.setStrikethrough( true );
+ } else if ( format == ChatColor.MAGIC )
+ {
+ component.setObfuscated( true );
+ } else
+ {
+ if ( format == ChatColor.RESET )
+ {
+ format = defaultColor;
+ }
+ component = new TextComponent();
+ component.setColor( format );
+ component.setReset( true );
+ }
+ continue;
+ }
+ int pos = message.indexOf( ' ', i );
+ if ( pos == -1 )
+ {
+ pos = message.length();
+ }
+ builder.append( c );
+ }
+
+ component.setText( builder.toString() );
+ components.add( component );
+
+ return components.toArray( new BaseComponent[ 0 ] );
+ }
+ // FlameCord end - Dont Process Links For Kick Messages
+
/**
* 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 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
@@ -833,7 +833,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
if ( canSendKickMessage() )
{
- disconnect( TextComponent.fromLegacyText( reason ) );
+ disconnect( TextComponent.fromLegacyTextFast( reason ) ); // FlameCord - Dont Process Links For Kick Messages
} else
{
ch.close();
--
2.37.3.windows.1

View File

@ -0,0 +1,97 @@
From f37bca815bffe22461c5b2760596ef18d56a1070 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Wed, 11 Jan 2023 10:14:12 -0300
Subject: [PATCH] Bungee Plugins Command
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
index 6175d8e2d..2ea33a94b 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
@@ -96,6 +96,11 @@ public class MessagesConfiguration extends FlameConfig {
setIfUnexistant("flamecord_firewall_remove", "&cThe ip {0} was removed from the firewall!", configuration);
// FlameCord end - Antibot System
+ // FlameCord - Bungee Plugins Command
+ setIfUnexistant("flamecord_bplugins_nopermission", "&cYou don't have permission to do this!", configuration);
+ setIfUnexistant("flamecord_bplugins_separator", ", ", configuration);
+ setIfUnexistant("flamecord_bplugins_header", "&aPlugins ({0}): ", configuration);
+
for (final String key : configuration.getKeys()) {
final Object value = configuration.get(key);
diff --git a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/BungeePluginsCommand.java b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/BungeePluginsCommand.java
new file mode 100644
index 000000000..2e20e9dca
--- /dev/null
+++ b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/BungeePluginsCommand.java
@@ -0,0 +1,45 @@
+package dev._2lstudios.flamecord.commands;
+
+import java.util.Collection;
+
+import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
+import net.md_5.bungee.BungeeCord;
+import net.md_5.bungee.api.CommandSender;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.plugin.Command;
+import net.md_5.bungee.api.plugin.Plugin;
+
+public class BungeePluginsCommand extends Command {
+ public BungeePluginsCommand() {
+ super("bplugins");
+ }
+
+ @Override
+ public void execute(final CommandSender sender, final String[] args) {
+ final FlameCord flameCord = FlameCord.getInstance();
+ final MessagesConfiguration messagesConfiguration = flameCord.getMessagesConfiguration();
+
+ if (sender.hasPermission("flamecord.usage")) {
+ Collection<Plugin> plugins = BungeeCord.getInstance().getPluginManager().getPlugins();
+ int amount = plugins.size();
+ String header = FlameCord.getInstance().getMessagesConfiguration().getTranslation("flamecord_bplugins_header", amount);
+ String separator = FlameCord.getInstance().getMessagesConfiguration().getTranslation("flamecord_bplugins_separator");
+ StringBuilder stringBuilder = new StringBuilder(header);
+ boolean first = true;
+
+ for (Plugin plugin : plugins) {
+ stringBuilder.append((first ? "" : separator) + plugin.getDescription().getName());
+
+ if (first) {
+ first = false;
+ }
+ }
+
+ sender.sendMessage(TextComponent.fromLegacyText(stringBuilder.toString()));
+ } else {
+ sender.sendMessage(TextComponent
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_bplugins_nopermission")));
+ }
+ }
+}
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index 62712330e..ec5fd4af2 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -11,6 +11,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.commands.BungeePluginsCommand;
import dev._2lstudios.flamecord.commands.FlameCordCommand;
import dev._2lstudios.flamecord.configuration.ModulesConfiguration;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -912,5 +913,8 @@ public class BungeeCord extends ProxyServer
// Flamecord Command
pluginManager.registerCommand(null, new FlameCordCommand(this));
+
+ // FlameCord - Bungee Plugins Command
+ pluginManager.registerCommand(null, new BungeePluginsCommand());
}
}
--
2.37.3.windows.1

View File

@ -0,0 +1,98 @@
From 79f33268f3f154170f55362decf8fcc8b99a68f8 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Sun, 15 Jan 2023 10:12:45 -0300
Subject: [PATCH] Bungee IP Command
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
index 2ea33a94b..e42bb29d5 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
@@ -101,6 +101,12 @@ public class MessagesConfiguration extends FlameConfig {
setIfUnexistant("flamecord_bplugins_separator", ", ", configuration);
setIfUnexistant("flamecord_bplugins_header", "&aPlugins ({0}): ", configuration);
+ // FlameCord - Bungee IP Command
+ setIfUnexistant("flamecord_bip_nopermission", "&cYou don't have permission to do this!", configuration);
+ setIfUnexistant("flamecord_bip_offline", "&cThe player is not online!", configuration);
+ setIfUnexistant("flamecord_bip_usage", "&c/bip <player>", configuration);
+ setIfUnexistant("flamecord_bip", "&aInformation about {0}&a:\n&aUUID: &b{1}\n&aIP: &b{2}\n&aPing: &b{3}ms\n&aLocale: &b{4}\n&aView Distance: &b{5}\n&aCurrent Server: &b{6}", configuration);
+
for (final String key : configuration.getKeys()) {
final Object value = configuration.get(key);
diff --git a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/BungeeIPCommand.java b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/BungeeIPCommand.java
new file mode 100644
index 000000000..85313491e
--- /dev/null
+++ b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/BungeeIPCommand.java
@@ -0,0 +1,45 @@
+package dev._2lstudios.flamecord.commands;
+
+import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
+import net.md_5.bungee.BungeeCord;
+import net.md_5.bungee.api.CommandSender;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.connection.ProxiedPlayer;
+import net.md_5.bungee.api.plugin.Command;
+
+public class BungeeIPCommand extends Command {
+ public BungeeIPCommand() {
+ super("bip");
+ }
+
+ @Override
+ public void execute(final CommandSender sender, final String[] args) {
+ final FlameCord flameCord = FlameCord.getInstance();
+ final MessagesConfiguration messagesConfiguration = flameCord.getMessagesConfiguration();
+
+ if (sender.hasPermission("flamecord.bip")) {
+ if (args.length > 0) {
+ ProxiedPlayer player = BungeeCord.getInstance().getPlayer(args[0]);
+
+ if (player != null) {
+ String message = messagesConfiguration.getTranslation("flamecord_bip", player.getDisplayName(),
+ player.getUniqueId(), player.getSocketAddress(), player.getPing(), player.getLocale(),
+ player.getViewDistance(), player.getServer().getInfo().getName());
+
+ sender.sendMessage(TextComponent.fromLegacyText(message));
+ } else {
+ sender.sendMessage(
+ TextComponent
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_bip_offline")));
+ }
+ } else {
+ sender.sendMessage(
+ TextComponent.fromLegacyText(messagesConfiguration.getTranslation("flamecord_bip_usage")));
+ }
+ } else {
+ sender.sendMessage(TextComponent
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_bip_nopermission")));
+ }
+ }
+}
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index ec5fd4af2..f5059666e 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -11,6 +11,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import dev._2lstudios.flamecord.FlameCord;
+import dev._2lstudios.flamecord.commands.BungeeIPCommand;
import dev._2lstudios.flamecord.commands.BungeePluginsCommand;
import dev._2lstudios.flamecord.commands.FlameCordCommand;
import dev._2lstudios.flamecord.configuration.ModulesConfiguration;
@@ -916,5 +917,8 @@ public class BungeeCord extends ProxyServer
// FlameCord - Bungee Plugins Command
pluginManager.registerCommand(null, new BungeePluginsCommand());
+
+ // FlameCord - Bungee IP Command
+ pluginManager.registerCommand(null, new BungeeIPCommand());
}
}
--
2.37.3.windows.1

View File

@ -0,0 +1,37 @@
From daefdd3d718eecc9ac09fbece9e7baff22e1c195 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Sun, 15 Jan 2023 19:03:34 -0300
Subject: [PATCH] List Command Format
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
index e42bb29d5..555319a7f 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
@@ -107,6 +107,9 @@ public class MessagesConfiguration extends FlameConfig {
setIfUnexistant("flamecord_bip_usage", "&c/bip <player>", configuration);
setIfUnexistant("flamecord_bip", "&aInformation about {0}&a:\n&aUUID: &b{1}\n&aIP: &b{2}\n&aPing: &b{3}ms\n&aLocale: &b{4}\n&aView Distance: &b{5}\n&aCurrent Server: &b{6}", configuration);
+ // FlameCord - List Command Format
+ setIfUnexistant("command_list_format", "&aServers:&r", configuration);
+
for (final String key : configuration.getKeys()) {
final Object value = configuration.get(key);
diff --git a/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java b/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java
index c22271105..0a5899319 100644
--- a/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java
+++ b/module/cmd-list/src/main/java/net/md_5/bungee/module/cmd/list/CommandList.java
@@ -25,6 +25,9 @@ public class CommandList extends Command
@Override
public void execute(CommandSender sender, String[] args)
{
+ // FlameCord - List Command Format
+ sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_list_format") );
+
for ( ServerInfo server : ProxyServer.getInstance().getServers().values() )
{
if ( !server.canAccess( sender ) )
--
2.37.3.windows.1

View File

@ -0,0 +1,124 @@
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 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
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING;
}
+ // FlameCord start - InitialHandler Processing State
+ private boolean processing = false;
+ // FlameCord end - InitialHandler Processing State
+
private boolean canSendKickMessage()
{
return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING;
@@ -275,6 +279,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
public void handle(StatusRequest statusRequest) throws Exception
{
Preconditions.checkState( thisState == State.STATUS, "Not expecting STATUS" );
+ // FlameCord start - InitialHandler Processing State
+ Preconditions.checkState( !processing, "Cannot request STATUS while processing another packet");
+ this.processing = true;
+ // FlameCord end - InitialHandler Processing State
ServerInfo forced = AbstractReconnectHandler.getForcedHost( this );
final int protocol = ( ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion();
@@ -392,6 +400,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
thisState = State.PING;
+ // FlameCord start - InitialHandler Processing State
+ processing = false;
+ // FlameCord end - InitialHandler Processing State
}
private static final boolean ACCEPT_INVALID_PACKETS = Boolean.parseBoolean(System.getProperty("waterfall.acceptInvalidPackets", "false"));
@@ -401,6 +412,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
// FlameCord - Never accept invalid packets
Preconditions.checkState( thisState == State.PING, "Not expecting PING" );
+ // FlameCord start - InitialHandler Processing State
+ Preconditions.checkState( !processing, "Cannot request PING while processing another packet");
+ this.processing = true;
+ // FlameCord end - InitialHandler Processing State
unsafe.sendPacket( ping );
@@ -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" );
-
+ // FlameCord start - InitialHandler Processing State
+ Preconditions.checkState( !processing, "Cannot request HANDSHAKE while processing another packet");
+ this.processing = true;
+ // FlameCord end - InitialHandler Processing State
+
// FlameCord start - Antibot System
// Close and firewall on invalid protocol
int protocol = handshake.getRequestedProtocol();
@@ -485,6 +504,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
// FlameCord end - Antibot System
+ // FlameCord start - InitialHandler Processing State
+ processing = false;
+ // FlameCord end - InitialHandler Processing State
+
break;
case 2:
// Login
@@ -517,6 +540,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
}
return;
}
+
+ // FlameCord start - InitialHandler Processing State
+ processing = false;
+ // FlameCord end - InitialHandler Processing State
+
break;
default:
throw new QuietException( "Cannot request protocol " + handshake.getRequestedProtocol() );
@@ -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" );
+ // FlameCord start - InitialHandler Processing State
+ Preconditions.checkState( !processing, "Cannot request USERNAME while processing another packet");
+ this.processing = true;
+ // FlameCord end - InitialHandler Processing State
if ( !FlameCord.getInstance().getFlameCordConfiguration().isAllowInvalidNames() && !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) )
{
@@ -634,6 +666,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
thisState = State.FINISHING;
finish();
}
+ // FlameCord start - InitialHandler Processing State
+ processing = false;
+ // FlameCord end - InitialHandler Processing State
}
};
@@ -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)
+ // FlameCord start - InitialHandler Processing State
+ Preconditions.checkState( !processing, "Cannot request ENCRYPT while processing another packet");
+ this.processing = true;
+ // FlameCord end - InitialHandler Processing State
SecretKey sharedKey = EncryptionUtil.getSecret( encryptResponse, request );
// Waterfall start
--
2.37.3.windows.1

File diff suppressed because it is too large Load Diff

25
pom.xml Normal file
View File

@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.waterfallmc</groupId>
<artifactId>waterfall-super</artifactId>
<version>dev-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Waterfall-Super</name>
<description>Super project for FlameCord.</description>
<url>https://github.com/2lstudios-mc/FlameCord</url>
<modules>
<module>FlameCord-Proxy</module>
</modules>
<build>
<defaultGoal>clean install</defaultGoal>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>