zestgodguap t.me/ratware
This commit is contained in:
commit
d938a5d028
|
@ -0,0 +1 @@
|
||||||
|
doxbin[[:space:]]db.txt filter=lfs diff=lfs merge=lfs -text
|
|
@ -0,0 +1 @@
|
||||||
|
custom: ['https://paypal.me/LinsaFTW']
|
|
@ -0,0 +1,11 @@
|
||||||
|
FlameCord-Proxy
|
||||||
|
|
||||||
|
# intellij
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
.idea/
|
||||||
|
out/
|
||||||
|
|
||||||
|
.project
|
||||||
|
.settings
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "Waterfall"]
|
||||||
|
path = Waterfall
|
||||||
|
url = https://github.com/WaterfallMC/Waterfall.git
|
|
@ -0,0 +1,99 @@
|
||||||
|
Contributing to FlameCord
|
||||||
|
==========================
|
||||||
|
FlameCord follows the parameters of the WaterfallMC project when making a Pull Request. WaterfallMC has a very lenient policy towards PRs, but would prefer that you try and adhere to the following guidelines.
|
||||||
|
|
||||||
|
## Understanding Patches
|
||||||
|
Patches to FlameCord are very simple, but center around the directory 'FlameCord-Proxy'
|
||||||
|
|
||||||
|
Assuming you already have forked the repository:
|
||||||
|
|
||||||
|
1. Pull the latest changes from the main repository
|
||||||
|
2. Type `./flamecord p` in git bash to apply the changes from upstream
|
||||||
|
3. cd into `FlameCord-Proxy` for proxy changes
|
||||||
|
|
||||||
|
This directory is not a git repository in the traditional sense:
|
||||||
|
|
||||||
|
- Every single commit in FlameCord-Proxy is a patch.
|
||||||
|
- 'origin/master' points to a directory similar to Waterfall-Proxy but for FlameCord
|
||||||
|
- Typing `git status` should show that we are 10 or 11 commits ahead of master, meaning we have 10 or 11 patches that FlameCord, Waterfall, and Bungeecord don't
|
||||||
|
- If it says something like `212 commits ahead, 207 commits behind`, then type `git fetch` to update FlameCord
|
||||||
|
|
||||||
|
## Adding Patches
|
||||||
|
Adding patches to FlameCord is very simple:
|
||||||
|
|
||||||
|
1. Modify `FlameCord-Proxy` with the appropriate changes
|
||||||
|
2. Type `git add .` to add your changes
|
||||||
|
3. Run `git commit` with the desired patch message
|
||||||
|
4. Run `./flamecord rb` in the main directory to convert your commit into a new patch
|
||||||
|
5. PR your patches back to this repository
|
||||||
|
|
||||||
|
Your commit will be converted into a patch that you can then PR into FlameCord
|
||||||
|
|
||||||
|
## Modifying Patches
|
||||||
|
Modifying previous patches is a bit more complex:
|
||||||
|
|
||||||
|
### Method 1
|
||||||
|
This method works by temporarily resetting HEAD to the desired commit to edit using rebase.
|
||||||
|
|
||||||
|
1. If you have changes you are working on type `git stash` to store them for later.
|
||||||
|
- Later you can type `git stash pop` to get them back.
|
||||||
|
2. Type `git rebase -i upstream/upstream`
|
||||||
|
3. Replace `pick` with `edit` for the commit/patch you want to modify, and "save" the changes.
|
||||||
|
- Only do this for one commit at a time.
|
||||||
|
4. Make the changes you want to make to the patch.
|
||||||
|
5. Type `git add .` to add your changes.
|
||||||
|
6. Type `git commit --amend` to commit.
|
||||||
|
- **MAKE SURE TO ADD `--amend`** or else a new patch will be created.
|
||||||
|
- You can also modify the commit message here.
|
||||||
|
7. Type `git rebase --continue` to finish rebasing.
|
||||||
|
8. Type `./flamecord rb` in the main directory.
|
||||||
|
- This will modify the appropriate patches based on your commits.
|
||||||
|
9. PR your modifications back to this project.
|
||||||
|
|
||||||
|
### Method 2 (sometimes easier)
|
||||||
|
If you are simply editing a more recent commit or your change is small, simply making the change at HEAD and then moving the commit after you have tested it may be easier.
|
||||||
|
|
||||||
|
1. Make your change while at HEAD
|
||||||
|
2. Make a temporary commit. You don't need to make a message for this.
|
||||||
|
3. Type `git rebase -i upstream/upstream`, move (cut) your temporary commit and move it under the line of the patch you wish to modify.
|
||||||
|
4. Change the `pick` with `f` (fixup) or `s` (squash) if you need to edit the commit message
|
||||||
|
5. Type `./flamecord rb` in the main directory.
|
||||||
|
- This will modify the appropriate patches based on your commits.
|
||||||
|
6. PR your modifications to github
|
||||||
|
|
||||||
|
|
||||||
|
## PR Policy
|
||||||
|
We'll accept changes that make sense. You should be able to justify their existence, along with any maintenance costs that come with them. Remember, these changes will affect everyone who runs FlameCord, not just you and your server.
|
||||||
|
While we will fix minor formatting issues, you should stick to the guide below when making and submitting changes.
|
||||||
|
|
||||||
|
## Formatting
|
||||||
|
All modifications to non-FlameCord files should be marked
|
||||||
|
- Multi line changes start with `// FlameCord start` and end with `// FlameCord end`
|
||||||
|
- You can put a messages with a change if it isn't obvious, like this: `// FlameCord start - reason
|
||||||
|
- Should generally be about the reason the change was made, what it was before, or what the change is
|
||||||
|
- Multi-line messages should start with `// FlameCord start` and use `/* Multi line message here */` for the message itself
|
||||||
|
- Single line changes should have `// FlameCord` or `// FlameCord - reason`
|
||||||
|
- For example:
|
||||||
|
````java
|
||||||
|
return getConfig().getNotStupid(); // FlameCord - was return getConfig().getStupid();
|
||||||
|
|
||||||
|
// FlameCord start
|
||||||
|
// con.disconnect( bungee.getTranslation( "lost_connection" ) );
|
||||||
|
ServerInfo def = con.updateAndGetNextServer( server.getInfo() );
|
||||||
|
ServerKickEvent event = bungee.getPluginManager().callEvent( new ServerKickEvent( con, server.getInfo(), TextComponent.fromLegacyText( bungee.getTranslation( "lost_connection" ) ), def, ServerKickEvent.State.CONNECTED, ServerKickEvent.Cause.LOST_CONNECTION ) );
|
||||||
|
if ( event.isCancelled() && event.getCancelServer() != null )
|
||||||
|
{
|
||||||
|
server.setObsolete( true );
|
||||||
|
con.connectNow( event.getCancelServer() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
con.disconnect0( event.getKickReasonComponent() );
|
||||||
|
}
|
||||||
|
// FlameCord end
|
||||||
|
````
|
||||||
|
- We generally follow usual java style, or what is programmed into most IDEs and formatters by default
|
||||||
|
- This is also known as oracle style
|
||||||
|
- It is fine to go over 80 lines as long as it doesn't hurt readability
|
||||||
|
- There are exceptions, especially in Bungeecord-related files
|
||||||
|
- When in doubt, use the same style as the surrounding code
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2015-2019 Waterfall Team
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,38 @@
|
||||||
|
FlameCord
|
||||||
|
=======
|
||||||
|
|
||||||
|
FlameCord is a Waterfall modification to fix exploits, improve performance and protect against bot attacks. Waterfall is a fork of the well-known [BungeeCord](https://github.com/SpigotMC/BungeeCord) server teleportation suite.
|
||||||
|
|
||||||
|
FlameCord is compiled like Waterfall does; Please follow the [CONTRIBUTING.md](https://github.com/2lstudios-mc/FlameCord/blob/master/CONTRIBUTING.md) file. If you need help you can always contact us on Discord.
|
||||||
|
|
||||||
|
<a href="https://discord.gg/gF36AT3"><img src="https://i.imgur.com/NyGBnuJ.png" width=10% height=10%><img/><a/> <a href="https://www.mc-market.org/resources/13492/"><img src="https://i.imgur.com/KLOpbAF.png" width=10% height=10%><img/><a/> <a href="https://ci.2lstudios.dev/job/FlameCord"><img src="https://i.imgur.com/lOUkJji.png" width=10% height=10%><img/><a/>
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
FlameCord being a fork of Waterfall, has all its features, and some of its own, such as:
|
||||||
|
|
||||||
|
* **Exploit Fixes**: FlameCord specializes in providing better server security by fixing major exploits, performance flaws and bugs that Bungeecord already has, and that have not yet been fixed in WaterfallMC.
|
||||||
|
* **Bot Protection**: FlameCord brings swift bot protection for your Minecraft server to avoid extra CPU usage and crashes in your machines.
|
||||||
|
|
||||||
|
## Why fork Waterfall?
|
||||||
|
|
||||||
|
FlameCord was forked out of a desire for greater protection to be afforded to a Bungeecord-based proxy, which Waterfall currently cannot offer.
|
||||||
|
|
||||||
|
FlameCord will track upstream Waterfall and merge changes as needed.
|
||||||
|
|
||||||
|
## How to (Server Admins)
|
||||||
|
|
||||||
|
You can support the development of FlameCord by purchasing it at [MC-Market](https://www.mc-market.org/resources/13492/).
|
||||||
|
|
||||||
|
FlameCord requires **Java 8** or above.
|
||||||
|
|
||||||
|
## How To (Compiling from source)
|
||||||
|
|
||||||
|
To compile FlameCord, you need JDK8 or above, git, bash, maven, and an internet connection.
|
||||||
|
|
||||||
|
Clone this repo, run `./flamecord b` from *bash*, get jar from `FlameCord-Proxy/bootstrap/target`
|
||||||
|
|
||||||
|
## Join us
|
||||||
|
|
||||||
|
* Feel free to open a PR! We accept contributions.
|
||||||
|
* Join to our [Discord Server](https://discord.gg/gF36AT3).
|
|
@ -0,0 +1,146 @@
|
||||||
|
From 9702193b1b27ffbe2fd79236b44d689d58ebafc1 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..f4bf5ec6
|
||||||
|
--- /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.18-R0.1-SNAPSHOT</version>
|
||||||
|
+ <relativePath>../pom.xml</relativePath>
|
||||||
|
+ </parent>
|
||||||
|
+
|
||||||
|
+ <groupId>dev._2lstudios</groupId>
|
||||||
|
+ <artifactId>waterfall-flamecord</artifactId>
|
||||||
|
+ <version>1.18-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 505d1d14..45f14084 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 a783d9b0..f45d4f7a 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 cca0ef95..3df0498a 100644
|
||||||
|
--- a/proxy/pom.xml
|
||||||
|
+++ b/proxy/pom.xml
|
||||||
|
@@ -150,6 +150,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>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
From 73739a822f6730c871a88ade6d7fe7d5efbc117c 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 00ce099c..cbd16c34 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 a4516ed9..9838f5c5 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 d703d6d2..49dce84b 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 07d74c67..a4b58d9c 100644
|
||||||
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||||
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||||
|
@@ -188,7 +188,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." );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
@@ -539,7 +539,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 0db3d76a..25da0a65 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 b26035cf..820f7b03 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 720d0c3b..5ab4db18 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 0644b8cd..9c11ac57 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.32.0
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
From 40ee61cc9b114b89dfabfc3f0f070edf18c2bd03 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 e31fb00ae..ff4bbf34d 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 a4b58d9c6..40ceeb18d 100644
|
||||||
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||||
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||||
|
@@ -545,7 +545,7 @@ public class BungeeCord extends ProxyServer
|
||||||
|
@Override
|
||||||
|
public String getVersion()
|
||||||
|
{
|
||||||
|
- return ( BungeeCord.class.getPackage().getImplementationVersion() == null ) ? "unknown" : BungeeCord.class.getPackage().getImplementationVersion();
|
||||||
|
+ return "0.8.5";
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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.32.0
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,56 @@
|
||||||
|
From fe67e1b15da0cebd4aa08a848529845a194dff24 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 2f7b38d9..e29b0ed3 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 f6378e03..23571d40 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
|
||||||
|
@@ -338,7 +338,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.32.0
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
From 11703076bee62715d944730066a85ed265510a55 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 25da0a65..d4b612b3 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,12 @@ 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 ) );
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ // FlameCord - Disable update checker
|
||||||
|
|
||||||
|
BungeeCord bungee = new BungeeCord();
|
||||||
|
ProxyServer.setInstance( bungee );
|
||||||
|
- bungee.getLogger().info( "Enabled FlameCord version " + bungee.getVersion() );
|
||||||
|
+ // FlameCord - Use bungee 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 9c11ac57..ae4c7ac2 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.32.0
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
From 6d9ca4241f7afcfba08144a7e247bfc36a4d5990 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 75028024..2ee16684 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 LoginResult.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 LoginResult.Property( ForgeConstants.EXTRA_DATA, user.getExtraDataInHandshake().replaceAll( "\0", "\1"), "" );
|
||||||
|
+ // FlameCord - Change replaceAll() to replace()
|
||||||
|
+ newp[newp.length - 1] = new LoginResult.Property( ForgeConstants.EXTRA_DATA, user.getExtraDataInHandshake().replace( "\0", "\1"), "" );
|
||||||
|
|
||||||
|
// All done.
|
||||||
|
properties = newp;
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
|
@ -0,0 +1,179 @@
|
||||||
|
From 4487e175bf2121239ffe3d12bb584c51fddb3e09 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 23571d40..1ec75614 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
|
||||||
|
@@ -195,6 +195,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 )
|
||||||
|
@@ -260,6 +267,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 ) )
|
||||||
|
@@ -304,11 +322,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
|
||||||
|
@@ -617,7 +637,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
{
|
||||||
|
if ( canSendKickMessage() )
|
||||||
|
{
|
||||||
|
- ch.delayedClose( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||||
|
+ // FlameCord - Changed delayedClose to close
|
||||||
|
+ ch.close( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
ch.close();
|
||||||
|
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..5c05f2b9 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,40 +80,27 @@ 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // FlameCord - Deprecate and "disable" delayedClose because it doesn't have a reason to exist
|
||||||
|
+ @Deprecated
|
||||||
|
public void delayedClose(final Kick kick)
|
||||||
|
{
|
||||||
|
- if ( !closing )
|
||||||
|
- {
|
||||||
|
- closing = true;
|
||||||
|
-
|
||||||
|
- // Minecraft client can take some time to switch protocols.
|
||||||
|
- // Sending the wrong disconnect packet whilst a protocol switch is in progress will crash it.
|
||||||
|
- // Delay 250ms to ensure that the protocol switch (if any) has definitely taken place.
|
||||||
|
- ch.eventLoop().schedule( new Runnable()
|
||||||
|
- {
|
||||||
|
-
|
||||||
|
- @Override
|
||||||
|
- public void run()
|
||||||
|
- {
|
||||||
|
- close( kick );
|
||||||
|
- }
|
||||||
|
- }, 250, TimeUnit.MILLISECONDS );
|
||||||
|
- }
|
||||||
|
+ close(kick);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 96704d5e..654203ab 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;
|
||||||
|
@@ -102,6 +103,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();
|
||||||
|
@@ -196,5 +205,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();
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 0c1ecfb8..b3bdfd05 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
|
||||||
|
@@ -71,6 +71,8 @@ public class QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
||||||
|
if ( in.readUnsignedByte() != 0xFE || in.readUnsignedByte() != 0xFD )
|
||||||
|
{
|
||||||
|
bungee.getLogger().log( Level.WARNING, "Query - Incorrect magic!: {0}", msg.sender() );
|
||||||
|
+ // FlameCord - Close on incorrect magic
|
||||||
|
+ ctx.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
From 772e70bce0c9626cb3c724b7c30c4802f7311e63 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 ac83e325..4b9b80b9 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.copy(); // Can't slice this one due to EntityMap :(
|
||||||
|
|
||||||
|
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 f8d6becd..33605007 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.32.0
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
From 36e054d017b32104a878faed79fb18b5d8b5c9df 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 85d2197a..3b5ce41e 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.32.0
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
From 1110d8e2d16633d02c7839b38f800ee5cedc0a84 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 d1cd1090..44cb1ce6 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.32.0
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
From 290e7f633bb2ecffad78a8a2518ea9efdf890767 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 5c05f2b9..606866a5 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)
|
||||||
|
@@ -111,25 +117,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.32.0
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
From 78fe174f45379f66c5a409e723804bd147b6859f 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 1ec75614..b402d1d3 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
|
||||||
|
@@ -695,7 +695,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.32.0
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
From 741f02f0787e16c9032d2a8490f669b69963dcda 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 adc25165..935d2e30 100644
|
||||||
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
||||||
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
||||||
|
@@ -311,7 +311,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.32.0
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
From 0ddd8121e5e1bb37c08836aef5189d3b4a4a8a7d 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 b402d1d3..0b5faf6b 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
|
||||||
|
@@ -505,7 +505,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.32.0
|
||||||
|
|
|
@ -0,0 +1,383 @@
|
||||||
|
From d22662f6826b0cced8e7cd3c4052fb87b502d0d7 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 00000000..8e69160d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
|
||||||
|
@@ -0,0 +1,35 @@
|
||||||
|
+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 reload(final Logger logger, final Collection<String> whitelistedAddresses) {
|
||||||
|
+ if (FlameCord.instance != null) {
|
||||||
|
+ instance.reload(logger);
|
||||||
|
+ } else {
|
||||||
|
+ FlameCord.instance = new FlameCord(logger, whitelistedAddresses);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Getter
|
||||||
|
+ private FlameCordConfiguration flameCordConfiguration;
|
||||||
|
+
|
||||||
|
+ private void reload(final Logger logger) {
|
||||||
|
+ final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
|
||||||
|
+
|
||||||
|
+ this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private FlameCord(final Logger logger, final Collection<String> whitelistedAddresses) {
|
||||||
|
+ reload(logger);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
\ 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 00000000..cfbd55c3
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
|
||||||
|
@@ -0,0 +1,38 @@
|
||||||
|
+package dev._2lstudios.flamecord.configuration;
|
||||||
|
+
|
||||||
|
+import java.util.ArrayList;
|
||||||
|
+import java.util.Collection;
|
||||||
|
+import java.util.HashSet;
|
||||||
|
+
|
||||||
|
+import net.md_5.bungee.config.Configuration;
|
||||||
|
+
|
||||||
|
+public class FlameConfig {
|
||||||
|
+ int setIfUnexistant(final String arg1, final int arg2, final Configuration configuration) {
|
||||||
|
+ return (int) 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 00000000..c8148e90
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||||
|
@@ -0,0 +1,33 @@
|
||||||
|
+package dev._2lstudios.flamecord.configuration;
|
||||||
|
+
|
||||||
|
+import java.io.File;
|
||||||
|
+import java.io.IOException;
|
||||||
|
+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) {
|
||||||
|
+ try {
|
||||||
|
+ final String fileName = "./flamecord.yml";
|
||||||
|
+ final File configurationFile = new File(fileName);
|
||||||
|
+ final Configuration configuration;
|
||||||
|
+ final boolean configurationExists = configurationFile.exists();
|
||||||
|
+
|
||||||
|
+ if (!configurationExists) {
|
||||||
|
+ configuration = new Configuration();
|
||||||
|
+ } else {
|
||||||
|
+ configuration = configurationProvider.load(configurationFile);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ configurationProvider.save(configuration, configurationFile);
|
||||||
|
+ } catch (final IOException e) {
|
||||||
|
+ e.printStackTrace();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
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 4b9b80b9..aa35f870 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 00000000..91d60bfb
|
||||||
|
--- /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.reload(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 0de754d5..a09d6baf 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;
|
||||||
|
@@ -233,11 +235,12 @@ 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() );
|
||||||
|
+ // FlameCord - We register commands in our new method
|
||||||
|
+ //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" ) )
|
||||||
|
{
|
||||||
|
@@ -286,6 +289,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.reload(logger, whitelistedAddresses);
|
||||||
|
+
|
||||||
|
if ( config.isForgeSupport() )
|
||||||
|
{
|
||||||
|
registerChannel( ForgeConstants.FML_TAG );
|
||||||
|
@@ -577,9 +589,7 @@ public class BungeeCord extends ProxyServer
|
||||||
|
String translation = "<translation '" + name + "' missing>";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
- final String string = customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name );
|
||||||
|
-
|
||||||
|
- translation = ( args.length == 0 ) ? string : MessageFormat.format( string, args );
|
||||||
|
+ translation = MessageFormat.format( customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name ), args );
|
||||||
|
} catch ( MissingResourceException ex )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
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 2ee16684..3a41769a 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,7 @@ 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 ) );
|
||||||
|
+ 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 935d2e30..e8eb555c 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;
|
||||||
|
@@ -65,6 +66,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
|
||||||
|
@@ -391,9 +393,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 0b5faf6b..39c54cf1 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
|
||||||
|
@@ -19,6 +19,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;
|
||||||
|
@@ -157,7 +159,7 @@ 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 ) );
|
||||||
|
+ throw new QuietException( "Unexpected packet received during server login 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 a409d440..3503c089 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 33605007..89a6d14a 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 654203ab..a840bc70 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.32.0
|
||||||
|
|
|
@ -0,0 +1,193 @@
|
||||||
|
From c701401d36a6cee1d4ba6a651eaec3148939b62c 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 8e69160d..ac37eaa3 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;
|
||||||
|
@@ -22,11 +23,14 @@ public class FlameCord {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private FlameCordConfiguration flameCordConfiguration;
|
||||||
|
+ @Getter
|
||||||
|
+ private ModulesConfiguration modulesConfiguration;
|
||||||
|
|
||||||
|
private void reload(final Logger logger) {
|
||||||
|
final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
|
||||||
|
|
||||||
|
this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider);
|
||||||
|
+ this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
private FlameCord(final Logger logger, final Collection<String> whitelistedAddresses) {
|
||||||
|
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 00000000..6c5bb961
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/ModulesConfiguration.java
|
||||||
|
@@ -0,0 +1,49 @@
|
||||||
|
+package dev._2lstudios.flamecord.configuration;
|
||||||
|
+
|
||||||
|
+import java.io.File;
|
||||||
|
+import java.io.IOException;
|
||||||
|
+
|
||||||
|
+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) {
|
||||||
|
+ try {
|
||||||
|
+ final String fileName = "./modules.yml";
|
||||||
|
+ final File configurationFile = new File(fileName);
|
||||||
|
+ final Configuration configuration;
|
||||||
|
+ final boolean configurationExists = configurationFile.exists();
|
||||||
|
+
|
||||||
|
+ if (!configurationExists) {
|
||||||
|
+ configuration = new Configuration();
|
||||||
|
+ } else {
|
||||||
|
+ configuration = configurationProvider.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);
|
||||||
|
+
|
||||||
|
+ configurationProvider.save(configuration, configurationFile);
|
||||||
|
+ } catch (final IOException e) {
|
||||||
|
+ e.printStackTrace();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
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 a09d6baf..ed5ce6e6 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;
|
||||||
|
@@ -88,6 +90,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;
|
||||||
|
@@ -279,9 +288,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 );
|
||||||
|
@@ -314,6 +324,7 @@ public class BungeeCord extends ProxyServer
|
||||||
|
connectionThrottle = new ConnectionThrottle( config.getThrottle(), config.getThrottleLimit() );
|
||||||
|
}
|
||||||
|
startListeners();
|
||||||
|
+ loadModules();
|
||||||
|
|
||||||
|
saveThread.scheduleAtFixedRate( new TimerTask()
|
||||||
|
{
|
||||||
|
@@ -831,4 +842,53 @@ public class BungeeCord extends ProxyServer
|
||||||
|
{
|
||||||
|
return new BungeeTitle();
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // FlameCord - Method to simplify module registering
|
||||||
|
+ 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 - Commands (Had to make it like this because of maven limitations)
|
||||||
|
+ pluginManager.registerCommand(null, new FlameCordCommand(this));
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
|
@ -0,0 +1,225 @@
|
||||||
|
From a2394941af909d50114567bebc428ee13099578d 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 ac37eaa3..c78ab3a7 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;
|
||||||
|
@@ -25,12 +26,15 @@ public class FlameCord {
|
||||||
|
private FlameCordConfiguration flameCordConfiguration;
|
||||||
|
@Getter
|
||||||
|
private ModulesConfiguration modulesConfiguration;
|
||||||
|
+ @Getter
|
||||||
|
+ private MessagesConfiguration messagesConfiguration;
|
||||||
|
|
||||||
|
private void reload(final Logger logger) {
|
||||||
|
final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
|
||||||
|
|
||||||
|
this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider);
|
||||||
|
this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
|
||||||
|
+ this.messagesConfiguration = new MessagesConfiguration(logger, configurationProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
private FlameCord(final Logger logger, final Collection<String> whitelistedAddresses) {
|
||||||
|
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 00000000..57462992
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
|
||||||
|
@@ -0,0 +1,113 @@
|
||||||
|
+package dev._2lstudios.flamecord.configuration;
|
||||||
|
+
|
||||||
|
+import java.io.File;
|
||||||
|
+import java.io.IOException;
|
||||||
|
+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;
|
||||||
|
+
|
||||||
|
+ try {
|
||||||
|
+ final String fileName = "./messages.yml";
|
||||||
|
+ final File configurationFile = new File(fileName);
|
||||||
|
+ final Configuration configuration;
|
||||||
|
+ final boolean configurationExists = configurationFile.exists();
|
||||||
|
+
|
||||||
|
+ if (!configurationExists) {
|
||||||
|
+ configuration = new Configuration();
|
||||||
|
+ } else {
|
||||||
|
+ configuration = configurationProvider.load(configurationFile);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // 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("timeout",
|
||||||
|
+ "Server not reachable (timeout). Offline? Incorrectly configured address/port/firewall?", 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("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("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);
|
||||||
|
+
|
||||||
|
+ // FlameCord
|
||||||
|
+ setIfUnexistant("flamecord_reload", "&aAll files had been successfully reloaded!", configuration);
|
||||||
|
+ setIfUnexistant("flamecord_help",
|
||||||
|
+ "&aFlameCord&b {0}&a by&b LinsaFTW&a &&b Sammwy&r\n&e /flamecord reload&7 >&b Reloads FlameCord files!\n&e /flamecord help&7 >&b Shows this message!",
|
||||||
|
+ configuration);
|
||||||
|
+ setIfUnexistant("flamecord_nopermission", "&cYou don't have permission to do this!", configuration);
|
||||||
|
+
|
||||||
|
+ configurationProvider.save(configuration, configurationFile);
|
||||||
|
+
|
||||||
|
+ for (final String key : configuration.getKeys()) {
|
||||||
|
+ final Object value = configuration.get(key);
|
||||||
|
+
|
||||||
|
+ if (value instanceof String) {
|
||||||
|
+ this.messages.put(key, ChatColor.translateAlternateColorCodes('&', (String) value));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } catch (final IOException e) {
|
||||||
|
+ e.printStackTrace();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ 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/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
|
||||||
|
index 91d60bfb..cc76325b 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.reload(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 ed5ce6e6..18c53872 100644
|
||||||
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||||
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||||
|
@@ -597,14 +597,8 @@ public class BungeeCord extends ProxyServer
|
||||||
|
@Override
|
||||||
|
public String getTranslation(String name, Object... args)
|
||||||
|
{
|
||||||
|
- String translation = "<translation '" + name + "' missing>";
|
||||||
|
- try
|
||||||
|
- {
|
||||||
|
- translation = MessageFormat.format( customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name ), args );
|
||||||
|
- } catch ( MissingResourceException ex )
|
||||||
|
- {
|
||||||
|
- }
|
||||||
|
- return translation;
|
||||||
|
+ // FlameCord - Use own translation system
|
||||||
|
+ return FlameCord.getInstance().getMessagesConfiguration().getTranslation(name, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
From 23d65a0daab152315d3815042c57d14e51674bb7 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 1509071f..b9bcecb5 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
|
||||||
|
@@ -151,11 +151,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 cefa0206..8d4439ab 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.32.0
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
From c727441bc5d674eface4fa65b416aceca4477406 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 aa35f870..3992f521 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.32.0
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
From d49ffb31a988bab4c7b0d2e2b652f65ce240c087 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 c8148e90..701db67c 100644
|
||||||
|
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||||
|
@@ -12,6 +12,15 @@ 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;
|
||||||
|
+
|
||||||
|
public FlameCordConfiguration(final ConfigurationProvider configurationProvider) {
|
||||||
|
try {
|
||||||
|
final String fileName = "./flamecord.yml";
|
||||||
|
@@ -25,6 +34,11 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||||
|
configuration = configurationProvider.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);
|
||||||
|
+
|
||||||
|
configurationProvider.save(configuration, configurationFile);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
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 39c54cf1..cfd6249e 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
|
||||||
|
@@ -370,7 +370,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 );
|
||||||
|
}
|
||||||
|
@@ -379,7 +380,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 89a6d14a..8eda3110 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.32.0
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
From d355f46a5efe21ebf60fa02dc5cd36acc9b6f227 Mon Sep 17 00:00:00 2001
|
||||||
|
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
|
||||||
|
Date: Sat, 1 May 2021 23:28:19 -0300
|
||||||
|
Subject: [PATCH] Always release packets
|
||||||
|
|
||||||
|
|
||||||
|
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 8eda3110..cef44d8a 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
|
||||||
|
@@ -116,12 +116,14 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if ( handler != null )
|
||||||
|
+ PacketWrapper packet = (PacketWrapper) msg;
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ try
|
||||||
|
{
|
||||||
|
- PacketWrapper packet = (PacketWrapper) msg;
|
||||||
|
- boolean sendPacket = handler.shouldHandle( packet );
|
||||||
|
- try
|
||||||
|
+ if ( handler != null )
|
||||||
|
{
|
||||||
|
+ boolean sendPacket = handler.shouldHandle( packet );
|
||||||
|
if ( sendPacket && packet.packet != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
@@ -136,10 +138,10 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
||||||
|
{
|
||||||
|
handler.handle( packet );
|
||||||
|
}
|
||||||
|
- } finally
|
||||||
|
- {
|
||||||
|
- packet.trySingleRelease();
|
||||||
|
}
|
||||||
|
+ } finally
|
||||||
|
+ {
|
||||||
|
+ packet.trySingleRelease();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
From 15a8f8edb2a5bca8b39560784ce8d20cb1f89d74 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 90031156..a190dfae 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.32.0
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
From 596bb7b14abdea0ba23fa966a6d594977c230331 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 86182cdd..b28f4081 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 7dbbfd3c..b7842055 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
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
|
@ -0,0 +1,204 @@
|
||||||
|
From e4f068cdf525de91cca34a4cc493303acbe1dec4 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/FlameConfig.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
|
||||||
|
index cfbd55c3..360305b9 100644
|
||||||
|
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
|
||||||
|
@@ -11,6 +11,10 @@ public class FlameConfig {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
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 701db67c..25716fa7 100644
|
||||||
|
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||||
|
@@ -3,15 +3,80 @@ package dev._2lstudios.flamecord.configuration;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
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 lombok.Getter;
|
||||||
|
+import net.md_5.bungee.api.ChatColor;
|
||||||
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
|
|
||||||
|
public class FlameCordConfiguration extends FlameConfig {
|
||||||
|
+ private List<String> colors(final List<String> strings) {
|
||||||
|
+ for (int i = 0; i < strings.size(); i++) {
|
||||||
|
+ strings.set(i, ChatColor.translateAlternateColorCodes('&', strings.get(i)));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return strings;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public String getMOTD(final int maxPlayers, final int onlinePlayers) {
|
||||||
|
+ final String motd = motds.get(new Random().nextInt(motds.size()));
|
||||||
|
+
|
||||||
|
+ return motd.replace("%maxplayers%", String.valueOf(maxPlayers)).replace("%onlineplayers%", String.valueOf(onlinePlayers));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public String[] getSample(final int maxPlayers, final int onlinePlayers) {
|
||||||
|
+ final String sample = samples.get(new Random().nextInt(samples.size()));
|
||||||
|
+
|
||||||
|
+ return sample.replace("%maxplayers%", String.valueOf(maxPlayers)).replace("%onlineplayers%", String.valueOf(onlinePlayers)).split("\n");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ 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;
|
||||||
|
+ @Getter
|
||||||
|
+ private List<String> motds = Collections.singletonList("&eDefault &cFlameCord&e custom motd!\n&eChange me in &cflamecord.yml&e file!");
|
||||||
|
+
|
||||||
|
+ @Getter
|
||||||
|
+ private boolean sampleEnabled = false;
|
||||||
|
+ @Getter
|
||||||
|
+ private List<String> samples = Collections.singletonList("&eDefault &cFlameCord&e sample!\n&eChange me in &cflamecord.yml&e file!");
|
||||||
|
+
|
||||||
|
+ @Getter
|
||||||
|
+ private boolean protocolEnabled = false;
|
||||||
|
+ @Getter
|
||||||
|
+ private String protocolName = "FlameCord 1.7-1.18";
|
||||||
|
+
|
||||||
|
+ @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
|
||||||
|
@@ -34,6 +99,19 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||||
|
configuration = configurationProvider.load(configurationFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ this.motdEnabled = setIfUnexistant("custom-motd.motd.enabled", this.motdEnabled, configuration);
|
||||||
|
+ this.motds = colors(new ArrayList<>(setIfUnexistant("custom-motd.motd.motds", this.motds, configuration)));
|
||||||
|
+ this.sampleEnabled = setIfUnexistant("custom-motd.sample.enabled", this.sampleEnabled, configuration);
|
||||||
|
+ this.samples = colors(new ArrayList<>(setIfUnexistant("custom-motd.sample.samples", this.samples, configuration)));
|
||||||
|
+ this.protocolEnabled = setIfUnexistant("custom-motd.protocol.enabled", this.protocolEnabled, configuration);
|
||||||
|
+ this.protocolName = setIfUnexistant("custom-motd.protocol.name", this.protocolName, 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);
|
||||||
|
+
|
||||||
|
this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration);
|
||||||
|
this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
|
||||||
|
this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, configuration);
|
||||||
|
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 cfd6249e..d1a06397 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 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;
|
||||||
|
@@ -250,7 +252,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>()
|
||||||
|
@@ -313,7 +314,52 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
( (BungeeServerInfo) forced ).ping( pingBack, handshake.getProtocolVersion() );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
- pingBack.done( getPingInfo( motd, protocol ), null );
|
||||||
|
+ // FlameCord - Custom MOTD
|
||||||
|
+ 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);
|
||||||
|
+ } else {
|
||||||
|
+ motd = ( forced != null ) ? forced.getMotd() : listener.getMotd();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (config.isProtocolEnabled()) {
|
||||||
|
+ protocolName = config.getProtocolName();
|
||||||
|
+ } else {
|
||||||
|
+ protocolName = bungee.getName() + " " + bungee.getGameVersion();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (config.isSampleEnabled()) {
|
||||||
|
+ final UUID fakeUuid = new UUID(0, 0);
|
||||||
|
+ final String[] sampleString = config.getSample(maxPlayers, onlinePlayers);
|
||||||
|
+
|
||||||
|
+ 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, protocol ),
|
||||||
|
+ new ServerPing.Players( maxPlayers, onlinePlayers, sample ),
|
||||||
|
+ motd, BungeeCord.getInstance().config.getFaviconObject() ), null );
|
||||||
|
}
|
||||||
|
|
||||||
|
thisState = State.PING;
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
From d520f9c83d7a5a455fd08bfa57f598140f512024 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 25716fa7..a77cecf0 100644
|
||||||
|
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||||
|
@@ -16,6 +16,10 @@ import net.md_5.bungee.config.Configuration;
|
||||||
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
|
|
||||||
|
public class FlameCordConfiguration extends FlameConfig {
|
||||||
|
+ // FlameCord - TCP Fast Open
|
||||||
|
+ @Getter
|
||||||
|
+ private int tcpFastOpen = 3;
|
||||||
|
+
|
||||||
|
private List<String> colors(final List<String> strings) {
|
||||||
|
for (int i = 0; i < strings.size(); i++) {
|
||||||
|
strings.set(i, ChatColor.translateAlternateColorCodes('&', strings.get(i)));
|
||||||
|
@@ -111,6 +115,7 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||||
|
this.fakePlayersEnabled = setIfUnexistant("custom-motd.fakeplayers.enabled", this.fakePlayersEnabled, configuration);
|
||||||
|
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
|
||||||
|
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);
|
||||||
|
+ this.tcpFastOpen = setIfUnexistant("tcp-fast-open", this.tcpFastOpen, configuration);
|
||||||
|
|
||||||
|
this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration);
|
||||||
|
this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
|
||||||
|
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 a840bc70..f4bf745c 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
|
||||||
|
@@ -198,6 +198,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.32.0
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
From 2955e7fb79cc4a078a7290263cf86e2da94381f8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
|
||||||
|
Date: Fri, 25 Feb 2022 12:28:31 -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 d1a06397..0a09f92c 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
|
||||||
|
@@ -130,12 +130,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
private enum State
|
||||||
|
{
|
||||||
|
|
||||||
|
- HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING;
|
||||||
|
+ PROCESSING, PROCESSING_USERNAME, HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHING;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canSendKickMessage()
|
||||||
|
{
|
||||||
|
- return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING;
|
||||||
|
+ return thisState == State.PROCESSING_USERNAME || thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHING;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -250,6 +250,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
public void handle(StatusRequest statusRequest) throws Exception
|
||||||
|
{
|
||||||
|
Preconditions.checkState( thisState == State.STATUS, "Not expecting STATUS" );
|
||||||
|
+ thisState = State.PROCESSING;
|
||||||
|
|
||||||
|
ServerInfo forced = AbstractReconnectHandler.getForcedHost( this );
|
||||||
|
final int protocol = ( ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion();
|
||||||
|
@@ -372,6 +373,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
{
|
||||||
|
// FlameCord - Never accept invalid packets
|
||||||
|
Preconditions.checkState( thisState == State.PING, "Not expecting PING" );
|
||||||
|
+ thisState = State.PROCESSING;
|
||||||
|
|
||||||
|
unsafe.sendPacket( ping );
|
||||||
|
|
||||||
|
@@ -383,6 +385,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
public void handle(Handshake handshake) throws Exception
|
||||||
|
{
|
||||||
|
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
|
||||||
|
+ thisState = State.PROCESSING;
|
||||||
|
this.handshake = handshake;
|
||||||
|
ch.setVersion( handshake.getProtocolVersion() );
|
||||||
|
|
||||||
|
@@ -455,6 +458,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
public void handle(LoginRequest loginRequest) throws Exception
|
||||||
|
{
|
||||||
|
Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" );
|
||||||
|
+ thisState = State.PROCESSING_USERNAME;
|
||||||
|
|
||||||
|
if ( !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) )
|
||||||
|
{
|
||||||
|
@@ -513,6 +517,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
public void handle(final EncryptionResponse encryptResponse) throws Exception
|
||||||
|
{
|
||||||
|
Preconditions.checkState( thisState == State.ENCRYPT, "Not expecting ENCRYPT" );
|
||||||
|
+ thisState = State.PROCESSING;
|
||||||
|
|
||||||
|
SecretKey sharedKey = EncryptionUtil.getSecret( encryptResponse, request );
|
||||||
|
// Waterfall start
|
||||||
|
@@ -740,14 +745,14 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
@Override
|
||||||
|
public void setOnlineMode(boolean onlineMode)
|
||||||
|
{
|
||||||
|
- Preconditions.checkState( thisState == State.USERNAME, "Can only set online mode status whilst state is username" );
|
||||||
|
+ Preconditions.checkState( thisState == State.USERNAME || thisState == State.PROCESSING_USERNAME, "Can only set online mode status whilst state is username" );
|
||||||
|
this.onlineMode = onlineMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUniqueId(UUID uuid)
|
||||||
|
{
|
||||||
|
- Preconditions.checkState( thisState == State.USERNAME, "Can only set uuid while state is username" );
|
||||||
|
+ Preconditions.checkState( thisState == State.USERNAME || thisState == State.PROCESSING_USERNAME, "Can only set uuid while state is username" );
|
||||||
|
// FlameCord - Allow custom uuids even if onlineMode is true
|
||||||
|
this.uniqueId = uuid;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,46 @@
|
||||||
|
From 979e4625e5efa8e34d885f6e7ce02dae8d008161 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 9ace4ff5..d2fa6216 100644
|
||||||
|
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||||
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||||
|
@@ -16,6 +16,10 @@ import net.md_5.bungee.config.Configuration;
|
||||||
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
|
|
||||||
|
public class FlameCordConfiguration extends FlameConfig {
|
||||||
|
+ // FlameCord - Allow Invalid Names
|
||||||
|
+ @Getter
|
||||||
|
+ private boolean allowInvalidNames = false;
|
||||||
|
+
|
||||||
|
// FlameCord start - Antibot System
|
||||||
|
@Getter
|
||||||
|
private boolean antibotAccountsEnabled = true;
|
||||||
|
@@ -223,6 +227,8 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||||
|
this.fakePlayersEnabled = setIfUnexistant("custom-motd.fakeplayers.enabled", this.fakePlayersEnabled, configuration);
|
||||||
|
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
|
||||||
|
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);
|
||||||
|
+ this.allowInvalidNames = setIfUnexistant("allow-invalid-names", this.allowInvalidNames, configuration);
|
||||||
|
+
|
||||||
|
loadAntibot(configuration);
|
||||||
|
|
||||||
|
this.tcpFastOpen = setIfUnexistant("tcp-fast-open", this.tcpFastOpen, configuration);
|
||||||
|
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 813f0e9b..7fa3217e 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
|
||||||
|
@@ -498,7 +498,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||||
|
Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" );
|
||||||
|
thisState = State.PROCESSING_USERNAME;
|
||||||
|
|
||||||
|
- if ( !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) )
|
||||||
|
+ if ( !FlameCord.getInstance().getFlameCordConfiguration().isAllowInvalidNames() && !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) )
|
||||||
|
{
|
||||||
|
disconnect( bungee.getTranslation( "name_invalid" ) );
|
||||||
|
return;
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
From 0c74e3dae65a16605b5faee82cac81a4dc72d933 Mon Sep 17 00:00:00 2001
|
||||||
|
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
|
||||||
|
Date: Wed, 9 Mar 2022 14:36:43 -0300
|
||||||
|
Subject: [PATCH] Duplicate buf instead of Copy
|
||||||
|
|
||||||
|
|
||||||
|
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 3992f521..074d2437 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
|
||||||
|
@@ -52,7 +52,8 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- ByteBuf slice = in.copy(); // Can't slice this one due to EntityMap :(
|
||||||
|
+ // FlameCord - Duplicate buf instead of Copy
|
||||||
|
+ ByteBuf slice = in.duplicate(); // Can't slice this one due to EntityMap :(
|
||||||
|
|
||||||
|
Object packetTypeInfo = null;
|
||||||
|
try
|
||||||
|
@@ -92,7 +93,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.32.0
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"rb" | "rbp" | "rebuild")
|
||||||
|
scripts/rebuildPatches.sh
|
||||||
|
;;
|
||||||
|
"p" | "patch")
|
||||||
|
scripts/build.sh
|
||||||
|
;;
|
||||||
|
"m" | "up" | "merge")
|
||||||
|
scripts/mergeUpstream.sh
|
||||||
|
;;
|
||||||
|
"b" | "build")
|
||||||
|
scripts/build.sh --jar
|
||||||
|
;;
|
||||||
|
"e" | "edit")
|
||||||
|
scripts/edit.sh
|
||||||
|
;;
|
||||||
|
"w" | "wiggle")
|
||||||
|
scripts/wigglePatch.py
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "FlameCord build tool command. This provides a variety of commands to control the FlameCord"
|
||||||
|
echo "build. View below for details of the available commands."
|
||||||
|
echo ""
|
||||||
|
echo "Commands:"
|
||||||
|
echo " * rb, rbp, rebuild | Rebuilds the patches"
|
||||||
|
echo " * p, patch | Applies all the patches to BungeeCord"
|
||||||
|
echo " * m, up, merge | Utility to aid in merging upstream"
|
||||||
|
echo " * b, build | Builds the project"
|
||||||
|
echo " | The bootstrap artifact can be found in FlameCord-Proxy/bootstrap/target/"
|
||||||
|
echo " * e, edit | Runs git rebase -i for Waterfall, allowing patches to be easily modified"
|
||||||
|
echo " * w, wiggle | Helps to apply patches that fail to using default Git."
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -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>
|
|
@ -0,0 +1,73 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
PS1="$"
|
||||||
|
basedir="$(cd "$1" && pwd -P)"
|
||||||
|
workdir="$basedir/work"
|
||||||
|
gpgsign="$(git config commit.gpgsign || echo "false")"
|
||||||
|
echo "Rebuilding Forked projects.... "
|
||||||
|
|
||||||
|
function enableCommitSigningIfNeeded {
|
||||||
|
if [[ "$gpgsign" == "true" ]]; then
|
||||||
|
echo "Re-enabling GPG Signing"
|
||||||
|
# Yes, this has to be global
|
||||||
|
git config --global commit.gpgsign true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyPatch {
|
||||||
|
what=$1
|
||||||
|
what_name=$(basename "$what")
|
||||||
|
target=$2
|
||||||
|
branch=$3
|
||||||
|
|
||||||
|
cd "$basedir/$what"
|
||||||
|
git fetch
|
||||||
|
git branch -f upstream "$branch" >/dev/null
|
||||||
|
|
||||||
|
cd "$basedir"
|
||||||
|
if [ ! -d "$basedir/$target" ]; then
|
||||||
|
git clone "$what" "$target"
|
||||||
|
fi
|
||||||
|
cd "$basedir/$target"
|
||||||
|
|
||||||
|
echo "Resetting $target to $what_name..."
|
||||||
|
git remote rm upstream > /dev/null 2>&1
|
||||||
|
git remote add upstream "$basedir/$what" >/dev/null 2>&1
|
||||||
|
git checkout master 2>/dev/null || git checkout -b master
|
||||||
|
git fetch upstream >/dev/null 2>&1
|
||||||
|
git reset --hard upstream/upstream
|
||||||
|
|
||||||
|
echo " Applying patches to $target..."
|
||||||
|
|
||||||
|
git am --abort >/dev/null 2>&1
|
||||||
|
git am --3way --ignore-whitespace "$basedir/${what_name}-Patches/"*.patch
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
echo " Something did not apply cleanly to $target."
|
||||||
|
echo " Please review above details and finish the apply then"
|
||||||
|
echo " save the changes with rebuildPatches.sh"
|
||||||
|
enableCommitSigningIfNeeded
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo " Patches applied cleanly to $target"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Disable GPG signing before AM, slows things down and doesn't play nicely.
|
||||||
|
# There is also zero rational or logical reason to do so for these sub-repo AMs.
|
||||||
|
# Calm down kids, it's re-enabled (if needed) immediately after, pass or fail.
|
||||||
|
if [[ "$gpgsign" == "true" ]]; then
|
||||||
|
echo "_Temporarily_ disabling GPG signing"
|
||||||
|
git config --global commit.gpgsign false
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Apply waterfall patches
|
||||||
|
basedir=$basedir/Waterfall
|
||||||
|
pushd Waterfall
|
||||||
|
applyPatch BungeeCord Waterfall-Proxy HEAD
|
||||||
|
popd
|
||||||
|
basedir=$(dirname "$basedir")
|
||||||
|
|
||||||
|
# Apply flamecord patches
|
||||||
|
applyPatch Waterfall/Waterfall-Proxy FlameCord-Proxy HEAD
|
||||||
|
|
||||||
|
enableCommitSigningIfNeeded
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
git submodule update --recursive --init && ./scripts/applyPatches.sh
|
||||||
|
if [ "$1" == "--jar" ]; then
|
||||||
|
pushd FlameCord-Proxy
|
||||||
|
mvn clean package
|
||||||
|
fi
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
pushd FlameCord-Proxy
|
||||||
|
git rebase --interactive upstream/upstream
|
||||||
|
popd
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
PS1="$"
|
||||||
|
basedir=`pwd`
|
||||||
|
|
||||||
|
function update {
|
||||||
|
cd "$basedir/$1"
|
||||||
|
git fetch && git reset --hard origin/master
|
||||||
|
cd "$basedir/$1/.."
|
||||||
|
git add $1
|
||||||
|
}
|
||||||
|
|
||||||
|
update Waterfall
|
||||||
|
|
||||||
|
# Update submodules
|
||||||
|
git submodule update --recursive
|
|
@ -0,0 +1,61 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
(
|
||||||
|
PS1="$"
|
||||||
|
basedir="$(cd "$1" && pwd -P)"
|
||||||
|
workdir="$basedir/work"
|
||||||
|
echo "Rebuilding patch files from current fork state..."
|
||||||
|
git config core.safecrlf false
|
||||||
|
|
||||||
|
function cleanupPatches {
|
||||||
|
cd "$1"
|
||||||
|
for patch in *.patch; do
|
||||||
|
echo "$patch"
|
||||||
|
gitver=$(tail -n 2 "$patch" | grep -ve "^$" | tail -n 1)
|
||||||
|
diffs=$(git diff --staged "$patch" | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index)")
|
||||||
|
|
||||||
|
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
|
||||||
|
if [ "x$testver" != "x" ]; then
|
||||||
|
diffs=$(echo "$diffs" | sed 'N;$!P;$!D;$d')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$diffs" == "x" ] ; then
|
||||||
|
git reset HEAD "$patch" >/dev/null
|
||||||
|
git checkout -- "$patch" >/dev/null
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function savePatches {
|
||||||
|
what=$1
|
||||||
|
what_name=$(basename "$what")
|
||||||
|
target=$2
|
||||||
|
echo "Formatting patches for $what..."
|
||||||
|
|
||||||
|
cd "$basedir/${what_name}-Patches/"
|
||||||
|
if [ -d "$basedir/$target/.git/rebase-apply" ]; then
|
||||||
|
# in middle of a rebase, be smarter
|
||||||
|
echo "REBASE DETECTED - PARTIAL SAVE"
|
||||||
|
last=$(cat "$basedir/$target/.git/rebase-apply/last")
|
||||||
|
next=$(cat "$basedir/$target/.git/rebase-apply/next")
|
||||||
|
for i in $(seq -f "%04g" 1 1 $last)
|
||||||
|
do
|
||||||
|
if [ $i -lt $next ]; then
|
||||||
|
rm ${i}-*.patch
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
rm -rf *.patch
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$basedir/$target"
|
||||||
|
|
||||||
|
git format-patch --no-stat -N -o "$basedir/${what_name}-Patches/" upstream/upstream >/dev/null
|
||||||
|
cd "$basedir"
|
||||||
|
git add -A "$basedir/${what_name}-Patches"
|
||||||
|
cleanupPatches "$basedir/${what_name}-Patches"
|
||||||
|
echo " Patches saved for $what to $what_name-Patches/"
|
||||||
|
}
|
||||||
|
|
||||||
|
savePatches "Waterfall/Waterfall-Proxy" "FlameCord-Proxy"
|
||||||
|
)
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
PS1="$"
|
||||||
|
|
||||||
|
function changelog() {
|
||||||
|
base=$(git ls-tree HEAD $1 | cut -d' ' -f3 | cut -f1)
|
||||||
|
cd $1 && git log --oneline ${base}...HEAD
|
||||||
|
}
|
||||||
|
waterfall=$(changelog Waterfall)
|
||||||
|
|
||||||
|
updated=""
|
||||||
|
logsuffix=""
|
||||||
|
if [ ! -z "$waterfall" ]; then
|
||||||
|
logsuffix="$logsuffix\n\nWaterfall Changes:\n$waterfall"
|
||||||
|
if [ -z "$updated" ]; then updated="Waterfall"; else updated="$updated/Waterfall"; fi
|
||||||
|
fi
|
||||||
|
disclaimer="Upstream has released updates that appear to apply and compile correctly.\nThis update has not been tested by 2LStudios and as with ANY update, please do your own testing"
|
||||||
|
|
||||||
|
if [ ! -z "$1" ]; then
|
||||||
|
disclaimer="$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log="${UP_LOG_PREFIX}Updated Upstream ($updated)\n\n${disclaimer}${logsuffix}"
|
||||||
|
|
||||||
|
echo -e "$log" | git commit -F -
|
||||||
|
|
||||||
|
) || exit 1
|
|
@ -0,0 +1,149 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
from subprocess import run, PIPE, CalledProcessError
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
import os
|
||||||
|
from os import path
|
||||||
|
from sys import stderr, stdout
|
||||||
|
import re
|
||||||
|
from enum import Enum, unique
|
||||||
|
|
||||||
|
@unique
|
||||||
|
class FileStatus(Enum):
|
||||||
|
UNTRACKED = '?'
|
||||||
|
UNMODIFIED = ' '
|
||||||
|
MODIFIED = 'M'
|
||||||
|
ADDED = 'A'
|
||||||
|
DELETED = 'D'
|
||||||
|
RENAMED = 'R'
|
||||||
|
COPIED = 'C'
|
||||||
|
UNMERGED = 'U'
|
||||||
|
IGNORED = '!'
|
||||||
|
|
||||||
|
class GitRepository:
|
||||||
|
def __init__(self, directory):
|
||||||
|
if not path.isdir(directory):
|
||||||
|
if not path.exists(directory):
|
||||||
|
raise ValueError("Repository doesn't exist:", directory)
|
||||||
|
else:
|
||||||
|
raise ValueError("Repository isn't a valid directory:", directory)
|
||||||
|
elif not path.isdir(path.join(directory, ".git")):
|
||||||
|
raise ValueError("Directory isn't a git repository:", directory)
|
||||||
|
self.directory = directory
|
||||||
|
|
||||||
|
def status(self):
|
||||||
|
status_lines = run(
|
||||||
|
["git", "status", "--porcelain"],
|
||||||
|
check=True, stdout=PIPE, universal_newlines=True,
|
||||||
|
cwd=self.directory
|
||||||
|
).stdout
|
||||||
|
status = dict()
|
||||||
|
for line in status_lines.splitlines():
|
||||||
|
old_status = FileStatus(line[0])
|
||||||
|
new_status = FileStatus(line[1])
|
||||||
|
file_name = line[3:]
|
||||||
|
status[file_name] = (old_status, new_status)
|
||||||
|
return status
|
||||||
|
|
||||||
|
def is_clean(self):
|
||||||
|
try:
|
||||||
|
return len(self.status()) == 0
|
||||||
|
except CalledProcessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def is_automatically_merging(self):
|
||||||
|
return path.exists(path.join(self.directory, ".git", "rebase-apply", "applying"))
|
||||||
|
|
||||||
|
def wiggle_patch(self, patch):
|
||||||
|
assert self.is_clean()
|
||||||
|
# By default, wiggle won't create files the patch needs, and just fails
|
||||||
|
for created_file in patch.created_files:
|
||||||
|
# mkdir -p $(dirname created_file)
|
||||||
|
os.makedirs(path.join(self.directory, path.dirname(created_file)), exist_ok=True)
|
||||||
|
# touch created_file
|
||||||
|
with open(path.join(self.directory, created_file), 'a'):
|
||||||
|
pass
|
||||||
|
result = run(["wiggle", "-rp", path.relpath(patch.file, start=self.directory)],
|
||||||
|
stderr=stderr, cwd=self.directory)
|
||||||
|
for file_name, (old_status, new_status) in self.status().items():
|
||||||
|
if new_status == FileStatus.UNTRACKED and old_status == FileStatus.UNTRACKED \
|
||||||
|
and file_name.endswith(".porig"):
|
||||||
|
# Remove wiggle's automatically created backup files
|
||||||
|
# They're completely unessicary since the entire repo is version-controlled
|
||||||
|
os.remove(path.join(self.directory, file_name))
|
||||||
|
if result.returncode == 1:
|
||||||
|
return False # There were unresolved conflicts
|
||||||
|
else:
|
||||||
|
# Check for an unexpected error
|
||||||
|
# Since conflicts were already checked for, this will only raise for unexpected errors
|
||||||
|
result.check_returncode()
|
||||||
|
return True # Successfully wiggled
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return path.basename(self.directory)
|
||||||
|
|
||||||
|
class PatchFile:
|
||||||
|
def __init__(self, file):
|
||||||
|
if not path.isfile(file):
|
||||||
|
if not path.exists(file):
|
||||||
|
raise ValueError("Patch file doesn't exist:", file)
|
||||||
|
else:
|
||||||
|
raise ValueError("Patch isn't a file:", file)
|
||||||
|
self.file = file
|
||||||
|
try:
|
||||||
|
summary = run(["git", "apply", "--summary", file],
|
||||||
|
check=True, stdout=PIPE, universal_newlines=True).stdout
|
||||||
|
except CalledProcessError:
|
||||||
|
raise ValueError("Invalid patch file:", file)
|
||||||
|
summary_pattern = re.compile(r"\s*(create) mode \d+ (\S+)")
|
||||||
|
created_files = list()
|
||||||
|
for line in summary.splitlines():
|
||||||
|
match = summary_pattern.match(line)
|
||||||
|
if not match:
|
||||||
|
raise NotImplementedError("Don't know how to parse summary line: {}".format(line))
|
||||||
|
(action, target_file) = match.groups()
|
||||||
|
if action == "create":
|
||||||
|
created_files.append(target_file)
|
||||||
|
self.created_files = tuple(created_files) # Immutable copy
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return path.basename(self.file)
|
||||||
|
|
||||||
|
parser = ArgumentParser(description="Wiggle the patch into the specified git repository")
|
||||||
|
parser.add_argument("repo", help="The git repository to apply the patch to", type=GitRepository)
|
||||||
|
parser.add_argument("patch", help="The patch to apply to the repository", type=PatchFile)
|
||||||
|
parser.add_argument("--git-am", "--am", "-a", action="store_true",
|
||||||
|
help="If an automatic merge is in progress, continue it after wiggling")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
repository, patch = args.repo, args.patch
|
||||||
|
|
||||||
|
if not repository.is_clean():
|
||||||
|
print(repository, "isn't a clean repo!")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
was_automatically_merging = False
|
||||||
|
if args.git_am and repository.is_automatically_merging():
|
||||||
|
print("Automatic merge in progress, will continue applying if successful")
|
||||||
|
was_automatically_merging = True
|
||||||
|
|
||||||
|
if not repository.wiggle_patch(patch):
|
||||||
|
print("Unresolved conflicts found while wiggling!", file=stderr)
|
||||||
|
print("Manual intervention is required to fix the conflicts!", file=stderr)
|
||||||
|
exit(2)
|
||||||
|
|
||||||
|
if args.git_am and was_automatically_merging:
|
||||||
|
assert repository.is_automatically_merging()
|
||||||
|
try:
|
||||||
|
print("Adding changed files to index")
|
||||||
|
run(["git", "add", "."], stdout=stdout, stderr=stderr, check=True,
|
||||||
|
cwd=repository.directory)
|
||||||
|
print("Continuing automatic merge after successful wiggle")
|
||||||
|
run(["git", "am", "--continue"], stdout=stdout, stderr=stderr, check=True,
|
||||||
|
cwd=repository.directory)
|
||||||
|
except CalledProcessError as e:
|
||||||
|
print("Failed to continue automatic merge!", file=stderr)
|
||||||
|
exit(3)
|
||||||
|
else:
|
||||||
|
print("Successfully Wiggled", patch, "into", repository)
|
Loading…
Reference in New Issue