From d938a5d028fbe69346c962839c0967734662c16a Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 10 Sep 2024 22:40:42 +0100 Subject: [PATCH] zestgodguap t.me/ratware --- .gitattributes | 1 + .github/FUNDING.yml | 1 + .gitignore | 11 + .gitmodules | 3 + CONTRIBUTING.md | 99 + LICENSE.txt | 21 + README.md | 38 + .../0001-FlameCord-POM-Changes.patch | 146 + ...ferences-from-Waterfall-to-FlameCord.patch | 122 + .../0003-FlameCord-rebrand.patch | 63 + .../0004-1.7.x-support.patch | 1627 +++++++++ ...ake-PlayerHandshakeEvent-cancellable.patch | 56 + .../0006-Make-a-getter-for-the-callback.patch | 23 + ...sable-update-checker-Use-bungee-name.patch | 74 + .../0008-Change-replaceAll-to-replace.patch | 23 + ...ections-Don-t-flush-if-not-necessary.patch | 179 + .../0010-Packet-Checks.patch | 53 + .../0011-Change-default-timeout.patch | 23 + ...0012-Don-t-allow-name-containing-dot.patch | 23 + ...13-Use-pipeline-to-reduce-redundancy.patch | 78 + ...tom-uuids-even-if-onlineMode-is-true.patch | 22 + ...ateException-to-QuietException-and-e.patch | 24 + ...-Don-t-declare-uuid-unless-it-s-null.patch | 25 + .../0017-FlameCord-General-Patch.patch | 383 ++ .../0018-FlameCord-module-system.patch | 193 + ...0019-FlameCord-message-configuration.patch | 225 ++ .../0020-Fix-ByteBuf-memory-leaks.patch | 68 + .../0021-Check-if-packetID-is-invalid.patch | 27 + .../0022-FlameCord-logger-options.patch | 116 + .../0023-Always-release-packets.patch | 46 + ...dded-an-api-method-to-unload-Plugins.patch | 86 + .../0025-Apply-packet-limits.patch | 55 + .../0026-Custom-motd-system.patch | 204 ++ .../0027-TCP-Fast-Open.patch | 45 + ...0028-InitialHandler-Processing-State.patch | 85 + .../0029-Antibot-System.patch | 1134 ++++++ .../0030-Allow-Invalid-Names.patch | 46 + .../0031-Duplicate-buf-instead-of-Copy.patch | 33 + ...0032-Disable-entity-Metadata-Rewrite.patch | 3234 +++++++++++++++++ flamecord | 35 + pom.xml | 25 + scripts/applyPatches.sh | 73 + scripts/build.sh | 7 + scripts/edit.sh | 5 + scripts/mergeUpstream.sh | 16 + scripts/rebuildPatches.sh | 61 + scripts/upstreamCommit.sh | 28 + scripts/wigglePatch.py | 149 + 48 files changed, 9114 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/FUNDING.yml create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 Waterfall-Proxy-Patches/0001-FlameCord-POM-Changes.patch create mode 100644 Waterfall-Proxy-Patches/0002-Rename-references-from-Waterfall-to-FlameCord.patch create mode 100644 Waterfall-Proxy-Patches/0003-FlameCord-rebrand.patch create mode 100644 Waterfall-Proxy-Patches/0004-1.7.x-support.patch create mode 100644 Waterfall-Proxy-Patches/0005-Make-PlayerHandshakeEvent-cancellable.patch create mode 100644 Waterfall-Proxy-Patches/0006-Make-a-getter-for-the-callback.patch create mode 100644 Waterfall-Proxy-Patches/0007-Disable-update-checker-Use-bungee-name.patch create mode 100644 Waterfall-Proxy-Patches/0008-Change-replaceAll-to-replace.patch create mode 100644 Waterfall-Proxy-Patches/0009-Close-connections-Don-t-flush-if-not-necessary.patch create mode 100644 Waterfall-Proxy-Patches/0010-Packet-Checks.patch create mode 100644 Waterfall-Proxy-Patches/0011-Change-default-timeout.patch create mode 100644 Waterfall-Proxy-Patches/0012-Don-t-allow-name-containing-dot.patch create mode 100644 Waterfall-Proxy-Patches/0013-Use-pipeline-to-reduce-redundancy.patch create mode 100644 Waterfall-Proxy-Patches/0014-Allow-custom-uuids-even-if-onlineMode-is-true.patch create mode 100644 Waterfall-Proxy-Patches/0015-Change-IllegalStateException-to-QuietException-and-e.patch create mode 100644 Waterfall-Proxy-Patches/0016-Don-t-declare-uuid-unless-it-s-null.patch create mode 100644 Waterfall-Proxy-Patches/0017-FlameCord-General-Patch.patch create mode 100644 Waterfall-Proxy-Patches/0018-FlameCord-module-system.patch create mode 100644 Waterfall-Proxy-Patches/0019-FlameCord-message-configuration.patch create mode 100644 Waterfall-Proxy-Patches/0020-Fix-ByteBuf-memory-leaks.patch create mode 100644 Waterfall-Proxy-Patches/0021-Check-if-packetID-is-invalid.patch create mode 100644 Waterfall-Proxy-Patches/0022-FlameCord-logger-options.patch create mode 100644 Waterfall-Proxy-Patches/0023-Always-release-packets.patch create mode 100644 Waterfall-Proxy-Patches/0024-Added-an-api-method-to-unload-Plugins.patch create mode 100644 Waterfall-Proxy-Patches/0025-Apply-packet-limits.patch create mode 100644 Waterfall-Proxy-Patches/0026-Custom-motd-system.patch create mode 100644 Waterfall-Proxy-Patches/0027-TCP-Fast-Open.patch create mode 100644 Waterfall-Proxy-Patches/0028-InitialHandler-Processing-State.patch create mode 100644 Waterfall-Proxy-Patches/0029-Antibot-System.patch create mode 100644 Waterfall-Proxy-Patches/0030-Allow-Invalid-Names.patch create mode 100644 Waterfall-Proxy-Patches/0031-Duplicate-buf-instead-of-Copy.patch create mode 100644 Waterfall-Proxy-Patches/0032-Disable-entity-Metadata-Rewrite.patch create mode 100755 flamecord create mode 100644 pom.xml create mode 100755 scripts/applyPatches.sh create mode 100755 scripts/build.sh create mode 100755 scripts/edit.sh create mode 100755 scripts/mergeUpstream.sh create mode 100755 scripts/rebuildPatches.sh create mode 100755 scripts/upstreamCommit.sh create mode 100644 scripts/wigglePatch.py diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..586fe34 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +doxbin[[:space:]]db.txt filter=lfs diff=lfs merge=lfs -text diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..5b3b2b0 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: ['https://paypal.me/LinsaFTW'] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e9b9b10 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +FlameCord-Proxy + +# intellij +*.iml +*.ipr +*.iws +.idea/ +out/ + +.project +.settings \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f5069af --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Waterfall"] + path = Waterfall + url = https://github.com/WaterfallMC/Waterfall.git diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0494f94 --- /dev/null +++ b/CONTRIBUTING.md @@ -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 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..e43a8af --- /dev/null +++ b/LICENSE.txt @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9acb91d --- /dev/null +++ b/README.md @@ -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. + + + +## 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). diff --git a/Waterfall-Proxy-Patches/0001-FlameCord-POM-Changes.patch b/Waterfall-Proxy-Patches/0001-FlameCord-POM-Changes.patch new file mode 100644 index 0000000..9ffae46 --- /dev/null +++ b/Waterfall-Proxy-Patches/0001-FlameCord-POM-Changes.patch @@ -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 @@ ++ ++ 4.0.0 ++ ++ ++ io.github.waterfallmc ++ waterfall-parent ++ 1.18-R0.1-SNAPSHOT ++ ../pom.xml ++ ++ ++ dev._2lstudios ++ waterfall-flamecord ++ 1.18-R0.1-SNAPSHOT ++ jar ++ ++ Waterfall-FlameCord ++ FlameCord adds security essentials and new configuration options ++ ++ ++ ++ io.github.waterfallmc ++ waterfall-config ++ ${project.version} ++ compile ++ ++ ++ io.github.waterfallmc ++ waterfall-chat ++ ${project.version} ++ compile ++ ++ ++ ++ ++ ${project.name} ++ ++ ++ true ++ ${basedir}/src/main/resources ++ ++ ++ ++ +diff --git a/pom.xml b/pom.xml +index 505d1d14..45f14084 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -63,6 +63,7 @@ + query + + native ++ flamecord + + + +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 @@ + 1.3.0 + compile + ++ ++ ++ ++ dev._2lstudios ++ waterfall-flamecord ++ ${project.version} ++ compile ++ ++ + + +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 @@ + runtime + + ++ ++ ++ ++ dev._2lstudios ++ waterfall-flamecord ++ ${project.version} ++ compile ++ ++ ++ io.github.waterfallmc ++ waterfall-module-cmd-alert ++ ${project.version} ++ compile ++ ++ ++ io.github.waterfallmc ++ waterfall-module-cmd-find ++ ${project.version} ++ compile ++ ++ ++ io.github.waterfallmc ++ waterfall-module-cmd-list ++ ${project.version} ++ compile ++ ++ ++ io.github.waterfallmc ++ waterfall-module-cmd-send ++ ${project.version} ++ compile ++ ++ ++ io.github.waterfallmc ++ waterfall-module-cmd-server ++ ${project.version} ++ compile ++ ++ ++ net.md-5 ++ bungeecord-module-reconnect-yaml ++ ${project.version} ++ compile ++ ++ + + + +-- +2.32.0 + diff --git a/Waterfall-Proxy-Patches/0002-Rename-references-from-Waterfall-to-FlameCord.patch b/Waterfall-Proxy-Patches/0002-Rename-references-from-Waterfall-to-FlameCord.patch new file mode 100644 index 0000000..5399cb3 --- /dev/null +++ b/Waterfall-Proxy-Patches/0002-Rename-references-from-Waterfall-to-FlameCord.patch @@ -0,0 +1,122 @@ +From 73739a822f6730c871a88ade6d7fe7d5efbc117c Mon Sep 17 00:00:00 2001 +From: Techcable +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 @@ + + + +- Waterfall ++ FlameCord + + + org.apache.maven.plugins +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 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 + diff --git a/Waterfall-Proxy-Patches/0003-FlameCord-rebrand.patch b/Waterfall-Proxy-Patches/0003-FlameCord-rebrand.patch new file mode 100644 index 0000000..750ef92 --- /dev/null +++ b/Waterfall-Proxy-Patches/0003-FlameCord-rebrand.patch @@ -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 + // Waterfall start + List 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 + diff --git a/Waterfall-Proxy-Patches/0004-1.7.x-support.patch b/Waterfall-Proxy-Patches/0004-1.7.x-support.patch new file mode 100644 index 0000000..512b813 --- /dev/null +++ b/Waterfall-Proxy-Patches/0004-1.7.x-support.patch @@ -0,0 +1,1627 @@ +From 4ad196ffeace48412b9dd00040c605ffc6f2fb36 Mon Sep 17 00:00:00 2001 +From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> +Date: Thu, 30 Sep 2021 19:54:33 -0300 +Subject: [PATCH] 1.7.x support + + +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java +index a310844d..d07b88b8 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java +@@ -303,4 +303,36 @@ public abstract class DefinedPacket + return 0; + } + // Waterfall end ++ ++ // FlameCord start - 1.7.x support ++ public static byte[] v17readArray(ByteBuf buf) ++ { ++ // Read in a 2 or 3 byte number that represents the length of the packet. (3 byte "shorts" for Forge only) ++ // No vanilla packet should give a 3 byte packet, this method will still retain vanilla behaviour. ++ int len = readVarShort( buf ); ++ ++ // (Integer.MAX_VALUE & 0x1FFF9A ) = 2097050 - Forge's current upper limit ++ Preconditions.checkArgument( len <= ( Integer.MAX_VALUE & 0x1FFF9A ), "Cannot receive array longer than 2097050 (got %s bytes)", len ); ++ ++ byte[] ret = new byte[ len ]; ++ buf.readBytes( ret ); ++ return ret; ++ } ++ ++ public static void v17writeArray(byte[] b, ByteBuf buf, boolean allowExtended) ++ { ++ // (Integer.MAX_VALUE & 0x1FFF9A ) = 2097050 - Forge's current upper limit ++ if ( allowExtended ) ++ { ++ Preconditions.checkArgument( b.length <= ( Integer.MAX_VALUE & 0x1FFF9A ), "Cannot send array longer than 2097050 (got %s bytes)", b.length ); ++ } else ++ { ++ Preconditions.checkArgument( b.length <= Short.MAX_VALUE, "Cannot send array longer than Short.MAX_VALUE (got %s bytes)", b.length ); ++ } ++ // Write a 2 or 3 byte number that represents the length of the packet. (3 byte "shorts" for Forge only) ++ // No vanilla packet should give a 3 byte packet, this method will still retain vanilla behaviour. ++ writeVarShort( buf, b.length ); ++ buf.writeBytes( b ); ++ } ++ // FlameCord end - 1.7.x support + } +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +index 7f0b71c9..04851233 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +@@ -58,7 +58,7 @@ public enum Protocol + TO_SERVER.registerPacket( + Handshake.class, + Handshake::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support + ); + } + }, +@@ -70,7 +70,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + KeepAlive.class, + KeepAlive::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x1F ), + map( ProtocolConstants.MINECRAFT_1_13, 0x21 ), + map( ProtocolConstants.MINECRAFT_1_14, 0x20 ), +@@ -82,7 +82,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + Login.class, + Login::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x23 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x25 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x26 ), +@@ -93,7 +93,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + Chat.class, + Chat::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x02 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x02 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x0F ), + map( ProtocolConstants.MINECRAFT_1_13, 0x0E ), + map( ProtocolConstants.MINECRAFT_1_15, 0x0F ), +@@ -103,7 +103,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + Respawn.class, + Respawn::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x07 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x07 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x33 ), + map( ProtocolConstants.MINECRAFT_1_12, 0x34 ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x35 ), +@@ -126,20 +126,20 @@ public enum Protocol + TO_CLIENT.registerPacket( + EntityEffect.class, + EntityEffect::new, +- map(ProtocolConstants.MINECRAFT_1_8, 0x1D), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x1D ), // FlameCord - 1.7.x support + map(ProtocolConstants.MINECRAFT_1_9, Integer.MIN_VALUE) + ); + TO_CLIENT.registerPacket( + EntityRemoveEffect.class, + EntityRemoveEffect::new, +- map(ProtocolConstants.MINECRAFT_1_8, 0x1E), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x1E ), // FlameCord - 1.7.x support + map(ProtocolConstants.MINECRAFT_1_9, Integer.MIN_VALUE) + ); + // Waterfall end + TO_CLIENT.registerPacket( + PlayerListItem.class, // PlayerInfo + PlayerListItem::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x38 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x38 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x2D ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E ), + map( ProtocolConstants.MINECRAFT_1_13, 0x30 ), +@@ -152,7 +152,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + TabCompleteResponse.class, + TabCompleteResponse::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x3A ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3A ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x0E ), + map( ProtocolConstants.MINECRAFT_1_13, 0x10 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x11 ), +@@ -163,7 +163,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + ScoreboardObjective.class, + ScoreboardObjective::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x3B ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3B ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x3F ), + map( ProtocolConstants.MINECRAFT_1_12, 0x41 ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 ), +@@ -175,7 +175,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + ScoreboardScore.class, + ScoreboardScore::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x3C ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3C ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x42 ), + map( ProtocolConstants.MINECRAFT_1_12, 0x44 ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 ), +@@ -187,7 +187,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + ScoreboardDisplay.class, + ScoreboardDisplay::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x3D ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3D ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x38 ), + map( ProtocolConstants.MINECRAFT_1_12, 0x3A ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B ), +@@ -199,7 +199,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + Team.class, + Team::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x3E ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3E ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x41 ), + map( ProtocolConstants.MINECRAFT_1_12, 0x43 ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 ), +@@ -211,7 +211,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + PluginMessage.class, + PluginMessage::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x3F ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3F ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x18 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x19 ), + map( ProtocolConstants.MINECRAFT_1_14, 0x18 ), +@@ -223,7 +223,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + Kick.class, + Kick::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x40 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x40 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x1A ), + map( ProtocolConstants.MINECRAFT_1_13, 0x1B ), + map( ProtocolConstants.MINECRAFT_1_14, 0x1A ), +@@ -235,7 +235,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + Title.class, + Title::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x45 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x45 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_12, 0x47 ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x48 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x4B ), +@@ -265,7 +265,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + PlayerListHeaderFooter.class, + PlayerListHeaderFooter::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x47 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x47 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x48 ), + map( ProtocolConstants.MINECRAFT_1_9_4, 0x47 ), + map( ProtocolConstants.MINECRAFT_1_12, 0x49 ), +@@ -280,7 +280,7 @@ public enum Protocol + TO_CLIENT.registerPacket( + EntityStatus.class, + EntityStatus::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x1A ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x1A ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x1B ), + map( ProtocolConstants.MINECRAFT_1_13, 0x1C ), + map( ProtocolConstants.MINECRAFT_1_14, 0x1B ), +@@ -318,7 +318,7 @@ public enum Protocol + TO_SERVER.registerPacket( + KeepAlive.class, + KeepAlive::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x0B ), + map( ProtocolConstants.MINECRAFT_1_12, 0x0C ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x0B ), +@@ -330,7 +330,7 @@ public enum Protocol + TO_SERVER.registerPacket( + Chat.class, + Chat::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x02 ), + map( ProtocolConstants.MINECRAFT_1_12, 0x03 ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x02 ), +@@ -339,7 +339,7 @@ public enum Protocol + TO_SERVER.registerPacket( + TabCompleteRequest.class, + TabCompleteRequest::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x14 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x14 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x01 ), + map( ProtocolConstants.MINECRAFT_1_12, 0x02 ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x01 ), +@@ -349,7 +349,7 @@ public enum Protocol + TO_SERVER.registerPacket( + ClientSettings.class, + ClientSettings::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x15 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x15 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x04 ), + map( ProtocolConstants.MINECRAFT_1_12, 0x05 ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ), +@@ -358,7 +358,7 @@ public enum Protocol + TO_SERVER.registerPacket( + PluginMessage.class, + PluginMessage::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x17 ), ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x17 ), // FlameCord - 1.7.x support + map( ProtocolConstants.MINECRAFT_1_9, 0x09 ), + map( ProtocolConstants.MINECRAFT_1_12, 0x0A ), + map( ProtocolConstants.MINECRAFT_1_12_1, 0x09 ), +@@ -376,23 +376,23 @@ public enum Protocol + TO_CLIENT.registerPacket( + StatusResponse.class, + StatusResponse::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support + ); + TO_CLIENT.registerPacket( + PingPacket.class, + PingPacket::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // FlameCord - 1.7.x support + ); + + TO_SERVER.registerPacket( + StatusRequest.class, + StatusRequest::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support + ); + TO_SERVER.registerPacket( + PingPacket.class, + PingPacket::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // FlameCord - 1.7.x support + ); + } + }, +@@ -404,22 +404,22 @@ public enum Protocol + TO_CLIENT.registerPacket( + Kick.class, + Kick::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support + ); + TO_CLIENT.registerPacket( + EncryptionRequest.class, + EncryptionRequest::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // FlameCord - 1.7.x support + ); + TO_CLIENT.registerPacket( + LoginSuccess.class, + LoginSuccess::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x02 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x02 ) // FlameCord - 1.7.x support + ); + TO_CLIENT.registerPacket( + SetCompression.class, + SetCompression::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x03 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x03 ) // FlameCord - 1.7.x support + ); + TO_CLIENT.registerPacket( + LoginPayloadRequest.class, +@@ -430,12 +430,12 @@ public enum Protocol + TO_SERVER.registerPacket( + LoginRequest.class, + LoginRequest::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support + ); + TO_SERVER.registerPacket( + EncryptionResponse.class, + EncryptionResponse::new, +- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ) ++ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // FlameCord - 1.7.x support + ); + TO_SERVER.registerPacket( + LoginPayloadResponse.class, +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java +index 6360818c..5e4f3d64 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java +@@ -7,6 +7,10 @@ public class ProtocolConstants + { + + private static final boolean SNAPSHOT_SUPPORT = Boolean.getBoolean( "net.md_5.bungee.protocol.snapshot" ); ++ // FlameCord start - 1.7.x support ++ public static final int MINECRAFT_1_7_2 = 4; ++ public static final int MINECRAFT_1_7_6 = 5; ++ // FlameCord end - 1.7.x support + public static final int MINECRAFT_1_8 = 47; + public static final int MINECRAFT_1_9 = 107; + public static final int MINECRAFT_1_9_1 = 108; +@@ -44,6 +48,7 @@ public class ProtocolConstants + static + { + ImmutableList.Builder supportedVersions = ImmutableList.builder().add( ++ "1.7.x", // FlameCord - 1.7.x support + "1.8.x", + "1.9.x", + "1.10.x", +@@ -57,6 +62,10 @@ public class ProtocolConstants + "1.18.x" + ); + ImmutableList.Builder supportedVersionIds = ImmutableList.builder().add( ++ // FlameCord start - 1.7.x support ++ ProtocolConstants.MINECRAFT_1_7_2, ++ ProtocolConstants.MINECRAFT_1_7_6, ++ // FlameCord end - 1.7.x support + ProtocolConstants.MINECRAFT_1_8, + ProtocolConstants.MINECRAFT_1_9, + ProtocolConstants.MINECRAFT_1_9_1, +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java +index 6034fc18..6100687c 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java +@@ -41,6 +41,7 @@ public class Chat extends DefinedPacket + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { + message = readString( buf, ( direction == ProtocolConstants.Direction.TO_CLIENT ) ? 262144 : ( protocolVersion >= ProtocolConstants.MINECRAFT_1_11 ? 256 : 100 ) ); ++ if ( ProtocolConstants.isAfterOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_8 ) ) // FlameCord - 1.7.x support + if ( direction == ProtocolConstants.Direction.TO_CLIENT ) + { + position = buf.readByte(); +@@ -60,6 +61,7 @@ public class Chat extends DefinedPacket + } else + // Waterfall end + writeString( message, buf ); ++ if ( ProtocolConstants.isAfterOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_8 ) ) // FlameCord - 1.7.x support + if ( direction == ProtocolConstants.Direction.TO_CLIENT ) + { + buf.writeByte( position ); +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java +index d7d4e6ab..570a89f0 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java +@@ -34,6 +34,12 @@ public class ClientSettings extends DefinedPacket + chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ? DefinedPacket.readVarInt( buf ) : buf.readUnsignedByte(); + chatColours = buf.readBoolean(); + skinParts = buf.readByte(); ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ difficulty = buf.readByte(); ++ } ++ // FlameCord end - 1.7.x support + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) + { + mainHand = DefinedPacket.readVarInt( buf ); +@@ -51,6 +57,19 @@ public class ClientSettings extends DefinedPacket + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ writeString( locale, buf ); ++ buf.writeByte( viewDistance ); ++ buf.writeByte( chatFlags ); ++ buf.writeBoolean( chatColours ); ++ buf.writeByte( skinParts ); ++ buf.writeByte( difficulty ); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + writeString( locale, buf ); + buf.writeByte( viewDistance ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) +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 a29524ca..86182cdd 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 +@@ -23,6 +23,16 @@ public class EncryptionRequest extends DefinedPacket + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ serverId = readString( buf ); ++ publicKey = v17readArray( buf ); ++ verifyToken = v17readArray( buf ); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + serverId = readString( buf ); + publicKey = readArray( buf ); + verifyToken = readArray( buf ); +@@ -31,6 +41,16 @@ public class EncryptionRequest extends DefinedPacket + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ writeString( serverId, buf ); ++ v17writeArray( publicKey, buf, false ); ++ v17writeArray( verifyToken, buf, false ); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + writeString( serverId, buf ); + writeArray( publicKey, buf ); + writeArray( verifyToken, buf ); +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java +index 53575ce0..52d7a5cc 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java +@@ -22,6 +22,15 @@ public class EncryptionResponse extends DefinedPacket + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ sharedSecret = v17readArray( buf ); ++ verifyToken = v17readArray( buf ); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + sharedSecret = readArray( buf, 128 ); + verifyToken = readArray( buf, 128 ); + } +@@ -29,6 +38,15 @@ public class EncryptionResponse extends DefinedPacket + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ v17writeArray( sharedSecret, buf, false ); ++ v17writeArray( verifyToken, buf, false ); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + writeArray( sharedSecret, buf ); + writeArray( verifyToken, buf ); + } +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java +index d11a9ea9..0ed78a8c 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.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 +@@ -21,20 +22,41 @@ public class EntityEffect extends DefinedPacket { + private boolean hideParticles; + + @Override +- public void read(ByteBuf buf) { +- this.entityId = readVarInt(buf); ++ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { ++ this.entityId = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readInt(); // FlameCord - 1.7.x support + this.effectId = buf.readUnsignedByte(); + this.amplifier = buf.readUnsignedByte(); +- this.duration = readVarInt(buf); +- this.hideParticles = buf.readBoolean(); ++ this.duration = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readShort(); // FlameCord - 1.7.x support ++ // FlameCord start - 1.7.x support ++ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) ++ { ++ this.hideParticles = buf.readBoolean(); ++ } ++ // FlameCord end - 1.7.x support + } + + @Override +- public void write(ByteBuf buf) { +- writeVarInt(this.entityId, buf); ++ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { ++ // FlameCord start - 1.7.x support ++ if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8) ++ { ++ writeVarInt(this.entityId, buf); ++ } else ++ { ++ buf.writeInt(effectId); ++ } ++ // FlameCord end - 1.7.x support + buf.writeByte(this.effectId); + buf.writeByte(this.amplifier); +- writeVarInt(this.duration, buf); ++ // FlameCord start - 1.7.x support ++ if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8) ++ { ++ writeVarInt(this.duration, buf); ++ } else ++ { ++ buf.writeShort(duration); ++ } ++ // FlameCord end - 1.7.x support + buf.writeBoolean(this.hideParticles); + } + +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java +index 7ed2dc3a..435b8578 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.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 +@@ -18,14 +19,22 @@ public class EntityRemoveEffect extends DefinedPacket { + private int effectId; + + @Override +- public void read(ByteBuf buf) { +- this.entityId = readVarInt(buf); ++ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { ++ this.entityId = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readInt(); // FlameCord - 1.7.x support + this.effectId = buf.readUnsignedByte(); + } + + @Override +- public void write(ByteBuf buf) { +- writeVarInt(this.entityId, buf); ++ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { ++ // FlameCord start - 1.7.x support ++ if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8) ++ { ++ writeVarInt(this.entityId, buf); ++ } else ++ { ++ buf.writeInt(entityId); ++ } ++ // FlameCord end - 1.7.x support + buf.writeByte(effectId); + } + +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java +index b004bc41..a8c3e773 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java +@@ -21,12 +21,28 @@ public class KeepAlive extends DefinedPacket + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ randomId = buf.readInt(); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + randomId = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_12_2 ) ? buf.readLong() : readVarInt( buf ); + } + + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ buf.writeInt((int) randomId); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_12_2 ) + { + buf.writeLong( randomId ); +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java +index 551bd104..5aeae06c 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java +@@ -23,6 +23,11 @@ public class LoginSuccess extends DefinedPacket + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_2 ) { ++ uuid = readUndashedUUID( buf ); ++ } else ++ // FlameCord end - 1.7.x support + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 ) + { + uuid = readUUID( buf ); +@@ -36,6 +41,11 @@ public class LoginSuccess extends DefinedPacket + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_2 ) { ++ writeUndashedUUID( uuid.toString(), buf ); ++ } else ++ // FlameCord end - 1.7.x support + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 ) + { + writeUUID( uuid, buf ); +@@ -51,4 +61,14 @@ public class LoginSuccess extends DefinedPacket + { + handler.handle( this ); + } ++ ++ // FlameCord start - 1.7.x support ++ private static UUID readUndashedUUID(ByteBuf buf) { ++ return UUID.fromString( new StringBuilder( readString( buf ) ).insert( 20, '-' ).insert( 16, '-' ).insert( 12, '-' ).insert( 8, '-' ).toString() ); ++ } ++ ++ private static void writeUndashedUUID(String uuid, ByteBuf buf) { ++ writeString( new StringBuilder( 32 ).append( uuid, 0, 8 ).append( uuid, 9, 13 ).append( uuid, 14, 18 ).append( uuid, 19, 23 ).append( uuid, 24, 36 ).toString(), buf ); ++ } ++ // FlameCord end - 1.7.x support + } +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java +index 92bacc7c..cae5bda5 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java +@@ -21,6 +21,18 @@ public class PlayerListItem extends DefinedPacket + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ items = new Item[ 1 ]; ++ Item item = items[ 0 ] = new Item(); ++ item.displayName = item.username = readString( buf ); ++ action = !buf.readBoolean() ? Action.REMOVE_PLAYER : Action.ADD_PLAYER; ++ item.ping = buf.readShort(); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + action = Action.values()[DefinedPacket.readVarInt( buf )]; + items = new Item[ DefinedPacket.readVarInt( buf ) ]; + for ( int i = 0; i < items.length; i++ ) +@@ -75,6 +87,17 @@ public class PlayerListItem extends DefinedPacket + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ Item item = items[0]; // Only one at a time ++ writeString( item.displayName, buf ); // TODO: Server unique only! ++ buf.writeBoolean( action != Action.REMOVE_PLAYER ); ++ buf.writeShort( item.ping ); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + DefinedPacket.writeVarInt( action.ordinal(), buf ); + DefinedPacket.writeVarInt( items.length, buf ); + for ( Item item : items ) +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java +index 4f3a8c72..2d87692f 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java +@@ -73,6 +73,15 @@ public class PluginMessage extends DefinedPacket + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ tag = readString( buf ); ++ data = v17readArray( buf ); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + tag = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( readString( buf ) ) : readString( buf, 20 ); + int maxSize = direction == ProtocolConstants.Direction.TO_SERVER ? Short.MAX_VALUE : 0x100000; + Preconditions.checkArgument( buf.readableBytes() < maxSize ); +@@ -83,6 +92,15 @@ public class PluginMessage extends DefinedPacket + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ writeString( tag, buf ); ++ v17writeArray( data, buf, allowExtendedPacket ); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + writeString( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( tag ) : tag, buf ); + buf.writeBytes( data ); + } +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java +index 3c7905d5..75b371e9 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java +@@ -28,6 +28,16 @@ public class ScoreboardObjective extends DefinedPacket + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ name = readString( buf ); ++ value = readString( buf ); ++ action = buf.readByte(); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + name = readString( buf ); + action = buf.readByte(); + if ( action == 0 || action == 2 ) +@@ -46,6 +56,16 @@ public class ScoreboardObjective extends DefinedPacket + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ writeString( name, buf ); ++ writeString( value, buf ); ++ buf.writeByte( action ); ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + writeString( name, buf ); + buf.writeByte( action ); + if ( action == 0 || action == 2 ) +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java +index 0b27fc86..a812441d 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java +@@ -27,6 +27,20 @@ public class ScoreboardScore extends DefinedPacket + @Override + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ itemName = readString( buf ); ++ action = buf.readByte(); ++ if ( action != 1 ) ++ { ++ scoreName = readString( buf ); ++ value = buf.readInt(); ++ } ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + itemName = readString( buf ); + action = buf.readByte(); + scoreName = readString( buf ); +@@ -39,6 +53,20 @@ public class ScoreboardScore extends DefinedPacket + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ writeString( itemName, buf ); ++ buf.writeByte( action ); ++ if ( action != 1 ) ++ { ++ writeString( scoreName, buf ); ++ buf.writeInt( value ); ++ } ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + writeString( itemName, buf ); + buf.writeByte( action ); + writeString( scoreName, buf ); +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java +index 80e4f85a..cab28b99 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java +@@ -43,6 +43,7 @@ public class TabCompleteRequest extends DefinedPacket + } + cursor = readString( buf, ( protocolVersion > ProtocolConstants.MINECRAFT_1_13 ? 32500 : ( protocolVersion == ProtocolConstants.MINECRAFT_1_13 ? 256 : 32767 ) ) ); + ++ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) // FlameCord - 1.7.x support + if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 ) + { + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) +@@ -66,6 +67,7 @@ public class TabCompleteRequest extends DefinedPacket + } + writeString( cursor, buf ); + ++ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) // FlameCord - 1.7.x support + if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 ) + { + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java +index a5555f6a..09dc67f9 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java +@@ -55,12 +55,22 @@ public class Team extends DefinedPacket + suffix = readString( buf ); + } + friendlyFire = buf.readByte(); +- nameTagVisibility = readString( buf ); ++ // FlameCord start - 1.7.x support ++ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) ++ { ++ nameTagVisibility = readString( buf ); ++ } ++ // FlameCord end - 1.7.x support + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) + { + collisionRule = readString( buf ); + } +- color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte(); ++ // FlameCord start - 1.7.x support ++ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) ++ { ++ color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte(); ++ } ++ // FlameCord end - 1.7.x support + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { + prefix = readString( buf ); +@@ -69,7 +79,7 @@ public class Team extends DefinedPacket + } + if ( mode == 0 || mode == 3 || mode == 4 ) + { +- int len = readVarInt( buf ); ++ int len = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt( buf ) : buf.readShort(); // FlameCord - 1.7.x support + players = new String[ len ]; + for ( int i = 0; i < len; i++ ) + { +@@ -81,6 +91,30 @@ public class Team extends DefinedPacket + @Override + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) + { ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ writeString( name, buf ); ++ buf.writeByte( mode ); ++ if ( mode == 0 || mode == 2 ) ++ { ++ writeString( displayName, buf ); ++ writeString( prefix, buf ); ++ writeString( suffix, buf ); ++ buf.writeByte( friendlyFire ); ++ } ++ if ( mode == 0 || mode == 3 || mode == 4 ) ++ { ++ buf.writeShort( players.length ); ++ for ( String player : players ) ++ { ++ writeString( player, buf ); ++ } ++ } ++ return; ++ } ++ // FlameCord end - 1.7.x support ++ + writeString( name, buf ); + buf.writeByte( mode ); + if ( mode == 0 || mode == 2 ) +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 28032ae4..d1994a52 100644 +--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java ++++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +@@ -170,6 +170,14 @@ public class BungeeCord extends ProxyServer + .registerTypeAdapter( SelectorComponent.class, new SelectorComponentSerializer() ) + .registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer() ) + .registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create(); ++ // FlameCord start - 1.7.x support ++ public final Gson gsonLegacy = new GsonBuilder() ++ .registerTypeAdapter( BaseComponent.class, new ComponentSerializer() ) ++ .registerTypeAdapter( TextComponent.class, new TextComponentSerializer() ) ++ .registerTypeAdapter( TranslatableComponent.class, new TranslatableComponentSerializer() ) ++ .registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer( ProtocolConstants.MINECRAFT_1_7_2 ) ) ++ .registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create(); ++ // FlameCord end - 1.7.x support + @Getter + private ConnectionThrottle connectionThrottle; + private final ModuleManager moduleManager = new ModuleManager(); +diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java b/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java +index 1d377a65..0ea5f90b 100644 +--- a/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java ++++ b/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java +@@ -183,6 +183,7 @@ public class BungeeTitle implements Title + @Override + public Title send(ProxiedPlayer player) + { ++ if ( ProtocolConstants.isBeforeOrEq( player.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return this; // FlameCord - 1.7.x support + sendPacket( player, clear ); + sendPacket( player, reset ); + sendPacket( player, times ); +diff --git a/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java b/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java +index 491cf1a1..6cd8ec3b 100644 +--- a/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java ++++ b/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java +@@ -10,9 +10,23 @@ import com.google.gson.JsonSerializer; + import java.lang.reflect.Type; + import java.util.UUID; + import net.md_5.bungee.api.ServerPing; ++import net.md_5.bungee.protocol.ProtocolConstants; + + public class PlayerInfoSerializer implements JsonSerializer, JsonDeserializer + { ++ // FlameCord start - 1.7.x support ++ private final int protocol; ++ ++ public PlayerInfoSerializer() ++ { ++ this.protocol = ProtocolConstants.MINECRAFT_1_7_6; ++ } ++ ++ public PlayerInfoSerializer(int protocol) ++ { ++ this.protocol = protocol; ++ } ++ // FlameCord end - 1.7.x support + + @Override + public ServerPing.PlayerInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException +@@ -20,7 +34,7 @@ public class PlayerInfoSerializer implements JsonSerializer= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) ); +- brand.release(); ++ // FlameCord start - 1.7.x support ++ String brandString = bungee.getName() + " (" + bungee.getVersion() + ")"; ++ ++ if ( ProtocolConstants.isBeforeOrEq( user.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ user.unsafe().sendPacket( new PluginMessage( "MC|Brand", brandString.getBytes( StandardCharsets.UTF_8 ), handshakeHandler.isServerForge() ) ); ++ } else ++ { ++ ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer(); ++ DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand ); ++ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) ); ++ brand.release(); ++ } ++ // FlameCord end - 1.7.x support + } + + user.setDimension( login.getDimension() ); +@@ -296,7 +306,7 @@ public class ServerConnector extends PacketHandler + if ( !user.isDisableEntityMetadataRewrite() ) { // Waterfall + for ( Objective objective : serverScoreboard.getObjectives() ) + { +- user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), ScoreboardObjective.HealthDisplay.fromString( objective.getType() ), (byte) 1 ) ); ++ user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), objective.getType() == null ? null : ScoreboardObjective.HealthDisplay.fromString(objective.getType()), (byte) 1 ) ); // FlameCord - 1.7 support + } + for ( Score score : serverScoreboard.getScores() ) + { +@@ -465,7 +475,13 @@ public class ServerConnector extends PacketHandler + if ( pluginMessage.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) || pluginMessage.getTag().equals( ForgeConstants.FORGE_REGISTER ) ) + { + this.handshakeHandler.handle( pluginMessage ); +- ++ // FlameCord start - 1.7.x support ++ if ( user.getForgeClientHandler().checkUserOutdated() ) ++ { ++ ch.close(); ++ user.getPendingConnects().remove(target); ++ } ++ // FlameCord end - 1.7.x support + // We send the message as part of the handler, so don't send it here. + throw CancelSendSignal.INSTANCE; + } +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 4a858f31..adc25165 100644 +--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java ++++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java +@@ -193,6 +193,7 @@ public final class UserConnection implements ProxiedPlayer + public void setDisplayName(String name) + { + Preconditions.checkNotNull( name, "displayName" ); ++ Preconditions.checkArgument( name.length() <= 16, "Display name cannot be longer than 16 characters" ); // FlameCord - 1.7.x support + displayName = name; + } + +@@ -506,7 +507,7 @@ public final class UserConnection implements ProxiedPlayer + // transform score components + message = ChatComponentTransformer.getInstance().transform( this, true, message ); + +- if ( position == ChatMessageType.ACTION_BAR && getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_17 ) ++ if ( position == ChatMessageType.ACTION_BAR && getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_17 && getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_8 ) // FlameCord - 1.7.x support + { + // Versions older than 1.11 cannot send the Action bar with the new JSON formattings + // Fix by converting to a legacy message, see https://bugs.mojang.com/browse/MC-119145 +@@ -702,6 +703,7 @@ public final class UserConnection implements ProxiedPlayer + @Override + public void setTabHeader(BaseComponent header, BaseComponent footer) + { ++ if ( ProtocolConstants.isBeforeOrEq( pendingConnection.getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return; // FlameCord + header = ChatComponentTransformer.getInstance().transform( this, true, header )[0]; + footer = ChatComponentTransformer.getInstance().transform( this, true, footer )[0]; + +@@ -714,6 +716,7 @@ public final class UserConnection implements ProxiedPlayer + @Override + public void setTabHeader(BaseComponent[] header, BaseComponent[] footer) + { ++ if ( ProtocolConstants.isBeforeOrEq( pendingConnection.getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return; // FlameCord + header = ChatComponentTransformer.getInstance().transform( this, true, header ); + footer = ChatComponentTransformer.getInstance().transform( this, true, footer ); + +@@ -743,6 +746,7 @@ public final class UserConnection implements ProxiedPlayer + + public void setCompressionThreshold(int compressionThreshold) + { ++ if ( ProtocolConstants.isBeforeOrEq( pendingConnection.getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return; // FlameCord + if ( !ch.isClosing() && this.compressionThreshold == -1 && compressionThreshold >= 0 ) + { + this.compressionThreshold = compressionThreshold; +diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +index 97c4b210..a0b03ec1 100644 +--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java ++++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +@@ -18,6 +18,7 @@ import io.netty.buffer.Unpooled; + import io.netty.channel.unix.DomainSocketAddress; + import java.io.DataInput; + import java.net.InetSocketAddress; ++import java.nio.charset.StandardCharsets; + import java.util.ArrayList; + import java.util.HashMap; // Waterfall + import java.util.List; +@@ -184,7 +185,7 @@ public class DownstreamBridge extends PacketHandler + switch ( objective.getAction() ) + { + case 0: +- serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType().toString() ) ); ++ serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType() != null ? objective.getType().toString() : null) ); // FlameCord - 1.7.x support + break; + case 1: + serverScoreboard.removeObjective( objective.getName() ); +@@ -194,7 +195,7 @@ public class DownstreamBridge extends PacketHandler + if ( oldObjective != null ) + { + oldObjective.setValue( objective.getValue() ); +- oldObjective.setType( objective.getType().toString() ); ++ oldObjective.setType( objective.getType() != null ? objective.getType().toString() : null ); // FlameCord - 1.7.x support + } + break; + default: +@@ -292,19 +293,28 @@ public class DownstreamBridge extends PacketHandler + + if ( pluginMessage.getTag().equals( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand" ) ) + { +- ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() ); +- String serverBrand = DefinedPacket.readString( brand ); +- brand.release(); +- +- Preconditions.checkState( !serverBrand.contains( bungee.getName() ), "Cannot connect proxy to itself!" ); +- +- brand = ByteBufAllocator.DEFAULT.heapBuffer(); +- DefinedPacket.writeString( bungee.getName() + " <- " + serverBrand, brand ); // Waterfall +- pluginMessage.setData( brand ); +- brand.release(); +- // changes in the packet are ignored so we need to send it manually +- con.unsafe().sendPacket( pluginMessage ); +- throw CancelSendSignal.INSTANCE; ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isAfterOrEq( con.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_8 ) ) ++ { ++ try ++ { ++ ByteBuf brand = Unpooled.wrappedBuffer(pluginMessage.getData()); ++ String serverBrand = DefinedPacket.readString(brand); ++ brand.release(); ++ brand = ByteBufAllocator.DEFAULT.heapBuffer(); ++ DefinedPacket.writeString(bungee.getName() + " <- " + serverBrand, brand ); // Waterfall ++ pluginMessage.setData(brand); ++ brand.release(); ++ } catch (Exception ProtocolHacksSuck) ++ { ++ return; ++ } ++ } else ++ { ++ String serverBrand = new String( pluginMessage.getData(), StandardCharsets.UTF_8); ++ pluginMessage.setData( ( bungee.getName() + " <- " + serverBrand ).getBytes(StandardCharsets.UTF_8) ); // FlameCord - 1.7.x support ++ } ++ // FlameCord end - 1.7.x support + } + + if ( pluginMessage.getTag().equals( "BungeeCord" ) ) +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 4afab05d..f6378e03 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 +@@ -3,6 +3,9 @@ package net.md_5.bungee.connection; + import com.google.common.base.Charsets; + import com.google.common.base.Preconditions; + import com.google.gson.Gson; ++import com.google.gson.JsonElement; ++import com.google.gson.JsonObject; ++ + import java.math.BigInteger; + import java.net.InetSocketAddress; + import java.net.SocketAddress; +@@ -257,8 +260,23 @@ public class InitialHandler extends PacketHandler implements PendingConnection + @Override + public void done(ProxyPingEvent pingResult, Throwable error) + { +- Gson gson = BungeeCord.getInstance().gson; +- unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) ); ++ // 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 ) ) ++ { ++ // Minecraft < 1.9 doesn't send string server descriptions as chat components. Older 1.7+ // clients even crash when encountering a chat component instead of a string. To be on the ++ // safe side, always send legacy descriptions for < 1.9 clients. ++ JsonElement element = gson.toJsonTree(pingResult.getResponse()); ++ Preconditions.checkArgument(element.isJsonObject(), "Response is not a JSON object"); ++ JsonObject object = element.getAsJsonObject(); ++ object.addProperty("description", pingResult.getResponse().getDescription()); ++ ++ unsafe.sendPacket(new StatusResponse(gson.toJson(element))); ++ } else ++ { ++ unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) ); ++ } ++ // FlameCord end - 1.7.x support + if ( bungee.getConnectionThrottle() != null ) + { + bungee.getConnectionThrottle().unthrottle( getSocketAddress() ); +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 6df3f3dd..a409d440 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 +@@ -16,6 +16,7 @@ import net.md_5.bungee.protocol.MinecraftDecoder; + import net.md_5.bungee.protocol.MinecraftEncoder; + import net.md_5.bungee.protocol.PacketWrapper; + import net.md_5.bungee.protocol.Protocol; ++import net.md_5.bungee.protocol.ProtocolConstants; + import net.md_5.bungee.protocol.packet.Handshake; + import net.md_5.bungee.protocol.packet.StatusRequest; + import net.md_5.bungee.protocol.packet.StatusResponse; +@@ -65,7 +66,7 @@ public class PingHandler extends PacketHandler + @SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") + public void handle(StatusResponse statusResponse) throws Exception + { +- Gson gson = BungeeCord.getInstance().gson; ++ Gson gson = protocol == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy : BungeeCord.getInstance().gson; // FlameCord - 1.7.x support + ServerPing serverPing = gson.fromJson( statusResponse.getResponse(), ServerPing.class ); + ( (BungeeServerInfo) target ).cachePing( serverPing ); + callback.done( serverPing, null ); +diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +index 9537208e..e354032a 100644 +--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java ++++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +@@ -85,7 +85,12 @@ public class UpstreamBridge extends PacketHandler + } ); + for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() ) + { +- player.unsafe().sendPacket( packet ); ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isAfterOrEq( player.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_8 ) ) ++ { ++ player.unsafe().sendPacket( packet ); ++ } ++ // FlameCord end - 1.7.x support + } + con.getServer().disconnect( "Quitting" ); + } +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 cda6451d..1509071f 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 +@@ -35,6 +35,12 @@ public abstract class EntityMap + // Waterfall end + switch ( version ) + { ++ // FlameCord start - 1.7.x support ++ case ProtocolConstants.MINECRAFT_1_7_2: ++ return EntityMap_1_7_2.INSTANCE; ++ case ProtocolConstants.MINECRAFT_1_7_6: ++ return EntityMap_1_7_6.INSTANCE; ++ // FlameCord end - 1.7.x support + case ProtocolConstants.MINECRAFT_1_8: + return EntityMap_1_8.INSTANCE; + case ProtocolConstants.MINECRAFT_1_9: +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java +new file mode 100644 +index 00000000..cdc07dc4 +--- /dev/null ++++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java +@@ -0,0 +1,102 @@ ++// FlameCord start - 1.7.x support ++package net.md_5.bungee.entitymap; ++ ++import io.netty.buffer.ByteBuf; ++import net.md_5.bungee.protocol.DefinedPacket; ++import net.md_5.bungee.protocol.ProtocolConstants; ++ ++class EntityMap_1_7_2 extends EntityMap ++{ ++ ++ static final EntityMap INSTANCE = new EntityMap_1_7_2(); ++ ++ EntityMap_1_7_2() ++ { ++ addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Equipment ++ addRewrite( 0x0A, ProtocolConstants.Direction.TO_CLIENT, false ); // Use bed ++ addRewrite( 0x0B, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation ++ addRewrite( 0x0C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player ++ addRewrite( 0x0D, ProtocolConstants.Direction.TO_CLIENT, false ); // Collect Item ++ addRewrite( 0x0E, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object ++ addRewrite( 0x0F, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob ++ addRewrite( 0x10, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting ++ addRewrite( 0x11, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb ++ addRewrite( 0x12, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Velocity ++ addRewrite( 0x14, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity ++ addRewrite( 0x15, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Relative Move ++ addRewrite( 0x16, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Look ++ addRewrite( 0x17, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Look and Relative Move ++ addRewrite( 0x18, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Teleport ++ addRewrite( 0x19, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Head Look ++ addRewrite( 0x1A, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status ++ addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity ++ addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Metadata ++ addRewrite( 0x1D, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Effect ++ addRewrite( 0x1E, ProtocolConstants.Direction.TO_CLIENT, false ); // Remove Entity Effect ++ addRewrite( 0x20, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Properties ++ addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation ++ addRewrite( 0x2C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Global Entity ++ ++ addRewrite( 0x02, ProtocolConstants.Direction.TO_SERVER, false ); // Use Entity ++ addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, false ); // Animation ++ addRewrite( 0x0B, ProtocolConstants.Direction.TO_SERVER, false ); // Entity Action ++ } ++ ++ @Override ++ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) ++ { ++ super.rewriteClientbound( packet, oldId, newId ); ++ ++ //Special cases ++ int readerIndex = packet.readerIndex(); ++ int packetId = DefinedPacket.readVarInt( packet ); ++ int packetIdLength = packet.readerIndex() - readerIndex; ++ if ( packetId == 0x0D /* Collect Item */ || packetId == 0x1B /* Attach Entity */ ) ++ { ++ rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); ++ } else if ( packetId == 0x13 /* Destroy Entities */ ) ++ { ++ int count = packet.getByte( packetIdLength ); ++ for ( int i = 0; i < count; i++ ) ++ { ++ rewriteInt( packet, oldId, newId, packetIdLength + 1 + i * 4 ); ++ } ++ } else if ( packetId == 0x0E /* Spawn Object */ ) ++ { ++ DefinedPacket.readVarInt( packet ); ++ int type = packet.readUnsignedByte(); ++ ++ if ( type == 60 || type == 90 ) ++ { ++ packet.skipBytes( 14 ); ++ int position = packet.readerIndex(); ++ int readId = packet.readInt(); ++ int changedId = -1; ++ if ( readId == oldId ) ++ { ++ packet.setInt( position, newId ); ++ changedId = newId; ++ } else if ( readId == newId ) ++ { ++ packet.setInt( position, oldId ); ++ changedId = oldId; ++ } ++ if ( changedId != -1 ) ++ { ++ if ( changedId == 0 && readId != 0 ) ++ { // Trim off the extra data ++ packet.readerIndex( readerIndex ); ++ packet.writerIndex( packet.readableBytes() - 6 ); ++ } else if ( changedId != 0 && readId == 0 ) ++ { // Add on the extra data ++ packet.readerIndex( readerIndex ); ++ packet.capacity( packet.readableBytes() + 6 ); ++ packet.writerIndex( packet.readableBytes() + 6 ); ++ } ++ } ++ } ++ } ++ packet.readerIndex( readerIndex ); ++ } ++} ++// FlameCord end - 1.7.x support +\ No newline at end of file +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java +new file mode 100644 +index 00000000..5ce42f62 +--- /dev/null ++++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java +@@ -0,0 +1,62 @@ ++// FlameCord start - 1.7.x support ++package net.md_5.bungee.entitymap; ++ ++import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; ++import io.netty.buffer.ByteBuf; ++import net.md_5.bungee.BungeeCord; ++import net.md_5.bungee.UserConnection; ++import net.md_5.bungee.connection.LoginResult; ++import net.md_5.bungee.protocol.DefinedPacket; ++ ++class EntityMap_1_7_6 extends EntityMap_1_7_2 ++{ ++ ++ static final EntityMap_1_7_6 INSTANCE = new EntityMap_1_7_6(); ++ ++ @Override ++ @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") ++ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) ++ { ++ super.rewriteClientbound( packet, oldId, newId ); ++ ++ int readerIndex = packet.readerIndex(); ++ int packetId = DefinedPacket.readVarInt( packet ); ++ int packetIdLength = packet.readerIndex() - readerIndex; ++ if ( packetId == 0x0C /* Spawn Player */ ) ++ { ++ DefinedPacket.readVarInt( packet ); ++ int idLength = packet.readerIndex() - readerIndex - packetIdLength; ++ String uuid = DefinedPacket.readString( packet ); ++ String username = DefinedPacket.readString( packet ); ++ int props = DefinedPacket.readVarInt( packet ); ++ if ( props == 0 ) ++ { ++ UserConnection player = (UserConnection) BungeeCord.getInstance().getPlayer( username ); ++ if ( player != null ) ++ { ++ LoginResult profile = player.getPendingConnection().getLoginProfile(); ++ if ( profile != null && profile.getProperties() != null ++ && profile.getProperties().length >= 1 ) ++ { ++ ByteBuf rest = packet.copy(); ++ packet.readerIndex( readerIndex ); ++ packet.writerIndex( readerIndex + packetIdLength + idLength ); ++ DefinedPacket.writeString( player.getUniqueId().toString(), packet ); ++ DefinedPacket.writeString( username, packet ); ++ DefinedPacket.writeVarInt( profile.getProperties().length, packet ); ++ for ( LoginResult.Property property : profile.getProperties() ) ++ { ++ DefinedPacket.writeString( property.getName(), packet ); ++ DefinedPacket.writeString( property.getValue(), packet ); ++ DefinedPacket.writeString( property.getSignature(), packet ); ++ } ++ packet.writeBytes( rest ); ++ rest.release(); ++ } ++ } ++ } ++ } ++ packet.readerIndex( readerIndex ); ++ } ++} ++// FlameCord end - 1.7.x support +\ No newline at end of file +diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java +index bea2bbff..caed4384 100644 +--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java ++++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java +@@ -8,6 +8,7 @@ import lombok.Getter; + import lombok.NonNull; + import lombok.RequiredArgsConstructor; + import lombok.Setter; ++import net.md_5.bungee.BungeeCord; + import net.md_5.bungee.UserConnection; + import net.md_5.bungee.protocol.ProtocolConstants; + import net.md_5.bungee.protocol.packet.EntityRemoveEffect; +@@ -23,6 +24,12 @@ public class ForgeClientHandler + @NonNull + private final UserConnection con; + ++ // FlameCord start - 1.7.x support ++ @Getter ++ @Setter(AccessLevel.PACKAGE) ++ private boolean forgeOutdated = false; ++ // FlameCord end - 1.7.x support ++ + /** + * The users' mod list. + */ +@@ -175,4 +182,21 @@ public class ForgeClientHandler + { + return fmlTokenInHandshake || clientModList != null; + } ++ ++ // FlameCord start - 1.7.x support ++ /** ++ * Checks to see if a user is using an outdated FML build, and takes ++ * appropriate action on the User side. This should only be called during a ++ * server connection, by the ServerConnector ++ * ++ * @return true if the user's FML build is outdated, otherwise ++ * false ++ */ ++ public boolean checkUserOutdated() { ++ if (forgeOutdated) { ++ con.disconnect( BungeeCord.getInstance().getTranslation("connect_kick_outdated_forge") ); ++ } ++ return forgeOutdated; ++ } ++ // FlameCord end - 1.7.x support + } +diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java +index 5e02f8c8..85bc21b9 100644 +--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java ++++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java +@@ -3,6 +3,7 @@ package net.md_5.bungee.forge; + import java.util.Map; + import net.md_5.bungee.ServerConnector; + import net.md_5.bungee.UserConnection; ++import net.md_5.bungee.protocol.ProtocolConstants; + import net.md_5.bungee.protocol.packet.PluginMessage; + + /** +@@ -84,6 +85,22 @@ enum ForgeClientHandshakeState implements IForgeClientPacketHandler clientModList = ForgeUtils.readModList( message ); + con.getForgeClientHandler().setClientModList( clientModList ); ++ // FlameCord start - 1.7.x support ++ // If the user is below 1.8, we need to check the version of FML - it's not always an OK version. ++ if ( ProtocolConstants.isBeforeOrEq( con.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) ++ { ++ // Get the version from the mod list. ++ int buildNumber = ForgeUtils.getFmlBuildNumber( clientModList ); ++ ++ // If we get 0, we're probably using a testing build, so let it though. Otherwise, check the build number. ++ if ( buildNumber < ForgeConstants.FML_MIN_BUILD_VERSION && buildNumber != 0 ) ++ { ++ // Mark the user as an old Forge user. This will then cause any Forge ServerConnectors to cancel any ++ // connections to it. ++ con.getForgeClientHandler().setForgeOutdated( true ); ++ } ++ } ++ // FlameCord end - 1.7.x support + } + + return WAITINGSERVERDATA; +diff --git a/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java b/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java +index daf12f74..7d053485 100644 +--- a/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java ++++ b/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java +@@ -4,12 +4,14 @@ import java.util.Collection; + import java.util.HashSet; + import java.util.UUID; + import net.md_5.bungee.api.connection.ProxiedPlayer; ++import net.md_5.bungee.protocol.ProtocolConstants; + import net.md_5.bungee.protocol.packet.PlayerListItem; + + public class ServerUnique extends TabList + { + + private final Collection uuids = new HashSet<>(); ++ private final Collection usernames = new HashSet<>(); // FlameCord - 1.7.x support + + public ServerUnique(ProxiedPlayer player) + { +@@ -23,10 +25,26 @@ public class ServerUnique extends TabList + { + if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER ) + { +- uuids.add( item.getUuid() ); ++ // FlameCord start - 1.7.x support ++ if ( item.getUuid() != null ) ++ { ++ uuids.add( item.getUuid() ); ++ } else ++ { ++ usernames.add( item.getUsername() ); ++ } ++ // FlameCord end - 1.7.x support + } else if ( playerListItem.getAction() == PlayerListItem.Action.REMOVE_PLAYER ) + { +- uuids.remove( item.getUuid() ); ++ // FlameCord start - 1.7.x support ++ if ( item.getUuid() != null ) ++ { ++ uuids.remove( item.getUuid() ); ++ } else ++ { ++ usernames.remove( item.getUsername() ); ++ } ++ // FlameCord end - 1.7.x support + } + } + player.unsafe().sendPacket( playerListItem ); +@@ -43,16 +61,46 @@ public class ServerUnique extends TabList + { + PlayerListItem packet = new PlayerListItem(); + packet.setAction( PlayerListItem.Action.REMOVE_PLAYER ); +- PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() ]; ++ PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() + usernames.size() ]; // FlameCord - 1.7.x support + int i = 0; ++ ++ // FlameCord start - 1.7.x support ++ for ( String username : usernames ) ++ { ++ PlayerListItem.Item item = items[i++] = new PlayerListItem.Item(); ++ item.setUsername( username ); ++ item.setDisplayName( username ); ++ } ++ // FlameCord end - 1.7.x support ++ + for ( UUID uuid : uuids ) + { + PlayerListItem.Item item = items[i++] = new PlayerListItem.Item(); + item.setUuid( uuid ); + } + packet.setItems( items ); +- player.unsafe().sendPacket( packet ); ++ // FlameCord start - 1.7.x support ++ if ( ProtocolConstants.isAfterOrEq( player.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_8 ) ) ++ { ++ player.unsafe().sendPacket( packet ); ++ } else ++ { ++ // Split up the packet ++ for ( PlayerListItem.Item item : packet.getItems() ) ++ { ++ PlayerListItem p2 = new PlayerListItem(); ++ p2.setAction( packet.getAction() ); ++ ++ p2.setItems( new PlayerListItem.Item[] ++ { ++ item ++ } ); ++ player.unsafe().sendPacket( p2 ); ++ } ++ } ++ // FlameCord end - 1.7.x support + uuids.clear(); ++ usernames.clear(); // FlameCord - 1.7.x support + } + + @Override +-- +2.32.0 + diff --git a/Waterfall-Proxy-Patches/0005-Make-PlayerHandshakeEvent-cancellable.patch b/Waterfall-Proxy-Patches/0005-Make-PlayerHandshakeEvent-cancellable.patch new file mode 100644 index 0000000..be3789d --- /dev/null +++ b/Waterfall-Proxy-Patches/0005-Make-PlayerHandshakeEvent-cancellable.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0006-Make-a-getter-for-the-callback.patch b/Waterfall-Proxy-Patches/0006-Make-a-getter-for-the-callback.patch new file mode 100644 index 0000000..f3bb074 --- /dev/null +++ b/Waterfall-Proxy-Patches/0006-Make-a-getter-for-the-callback.patch @@ -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 extends Event + { +- ++ // FlameCord - Make a getter for the callback ++ @Getter + private final Callback done; + private final Map intents = new ConcurrentHashMap<>(); + private final AtomicBoolean fired = new AtomicBoolean(); +-- +2.32.0 + diff --git a/Waterfall-Proxy-Patches/0007-Disable-update-checker-Use-bungee-name.patch b/Waterfall-Proxy-Patches/0007-Disable-update-checker-Use-bungee-name.patch new file mode 100644 index 0000000..d1cd6f1 --- /dev/null +++ b/Waterfall-Proxy-Patches/0007-Disable-update-checker-Use-bungee-name.patch @@ -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 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 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 + diff --git a/Waterfall-Proxy-Patches/0008-Change-replaceAll-to-replace.patch b/Waterfall-Proxy-Patches/0008-Change-replaceAll-to-replace.patch new file mode 100644 index 0000000..e287e35 --- /dev/null +++ b/Waterfall-Proxy-Patches/0008-Change-replaceAll-to-replace.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0009-Close-connections-Don-t-flush-if-not-necessary.patch b/Waterfall-Proxy-Patches/0009-Close-connections-Don-t-flush-if-not-necessary.patch new file mode 100644 index 0000000..c654976 --- /dev/null +++ b/Waterfall-Proxy-Patches/0009-Close-connections-Don-t-flush-if-not-necessary.patch @@ -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 + 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 + diff --git a/Waterfall-Proxy-Patches/0010-Packet-Checks.patch b/Waterfall-Proxy-Patches/0010-Packet-Checks.patch new file mode 100644 index 0000000..393cb66 --- /dev/null +++ b/Waterfall-Proxy-Patches/0010-Packet-Checks.patch @@ -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 + } + + 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 + diff --git a/Waterfall-Proxy-Patches/0011-Change-default-timeout.patch b/Waterfall-Proxy-Patches/0011-Change-default-timeout.patch new file mode 100644 index 0000000..8ec0a61 --- /dev/null +++ b/Waterfall-Proxy-Patches/0011-Change-default-timeout.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0012-Don-t-allow-name-containing-dot.patch b/Waterfall-Proxy-Patches/0012-Don-t-allow-name-containing-dot.patch new file mode 100644 index 0000000..617a503 --- /dev/null +++ b/Waterfall-Proxy-Patches/0012-Don-t-allow-name-containing-dot.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0013-Use-pipeline-to-reduce-redundancy.patch b/Waterfall-Proxy-Patches/0013-Use-pipeline-to-reduce-redundancy.patch new file mode 100644 index 0000000..f4ee95a --- /dev/null +++ b/Waterfall-Proxy-Patches/0013-Use-pipeline-to-reduce-redundancy.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0014-Allow-custom-uuids-even-if-onlineMode-is-true.patch b/Waterfall-Proxy-Patches/0014-Allow-custom-uuids-even-if-onlineMode-is-true.patch new file mode 100644 index 0000000..786d471 --- /dev/null +++ b/Waterfall-Proxy-Patches/0014-Allow-custom-uuids-even-if-onlineMode-is-true.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0015-Change-IllegalStateException-to-QuietException-and-e.patch b/Waterfall-Proxy-Patches/0015-Change-IllegalStateException-to-QuietException-and-e.patch new file mode 100644 index 0000000..20d03ad --- /dev/null +++ b/Waterfall-Proxy-Patches/0015-Change-IllegalStateException-to-QuietException-and-e.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0016-Don-t-declare-uuid-unless-it-s-null.patch b/Waterfall-Proxy-Patches/0016-Don-t-declare-uuid-unless-it-s-null.patch new file mode 100644 index 0000000..d006fa0 --- /dev/null +++ b/Waterfall-Proxy-Patches/0016-Don-t-declare-uuid-unless-it-s-null.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0017-FlameCord-General-Patch.patch b/Waterfall-Proxy-Patches/0017-FlameCord-General-Patch.patch new file mode 100644 index 0000000..4d55418 --- /dev/null +++ b/Waterfall-Proxy-Patches/0017-FlameCord-General-Patch.patch @@ -0,0 +1,383 @@ +From d22662f6826b0cced8e7cd3c4052fb87b502d0d7 Mon Sep 17 00:00:00 2001 +From: Juan Cruz Linsalata +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 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 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 setIfUnexistant(final String arg1, final Collection 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 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 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 = ""; + 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 + diff --git a/Waterfall-Proxy-Patches/0018-FlameCord-module-system.patch b/Waterfall-Proxy-Patches/0018-FlameCord-module-system.patch new file mode 100644 index 0000000..e10ddcc --- /dev/null +++ b/Waterfall-Proxy-Patches/0018-FlameCord-module-system.patch @@ -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 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 + diff --git a/Waterfall-Proxy-Patches/0019-FlameCord-message-configuration.patch b/Waterfall-Proxy-Patches/0019-FlameCord-message-configuration.patch new file mode 100644 index 0000000..543bd02 --- /dev/null +++ b/Waterfall-Proxy-Patches/0019-FlameCord-message-configuration.patch @@ -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 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 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 ", 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, ""), 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 = ""; +- 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 + diff --git a/Waterfall-Proxy-Patches/0020-Fix-ByteBuf-memory-leaks.patch b/Waterfall-Proxy-Patches/0020-Fix-ByteBuf-memory-leaks.patch new file mode 100644 index 0000000..b34cdbf --- /dev/null +++ b/Waterfall-Proxy-Patches/0020-Fix-ByteBuf-memory-leaks.patch @@ -0,0 +1,68 @@ +From 23d65a0daab152315d3815042c57d14e51674bb7 Mon Sep 17 00:00:00 2001 +From: linsaftw +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 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 + diff --git a/Waterfall-Proxy-Patches/0021-Check-if-packetID-is-invalid.patch b/Waterfall-Proxy-Patches/0021-Check-if-packetID-is-invalid.patch new file mode 100644 index 0000000..e836a7c --- /dev/null +++ b/Waterfall-Proxy-Patches/0021-Check-if-packetID-is-invalid.patch @@ -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 + + 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 + diff --git a/Waterfall-Proxy-Patches/0022-FlameCord-logger-options.patch b/Waterfall-Proxy-Patches/0022-FlameCord-logger-options.patch new file mode 100644 index 0000000..5ed25b7 --- /dev/null +++ b/Waterfall-Proxy-Patches/0022-FlameCord-logger-options.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0023-Always-release-packets.patch b/Waterfall-Proxy-Patches/0023-Always-release-packets.patch new file mode 100644 index 0000000..abcbe85 --- /dev/null +++ b/Waterfall-Proxy-Patches/0023-Always-release-packets.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0024-Added-an-api-method-to-unload-Plugins.patch b/Waterfall-Proxy-Patches/0024-Added-an-api-method-to-unload-Plugins.patch new file mode 100644 index 0000000..d9eabf0 --- /dev/null +++ b/Waterfall-Proxy-Patches/0024-Added-an-api-method-to-unload-Plugins.patch @@ -0,0 +1,86 @@ +From 15a8f8edb2a5bca8b39560784ce8d20cb1f89d74 Mon Sep 17 00:00:00 2001 +From: abhiram +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 toLoad = new HashMap<>(); + private final Multimap commandsByPlugin = ArrayListMultimap.create(); + private final Multimap listenersByPlugin = ArrayListMultimap.create(); ++ private final HashMap 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 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 + diff --git a/Waterfall-Proxy-Patches/0025-Apply-packet-limits.patch b/Waterfall-Proxy-Patches/0025-Apply-packet-limits.patch new file mode 100644 index 0000000..178f94b --- /dev/null +++ b/Waterfall-Proxy-Patches/0025-Apply-packet-limits.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0026-Custom-motd-system.patch b/Waterfall-Proxy-Patches/0026-Custom-motd-system.patch new file mode 100644 index 0000000..033d9fc --- /dev/null +++ b/Waterfall-Proxy-Patches/0026-Custom-motd-system.patch @@ -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 colors(final List 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 motds = Collections.singletonList("&eDefault &cFlameCord&e custom motd!\n&eChange me in &cflamecord.yml&e file!"); ++ ++ @Getter ++ private boolean sampleEnabled = false; ++ @Getter ++ private List 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 pingBack = new Callback() +@@ -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 + diff --git a/Waterfall-Proxy-Patches/0027-TCP-Fast-Open.patch b/Waterfall-Proxy-Patches/0027-TCP-Fast-Open.patch new file mode 100644 index 0000000..602d03f --- /dev/null +++ b/Waterfall-Proxy-Patches/0027-TCP-Fast-Open.patch @@ -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 colors(final List 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 + diff --git a/Waterfall-Proxy-Patches/0028-InitialHandler-Processing-State.patch b/Waterfall-Proxy-Patches/0028-InitialHandler-Processing-State.patch new file mode 100644 index 0000000..44a1b33 --- /dev/null +++ b/Waterfall-Proxy-Patches/0028-InitialHandler-Processing-State.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0029-Antibot-System.patch b/Waterfall-Proxy-Patches/0029-Antibot-System.patch new file mode 100644 index 0000000..ce3d8f2 --- /dev/null +++ b/Waterfall-Proxy-Patches/0029-Antibot-System.patch @@ -0,0 +1,1134 @@ +From f46da0d9a58d8a72acf3e144b6e59d96ca0c3aca Mon Sep 17 00:00:00 2001 +From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> +Date: Fri, 4 Mar 2022 13:35:53 -0300 +Subject: [PATCH] Antibot System + + +diff --git a/flamecord/pom.xml b/flamecord/pom.xml +index f4bf5ec6..4a0d8e5d 100644 +--- a/flamecord/pom.xml ++++ b/flamecord/pom.xml +@@ -30,6 +30,11 @@ + ${project.version} + compile + ++ ++ com.maxmind.db ++ maxmind-db ++ 2.0.0 ++ + + + +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/AccountsCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/AccountsCheck.java +new file mode 100644 +index 00000000..dfee9bf8 +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/AccountsCheck.java +@@ -0,0 +1,36 @@ ++package dev._2lstudios.antibot; ++ ++import java.net.SocketAddress; ++import java.util.Collection; ++ ++import dev._2lstudios.flamecord.FlameCord; ++import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; ++ ++public class AccountsCheck { ++ private final AddressDataManager addressDataManager; ++ ++ public AccountsCheck(final AddressDataManager addressDataManager) { ++ this.addressDataManager = addressDataManager; ++ } ++ ++ public boolean check(final SocketAddress socketAddress, final String nickname) { ++ final FlameCordConfiguration config = FlameCord.getInstance().getFlameCordConfiguration(); ++ ++ if (config.isAntibotAccountsEnabled()) { ++ final AddressData addressData = addressDataManager.getAddressData(socketAddress); ++ final Collection nicknames = addressData.getNicknames(); ++ ++ if (nicknames.size() > config.getAntibotAccountsLimit()) { ++ nicknames.remove(nickname); ++ ++ if (config.isAntibotAccountsFirewall()) { ++ addressData.firewall(); ++ } ++ ++ return true; ++ } ++ } ++ ++ return false; ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/AddressData.java b/flamecord/src/main/java/dev/_2lstudios/antibot/AddressData.java +new file mode 100644 +index 00000000..cd8220d1 +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/AddressData.java +@@ -0,0 +1,149 @@ ++package dev._2lstudios.antibot; ++ ++import java.io.IOException; ++import java.util.Collection; ++import java.util.HashSet; ++ ++import dev._2lstudios.flamecord.FlameCord; ++ ++public class AddressData { ++ private final Collection nicknames = new HashSet<>(); ++ private final String hostString; ++ private String lastNickname = ""; ++ private String country = null; ++ private long lastPing = 0; ++ private long penultimateConnection = 0; ++ private long lastConnection = 0; ++ private long lastFirewall = 0; ++ private int pingsSecond = 0; ++ private int totalPings = 0; ++ private int connectionsSecond = 0; ++ private int totalConnections = 0; ++ ++ public AddressData(final String hostString) { ++ this.hostString = hostString; ++ } ++ ++ public Collection getNicknames() { ++ return nicknames; ++ } ++ ++ public String getLastNickname() { ++ return lastNickname; ++ } ++ ++ public void addNickname(final String nickname) { ++ if (!lastNickname.equals(nickname)) { ++ this.lastNickname = nickname; ++ this.totalConnections = 1; ++ } ++ ++ if (!this.nicknames.contains(nickname)) { ++ this.nicknames.add(nickname); ++ } ++ } ++ ++ public long getPenultimateConnection() { ++ return penultimateConnection; ++ } ++ ++ public long getTimeSincePenultimateConnection() { ++ return System.currentTimeMillis() - penultimateConnection; ++ } ++ ++ public long getLastConnection() { ++ return lastConnection; ++ } ++ ++ public long getTimeSinceLastConnection() { ++ return System.currentTimeMillis() - lastConnection; ++ } ++ ++ private void updatePingsSecond() { ++ if (System.currentTimeMillis() - lastPing >= 1000) { ++ pingsSecond = 0; ++ } ++ } ++ ++ public int getPingsSecond() { ++ updatePingsSecond(); ++ return pingsSecond; ++ } ++ ++ public void addPing() { ++ updatePingsSecond(); ++ lastPing = System.currentTimeMillis(); ++ pingsSecond++; ++ totalPings++; ++ } ++ ++ public int getTotalPings() { ++ return totalPings; ++ } ++ ++ private void updateConnectionsSecond() { ++ if (System.currentTimeMillis() - lastConnection >= 1000) { ++ connectionsSecond = 0; ++ } ++ } ++ ++ public int getConnectionsSecond() { ++ updateConnectionsSecond(); ++ return connectionsSecond; ++ } ++ ++ public void addConnection() { ++ final long currentTime = System.currentTimeMillis(); ++ ++ updateConnectionsSecond(); ++ penultimateConnection = lastConnection == 0 ? currentTime : lastConnection; ++ lastConnection = currentTime; ++ connectionsSecond++; ++ totalConnections++; ++ } ++ ++ public int getTotalConnections() { ++ return totalConnections; ++ } ++ ++ public boolean isFirewalled() { ++ return System.currentTimeMillis() - lastFirewall < FlameCord.getInstance().getFlameCordConfiguration() ++ .getAntibotFirewallExpire() * 1000; ++ } ++ ++ public String getHostString() { ++ return hostString; ++ } ++ ++ public void firewall() { ++ if (!hostString.equals("127.0.0.1")) { ++ if (FlameCord.getInstance().getFlameCordConfiguration().isAntibotFirewallIpset()) { ++ Runtime runtime = Runtime.getRuntime(); ++ ++ try { ++ runtime.exec("ipset add flamecord_blacklist " + hostString); ++ } catch (IOException exception) { ++ // Ignored ++ } ++ } ++ ++ this.lastFirewall = System.currentTimeMillis(); ++ } ++ } ++ ++ public void setTotalConnections(final int totalConnections) { ++ this.totalConnections = totalConnections; ++ } ++ ++ public String setCountry(final String country) { ++ return this.country = country; ++ } ++ ++ public String getCountry() { ++ return country; ++ } ++ ++ public boolean hasNickname(final String nickname) { ++ return nicknames.contains(nickname); ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/AddressDataManager.java b/flamecord/src/main/java/dev/_2lstudios/antibot/AddressDataManager.java +new file mode 100644 +index 00000000..3f6e4186 +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/AddressDataManager.java +@@ -0,0 +1,25 @@ ++package dev._2lstudios.antibot; ++ ++import java.net.InetSocketAddress; ++import java.net.SocketAddress; ++import java.util.HashMap; ++import java.util.Map; ++ ++public class AddressDataManager { ++ private final Map addressData = new HashMap<>(); ++ ++ public AddressData getAddressData(final SocketAddress address) { ++ final InetSocketAddress iNetSocketAddress = (InetSocketAddress) address; ++ final String addressString = iNetSocketAddress.getHostString(); ++ ++ if (addressData.containsKey(addressString)) { ++ return addressData.get(addressString); ++ } else { ++ AddressData data = new AddressData(addressString); ++ ++ addressData.put(addressString, data); ++ ++ return data; ++ } ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/CheckManager.java b/flamecord/src/main/java/dev/_2lstudios/antibot/CheckManager.java +new file mode 100644 +index 00000000..137ed980 +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/CheckManager.java +@@ -0,0 +1,41 @@ ++package dev._2lstudios.antibot; ++ ++import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; ++import lombok.Getter; ++ ++public class CheckManager { ++ @Getter ++ private final AccountsCheck accountsCheck; ++ @Getter ++ private final CountryCheck countryCheck; ++ @Getter ++ private final FastChatCheck fastChatCheck; ++ @Getter ++ private final FirewallCheck firewallCheck; ++ @Getter ++ private final NicknameCheck nicknameCheck; ++ @Getter ++ private final PasswordCheck passwordCheck; ++ @Getter ++ private final RatelimitCheck ratelimitCheck; ++ @Getter ++ private final ReconnectCheck reconnectCheck; ++ ++ public CheckManager(final AddressDataManager addressDataManager, final FlameCordConfiguration flameCordConfiguration) { ++ this.accountsCheck = new AccountsCheck(addressDataManager); ++ this.countryCheck = new CountryCheck(addressDataManager); ++ this.fastChatCheck = new FastChatCheck(addressDataManager); ++ this.firewallCheck = new FirewallCheck(addressDataManager, flameCordConfiguration); ++ this.nicknameCheck = new NicknameCheck(addressDataManager); ++ this.passwordCheck = new PasswordCheck(addressDataManager); ++ this.ratelimitCheck = new RatelimitCheck(addressDataManager); ++ this.reconnectCheck = new ReconnectCheck(addressDataManager); ++ ++ this.countryCheck.load(); ++ this.firewallCheck.load(); ++ } ++ ++ public void unload() { ++ this.countryCheck.unload(); ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/CountryCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/CountryCheck.java +new file mode 100644 +index 00000000..5cb5021a +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/CountryCheck.java +@@ -0,0 +1,140 @@ ++package dev._2lstudios.antibot; ++ ++import java.io.File; ++import java.io.IOException; ++import java.io.InputStream; ++import java.net.InetAddress; ++import java.net.InetSocketAddress; ++import java.net.SocketAddress; ++import java.net.URL; ++import java.nio.file.Files; ++ ++import com.maxmind.db.CHMCache; ++import com.maxmind.db.MaxMindDbConstructor; ++import com.maxmind.db.MaxMindDbParameter; ++import com.maxmind.db.Reader; ++ ++import dev._2lstudios.flamecord.FlameCord; ++import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; ++ ++public class CountryCheck { ++ private final AddressDataManager addressDataManager; ++ private Reader maxMindReader; ++ ++ public CountryCheck(final AddressDataManager addressDataManager) { ++ this.addressDataManager = addressDataManager; ++ } ++ ++ public void download(final URL url, final File file) throws Exception { ++ try (InputStream in = url.openStream()) { ++ Files.copy(in, file.toPath()); ++ } ++ } ++ ++ public void load() { ++ final File file = new File("GeoLite2-Country.mmdb"); ++ ++ try { ++ if (!file.exists()) { ++ System.out.println("Starting download of MaxMindDB (This will take some seconds...)"); ++ download(new URL("https://git.io/GeoLite2-Country.mmdb"), file); ++ } ++ ++ this.maxMindReader = new Reader(file, new CHMCache()); ++ } catch (final Exception exception) { ++ // Ignored ++ } ++ } ++ ++ public void unload() { ++ try { ++ if (this.maxMindReader != null) { ++ this.maxMindReader.close(); ++ } ++ } catch (final IOException ex) { ++ // Ignored ++ } ++ } ++ ++ private boolean isBlacklisted(final FlameCordConfiguration config, final String isoCode) { ++ for (final String blacklisted : config.getAntibotCountryBlacklist()) { ++ if (isoCode.contains(blacklisted)) { ++ return true; ++ } ++ } ++ ++ return false; ++ } ++ ++ public static class LookupResult { ++ private final Country country; ++ ++ @MaxMindDbConstructor ++ public LookupResult(@MaxMindDbParameter(name = "country") final Country country) { ++ this.country = country; ++ } ++ ++ public Country getCountry() { ++ return this.country; ++ } ++ } ++ ++ public static class Country { ++ private final String isoCode; ++ ++ @MaxMindDbConstructor ++ public Country(@MaxMindDbParameter(name = "iso_code") final String isoCode) { ++ this.isoCode = isoCode; ++ } ++ ++ public String getIsoCode() { ++ return this.isoCode; ++ } ++ } ++ ++ private String getIsoCode(final InetAddress address) { ++ try { ++ final LookupResult lookupResult = maxMindReader.get(address, LookupResult.class); ++ ++ if (lookupResult == null) { ++ return "LOCAL"; ++ } else { ++ final Country country = lookupResult.getCountry(); ++ final String isoCode = country.getIsoCode(); ++ ++ return isoCode; ++ } ++ } catch (final IOException exception) { ++ // Ignored ++ } ++ ++ return null; ++ } ++ ++ public boolean check(final SocketAddress socketAddress) { ++ final FlameCordConfiguration config = FlameCord.getInstance().getFlameCordConfiguration(); ++ ++ if (config.isAntibotCountryEnabled()) { ++ final AddressData addressData = addressDataManager.getAddressData(socketAddress); ++ final String addressCountry = addressData.getCountry(); ++ final String country; ++ ++ if (addressCountry != null) { ++ country = addressCountry; ++ } else { ++ country = getIsoCode(((InetSocketAddress) socketAddress).getAddress()); ++ addressData.setCountry(country); ++ } ++ ++ if (country != null && isBlacklisted(config, country)) { ++ if (config.isAntibotNicknameFirewall()) { ++ addressData.firewall(); ++ } ++ ++ return true; ++ } ++ } ++ ++ return false; ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/FastChatCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/FastChatCheck.java +new file mode 100644 +index 00000000..76902c27 +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/FastChatCheck.java +@@ -0,0 +1,32 @@ ++package dev._2lstudios.antibot; ++ ++import java.net.SocketAddress; ++ ++import dev._2lstudios.flamecord.FlameCord; ++import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; ++ ++public class FastChatCheck { ++ private final AddressDataManager addressDataManager; ++ ++ public FastChatCheck(final AddressDataManager addressDataManager) { ++ this.addressDataManager = new AddressDataManager(); ++ } ++ ++ public boolean check(final SocketAddress socketAddress) { ++ final FlameCordConfiguration config = FlameCord.getInstance().getFlameCordConfiguration(); ++ ++ if (config.isAntibotFastChatEnabled()) { ++ final AddressData addressData = addressDataManager.getAddressData(socketAddress); ++ ++ if (addressData.getTimeSinceLastConnection() <= config.getAntibotFastChatTime()) { ++ if (config.isAntibotFastChatFirewall()) { ++ addressData.firewall(); ++ } ++ ++ return true; ++ } ++ } ++ ++ return false; ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/FirewallCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/FirewallCheck.java +new file mode 100644 +index 00000000..d3b77f03 +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/FirewallCheck.java +@@ -0,0 +1,42 @@ ++package dev._2lstudios.antibot; ++ ++import java.io.IOException; ++import java.net.SocketAddress; ++ ++import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; ++ ++public class FirewallCheck { ++ private final AddressDataManager addressDataManager; ++ private final FlameCordConfiguration flameCordConfiguration; ++ ++ public FirewallCheck(final AddressDataManager addressDataManager, final FlameCordConfiguration flameCordConfiguration) { ++ this.addressDataManager = addressDataManager; ++ this.flameCordConfiguration = flameCordConfiguration; ++ } ++ ++ public void load() { ++ if (flameCordConfiguration.isAntibotFirewallIpset()) { ++ Runtime runtime = Runtime.getRuntime(); ++ ++ try { ++ runtime.exec("iptables -D INPUT -p tcp -m set --match-set flamecord_blacklist src -j DROP"); ++ runtime.exec("ipset flush flamecord_blacklist"); ++ runtime.exec("ipset destroy flamecord_blacklist"); ++ runtime.exec("ipset create flamecord_blacklist hash:ip timeout " + flameCordConfiguration.getAntibotFirewallExpire()); ++ runtime.exec("iptables -I INPUT -p tcp -m set --match-set flamecord_blacklist src -j DROP"); ++ } catch (IOException exception) { ++ // Ignored ++ } ++ } ++ } ++ ++ public boolean check(final SocketAddress socketAddress) { ++ if (flameCordConfiguration.isAntibotFirewallEnabled()) { ++ final AddressData addressData = addressDataManager.getAddressData(socketAddress); ++ ++ return addressData.isFirewalled(); ++ } ++ ++ return false; ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/NicknameCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/NicknameCheck.java +new file mode 100644 +index 00000000..f9b1ad70 +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/NicknameCheck.java +@@ -0,0 +1,43 @@ ++package dev._2lstudios.antibot; ++ ++import java.net.SocketAddress; ++ ++import dev._2lstudios.flamecord.FlameCord; ++import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; ++ ++public class NicknameCheck { ++ private AddressDataManager addressDataManager; ++ ++ public NicknameCheck(final AddressDataManager addressDataManager) { ++ this.addressDataManager = addressDataManager; ++ } ++ ++ private boolean isBlacklisted(final FlameCordConfiguration config, final String nickname) { ++ for (final String blacklisted : config.getAntibotNicknameBlacklist()) { ++ if (nickname.toLowerCase().contains(blacklisted)) { ++ return true; ++ } ++ } ++ ++ return false; ++ } ++ ++ public boolean check(final SocketAddress socketAddress) { ++ final FlameCordConfiguration config = FlameCord.getInstance().getFlameCordConfiguration(); ++ ++ if (config.isAntibotNicknameEnabled()) { ++ final AddressData addressData = addressDataManager.getAddressData(socketAddress); ++ final String nickname = addressData.getLastNickname(); ++ ++ if (isBlacklisted(config, nickname)) { ++ if (config.isAntibotNicknameFirewall()) { ++ addressData.firewall(); ++ } ++ ++ return true; ++ } ++ } ++ ++ return false; ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/PasswordCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/PasswordCheck.java +new file mode 100644 +index 00000000..8ffe1e21 +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/PasswordCheck.java +@@ -0,0 +1,62 @@ ++package dev._2lstudios.antibot; ++ ++import java.net.SocketAddress; ++ ++import dev._2lstudios.flamecord.FlameCord; ++import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; ++ ++public class PasswordCheck { ++ private AddressDataManager addressDataManager; ++ private String lastNickname = ""; ++ private String lastPassword = ""; ++ private int repeatCount = 0; ++ ++ public PasswordCheck(final AddressDataManager addressDataManager) { ++ this.addressDataManager = addressDataManager; ++ } ++ ++ private void updatePassword(final FlameCordConfiguration config, final String nickname, final String password) { ++ if (!nickname.equals(lastNickname)) { ++ if (password.equals(lastPassword)) { ++ if (repeatCount < config.getAntibotPasswordLimit()) { ++ repeatCount++; ++ } ++ } else if (repeatCount > 0) { ++ repeatCount--; ++ } ++ } ++ ++ lastNickname = nickname; ++ lastPassword = password; ++ } ++ ++ public boolean check(final SocketAddress socketAddress, final String passwordMessage) { ++ final FlameCordConfiguration config = FlameCord.getInstance().getFlameCordConfiguration(); ++ ++ if (config.isAntibotPasswordEnabled()) { ++ if (passwordMessage.contains("/login ") || passwordMessage.contains("/l ") ++ || passwordMessage.contains("/register ") ++ || passwordMessage.contains("/reg ")) { ++ final AddressData addressData = addressDataManager.getAddressData(socketAddress); ++ final String nickname = addressData.getLastNickname(); ++ final String password = passwordMessage.split(" ")[1]; ++ ++ updatePassword(config, nickname, password); ++ ++ if (repeatCount >= config.getAntibotPasswordLimit()) { ++ if (config.isAntibotPasswordFirewall()) { ++ addressData.firewall(); ++ } ++ ++ return true; ++ } ++ } ++ } ++ ++ return false; ++ } ++ ++ public int getRepeatCount() { ++ return repeatCount; ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/RatelimitCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/RatelimitCheck.java +new file mode 100644 +index 00000000..f9ab936b +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/RatelimitCheck.java +@@ -0,0 +1,33 @@ ++package dev._2lstudios.antibot; ++ ++import java.net.SocketAddress; ++ ++import dev._2lstudios.flamecord.FlameCord; ++import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; ++ ++public class RatelimitCheck { ++ private final AddressDataManager addressDataManager; ++ ++ public RatelimitCheck(final AddressDataManager addressDataManager) { ++ this.addressDataManager = addressDataManager; ++ } ++ ++ public boolean check(final SocketAddress socketAddress) { ++ final FlameCordConfiguration config = FlameCord.getInstance().getFlameCordConfiguration(); ++ ++ if (config.isAntibotRatelimitEnabled()) { ++ final AddressData addressData = addressDataManager.getAddressData(socketAddress); ++ ++ if (addressData.getConnectionsSecond() >= config.getAntibotRatelimitConnectionsPerSecond() ++ || addressData.getPingsSecond() >= config.getAntibotRatelimitPingsPerSecond()) { ++ if (config.isAntibotRatelimitFirewall()) { ++ addressData.firewall(); ++ } ++ ++ return true; ++ } ++ } ++ ++ return false; ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/antibot/ReconnectCheck.java b/flamecord/src/main/java/dev/_2lstudios/antibot/ReconnectCheck.java +new file mode 100644 +index 00000000..f958a6f2 +--- /dev/null ++++ b/flamecord/src/main/java/dev/_2lstudios/antibot/ReconnectCheck.java +@@ -0,0 +1,33 @@ ++package dev._2lstudios.antibot; ++ ++import java.net.SocketAddress; ++ ++import dev._2lstudios.flamecord.FlameCord; ++import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; ++ ++public class ReconnectCheck { ++ private final AddressDataManager addressDataManager; ++ ++ public ReconnectCheck(final AddressDataManager addressDataManager) { ++ this.addressDataManager = addressDataManager; ++ } ++ ++ public boolean check(final SocketAddress socketAddress) { ++ final FlameCordConfiguration config = FlameCord.getInstance().getFlameCordConfiguration(); ++ ++ if (config.isAntibotReconnectEnabled()) { ++ final AddressData addressData = addressDataManager.getAddressData(socketAddress); ++ final boolean needsAttempts = addressData.getTotalConnections() < config.getAntibotReconnectAttempts() || addressData.getTotalPings() < config.getAntibotReconnectPings(); ++ final boolean tooSlow = addressData.getTimeSincePenultimateConnection() > config.getAntibotReconnectMaxTime(); ++ ++ if (tooSlow) { ++ addressData.setTotalConnections(0); ++ return false; ++ } else { ++ return needsAttempts; ++ } ++ } ++ ++ return false; ++ } ++} +diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java +index c78ab3a7..4079caa5 100644 +--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java ++++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java +@@ -3,6 +3,8 @@ package dev._2lstudios.flamecord; + import java.util.Collection; + import java.util.logging.Logger; + ++import dev._2lstudios.antibot.AddressDataManager; ++import dev._2lstudios.antibot.CheckManager; + import dev._2lstudios.flamecord.configuration.FlameCordConfiguration; + import dev._2lstudios.flamecord.configuration.MessagesConfiguration; + import dev._2lstudios.flamecord.configuration.ModulesConfiguration; +@@ -25,16 +27,24 @@ public class FlameCord { + @Getter + private FlameCordConfiguration flameCordConfiguration; + @Getter ++ private AddressDataManager addressDataManager; ++ @Getter ++ private CheckManager checkManager; ++ @Getter + private ModulesConfiguration modulesConfiguration; + @Getter + private MessagesConfiguration messagesConfiguration; + + private void reload(final Logger logger) { + final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class); ++ ++ if (checkManager != null) checkManager.unload(); + + this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider); + this.modulesConfiguration = new ModulesConfiguration(configurationProvider); + this.messagesConfiguration = new MessagesConfiguration(logger, configurationProvider); ++ this.addressDataManager = new AddressDataManager(); ++ this.checkManager = new CheckManager(addressDataManager, flameCordConfiguration); + } + + private FlameCord(final Logger logger, final Collection whitelistedAddresses) { +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 a77cecf0..9ace4ff5 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,114 @@ import net.md_5.bungee.config.Configuration; + import net.md_5.bungee.config.ConfigurationProvider; + + public class FlameCordConfiguration extends FlameConfig { ++ // FlameCord start - Antibot System ++ @Getter ++ private boolean antibotAccountsEnabled = true; ++ @Getter ++ private boolean antibotAccountsFirewall = true; ++ @Getter ++ private int antibotAccountsLimit = 3; ++ @Getter ++ private boolean antibotAccountsLog = true; ++ @Getter ++ private boolean antibotCountryEnabled = true; ++ @Getter ++ private boolean antibotCountryFirewall = true; ++ @Getter ++ private Collection antibotCountryBlacklist = Arrays.asList("CN", "HK", "RU", "IN", "TH", "ID", "DZ", "VN", "IR", "PK"); ++ @Getter ++ private boolean antibotCountryLog = true; ++ @Getter ++ private boolean antibotFastChatEnabled = true; ++ @Getter ++ private boolean antibotFastChatFirewall = true; ++ @Getter ++ private int antibotFastChatTime = 1000; ++ @Getter ++ private boolean antibotFastChatLog = true; ++ @Getter ++ private boolean antibotFirewallEnabled = true; ++ @Getter ++ private boolean antibotFirewallIpset = true; ++ @Getter ++ private int antibotFirewallExpire = 60; ++ @Getter ++ private boolean antibotFirewallLog = true; ++ @Getter ++ private boolean antibotNicknameEnabled = true; ++ @Getter ++ private boolean antibotNicknameFirewall = true; ++ @Getter ++ private Collection antibotNicknameBlacklist = Arrays.asList("mcstorm", "mcdown", "mcbot", "theresa_bot", "dropbot", "kingbot"); ++ @Getter ++ private boolean antibotNicknameLog = true; ++ @Getter ++ private boolean antibotPasswordEnabled = true; ++ @Getter ++ private boolean antibotPasswordFirewall = true; ++ @Getter ++ private int antibotPasswordLimit = 3; ++ @Getter ++ private boolean antibotPasswordLog = true; ++ @Getter ++ private boolean antibotRatelimitEnabled = true; ++ @Getter ++ private boolean antibotRatelimitFirewall = true; ++ @Getter ++ private int antibotRatelimitConnectionsPerSecond = 3; ++ @Getter ++ private int antibotRatelimitPingsPerSecond = 8; ++ @Getter ++ private boolean antibotRatelimitLog = true; ++ @Getter ++ private boolean antibotReconnectEnabled = true; ++ @Getter ++ private int antibotReconnectAttempts = 2; ++ @Getter ++ private int antibotReconnectPings = 0; ++ @Getter ++ private int antibotReconnectMaxTime = 10000; ++ @Getter ++ private boolean antibotReconnectLog = true; ++ ++ public void loadAntibot(final Configuration config) { ++ this.antibotAccountsEnabled = setIfUnexistant("antibot.accounts.enabled", this.antibotAccountsEnabled, config); ++ this.antibotAccountsFirewall = setIfUnexistant("antibot.accounts.firewall", this.antibotAccountsFirewall, config); ++ this.antibotAccountsLimit = setIfUnexistant("antibot.accounts.limit", this.antibotAccountsLimit, config); ++ this.antibotAccountsLog = setIfUnexistant("antibot.accounts.log", this.antibotAccountsLog, config); ++ this.antibotCountryEnabled = setIfUnexistant("antibot.country.enabled", this.antibotCountryEnabled, config); ++ this.antibotCountryFirewall = setIfUnexistant("antibot.country.firewall", this.antibotCountryFirewall, config); ++ this.antibotCountryBlacklist = setIfUnexistant("antibot.country.blacklist", this.antibotCountryBlacklist, config); ++ this.antibotCountryLog = setIfUnexistant("antibot.country.log", this.antibotCountryLog, config); ++ this.antibotFastChatEnabled = setIfUnexistant("antibot.fastchat.enabled", this.antibotFastChatEnabled, config); ++ this.antibotFastChatFirewall = setIfUnexistant("antibot.fastchat.firewall", this.antibotFastChatFirewall, config); ++ this.antibotFastChatTime = setIfUnexistant("antibot.fastchat.time", this.antibotFastChatTime, config); ++ this.antibotFastChatLog = setIfUnexistant("antibot.fastchat.log", this.antibotFastChatLog, config); ++ this.antibotFirewallEnabled = setIfUnexistant("antibot.firewall.enabled", this.antibotFirewallEnabled, config); ++ this.antibotFirewallIpset = setIfUnexistant("antibot.firewall.ipset", this.antibotFirewallIpset, config); ++ this.antibotFirewallExpire = setIfUnexistant("antibot.firewall.time", this.antibotFirewallExpire, config); ++ this.antibotFirewallLog = setIfUnexistant("antibot.firewall.log", this.antibotFirewallLog, config); ++ this.antibotNicknameEnabled = setIfUnexistant("antibot.nickname.enabled", this.antibotNicknameEnabled, config); ++ this.antibotNicknameFirewall = setIfUnexistant("antibot.nickname.firewall", this.antibotNicknameFirewall, config); ++ this.antibotNicknameBlacklist = setIfUnexistant("antibot.nickname.blacklist", this.antibotNicknameBlacklist, config); ++ this.antibotNicknameLog = setIfUnexistant("antibot.nickname.log", this.antibotNicknameLog, config); ++ this.antibotPasswordEnabled = setIfUnexistant("antibot.password.enabled", this.antibotPasswordEnabled, config); ++ this.antibotPasswordFirewall = setIfUnexistant("antibot.password.firewall", this.antibotPasswordFirewall, config); ++ this.antibotPasswordLimit = setIfUnexistant("antibot.password.limit", this.antibotPasswordLimit, config); ++ this.antibotPasswordLog = setIfUnexistant("antibot.password.log", this.antibotPasswordLog, config); ++ this.antibotRatelimitEnabled = setIfUnexistant("antibot.ratelimit.enabled", this.antibotRatelimitEnabled, config); ++ this.antibotRatelimitFirewall = setIfUnexistant("antibot.ratelimit.firewall", this.antibotRatelimitFirewall, config); ++ this.antibotRatelimitConnectionsPerSecond = setIfUnexistant("antibot.ratelimit.connections-per-second", this.antibotRatelimitConnectionsPerSecond, config); ++ this.antibotRatelimitPingsPerSecond = setIfUnexistant("antibot.ratelimit.pings-per-second", this.antibotRatelimitPingsPerSecond, config); ++ this.antibotRatelimitLog = setIfUnexistant("antibot.ratelimit.log", this.antibotRatelimitLog, config); ++ this.antibotReconnectEnabled = setIfUnexistant("antibot.reconnect.enabled", this.antibotReconnectEnabled, config); ++ this.antibotReconnectAttempts = setIfUnexistant("antibot.reconnect.attempts", this.antibotReconnectAttempts, config); ++ this.antibotReconnectPings = setIfUnexistant("antibot.reconnect.pings", this.antibotReconnectPings, config); ++ this.antibotReconnectMaxTime = setIfUnexistant("antibot.reconnect.max-time", this.antibotReconnectMaxTime, config); ++ this.antibotReconnectLog = setIfUnexistant("antibot.reconnect.log", this.antibotReconnectLog, config); ++ } ++ // FlameCord end - Antibot System ++ + // FlameCord - TCP Fast Open + @Getter + private int tcpFastOpen = 3; +@@ -115,6 +223,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); ++ loadAntibot(configuration); ++ + this.tcpFastOpen = setIfUnexistant("tcp-fast-open", this.tcpFastOpen, configuration); + + this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration); +diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java +index 57462992..ee0295c7 100644 +--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java ++++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java +@@ -81,6 +81,17 @@ public class MessagesConfiguration extends FlameConfig { + setIfUnexistant("command_ip", "&9IP of {0} is {1}", configuration); + setIfUnexistant("illegal_chat_characters", "&cIllegal characters in chat ({0})", configuration); + ++ // FlameCord start - Antibot System ++ setIfUnexistant("antibot_accounts", "&c&lFlameCord\n\n&cYou have too many accounts! ({0})\n\n&cError? Contact us on discord.gg/gF36AT3", configuration); ++ setIfUnexistant("antibot_fastchat", "&c&lFlameCord\n\n&cYou are chatting too fast!\n\n&cError? Contact us on discord.gg/gF36AT3", configuration); ++ setIfUnexistant("antibot_firewall", "&c&lFlameCord\n\n&cYou are blocked from this server!\n\n&cError? Contact us on discord.gg/gF36AT3", configuration); ++ setIfUnexistant("antibot_nickname", "&c&lFlameCord\n\n&cYour nickname was detected as bot! ({0})\n\n&cError? Contact us on discord.gg/gF36AT3", configuration); ++ setIfUnexistant("antibot_password", "&c&lFlameCord\n\n&cYour password is used by other players! ({0})\n\n&cError? Contact us on discord.gg/gF36AT3", configuration); ++ setIfUnexistant("antibot_ratelimit", "&c&lFlameCord\n\n&cYou are connecting too fast! ({0})\n\n&cError? Contact us on discord.gg/gF36AT3", configuration); ++ setIfUnexistant("antibot_reconnect", "&c&lFlameCord\n\n&cReconnect {0} more times to enter!\n\n&cError? Contact us on discord.gg/gF36AT3", configuration); ++ setIfUnexistant("antibot_country", "&c&lFlameCord\n\n&cYour country {0} is blacklisted!\n\n&cError? Contact us on discord.gg/gF36AT3", configuration); ++ // FlameCord end - Antibot System ++ + // FlameCord + setIfUnexistant("flamecord_reload", "&aAll files had been successfully reloaded!", configuration); + setIfUnexistant("flamecord_help", +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 0a09f92c..813f0e9b 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.antibot.AddressData; ++import dev._2lstudios.antibot.CheckManager; + import dev._2lstudios.flamecord.FlameCord; + + import dev._2lstudios.flamecord.configuration.FlameConfig; +@@ -415,6 +417,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection + return; + } + ++ // FlameCord start - Antibot System ++ AddressData addressData = FlameCord.getInstance().getAddressDataManager().getAddressData( ch.getRemoteAddress() ); ++ CheckManager checkManager = FlameCord.getInstance().getCheckManager(); ++ // FlameCord end - Antibot System ++ + switch ( handshake.getRequestedProtocol() ) + { + case 1: +@@ -426,6 +433,22 @@ public class InitialHandler extends PacketHandler implements PendingConnection + } + thisState = State.STATUS; + ch.setProtocol( Protocol.STATUS ); ++ ++ // FlameCord start - Antibot System ++ addressData.addPing(); ++ ++ if ( checkManager.getRatelimitCheck().check( ch.getRemoteAddress() ) ) ++ { ++ if ( FlameCord.getInstance().getFlameCordConfiguration().isAntibotRatelimitLog() ) ++ { ++ bungee.getLogger().log( Level.INFO, "[{0}] is pinging too many times", ch.getRemoteAddress() ); ++ } ++ ++ disconnect( bungee.getTranslation( "antibot_ratelimit", addressData.getPingsSecond() ) ); ++ return; ++ } ++ // FlameCord end - Antibot System ++ + break; + case 2: + // Login +@@ -437,6 +460,21 @@ public class InitialHandler extends PacketHandler implements PendingConnection + thisState = State.USERNAME; + ch.setProtocol( Protocol.LOGIN ); + ++ // FlameCord start - Antibot System ++ addressData.addConnection(); ++ ++ if ( checkManager.getRatelimitCheck().check( ch.getRemoteAddress() ) ) ++ { ++ if ( FlameCord.getInstance().getFlameCordConfiguration().isAntibotRatelimitLog() ) ++ { ++ bungee.getLogger().log( Level.INFO, "[{0}] is connecting too many times", ch.getRemoteAddress() ); ++ } ++ ++ disconnect( bungee.getTranslation( "antibot_ratelimit", addressData.getConnectionsSecond() ) ); ++ return; ++ } ++ // FlameCord end - Antibot System ++ + if ( !ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) + { + if ( handshake.getProtocolVersion() > bungee.getProtocolVersion() ) +@@ -474,6 +512,58 @@ public class InitialHandler extends PacketHandler implements PendingConnection + return; + } + ++ // FlameCord start - Antibot System ++ CheckManager checkManager = FlameCord.getInstance().getCheckManager(); ++ AddressData addressData = FlameCord.getInstance().getAddressDataManager().getAddressData( ch.getRemoteAddress() ); ++ String nickname = loginRequest.getData(); ++ ++ addressData.addNickname( nickname ); ++ ++ if ( checkManager.getAccountsCheck().check( ch.getRemoteAddress(), nickname ) ) ++ { ++ if ( FlameCord.getInstance().getFlameCordConfiguration().isAntibotAccountsLog() ) ++ { ++ bungee.getLogger().log( Level.INFO, "[{0}] has too many accounts", ch.getRemoteAddress() ); ++ } ++ ++ disconnect( bungee.getTranslation( "antibot_accounts", addressData.getNicknames().size() ) ); ++ return; ++ } ++ ++ if ( checkManager.getNicknameCheck().check( ch.getRemoteAddress() ) ) ++ { ++ if ( FlameCord.getInstance().getFlameCordConfiguration().isAntibotNicknameLog() ) ++ { ++ bungee.getLogger().log( Level.INFO, "[{0}] has a blacklisted nickname", ch.getRemoteAddress() ); ++ } ++ ++ disconnect( bungee.getTranslation( "antibot_nickname", loginRequest.getData() ) ); ++ return; ++ } ++ ++ if ( checkManager.getReconnectCheck().check( ch.getRemoteAddress() ) ) ++ { ++ if ( FlameCord.getInstance().getFlameCordConfiguration().isAntibotReconnectLog() ) ++ { ++ bungee.getLogger().log( Level.INFO, "[{0}] has to reconnect to join", ch.getRemoteAddress() ); ++ } ++ ++ disconnect( bungee.getTranslation( "antibot_reconnect", FlameCord.getInstance().getFlameCordConfiguration().getAntibotReconnectAttempts() - addressData.getTotalConnections() ) ); ++ return; ++ } ++ ++ if ( checkManager.getCountryCheck().check( ch.getRemoteAddress() ) ) ++ { ++ if ( FlameCord.getInstance().getFlameCordConfiguration().isAntibotCountryLog() ) ++ { ++ bungee.getLogger().log( Level.INFO, "[{0}] had his country blocked from the server", ch.getRemoteAddress() ); ++ } ++ ++ disconnect( bungee.getTranslation( "antibot_country", addressData.getCountry() ) ); ++ return; ++ } ++ // FlameCord end - Antibot System ++ + // If offline mode and they are already on, don't allow connect + // We can just check by UUID here as names are based on UUID + if ( !isOnlineMode() && bungee.getPlayer( getUniqueId() ) != null ) +diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +index e354032a..976c37e1 100644 +--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java ++++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +@@ -4,10 +4,15 @@ import com.google.common.base.Preconditions; + import com.mojang.brigadier.context.StringRange; + import com.mojang.brigadier.suggestion.Suggestion; + import com.mojang.brigadier.suggestion.Suggestions; ++ ++import dev._2lstudios.antibot.CheckManager; ++import dev._2lstudios.flamecord.FlameCord; + import io.netty.channel.Channel; + import java.util.ArrayList; + import java.util.LinkedList; + import java.util.List; ++import java.util.logging.Level; ++ + import net.md_5.bungee.BungeeCord; + import net.md_5.bungee.ServerConnection.KeepAliveData; + import net.md_5.bungee.UserConnection; +@@ -166,6 +171,32 @@ public class UpstreamBridge extends PacketHandler + } + Preconditions.checkArgument(!empty, "Chat message is empty"); + ++ // FlameCord start - Antibot System ++ final CheckManager checkManager = FlameCord.getInstance().getCheckManager(); ++ ++ if ( checkManager.getFastChatCheck().check( con.getCh().getRemoteAddress() ) ) ++ { ++ if ( FlameCord.getInstance().getFlameCordConfiguration().isAntibotFastChatLog() ) ++ { ++ bungee.getLogger().log( Level.INFO, "[{0}] is chatting too fast", con.getCh().getRemoteAddress() ); ++ } ++ ++ con.disconnect( bungee.getTranslation( "antibot_fastchat" ) ); ++ throw CancelSendSignal.INSTANCE; ++ } ++ ++ if ( checkManager.getPasswordCheck().check( con.getCh().getRemoteAddress(), chat.getMessage() ) ) ++ { ++ if ( FlameCord.getInstance().getFlameCordConfiguration().isAntibotPasswordLog() ) ++ { ++ bungee.getLogger().log( Level.INFO, "[{0}] has entered a repeated password", con.getCh().getRemoteAddress() ); ++ } ++ ++ con.disconnect( bungee.getTranslation( "antibot_password", checkManager.getPasswordCheck().getRepeatCount() ) ); ++ throw CancelSendSignal.INSTANCE; ++ } ++ // FlameCord end - Antibot System ++ + ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.getMessage() ); + if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() ) + { +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 cef44d8a..8fe2b37f 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 +@@ -152,6 +152,13 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter + { + boolean logExceptions = !( handler instanceof PingHandler ); + ++ // Flamecord start - Antibot System ++ if (!(cause instanceof ReadTimeoutException)) ++ { ++ FlameCord.getInstance().getAddressDataManager().getAddressData(ctx.channel().remoteAddress()).firewall(); ++ } ++ // Flamecord end - Antibot System ++ + // FlameCord - Option to log exceptions + logExceptions = FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions() ? logExceptions : false; + +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 f4bf745c..eaedb459 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 +@@ -63,6 +63,14 @@ public class PipelineUtils + { + SocketAddress remoteAddress = ( ch.remoteAddress() == null ) ? ch.parent().localAddress() : ch.remoteAddress(); + ++ // FlameCord start - Antibot System ++ if ( FlameCord.getInstance().getCheckManager().getFirewallCheck().check( ch.remoteAddress() ) ) ++ { ++ ch.close(); ++ return; ++ } ++ // FlameCord end - Antibot System ++ + if ( BungeeCord.getInstance().getConnectionThrottle() != null && BungeeCord.getInstance().getConnectionThrottle().throttle( remoteAddress ) ) + { + ch.close(); +-- +2.32.0 + diff --git a/Waterfall-Proxy-Patches/0030-Allow-Invalid-Names.patch b/Waterfall-Proxy-Patches/0030-Allow-Invalid-Names.patch new file mode 100644 index 0000000..37ea18e --- /dev/null +++ b/Waterfall-Proxy-Patches/0030-Allow-Invalid-Names.patch @@ -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 + diff --git a/Waterfall-Proxy-Patches/0031-Duplicate-buf-instead-of-Copy.patch b/Waterfall-Proxy-Patches/0031-Duplicate-buf-instead-of-Copy.patch new file mode 100644 index 0000000..d621b4a --- /dev/null +++ b/Waterfall-Proxy-Patches/0031-Duplicate-buf-instead-of-Copy.patch @@ -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 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 + 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 + diff --git a/Waterfall-Proxy-Patches/0032-Disable-entity-Metadata-Rewrite.patch b/Waterfall-Proxy-Patches/0032-Disable-entity-Metadata-Rewrite.patch new file mode 100644 index 0000000..03e402c --- /dev/null +++ b/Waterfall-Proxy-Patches/0032-Disable-entity-Metadata-Rewrite.patch @@ -0,0 +1,3234 @@ +From 05caaeafd1d30cd331e17dd438d21f8d7505890a Mon Sep 17 00:00:00 2001 +From: LinsaFTW <25271111+linsaftw@users.noreply.github.com> +Date: Thu, 10 Mar 2022 20:23:55 -0300 +Subject: [PATCH] Disable entity Metadata Rewrite + + +diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java +index 469fe0e1..97bd384b 100644 +--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java ++++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java +@@ -251,11 +251,6 @@ public interface ProxyConfig + */ + boolean isDisableModernTabLimiter(); + +- /** +- * @return Should we disable entity metadata rewriting? +- */ +- boolean isDisableEntityMetadataRewrite(); +- + /** + * Whether tablist rewriting should be disabled or not + * @return {@code true} if tablist rewriting is disabled, {@code false} otherwise +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java +index ee2317e8..15a61b7e 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java +@@ -8,8 +8,6 @@ import net.md_5.bungee.protocol.packet.ClientStatus; + import net.md_5.bungee.protocol.packet.Commands; + import net.md_5.bungee.protocol.packet.EncryptionRequest; + import net.md_5.bungee.protocol.packet.EncryptionResponse; +-import net.md_5.bungee.protocol.packet.EntityEffect; // Waterfall +-import net.md_5.bungee.protocol.packet.EntityRemoveEffect; // Waterfall + import net.md_5.bungee.protocol.packet.EntityStatus; + import net.md_5.bungee.protocol.packet.GameState; + import net.md_5.bungee.protocol.packet.Handshake; +@@ -195,14 +193,4 @@ public abstract class AbstractPacketHandler + public void handle(GameState gameState) throws Exception + { + } +- +- // Waterfall start +- public void handle(EntityEffect entityEffect) throws Exception +- { +- } +- +- public void handle(EntityRemoveEffect removeEffect) throws Exception +- { +- } +- // Waterfall end + } +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +index 04851233..8e59720f 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +@@ -18,8 +18,6 @@ import net.md_5.bungee.protocol.packet.EncryptionRequest; + import net.md_5.bungee.protocol.packet.EncryptionResponse; + import net.md_5.bungee.protocol.packet.EntityStatus; + import net.md_5.bungee.protocol.packet.GameState; +-import net.md_5.bungee.protocol.packet.EntityEffect; +-import net.md_5.bungee.protocol.packet.EntityRemoveEffect; + import net.md_5.bungee.protocol.packet.Handshake; + import net.md_5.bungee.protocol.packet.KeepAlive; + import net.md_5.bungee.protocol.packet.Kick; +@@ -122,20 +120,6 @@ public enum Protocol + map( ProtocolConstants.MINECRAFT_1_16, 0x0C ), + map( ProtocolConstants.MINECRAFT_1_17, 0x0D ) + ); +- // Waterfall start +- TO_CLIENT.registerPacket( +- EntityEffect.class, +- EntityEffect::new, +- map( ProtocolConstants.MINECRAFT_1_7_2, 0x1D ), // FlameCord - 1.7.x support +- map(ProtocolConstants.MINECRAFT_1_9, Integer.MIN_VALUE) +- ); +- TO_CLIENT.registerPacket( +- EntityRemoveEffect.class, +- EntityRemoveEffect::new, +- map( ProtocolConstants.MINECRAFT_1_7_2, 0x1E ), // FlameCord - 1.7.x support +- map(ProtocolConstants.MINECRAFT_1_9, Integer.MIN_VALUE) +- ); +- // Waterfall end + TO_CLIENT.registerPacket( + PlayerListItem.class, // PlayerInfo + PlayerListItem::new, +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java +deleted file mode 100644 +index 0ed78a8c..00000000 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java ++++ /dev/null +@@ -1,67 +0,0 @@ +-package net.md_5.bungee.protocol.packet; +- +-import io.netty.buffer.ByteBuf; +-import lombok.AllArgsConstructor; +-import lombok.Data; +-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 +-@AllArgsConstructor +-@EqualsAndHashCode(callSuper = false) +-public class EntityEffect extends DefinedPacket { +- +- private int entityId; +- private int effectId; +- private int amplifier; +- private int duration; +- private boolean hideParticles; +- +- @Override +- public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { +- this.entityId = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readInt(); // FlameCord - 1.7.x support +- this.effectId = buf.readUnsignedByte(); +- this.amplifier = buf.readUnsignedByte(); +- this.duration = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readShort(); // FlameCord - 1.7.x support +- // FlameCord start - 1.7.x support +- if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) +- { +- this.hideParticles = buf.readBoolean(); +- } +- // FlameCord end - 1.7.x support +- } +- +- @Override +- public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { +- // FlameCord start - 1.7.x support +- if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8) +- { +- writeVarInt(this.entityId, buf); +- } else +- { +- buf.writeInt(effectId); +- } +- // FlameCord end - 1.7.x support +- buf.writeByte(this.effectId); +- buf.writeByte(this.amplifier); +- // FlameCord start - 1.7.x support +- if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8) +- { +- writeVarInt(this.duration, buf); +- } else +- { +- buf.writeShort(duration); +- } +- // FlameCord end - 1.7.x support +- buf.writeBoolean(this.hideParticles); +- } +- +- @Override +- public void handle(AbstractPacketHandler handler) throws Exception { +- handler.handle(this); +- } +-} +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java +deleted file mode 100644 +index 435b8578..00000000 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java ++++ /dev/null +@@ -1,45 +0,0 @@ +-package net.md_5.bungee.protocol.packet; +- +-import io.netty.buffer.ByteBuf; +-import lombok.AllArgsConstructor; +-import lombok.Data; +-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 +-@AllArgsConstructor +-@EqualsAndHashCode(callSuper = false) +-public class EntityRemoveEffect extends DefinedPacket { +- +- private int entityId; +- private int effectId; +- +- @Override +- public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { +- this.entityId = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readInt(); // FlameCord - 1.7.x support +- this.effectId = buf.readUnsignedByte(); +- } +- +- @Override +- public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { +- // FlameCord start - 1.7.x support +- if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8) +- { +- writeVarInt(this.entityId, buf); +- } else +- { +- buf.writeInt(entityId); +- } +- // FlameCord end - 1.7.x support +- buf.writeByte(effectId); +- } +- +- @Override +- public void handle(AbstractPacketHandler handler) throws Exception { +- handler.handle(this); +- } +-} +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 ff4bbf34..a008b132 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 +@@ -42,7 +42,6 @@ public class WaterfallConfiguration extends Configuration { + private int tabThrottle = 1000; + private boolean disableModernTabLimiter = true; + +- private boolean disableEntityMetadataRewrite = false; + private boolean disableTabListRewrite = false; + + /* +@@ -74,7 +73,6 @@ public class WaterfallConfiguration extends Configuration { + // Throttling options + tabThrottle = config.getInt("throttling.tab_complete", tabThrottle); + disableModernTabLimiter = config.getBoolean("disable_modern_tab_limiter", disableModernTabLimiter); +- disableEntityMetadataRewrite = config.getBoolean("disable_entity_metadata_rewrite", disableEntityMetadataRewrite); + disableTabListRewrite = config.getBoolean("disable_tab_list_rewrite", disableTabListRewrite); + pluginChannelLimit = config.getInt("registered_plugin_channels_limit", pluginChannelLimit); + pluginChannelNameLimit = config.getInt("plugin_channel_name_limit", pluginChannelNameLimit); +@@ -105,11 +103,6 @@ public class WaterfallConfiguration extends Configuration { + return disableModernTabLimiter; + } + +- @Override +- public boolean isDisableEntityMetadataRewrite() { +- return disableEntityMetadataRewrite; +- } +- + @Override + public boolean isDisableTabListRewrite() { + return disableTabListRewrite; +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 3a41769a..d2bf095a 100644 +--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java ++++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +@@ -243,11 +243,6 @@ public class ServerConnector extends PacketHandler + ch.write( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:register" : "REGISTER", Joiner.on( "\0" ).join( registeredChannels ).getBytes( StandardCharsets.UTF_8 ), false ) ); + } + +- if (!user.isDisableEntityMetadataRewrite() && user.getSettings() != null ) +- { +- ch.write( user.getSettings() ); +- } +- + if ( user.getForgeClientHandler().getClientModList() == null && !user.getForgeClientHandler().isHandshakeComplete() ) // Vanilla + { + user.getForgeClientHandler().setHandshakeComplete(); +@@ -306,20 +301,6 @@ public class ServerConnector extends PacketHandler + user.getTabListHandler().onServerChange(); + + Scoreboard serverScoreboard = user.getServerSentScoreboard(); +- if ( !user.isDisableEntityMetadataRewrite() ) { // Waterfall +- for ( Objective objective : serverScoreboard.getObjectives() ) +- { +- user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), objective.getType() == null ? null : ScoreboardObjective.HealthDisplay.fromString(objective.getType()), (byte) 1 ) ); // FlameCord - 1.7 support +- } +- for ( Score score : serverScoreboard.getScores() ) +- { +- user.unsafe().sendPacket( new ScoreboardScore( score.getItemName(), (byte) 1, score.getScoreName(), score.getValue() ) ); +- } +- for ( Team team : serverScoreboard.getTeams() ) +- { +- user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.Team( team.getName() ) ); +- } +- } // Waterfall + serverScoreboard.clear(); + + for ( UUID bossbar : user.getSentBossBars() ) +@@ -338,33 +319,27 @@ public class ServerConnector extends PacketHandler + } + + user.setDimensionChange( true ); +- if ( !user.isDisableEntityMetadataRewrite() && login.getDimension() == user.getDimension() ) // Waterfall - defer +- { +- user.unsafe().sendPacket( new Respawn( (Integer) login.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), false ) ); +- } + + user.setServerEntityId( login.getEntityId() ); + + // Waterfall start +- if ( user.isDisableEntityMetadataRewrite() ) { +- // Ensure that we maintain consistency +- user.setClientEntityId( login.getEntityId() ); ++ // Ensure that we maintain consistency ++ user.setClientEntityId( login.getEntityId() ); + +- // Only send if we are not in the same dimension +- if ( login.getDimension() != user.getDimension() ) // Waterfall - defer +- { +- user.unsafe().sendPacket( new Respawn( (Integer) user.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), false ) ); +- } ++ // Only send if we are not in the same dimension ++ if ( login.getDimension() != user.getDimension() ) // Waterfall - defer ++ { ++ user.unsafe().sendPacket( new Respawn( (Integer) user.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), false ) ); ++ } + +- Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), +- (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isDebug(), login.isFlat() ); +- user.unsafe().sendPacket(modLogin); ++ Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), ++ (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isDebug(), login.isFlat() ); ++ user.unsafe().sendPacket(modLogin); + +- // Only send if we're in the same dimension +- if ( login.getDimension() == user.getDimension() ) // Waterfall - defer +- { +- user.unsafe().sendPacket( new Respawn( (Integer) login.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), false ) ); +- } ++ // Only send if we're in the same dimension ++ if ( login.getDimension() == user.getDimension() ) // Waterfall - defer ++ { ++ user.unsafe().sendPacket( new Respawn( (Integer) login.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), false ) ); + } + // Waterfall end + user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), false ) ); +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 e8eb555c..723b004a 100644 +--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java ++++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java +@@ -43,7 +43,6 @@ import net.md_5.bungee.api.event.ServerConnectEvent; + import net.md_5.bungee.api.score.Scoreboard; + import net.md_5.bungee.chat.ComponentSerializer; + import net.md_5.bungee.connection.InitialHandler; +-import net.md_5.bungee.entitymap.EntityMap; + import net.md_5.bungee.forge.ForgeClientHandler; + import net.md_5.bungee.forge.ForgeConstants; + import net.md_5.bungee.forge.ForgeServerHandler; +@@ -135,8 +134,6 @@ public final class UserConnection implements ProxiedPlayer + /*========================================================================*/ + @Getter + private String displayName; +- @Getter +- private EntityMap entityRewrite; + private Locale locale; + /*========================================================================*/ + @Getter +@@ -157,8 +154,6 @@ public final class UserConnection implements ProxiedPlayer + + public void init() + { +- this.entityRewrite = EntityMap.getEntityMap( getPendingConnection().getVersion() ); +- + this.displayName = name; + + tabListHandler = new ServerUnique( this ); +@@ -771,10 +766,4 @@ public final class UserConnection implements ProxiedPlayer + { + return serverSentScoreboard; + } +- +- // Waterfall start +- public boolean isDisableEntityMetadataRewrite() { +- return entityRewrite == net.md_5.bungee.entitymap.EntityMap_Dummy.INSTANCE; +- } +- // Waterfall end + } +diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +index a0b03ec1..20adce50 100644 +--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java ++++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +@@ -46,7 +46,6 @@ import net.md_5.bungee.api.score.Score; + import net.md_5.bungee.api.score.Scoreboard; + import net.md_5.bungee.api.score.Team; + import net.md_5.bungee.chat.ComponentSerializer; +-import net.md_5.bungee.entitymap.EntityMap; + import net.md_5.bungee.netty.ChannelWrapper; + import net.md_5.bungee.netty.PacketHandler; + import net.md_5.bungee.protocol.DefinedPacket; +@@ -54,8 +53,6 @@ import net.md_5.bungee.protocol.PacketWrapper; + import net.md_5.bungee.protocol.ProtocolConstants; + import net.md_5.bungee.protocol.packet.BossBar; + import net.md_5.bungee.protocol.packet.Commands; +-import net.md_5.bungee.protocol.packet.EntityEffect; +-import net.md_5.bungee.protocol.packet.EntityRemoveEffect; + import net.md_5.bungee.protocol.packet.KeepAlive; + import net.md_5.bungee.protocol.packet.Kick; + import net.md_5.bungee.protocol.packet.PlayerListItem; +@@ -147,11 +144,6 @@ public class DownstreamBridge extends PacketHandler + @Override + public void handle(PacketWrapper packet) throws Exception + { +- EntityMap rewrite = con.getEntityRewrite(); +- if ( rewrite != null ) +- { +- rewrite.rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId(), con.getPendingConnection().getVersion() ); +- } + con.sendPacket( packet ); + } + +@@ -685,34 +677,6 @@ public class DownstreamBridge extends PacketHandler + } + } + +- // Waterfall start +- @Override +- public void handle(EntityEffect entityEffect) throws Exception +- { +- if (con.isDisableEntityMetadataRewrite()) return; // Waterfall +- // Don't send any potions when switching between servers (which involves a handshake), which can trigger a race +- // condition on the client. +- if (this.con.getForgeClientHandler().isForgeUser() && !this.con.getForgeClientHandler().isHandshakeComplete()) { +- throw CancelSendSignal.INSTANCE; +- } +- con.getPotions().put(rewriteEntityId(entityEffect.getEntityId()), entityEffect.getEffectId()); +- } +- +- @Override +- public void handle(EntityRemoveEffect removeEffect) throws Exception +- { +- if (con.isDisableEntityMetadataRewrite()) return; // Waterfall +- con.getPotions().remove(rewriteEntityId(removeEffect.getEntityId()), removeEffect.getEffectId()); +- } +- +- private int rewriteEntityId(int entityId) { +- if (entityId == con.getServerEntityId()) { +- return con.getClientEntityId(); +- } +- return entityId; +- } +- // Waterfall end +- + @Override + public void handle(Respawn respawn) + { +diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +index 976c37e1..ec20e714 100644 +--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java ++++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +@@ -24,7 +24,6 @@ import net.md_5.bungee.api.event.PlayerDisconnectEvent; + import net.md_5.bungee.api.event.PluginMessageEvent; + import net.md_5.bungee.api.event.SettingsChangedEvent; + import net.md_5.bungee.api.event.TabCompleteEvent; +-import net.md_5.bungee.entitymap.EntityMap; + import net.md_5.bungee.forge.ForgeConstants; + import net.md_5.bungee.netty.ChannelWrapper; + import net.md_5.bungee.netty.PacketHandler; +@@ -128,11 +127,6 @@ public class UpstreamBridge extends PacketHandler + { + if ( con.getServer() != null ) + { +- EntityMap rewrite = con.getEntityRewrite(); +- if ( rewrite != null ) +- { +- rewrite.rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId(), con.getPendingConnection().getVersion() ); +- } + con.getServer().getCh().write( packet ); + } + } +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 +deleted file mode 100644 +index b9bcecb5..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java ++++ /dev/null +@@ -1,368 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import io.netty.buffer.ByteBufInputStream; +-import java.io.DataInputStream; +-import lombok.AccessLevel; +-import lombok.NoArgsConstructor; +- +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +-import se.llbit.nbt.NamedTag; +-import se.llbit.nbt.Tag; +- +-/** +- * Class to rewrite integers within packets. +- */ +-@NoArgsConstructor(access = AccessLevel.PACKAGE) +-public abstract class EntityMap +-{ +- +- private final boolean[] clientboundInts = new boolean[ 256 ]; +- private final boolean[] clientboundVarInts = new boolean[ 256 ]; +- +- private final boolean[] serverboundInts = new boolean[ 256 ]; +- private final boolean[] serverboundVarInts = new boolean[ 256 ]; +- +- // Returns the correct entity map for the protocol version +- public static EntityMap getEntityMap(int version) +- { +- // Waterfall start +- if (net.md_5.bungee.api.ProxyServer.getInstance().getConfig().isDisableEntityMetadataRewrite()) { +- return EntityMap_Dummy.INSTANCE; +- } +- // Waterfall end +- switch ( version ) +- { +- // FlameCord start - 1.7.x support +- case ProtocolConstants.MINECRAFT_1_7_2: +- return EntityMap_1_7_2.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_7_6: +- return EntityMap_1_7_6.INSTANCE; +- // FlameCord end - 1.7.x support +- case ProtocolConstants.MINECRAFT_1_8: +- return EntityMap_1_8.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_9: +- case ProtocolConstants.MINECRAFT_1_9_1: +- case ProtocolConstants.MINECRAFT_1_9_2: +- return EntityMap_1_9.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_9_4: +- return EntityMap_1_9_4.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_10: +- return EntityMap_1_10.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_11: +- case ProtocolConstants.MINECRAFT_1_11_1: +- return EntityMap_1_11.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_12: +- return EntityMap_1_12.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_12_1: +- case ProtocolConstants.MINECRAFT_1_12_2: +- return EntityMap_1_12_1.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_13: +- case ProtocolConstants.MINECRAFT_1_13_1: +- case ProtocolConstants.MINECRAFT_1_13_2: +- return EntityMap_1_13.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_14: +- case ProtocolConstants.MINECRAFT_1_14_1: +- case ProtocolConstants.MINECRAFT_1_14_2: +- case ProtocolConstants.MINECRAFT_1_14_3: +- case ProtocolConstants.MINECRAFT_1_14_4: +- return EntityMap_1_14.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_15: +- case ProtocolConstants.MINECRAFT_1_15_1: +- case ProtocolConstants.MINECRAFT_1_15_2: +- return EntityMap_1_15.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_16: +- case ProtocolConstants.MINECRAFT_1_16_1: +- return EntityMap_1_16.INSTANCE; +- case ProtocolConstants.MINECRAFT_1_16_2: +- case ProtocolConstants.MINECRAFT_1_16_3: +- case ProtocolConstants.MINECRAFT_1_16_4: +- return EntityMap_1_16_2.INSTANCE_1_16_2; +- case ProtocolConstants.MINECRAFT_1_17: +- case ProtocolConstants.MINECRAFT_1_17_1: +- return EntityMap_1_16_2.INSTANCE_1_17; +- case ProtocolConstants.MINECRAFT_1_18: +- case ProtocolConstants.MINECRAFT_1_18_2: +- return EntityMap_1_16_2.INSTANCE_1_18; +- } +- throw new RuntimeException( "Version " + version + " has no entity map" ); +- } +- +- protected void addRewrite(int id, ProtocolConstants.Direction direction, boolean varint) +- { +- if ( direction == ProtocolConstants.Direction.TO_CLIENT ) +- { +- if ( varint ) +- { +- clientboundVarInts[id] = true; +- } else +- { +- clientboundInts[id] = true; +- } +- } else if ( varint ) +- { +- serverboundVarInts[id] = true; +- } else +- { +- serverboundInts[id] = true; +- } +- } +- +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- rewrite( packet, oldId, newId, serverboundInts, serverboundVarInts ); +- } +- +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId, int protocolVersion) +- { +- rewriteServerbound( packet, oldId, newId ); +- } +- +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- rewrite( packet, oldId, newId, clientboundInts, clientboundVarInts ); +- } +- +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) +- { +- rewriteClientbound( packet, oldId, newId ); +- } +- +- protected static void rewriteInt(ByteBuf packet, int oldId, int newId, int offset) +- { +- int readId = packet.getInt( offset ); +- if ( readId == oldId ) +- { +- packet.setInt( offset, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( offset, oldId ); +- } +- } +- +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- protected static void rewriteVarInt(ByteBuf packet, int oldId, int newId, int offset) +- { +- // Need to rewrite the packet because VarInts are variable length +- int readId = DefinedPacket.readVarInt( packet ); +- int readIdLength = packet.readerIndex() - offset; +- if ( readId == oldId || readId == newId ) +- { +- ByteBuf data = packet.copy(); +- +- try { +- packet.readerIndex( offset ); +- packet.writerIndex( offset ); +- DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet ); +- packet.writeBytes( data ); +- } finally { +- data.release(); +- } +- } +- } +- +- protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, int metaIndex) +- { +- rewriteMetaVarInt( packet, oldId, newId, metaIndex, -1 ); +- } +- +- protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, int metaIndex, int protocolVersion) +- { +- int readerIndex = packet.readerIndex(); +- +- short index; +- while ( ( index = packet.readUnsignedByte() ) != 0xFF ) +- { +- int type = DefinedPacket.readVarInt( packet ); +- if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) +- { +- switch ( type ) +- { +- case 5: // optional chat +- if ( packet.readBoolean() ) +- { +- DefinedPacket.readString( packet ); +- } +- continue; +- case 15: // particle +- int particleId = DefinedPacket.readVarInt( packet ); +- +- if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_14 ) +- { +- switch ( particleId ) +- { +- case 3: // minecraft:block +- case 23: // minecraft:falling_dust +- DefinedPacket.readVarInt( packet ); // block state +- break; +- case 14: // minecraft:dust +- packet.skipBytes( 16 ); // float, float, float, flat +- break; +- case 32: // minecraft:item +- readSkipSlot( packet, protocolVersion ); +- break; +- } +- } else +- { +- switch ( particleId ) +- { +- case 3: // minecraft:block +- case 20: // minecraft:falling_dust +- DefinedPacket.readVarInt( packet ); // block state +- break; +- case 11: // minecraft:dust +- packet.skipBytes( 16 ); // float, float, float, flat +- break; +- case 27: // minecraft:item +- readSkipSlot( packet, protocolVersion ); +- break; +- } +- } +- continue; +- default: +- if ( type >= 6 ) +- { +- type--; +- } +- break; +- } +- } +- +- switch ( type ) +- { +- case 0: +- packet.skipBytes( 1 ); // byte +- break; +- case 1: +- if ( index == metaIndex ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, position ); +- packet.readerIndex( position ); +- } +- DefinedPacket.readVarInt( packet ); +- break; +- case 2: +- packet.skipBytes( 4 ); // float +- break; +- case 3: +- case 4: +- DefinedPacket.readString( packet ); +- break; +- case 5: +- readSkipSlot( packet, protocolVersion ); +- break; +- case 6: +- packet.skipBytes( 1 ); // boolean +- break; +- case 7: +- packet.skipBytes( 12 ); // float, float, float +- break; +- case 8: +- packet.readLong(); +- break; +- case 9: +- if ( packet.readBoolean() ) +- { +- packet.skipBytes( 8 ); // long +- } +- break; +- case 10: +- DefinedPacket.readVarInt( packet ); +- break; +- case 11: +- if ( packet.readBoolean() ) +- { +- packet.skipBytes( 16 ); // long, long +- } +- break; +- case 12: +- DefinedPacket.readVarInt( packet ); +- break; +- case 13: +- Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( packet ) ) ); +- if ( tag.isError() ) +- { +- throw new RuntimeException( tag.error() ); +- } +- break; +- case 15: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readVarInt( packet ); +- break; +- case 16: +- if ( index == metaIndex ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId + 1, newId + 1, position ); +- packet.readerIndex( position ); +- } +- DefinedPacket.readVarInt( packet ); +- break; +- case 17: +- DefinedPacket.readVarInt( packet ); +- break; +- default: +- // Waterfall start - Don't lie +- if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) +- { +- type++; +- } +- throw new IllegalArgumentException( "Unknown meta type " + type + ": Using mods? refer to disable_entity_metadata_rewrite in waterfall.yml" ); +- // Waterfall end +- } +- } +- +- packet.readerIndex( readerIndex ); +- } +- +- private static void readSkipSlot(ByteBuf packet, int protocolVersion) +- { +- if ( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13_2 ) ? packet.readBoolean() : packet.readShort() != -1 ) +- { +- if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13_2 ) +- { +- DefinedPacket.readVarInt( packet ); +- } +- packet.skipBytes( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? 1 : 3 ); // byte vs byte, short +- +- int position = packet.readerIndex(); +- if ( packet.readByte() != 0 ) +- { +- packet.readerIndex( position ); +- +- Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( packet ) ) ); +- if ( tag.isError() ) +- { +- throw new RuntimeException( tag.error() ); +- } +- } +- } +- } +- +- // Handles simple packets +- private static void rewrite(ByteBuf packet, int oldId, int newId, boolean[] ints, boolean[] varints) +- { +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if (packetId < 0 || packetId > ints.length || packetId > varints.length) { // Invalid packet id +- // Ignore these invalid packets for compatibility reasons +- packet.readerIndex( readerIndex ); +- return; +- } +- +- if ( ints[packetId] ) +- { +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength ); +- } else if ( varints[packetId] ) +- { +- rewriteVarInt( packet, oldId, newId, readerIndex + packetIdLength ); +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java +deleted file mode 100644 +index 6db530c3..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java ++++ /dev/null +@@ -1,182 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_10 extends EntityMap +-{ +- +- static final EntityMap_1_10 INSTANCE = new EntityMap_1_10(); +- +- EntityMap_1_10() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed +- addRewrite( 0x31, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x34, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x3A, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, true ); // Attach Entity : PacketPlayOutMount +- addRewrite( 0x48, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x14, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x48 /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x40 /* Attach Entity : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = packet.readUnsignedByte(); +- +- if ( type == 60 || type == 90 || type == 91 ) +- { +- if ( type == 60 || type == 91 ) +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x39 /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6 ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 13 ); // guardian beam +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java +deleted file mode 100644 +index 36822127..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java ++++ /dev/null +@@ -1,183 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_11 extends EntityMap +-{ +- +- static final EntityMap_1_11 INSTANCE = new EntityMap_1_11(); +- +- EntityMap_1_11() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed +- addRewrite( 0x31, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x34, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x3A, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, true ); // Attach Entity : PacketPlayOutMount +- addRewrite( 0x48, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x14, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x48 /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x40 /* Attach Entity : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = packet.readUnsignedByte(); +- +- if ( type == 60 || type == 90 || type == 91 ) +- { +- if ( type == 60 || type == 91 ) +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x39 /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6 ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 7 ); // fireworks (et al) +- rewriteMetaVarInt( packet, oldId, newId, 13 ); // guardian beam +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java +deleted file mode 100644 +index 38e12ce4..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java ++++ /dev/null +@@ -1,183 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_12 extends EntityMap +-{ +- +- static final EntityMap_1_12 INSTANCE = new EntityMap_1_12(); +- +- EntityMap_1_12() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed +- addRewrite( 0x32, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x35, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x38, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x3D, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x3E, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x42, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount +- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x4D, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x4E, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0B, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x15, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x3C /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x4A /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x42 /* Attach Entity : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x31 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = packet.readUnsignedByte(); +- +- if ( type == 60 || type == 90 || type == 91 ) +- { +- if ( type == 60 || type == 91 ) +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x3B /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6 ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 7 ); // fireworks (et al) +- rewriteMetaVarInt( packet, oldId, newId, 13 ); // guardian beam +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java +deleted file mode 100644 +index 5f296839..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java ++++ /dev/null +@@ -1,183 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_12_1 extends EntityMap +-{ +- +- static final EntityMap_1_12_1 INSTANCE = new EntityMap_1_12_1(); +- +- EntityMap_1_12_1() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x30, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed +- addRewrite( 0x33, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x3D, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x3E, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x3F, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x43, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount +- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x4C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x4E, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x4F, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x15, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x3D /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x4B /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x43 /* Attach Entity : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x32 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = packet.readUnsignedByte(); +- +- if ( type == 60 || type == 90 || type == 91 ) +- { +- if ( type == 60 || type == 91 ) +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x2D /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x3C /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6 ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 7 ); // fireworks (et al) +- rewriteMetaVarInt( packet, oldId, newId, 13 ); // guardian beam +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java +deleted file mode 100644 +index f3372f08..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java ++++ /dev/null +@@ -1,183 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_13 extends EntityMap +-{ +- +- static final EntityMap_1_13 INSTANCE = new EntityMap_1_13(); +- +- EntityMap_1_13() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x33, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed +- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x3F, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x41, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x42, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount +- addRewrite( 0x4F, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x50, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x52, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x53, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0D, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x19, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x40 /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x4F /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x46 /* Set Passengers : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x35 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = packet.readUnsignedByte(); +- +- if ( type == 60 || type == 90 || type == 91 ) +- { +- if ( type == 60 || type == 91 ) +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x2F /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x3F /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6, protocolVersion ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 7, protocolVersion ); // fireworks (et al) +- rewriteMetaVarInt( packet, oldId, newId, 13, protocolVersion ); // guardian beam +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java +deleted file mode 100644 +index 8210b0a7..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java ++++ /dev/null +@@ -1,187 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_14 extends EntityMap +-{ +- +- static final EntityMap_1_14 INSTANCE = new EntityMap_1_14(); +- +- EntityMap_1_14() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x2B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x38, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x3E, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x43, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x44, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x45, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount +- addRewrite( 0x55, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x56, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x58, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x59, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0E, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x44 /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x55 /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x4A /* Set Passengers : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x37 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = DefinedPacket.readVarInt( packet ); +- +- if ( type == 2 || type == 101 || type == 71 ) // arrow, fishing_bobber or spectral_arrow +- { +- if ( type == 2 || type == 71 ) // arrow or spectral_arrow +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x32 /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x43 /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 7, protocolVersion ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 8, protocolVersion ); // fireworks (et al) +- rewriteMetaVarInt( packet, oldId, newId, 15, protocolVersion ); // guardian beam +- break; +- case 0x50 /* Entity Sound Effect : PacketPlayOutEntitySound */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java +deleted file mode 100644 +index c2cf810f..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java ++++ /dev/null +@@ -1,187 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_15 extends EntityMap +-{ +- +- static final EntityMap_1_15 INSTANCE = new EntityMap_1_15(); +- +- EntityMap_1_15() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x09, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x2B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x2C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x3F, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x44, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x45, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x47, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount +- addRewrite( 0x56, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x57, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x59, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x5A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0E, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x45 /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x56 /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x4B /* Set Passengers : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x38 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = DefinedPacket.readVarInt( packet ); +- +- if ( type == 2 || type == 102 || type == 72 ) // arrow, fishing_bobber or spectral_arrow +- { +- if ( type == 2 || type == 72 ) // arrow or spectral_arrow +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x33 /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x44 /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 7, protocolVersion ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 8, protocolVersion ); // fireworks (et al) +- rewriteMetaVarInt( packet, oldId, newId, 16, protocolVersion ); // guardian beam +- break; +- case 0x51 /* Entity Sound Effect : PacketPlayOutEntitySound */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java +deleted file mode 100644 +index c8b06707..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java ++++ /dev/null +@@ -1,187 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_16 extends EntityMap +-{ +- +- static final EntityMap_1_16 INSTANCE = new EntityMap_1_16(); +- +- EntityMap_1_16() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x02, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x2B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x38, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x3E, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x44, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x45, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x47, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount +- addRewrite( 0x55, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x56, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x58, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x59, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0E, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x1C, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x45 /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x55 /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x4B /* Set Passengers : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x37 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = DefinedPacket.readVarInt( packet ); +- +- if ( type == 2 || type == 102 || type == 72 ) // arrow, fishing_bobber or spectral_arrow +- { +- if ( type == 2 || type == 72 ) // arrow or spectral_arrow +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x04 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x32 /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x44 /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 7, protocolVersion ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 8, protocolVersion ); // fireworks (et al) +- rewriteMetaVarInt( packet, oldId, newId, 16, protocolVersion ); // guardian beam +- break; +- case 0x50 /* Entity Sound Effect : PacketPlayOutEntitySound */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x2C /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java +deleted file mode 100644 +index 2f0e303d..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java ++++ /dev/null +@@ -1,74 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import lombok.AccessLevel; +-import lombok.RequiredArgsConstructor; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +- +-@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +-class EntityMap_1_16_2 extends EntityMap +-{ +- +- static final EntityMap_1_16_2 INSTANCE_1_16_2 = new EntityMap_1_16_2( 0x04, 0x2D ); +- static final EntityMap_1_16_2 INSTANCE_1_17 = new EntityMap_1_16_2( 0x04, 0x2D ); +- static final EntityMap_1_16_2 INSTANCE_1_18 = new EntityMap_1_16_2( 0x04, 0x2D ); +- // +- private final int spawnPlayerId; +- private final int spectateId; +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) +- { +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == spawnPlayerId ) +- { +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == spectateId && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java +deleted file mode 100644 +index cdc07dc4..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java ++++ /dev/null +@@ -1,102 +0,0 @@ +-// FlameCord start - 1.7.x support +-package net.md_5.bungee.entitymap; +- +-import io.netty.buffer.ByteBuf; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_7_2 extends EntityMap +-{ +- +- static final EntityMap INSTANCE = new EntityMap_1_7_2(); +- +- EntityMap_1_7_2() +- { +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Equipment +- addRewrite( 0x0A, ProtocolConstants.Direction.TO_CLIENT, false ); // Use bed +- addRewrite( 0x0B, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation +- addRewrite( 0x0C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player +- addRewrite( 0x0D, ProtocolConstants.Direction.TO_CLIENT, false ); // Collect Item +- addRewrite( 0x0E, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object +- addRewrite( 0x0F, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob +- addRewrite( 0x10, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting +- addRewrite( 0x11, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb +- addRewrite( 0x12, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Velocity +- addRewrite( 0x14, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity +- addRewrite( 0x15, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Relative Move +- addRewrite( 0x16, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Look +- addRewrite( 0x17, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Look and Relative Move +- addRewrite( 0x18, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Teleport +- addRewrite( 0x19, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Head Look +- addRewrite( 0x1A, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity +- addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Metadata +- addRewrite( 0x1D, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Effect +- addRewrite( 0x1E, ProtocolConstants.Direction.TO_CLIENT, false ); // Remove Entity Effect +- addRewrite( 0x20, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Properties +- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation +- addRewrite( 0x2C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Global Entity +- +- addRewrite( 0x02, ProtocolConstants.Direction.TO_SERVER, false ); // Use Entity +- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, false ); // Animation +- addRewrite( 0x0B, ProtocolConstants.Direction.TO_SERVER, false ); // Entity Action +- } +- +- @Override +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- //Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- if ( packetId == 0x0D /* Collect Item */ || packetId == 0x1B /* Attach Entity */ ) +- { +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- } else if ( packetId == 0x13 /* Destroy Entities */ ) +- { +- int count = packet.getByte( packetIdLength ); +- for ( int i = 0; i < count; i++ ) +- { +- rewriteInt( packet, oldId, newId, packetIdLength + 1 + i * 4 ); +- } +- } else if ( packetId == 0x0E /* Spawn Object */ ) +- { +- DefinedPacket.readVarInt( packet ); +- int type = packet.readUnsignedByte(); +- +- if ( type == 60 || type == 90 ) +- { +- packet.skipBytes( 14 ); +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- int changedId = -1; +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- changedId = newId; +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- changedId = oldId; +- } +- if ( changedId != -1 ) +- { +- if ( changedId == 0 && readId != 0 ) +- { // Trim off the extra data +- packet.readerIndex( readerIndex ); +- packet.writerIndex( packet.readableBytes() - 6 ); +- } else if ( changedId != 0 && readId == 0 ) +- { // Add on the extra data +- packet.readerIndex( readerIndex ); +- packet.capacity( packet.readableBytes() + 6 ); +- packet.writerIndex( packet.readableBytes() + 6 ); +- } +- } +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +-// FlameCord end - 1.7.x support +\ No newline at end of file +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java +deleted file mode 100644 +index 5ce42f62..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java ++++ /dev/null +@@ -1,62 +0,0 @@ +-// FlameCord start - 1.7.x support +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.connection.LoginResult; +-import net.md_5.bungee.protocol.DefinedPacket; +- +-class EntityMap_1_7_6 extends EntityMap_1_7_2 +-{ +- +- static final EntityMap_1_7_6 INSTANCE = new EntityMap_1_7_6(); +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- if ( packetId == 0x0C /* Spawn Player */ ) +- { +- DefinedPacket.readVarInt( packet ); +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- String uuid = DefinedPacket.readString( packet ); +- String username = DefinedPacket.readString( packet ); +- int props = DefinedPacket.readVarInt( packet ); +- if ( props == 0 ) +- { +- UserConnection player = (UserConnection) BungeeCord.getInstance().getPlayer( username ); +- if ( player != null ) +- { +- LoginResult profile = player.getPendingConnection().getLoginProfile(); +- if ( profile != null && profile.getProperties() != null +- && profile.getProperties().length >= 1 ) +- { +- ByteBuf rest = packet.copy(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeString( player.getUniqueId().toString(), packet ); +- DefinedPacket.writeString( username, packet ); +- DefinedPacket.writeVarInt( profile.getProperties().length, packet ); +- for ( LoginResult.Property property : profile.getProperties() ) +- { +- DefinedPacket.writeString( property.getName(), packet ); +- DefinedPacket.writeString( property.getValue(), packet ); +- DefinedPacket.writeString( property.getSignature(), packet ); +- } +- packet.writeBytes( rest ); +- rest.release(); +- } +- } +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +-// FlameCord end - 1.7.x support +\ No newline at end of file +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java +deleted file mode 100644 +index 8e2dbe69..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java ++++ /dev/null +@@ -1,176 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_8 extends EntityMap +-{ +- +- static final EntityMap_1_8 INSTANCE = new EntityMap_1_8(); +- +- EntityMap_1_8() +- { +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment +- addRewrite( 0x0A, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed +- addRewrite( 0x0B, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation +- addRewrite( 0x0C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player +- addRewrite( 0x0D, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item +- addRewrite( 0x0E, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object +- addRewrite( 0x0F, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob +- addRewrite( 0x10, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting +- addRewrite( 0x11, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb +- addRewrite( 0x12, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity +- addRewrite( 0x14, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity +- addRewrite( 0x15, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move +- addRewrite( 0x16, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look +- addRewrite( 0x17, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move +- addRewrite( 0x18, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport +- addRewrite( 0x19, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look +- addRewrite( 0x1A, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity +- addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata +- addRewrite( 0x1D, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect +- addRewrite( 0x1E, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect +- addRewrite( 0x20, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties +- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation +- addRewrite( 0x2C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Global Entity +- addRewrite( 0x43, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera +- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Update Entity NBT +- +- addRewrite( 0x02, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity +- addRewrite( 0x0B, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- //Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- if ( packetId == 0x0D /* Collect Item */ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( packetId == 0x1B /* Attach Entity */ ) +- { +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- } else if ( packetId == 0x13 /* Destroy Entities */ ) +- { +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( readerIndex + packetIdLength ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- } else if ( packetId == 0x0E /* Spawn Object */ ) +- { +- +- DefinedPacket.readVarInt( packet ); +- int type = packet.readUnsignedByte(); +- +- if ( type == 60 || type == 90 ) +- { +- packet.skipBytes( 14 ); +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- int changedId = readId; +- +- if ( readId == oldId ) +- { +- packet.setInt( position, changedId = newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, changedId = oldId ); +- } +- +- if ( readId > 0 && changedId <= 0 ) +- { +- packet.writerIndex( packet.writerIndex() - 6 ); +- } else if ( changedId > 0 && readId <= 0 ) +- { +- packet.ensureWritable( 6 ); +- packet.writerIndex( packet.writerIndex() + 6 ); +- } +- } +- } else if ( packetId == 0x0C /* Spawn Player */ ) +- { +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- } else if ( packetId == 0x42 /* Combat Event */ ) +- { +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- //Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x18 /* Spectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java +deleted file mode 100644 +index d61dc0cb..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java ++++ /dev/null +@@ -1,182 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_9 extends EntityMap +-{ +- +- static final EntityMap_1_9 INSTANCE = new EntityMap_1_9(); +- +- EntityMap_1_9() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed +- addRewrite( 0x31, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x34, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x3A, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, true ); // Attach Entity : PacketPlayOutMount +- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x4C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x14, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x49 /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x40 /* Attach Entity : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = packet.readUnsignedByte(); +- +- if ( type == 60 || type == 90 || type == 91 ) +- { +- if ( type == 60 || type == 91 ) +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x39 /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 5 ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 12 ); // guardian beam +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java +deleted file mode 100644 +index bfbc8432..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java ++++ /dev/null +@@ -1,182 +0,0 @@ +-package net.md_5.bungee.entitymap; +- +-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import io.netty.buffer.ByteBuf; +-import java.util.UUID; +-import net.md_5.bungee.BungeeCord; +-import net.md_5.bungee.UserConnection; +-import net.md_5.bungee.api.connection.ProxiedPlayer; +-import net.md_5.bungee.protocol.DefinedPacket; +-import net.md_5.bungee.protocol.ProtocolConstants; +- +-class EntityMap_1_9_4 extends EntityMap +-{ +- +- static final EntityMap_1_9_4 INSTANCE = new EntityMap_1_9_4(); +- +- EntityMap_1_9_4() +- { +- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity +- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb +- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving +- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting +- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn +- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation +- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation +- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus +- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove +- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook +- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook +- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity +- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed +- addRewrite( 0x31, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect +- addRewrite( 0x34, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation +- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera +- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata +- addRewrite( 0x3A, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity +- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity +- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment +- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, true ); // Attach Entity : PacketPlayOutMount +- addRewrite( 0x48, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect +- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport +- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes +- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect +- +- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity +- addRewrite( 0x14, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction +- } +- +- @Override +- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteClientbound( packet, oldId, newId ); +- +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- int jumpIndex = packet.readerIndex(); +- switch ( packetId ) +- { +- case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */: +- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); +- break; +- case 0x48 /* Collect Item : PacketPlayOutCollect */: +- DefinedPacket.readVarInt( packet ); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- break; +- case 0x40 /* Attach Entity : PacketPlayOutMount */: +- DefinedPacket.readVarInt( packet ); +- jumpIndex = packet.readerIndex(); +- // Fall through on purpose to int array of IDs +- case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */: +- int count = DefinedPacket.readVarInt( packet ); +- int[] ids = new int[ count ]; +- for ( int i = 0; i < count; i++ ) +- { +- ids[i] = DefinedPacket.readVarInt( packet ); +- } +- packet.readerIndex( jumpIndex ); +- packet.writerIndex( jumpIndex ); +- DefinedPacket.writeVarInt( count, packet ); +- for ( int id : ids ) +- { +- if ( id == oldId ) +- { +- id = newId; +- } else if ( id == newId ) +- { +- id = oldId; +- } +- DefinedPacket.writeVarInt( id, packet ); +- } +- break; +- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: +- DefinedPacket.readVarInt( packet ); +- DefinedPacket.readUUID( packet ); +- int type = packet.readUnsignedByte(); +- +- if ( type == 60 || type == 90 || type == 91 ) +- { +- if ( type == 60 || type == 91 ) +- { +- oldId = oldId + 1; +- newId = newId + 1; +- } +- +- packet.skipBytes( 26 ); // double, double, double, byte, byte +- int position = packet.readerIndex(); +- int readId = packet.readInt(); +- if ( readId == oldId ) +- { +- packet.setInt( position, newId ); +- } else if ( readId == newId ) +- { +- packet.setInt( position, oldId ); +- } +- } +- break; +- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- int idLength = packet.readerIndex() - readerIndex - packetIdLength; +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength + idLength ); +- DefinedPacket.writeUUID( player.getUniqueId(), packet ); +- packet.writerIndex( previous ); +- } +- break; +- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: +- int event = packet.readUnsignedByte(); +- if ( event == 1 /* End Combat*/ ) +- { +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } else if ( event == 2 /* Entity Dead */ ) +- { +- int position = packet.readerIndex(); +- rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); +- packet.readerIndex( position ); +- DefinedPacket.readVarInt( packet ); +- rewriteInt( packet, oldId, newId, packet.readerIndex() ); +- } +- break; +- case 0x39 /* EntityMetadata : PacketPlayOutEntityMetadata */: +- DefinedPacket.readVarInt( packet ); // Entity ID +- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 5 ); // fishing hook +- rewriteMetaVarInt( packet, oldId, newId, 12 ); // guardian beam +- break; +- } +- packet.readerIndex( readerIndex ); +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) +- { +- super.rewriteServerbound( packet, oldId, newId ); +- // Special cases +- int readerIndex = packet.readerIndex(); +- int packetId = DefinedPacket.readVarInt( packet ); +- int packetIdLength = packet.readerIndex() - readerIndex; +- +- if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) +- { +- UUID uuid = DefinedPacket.readUUID( packet ); +- ProxiedPlayer player; +- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) +- { +- int previous = packet.writerIndex(); +- packet.readerIndex( readerIndex ); +- packet.writerIndex( readerIndex + packetIdLength ); +- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); +- packet.writerIndex( previous ); +- } +- } +- packet.readerIndex( readerIndex ); +- } +-} +diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_Dummy.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_Dummy.java +deleted file mode 100644 +index cb81d1dd..00000000 +--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_Dummy.java ++++ /dev/null +@@ -1,30 +0,0 @@ +- +-package net.md_5.bungee.entitymap; +- +-import io.netty.buffer.ByteBuf; +-// Waterfall start +- +-public class EntityMap_Dummy extends EntityMap { +- +- public static final EntityMap_Dummy INSTANCE = new EntityMap_Dummy(); +- +- EntityMap_Dummy() { +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId) { +- } +- +- @Override +- public void rewriteServerbound(ByteBuf packet, int oldId, int newId, int protocolVersion) { +- } +- +- @Override +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId) { +- } +- +- @Override +- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) { +- } +-} +-// Waterfall end +\ No newline at end of file +diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java +index caed4384..af428090 100644 +--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java ++++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java +@@ -11,7 +11,6 @@ import lombok.Setter; + import net.md_5.bungee.BungeeCord; + import net.md_5.bungee.UserConnection; + import net.md_5.bungee.protocol.ProtocolConstants; +-import net.md_5.bungee.protocol.packet.EntityRemoveEffect; + import net.md_5.bungee.protocol.packet.PluginMessage; + + /** +@@ -113,10 +112,6 @@ public class ForgeClientHandler + } + + private void resetAllThePotions(UserConnection con) { +- // Just to be sure +- for (Map.Entry entry: con.getPotions().entries()) { +- con.unsafe().sendPacket(new EntityRemoveEffect(entry.getKey(), entry.getValue())); +- } + con.getPotions().clear(); + } + +-- +2.32.0 + diff --git a/flamecord b/flamecord new file mode 100755 index 0000000..744b8f5 --- /dev/null +++ b/flamecord @@ -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 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a1167dd --- /dev/null +++ b/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + io.github.waterfallmc + waterfall-super + dev-SNAPSHOT + pom + + Waterfall-Super + Super project for FlameCord. + https://github.com/2lstudios-mc/FlameCord + + + FlameCord-Proxy + + + + clean install + + + + UTF-8 + + diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh new file mode 100755 index 0000000..b8b42a5 --- /dev/null +++ b/scripts/applyPatches.sh @@ -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 diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..1533f78 --- /dev/null +++ b/scripts/build.sh @@ -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 diff --git a/scripts/edit.sh b/scripts/edit.sh new file mode 100755 index 0000000..cde4c61 --- /dev/null +++ b/scripts/edit.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +pushd FlameCord-Proxy +git rebase --interactive upstream/upstream +popd diff --git a/scripts/mergeUpstream.sh b/scripts/mergeUpstream.sh new file mode 100755 index 0000000..3633c92 --- /dev/null +++ b/scripts/mergeUpstream.sh @@ -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 diff --git a/scripts/rebuildPatches.sh b/scripts/rebuildPatches.sh new file mode 100755 index 0000000..901cadb --- /dev/null +++ b/scripts/rebuildPatches.sh @@ -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" +) diff --git a/scripts/upstreamCommit.sh b/scripts/upstreamCommit.sh new file mode 100755 index 0000000..4880b35 --- /dev/null +++ b/scripts/upstreamCommit.sh @@ -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 diff --git a/scripts/wigglePatch.py b/scripts/wigglePatch.py new file mode 100644 index 0000000..d2a6bb6 --- /dev/null +++ b/scripts/wigglePatch.py @@ -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)