├── .github └── workflows │ ├── build.yml │ └── pullrequest.yml ├── .gitignore ├── .gitmodules ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml └── copyright │ ├── GeyserMC.xml │ └── profiles_settings.xml ├── LICENSE ├── README.md ├── ap ├── build.gradle.kts └── src │ └── main │ ├── java │ └── org │ │ └── geysermc │ │ └── floodgate │ │ └── ap │ │ ├── AutoBindProcessor.java │ │ └── ClassProcessor.java │ └── resources │ └── META-INF │ └── services │ └── javax.annotation.processing.Processor ├── api ├── build.gradle.kts └── src │ └── main │ └── java │ └── org │ └── geysermc │ └── floodgate │ └── api │ ├── FloodgateApi.java │ ├── InstanceHolder.java │ ├── event │ ├── FloodgateEventBus.java │ ├── FloodgateSubscriber.java │ └── skin │ │ └── SkinApplyEvent.java │ ├── handshake │ ├── HandshakeData.java │ ├── HandshakeHandler.java │ └── HandshakeHandlers.java │ ├── inject │ ├── InjectorAddon.java │ └── PlatformInjector.java │ ├── link │ ├── LinkRequest.java │ ├── LinkRequestResult.java │ └── PlayerLink.java │ ├── logger │ └── FloodgateLogger.java │ ├── packet │ ├── PacketHandler.java │ └── PacketHandlers.java │ ├── player │ ├── FloodgatePlayer.java │ └── PropertyKey.java │ ├── unsafe │ └── Unsafe.java │ └── util │ └── TriFunction.java ├── build-logic ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ ├── Versions.kt │ ├── extensions.kt │ ├── floodgate.base-conventions.gradle.kts │ ├── floodgate.build-logic.gradle.kts │ ├── floodgate.database-conventions.gradle.kts │ ├── floodgate.generate-templates.gradle.kts │ ├── floodgate.publish-conventions.gradle.kts │ └── floodgate.shadow-conventions.gradle.kts ├── build.gradle.kts ├── bungee ├── build.gradle.kts └── src │ └── main │ ├── java │ └── org │ │ └── geysermc │ │ └── floodgate │ │ ├── BungeePlugin.java │ │ ├── addon │ │ └── data │ │ │ ├── BungeeDataAddon.java │ │ │ ├── BungeeProxyDataHandler.java │ │ │ └── BungeeServerDataHandler.java │ │ ├── inject │ │ └── bungee │ │ │ └── BungeeInjector.java │ │ ├── listener │ │ ├── BungeeListener.java │ │ └── BungeeListenerRegistration.java │ │ ├── module │ │ ├── BungeeAddonModule.java │ │ ├── BungeeListenerModule.java │ │ └── BungeePlatformModule.java │ │ ├── pluginmessage │ │ ├── BungeePluginMessageRegistration.java │ │ ├── BungeePluginMessageUtils.java │ │ └── BungeeSkinApplier.java │ │ └── util │ │ ├── BungeeCommandUtil.java │ │ ├── BungeePlatformUtils.java │ │ └── BungeeReflectionUtils.java │ └── resources │ └── plugin.yml ├── checkstyle.xml ├── core ├── build.gradle.kts └── src │ └── main │ ├── java │ └── org │ │ └── geysermc │ │ └── floodgate │ │ ├── FloodgatePlatform.java │ │ ├── addon │ │ ├── AddonManagerAddon.java │ │ ├── DebugAddon.java │ │ ├── PacketHandlerAddon.java │ │ ├── data │ │ │ ├── CommonDataHandler.java │ │ │ ├── HandshakeDataImpl.java │ │ │ ├── HandshakeHandlersImpl.java │ │ │ └── PacketBlocker.java │ │ ├── debug │ │ │ ├── ChannelInDebugHandler.java │ │ │ ├── ChannelOutDebugHandler.java │ │ │ └── State.java │ │ └── packethandler │ │ │ ├── ChannelInPacketHandler.java │ │ │ └── ChannelOutPacketHandler.java │ │ ├── api │ │ ├── ProxyFloodgateApi.java │ │ ├── SimpleFloodgateApi.java │ │ └── UnsafeFloodgateApi.java │ │ ├── command │ │ ├── CommonCommandMessage.java │ │ ├── LinkAccountCommand.java │ │ ├── TestCommand.java │ │ ├── UnlinkAccountCommand.java │ │ ├── WhitelistCommand.java │ │ ├── main │ │ │ ├── FirewallCheckSubcommand.java │ │ │ ├── MainCommand.java │ │ │ └── VersionSubcommand.java │ │ └── util │ │ │ ├── Permission.java │ │ │ └── PermissionDefault.java │ │ ├── config │ │ ├── ConfigLoader.java │ │ ├── FloodgateConfig.java │ │ └── ProxyFloodgateConfig.java │ │ ├── database │ │ └── config │ │ │ ├── DatabaseConfig.java │ │ │ └── DatabaseConfigLoader.java │ │ ├── event │ │ ├── EventBus.java │ │ ├── EventSubscriber.java │ │ ├── lifecycle │ │ │ ├── PostEnableEvent.java │ │ │ └── ShutdownEvent.java │ │ ├── skin │ │ │ └── SkinApplyEventImpl.java │ │ └── util │ │ │ └── ListenerAnnotationMatcher.java │ │ ├── inject │ │ └── CommonPlatformInjector.java │ │ ├── link │ │ ├── CommonPlayerLink.java │ │ ├── DisabledPlayerLink.java │ │ ├── GlobalPlayerLinking.java │ │ ├── LinkRequestImpl.java │ │ └── PlayerLinkHolder.java │ │ ├── logger │ │ └── JavaUtilFloodgateLogger.java │ │ ├── module │ │ ├── AutoBindModule.java │ │ ├── CommandModule.java │ │ ├── CommonModule.java │ │ ├── ConfigLoadedModule.java │ │ ├── PluginMessageModule.java │ │ ├── PostInitializeModule.java │ │ ├── ProxyCommonModule.java │ │ └── ServerCommonModule.java │ │ ├── news │ │ └── NewsChecker.java │ │ ├── packet │ │ └── PacketHandlersImpl.java │ │ ├── platform │ │ ├── command │ │ │ ├── CommandUtil.java │ │ │ ├── FloodgateCommand.java │ │ │ ├── FloodgateSubCommand.java │ │ │ ├── SubCommands.java │ │ │ └── TranslatableMessage.java │ │ ├── listener │ │ │ └── ListenerRegistration.java │ │ ├── pluginmessage │ │ │ └── PluginMessageUtils.java │ │ └── util │ │ │ ├── PlatformUtils.java │ │ │ └── PlayerType.java │ │ ├── player │ │ ├── FloodgateCommandPreprocessor.java │ │ ├── FloodgateHandshakeHandler.java │ │ ├── FloodgatePlayerImpl.java │ │ ├── HostnameSeparationResult.java │ │ ├── UserAudience.java │ │ └── audience │ │ │ ├── FloodgateSenderMapper.java │ │ │ ├── InvalidPlayerIdentifierException.java │ │ │ ├── PlayerAudienceArgument.java │ │ │ └── ProfileAudience.java │ │ ├── pluginmessage │ │ ├── PluginMessageChannel.java │ │ ├── PluginMessageManager.java │ │ ├── PluginMessageRegistration.java │ │ └── channel │ │ │ ├── FormChannel.java │ │ │ ├── PacketChannel.java │ │ │ ├── SkinChannel.java │ │ │ └── TransferChannel.java │ │ ├── register │ │ ├── AddonRegister.java │ │ ├── CommandRegister.java │ │ ├── ListenerRegister.java │ │ └── PluginMessageRegister.java │ │ ├── skin │ │ ├── SkinApplier.java │ │ ├── SkinDataImpl.java │ │ ├── SkinUploadManager.java │ │ └── SkinUploadSocket.java │ │ └── util │ │ ├── AutoBind.java │ │ ├── BrigadierUtils.java │ │ ├── HttpClient.java │ │ ├── InjectorHolder.java │ │ ├── LanguageManager.java │ │ ├── MessageFormatter.java │ │ ├── Metrics.java │ │ ├── MojangUtils.java │ │ ├── PostEnableMessages.java │ │ ├── ReflectionUtils.java │ │ └── Utils.java │ ├── resources │ ├── config.yml │ └── proxy-config.yml │ └── templates │ └── org │ └── geysermc │ └── floodgate │ └── util │ └── Constants.java ├── database ├── mongo │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── geysermc │ │ │ └── floodgate │ │ │ └── database │ │ │ ├── MongoDbDatabase.java │ │ │ └── config │ │ │ └── MongoConfig.java │ │ └── resources │ │ ├── init.json │ │ └── mongo.yml ├── mysql │ ├── .editorconfig │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── geysermc │ │ │ └── floodgate │ │ │ └── database │ │ │ ├── MysqlDatabase.java │ │ │ └── config │ │ │ └── MysqlConfig.java │ │ └── resources │ │ ├── init.json │ │ └── mysql.yml └── sqlite │ ├── build.gradle.kts │ └── src │ └── main │ ├── java │ └── org │ │ └── geysermc │ │ └── floodgate │ │ └── database │ │ └── SqliteDatabase.java │ └── resources │ └── init.json ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── ruleset.xml ├── settings.gradle.kts ├── spigot ├── build.gradle.kts └── src │ └── main │ ├── java │ └── org │ │ └── geysermc │ │ └── floodgate │ │ ├── SpigotPlugin.java │ │ ├── addon │ │ └── data │ │ │ ├── SpigotDataAddon.java │ │ │ └── SpigotDataHandler.java │ │ ├── inject │ │ └── spigot │ │ │ ├── CustomList.java │ │ │ └── SpigotInjector.java │ │ ├── listener │ │ ├── PaperProfileListener.java │ │ ├── SpigotListener.java │ │ └── SpigotListenerRegistration.java │ │ ├── module │ │ ├── PaperListenerModule.java │ │ ├── SpigotAddonModule.java │ │ ├── SpigotCommandModule.java │ │ ├── SpigotListenerModule.java │ │ └── SpigotPlatformModule.java │ │ ├── pluginmessage │ │ ├── SpigotPluginMessageRegistration.java │ │ ├── SpigotPluginMessageUtils.java │ │ └── SpigotSkinApplier.java │ │ └── util │ │ ├── ClassNames.java │ │ ├── ProxyUtils.java │ │ ├── SpigotCommandUtil.java │ │ ├── SpigotHandshakeHandler.java │ │ ├── SpigotPlatformUtils.java │ │ ├── SpigotProtocolSupportHandler.java │ │ ├── SpigotProtocolSupportListener.java │ │ ├── SpigotVersionSpecificMethods.java │ │ └── WhitelistUtils.java │ └── resources │ └── plugin.yml └── velocity ├── build.gradle.kts └── src └── main ├── java └── org │ └── geysermc │ └── floodgate │ ├── VelocityPlugin.java │ ├── addon │ └── data │ │ ├── VelocityDataAddon.java │ │ ├── VelocityProxyDataHandler.java │ │ └── VelocityServerDataHandler.java │ ├── inject │ └── velocity │ │ └── VelocityInjector.java │ ├── listener │ ├── VelocityListener.java │ └── VelocityListenerRegistration.java │ ├── logger │ └── Slf4jFloodgateLogger.java │ ├── module │ ├── VelocityAddonModule.java │ ├── VelocityListenerModule.java │ └── VelocityPlatformModule.java │ ├── pluginmessage │ ├── VelocityPluginMessageRegistration.java │ └── VelocityPluginMessageUtils.java │ └── util │ ├── VelocityCommandUtil.java │ ├── VelocityPlatformUtils.java │ └── VelocitySkinApplier.java └── resources └── velocity-plugin.json /.github/workflows/pullrequest.yml: -------------------------------------------------------------------------------- 1 | name: Build Pull Request 2 | 3 | on: [ pull_request ] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - name: Set Build Number 12 | run: | 13 | echo "BUILD_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV 14 | 15 | - name: Checkout repository and submodules 16 | # See https://github.com/actions/checkout/commits 17 | uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 18 | with: 19 | submodules: recursive 20 | 21 | - name: Validate Gradle Wrapper 22 | # See https://github.com/gradle/wrapper-validation-action/commits 23 | uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 24 | 25 | - name: Setup Java 26 | # See https://github.com/actions/setup-java/commits 27 | uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 28 | with: 29 | java-version: 17 30 | distribution: temurin 31 | 32 | - name: Setup Gradle 33 | # See https://github.com/gradle/actions/commits 34 | uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 35 | with: 36 | cache-read-only: true 37 | 38 | - name: Build Floodgate 39 | run: ./gradlew build 40 | 41 | - name: Archive artifacts (Floodgate Bungee) 42 | # See https://github.com/actions/upload-artifact/commits 43 | uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 44 | if: success() 45 | with: 46 | name: Floodgate Bungee 47 | path: bungee/build/libs/floodgate-bungee.jar 48 | if-no-files-found: error 49 | 50 | - name: Archive artifacts (Floodgate Spigot) 51 | uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 52 | if: success() 53 | with: 54 | name: Floodgate Spigot 55 | path: spigot/build/libs/floodgate-spigot.jar 56 | if-no-files-found: error 57 | 58 | - name: Archive artifacts (Floodgate Velocity) 59 | uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 60 | if: success() 61 | with: 62 | name: Floodgate Velocity 63 | path: velocity/build/libs/floodgate-velocity.jar 64 | if-no-files-found: error 65 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "core/src/main/resources/languages"] 2 | path = core/src/main/resources/languages 3 | url = https://github.com/GeyserMC/languages 4 | branch = floodgate -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/copyright/GeyserMC.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2022 GeyserMC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Floodgate 2 | 3 | [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) 4 | [![Build Status](https://github.com/GeyserMC/Floodgate/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/GeyserMC/Floodgate/actions/workflows/build.yml?query=branch%3Amaster) 5 | [![Discord](https://img.shields.io/discord/613163671870242838.svg?color=%237289da&label=discord)](http://discord.geysermc.org/) 6 | [![HitCount](https://hits.dwyl.com/GeyserMC/Floodgate.svg)](http://hits.dwyl.com/GeyserMC/Floodgate) 7 | 8 | [Download](https://geysermc.org/download/?project=floodgate) 9 | 10 | Hybrid mode plugin to allow for connections from [Geyser](https://github.com/GeyserMC/Geyser) to join online mode servers. 11 | 12 | Geyser is an open collaboration project by [CubeCraft Games](https://cubecraft.net). 13 | 14 | See the [Floodgate](https://geysermc.org/wiki/floodgate/) section in the GeyserMC Wiki for more info about what Floodgate is, how you setup Floodgate and known issues/caveats. Additionally, it includes a more in-depth look into how Floodgate works and the Floodgate API. 15 | -------------------------------------------------------------------------------- /ap/build.gradle.kts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeyserMC/Floodgate/0e3163c94220cdc516d1d1219557376c5216312b/ap/build.gradle.kts -------------------------------------------------------------------------------- /ap/src/main/java/org/geysermc/floodgate/ap/AutoBindProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.ap; 27 | 28 | import javax.annotation.processing.SupportedAnnotationTypes; 29 | import javax.annotation.processing.SupportedSourceVersion; 30 | import javax.lang.model.SourceVersion; 31 | 32 | @SupportedAnnotationTypes("*") 33 | @SupportedSourceVersion(SourceVersion.RELEASE_8) 34 | public class AutoBindProcessor extends ClassProcessor { 35 | public AutoBindProcessor() { 36 | super("org.geysermc.floodgate.util.AutoBind"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ap/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | org.geysermc.floodgate.ap.AutoBindProcessor -------------------------------------------------------------------------------- /api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar 2 | 3 | dependencies { 4 | api("org.geysermc.geyser", "common", Versions.geyserVersion) 5 | api("org.geysermc.cumulus", "cumulus", Versions.cumulusVersion) 6 | api("org.geysermc.event", "events", Versions.eventsVersion) 7 | 8 | compileOnly("io.netty", "netty-transport", Versions.nettyVersion) 9 | } 10 | 11 | tasks { 12 | named("jar") { 13 | archiveClassifier.set("") 14 | } 15 | named("shadowJar") { 16 | archiveClassifier.set("shaded") 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /api/src/main/java/org/geysermc/floodgate/api/event/FloodgateEventBus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api.event; 27 | 28 | import org.geysermc.event.bus.EventBus; 29 | 30 | public interface FloodgateEventBus extends EventBus> { 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/org/geysermc/floodgate/api/event/FloodgateSubscriber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api.event; 27 | 28 | import org.geysermc.event.subscribe.Subscriber; 29 | 30 | public interface FloodgateSubscriber extends Subscriber { 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/org/geysermc/floodgate/api/event/skin/SkinApplyEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api.event.skin; 27 | 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | import org.checkerframework.checker.nullness.qual.Nullable; 30 | import org.checkerframework.common.returnsreceiver.qual.This; 31 | import org.geysermc.event.Cancellable; 32 | import org.geysermc.floodgate.api.player.FloodgatePlayer; 33 | 34 | /** 35 | * An event that's fired when Floodgate receives a player skin. The event will be cancelled by 36 | * default when hasSkin is true, as Floodgate by default only applies skins when the player has no 37 | * skin applied yet. 38 | */ 39 | public interface SkinApplyEvent extends Cancellable { 40 | /** 41 | * Returns the player that will receive the skin. 42 | */ 43 | @NonNull FloodgatePlayer player(); 44 | 45 | /** 46 | * Returns the skin texture currently applied to the player. 47 | */ 48 | @Nullable SkinData currentSkin(); 49 | 50 | /** 51 | * Returns the skin texture to be applied to the player. 52 | */ 53 | @NonNull SkinData newSkin(); 54 | 55 | /** 56 | * Sets the skin texture to be applied to the player 57 | * 58 | * @param skinData the skin to apply 59 | * @return this 60 | */ 61 | @This SkinApplyEvent newSkin(@NonNull SkinData skinData); 62 | 63 | interface SkinData { 64 | /** 65 | * Returns the value of the skin texture. 66 | */ 67 | @NonNull String value(); 68 | 69 | /** 70 | * Returns the signature of the skin texture. 71 | */ 72 | @NonNull String signature(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /api/src/main/java/org/geysermc/floodgate/api/handshake/HandshakeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api.handshake; 27 | 28 | /** 29 | * @deprecated Handshake handlers will be removed with the launch of Floodgate 3.0. Please look at 30 | * #536 for additional context. 31 | */ 32 | @Deprecated 33 | @FunctionalInterface 34 | public interface HandshakeHandler { 35 | /** 36 | * Method that will be called during the time that Floodgate handles the handshake. 37 | * 38 | * @param data the data usable during the handshake 39 | */ 40 | void handle(HandshakeData data); 41 | } 42 | -------------------------------------------------------------------------------- /api/src/main/java/org/geysermc/floodgate/api/handshake/HandshakeHandlers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api.handshake; 27 | 28 | /** 29 | * @deprecated Handshake handlers will be removed with the launch of Floodgate 3.0. Please look at 30 | * #536 for additional context. 31 | */ 32 | @Deprecated 33 | public interface HandshakeHandlers { 34 | /** 35 | * Register a custom handshake handler. This can be used to check and edit the player during the 36 | * handshake handling. 37 | * 38 | * @param handshakeHandler the handshake handler to register 39 | * @return a random (unique) int to identify this handshake handler or -1 if null 40 | */ 41 | int addHandshakeHandler(HandshakeHandler handshakeHandler); 42 | 43 | /** 44 | * Removes a custom handshake handler by id. 45 | * 46 | * @param handshakeHandlerId the id of the handshake handler to remove 47 | */ 48 | void removeHandshakeHandler(int handshakeHandlerId); 49 | 50 | /** 51 | * Remove a custom handshake handler by instance. 52 | * 53 | * @param handshakeHandler the instance to remove 54 | */ 55 | void removeHandshakeHandler(Class handshakeHandler); 56 | } 57 | -------------------------------------------------------------------------------- /api/src/main/java/org/geysermc/floodgate/api/link/LinkRequestResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api.link; 27 | 28 | /** 29 | * This enum has all the available result types of both creating a player link request and 30 | * validating it. 31 | */ 32 | public enum LinkRequestResult { 33 | /** 34 | * An unknown error encountered while creating / verifying the link request. 35 | */ 36 | UNKNOWN_ERROR, 37 | /** 38 | * The specified bedrock username is already linked to a Java account. 39 | */ 40 | ALREADY_LINKED, 41 | /** 42 | * The Bedrock player verified the request too late. The request has been expired. 43 | */ 44 | REQUEST_EXPIRED, 45 | /** 46 | * The Java player hasn't requested a link to this Bedrock account. 47 | */ 48 | NO_LINK_REQUESTED, 49 | /** 50 | * The entered code is invalid. 51 | */ 52 | INVALID_CODE, 53 | /** 54 | * The link request has been verified successfully! 55 | */ 56 | LINK_COMPLETED 57 | } 58 | -------------------------------------------------------------------------------- /api/src/main/java/org/geysermc/floodgate/api/packet/PacketHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api.packet; 27 | 28 | import io.netty.channel.ChannelHandlerContext; 29 | 30 | /** 31 | * @deprecated Packet handlers will be removed with the launch of Floodgate 3.0. Please look at 32 | * #536 for additional context. 33 | */ 34 | @Deprecated 35 | public interface PacketHandler { 36 | /** 37 | * Called when a registered packet has been seen. 38 | * 39 | * @param ctx the channel handler context of the connection 40 | * @param packet the packet instance 41 | * @param serverbound if the packet is serverbound 42 | * @return the packet it should forward. Can be null or a different packet / instance 43 | */ 44 | Object handle(ChannelHandlerContext ctx, Object packet, boolean serverbound); 45 | } 46 | -------------------------------------------------------------------------------- /api/src/main/java/org/geysermc/floodgate/api/unsafe/Unsafe.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api.unsafe; 27 | 28 | import java.util.UUID; 29 | import org.geysermc.floodgate.api.player.FloodgatePlayer; 30 | 31 | public interface Unsafe { 32 | /** 33 | * Send a raw Bedrock packet to the given online Bedrock player. 34 | * 35 | * @param bedrockPlayer the uuid of the online Bedrock player 36 | * @param packetId the id of the packet to send 37 | * @param packetData the raw packet data 38 | */ 39 | void sendPacket(UUID bedrockPlayer, int packetId, byte[] packetData); 40 | 41 | /** 42 | * Send a raw Bedrock packet to the given online Bedrock player. 43 | * 44 | * @param player the Bedrock player to send the packet to 45 | * @param packetId the id of the packet to send 46 | * @param packetData the raw packet data 47 | */ 48 | default void sendPacket(FloodgatePlayer player, int packetId, byte[] packetData) { 49 | sendPacket(player.getCorrectUniqueId(), packetId, packetData); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /build-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | plugins { 4 | `kotlin-dsl` 5 | } 6 | 7 | repositories { 8 | gradlePluginPortal() 9 | } 10 | 11 | dependencies { 12 | implementation("net.kyori", "indra-common", "3.0.1") 13 | implementation("net.kyori", "indra-git", "3.0.1") 14 | implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.1") 15 | implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext", "gradle-idea-ext", "1.1.7") 16 | } 17 | 18 | tasks.withType { 19 | kotlinOptions { 20 | jvmTarget = "1.8" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "build-logic" -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/Versions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | object Versions { 27 | const val geyserVersion = "2.2.1-SNAPSHOT" 28 | const val cumulusVersion = "1.1.2" 29 | const val eventsVersion = "1.1-SNAPSHOT" 30 | const val configUtilsVersion = "1.0-SNAPSHOT" 31 | const val spigotVersion = "1.19.4-R0.1-SNAPSHOT" 32 | const val fastutilVersion = "8.5.3" 33 | const val guiceVersion = "6.0.0" 34 | const val nettyVersion = "4.1.49.Final" 35 | const val snakeyamlVersion = "1.28" 36 | const val cloudVersion = "2.0.0-SNAPSHOT" // for cloud-minecraft 37 | const val cloudCore = "2.0.0-rc.1" 38 | const val bstatsVersion = "3.0.2" 39 | 40 | const val javaWebsocketVersion = "1.5.2" 41 | 42 | const val checkerQual = "3.19.0" 43 | } 44 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | // id("net.ltgt.errorprone") 4 | id("net.kyori.indra") 5 | id("net.kyori.indra.git") 6 | } 7 | 8 | dependencies { 9 | compileOnly("org.checkerframework", "checker-qual", Versions.checkerQual) 10 | } 11 | 12 | indra { 13 | github("GeyserMC", "Floodgate") { 14 | ci(true) 15 | issues(true) 16 | scm(true) 17 | } 18 | mitLicense() 19 | 20 | javaVersions { 21 | // without toolchain & strictVersion sun.misc.Unsafe won't be found 22 | minimumToolchain(8) 23 | strictVersions(true) 24 | } 25 | } 26 | 27 | tasks { 28 | processResources { 29 | filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) { 30 | expand( 31 | "id" to "floodgate", 32 | "name" to "floodgate", 33 | "version" to fullVersion(), 34 | "description" to project.description, 35 | "url" to "https://geysermc.org", 36 | "author" to "GeyserMC" 37 | ) 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/floodgate.build-logic.gradle.kts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeyserMC/Floodgate/0e3163c94220cdc516d1d1219557376c5216312b/build-logic/src/main/kotlin/floodgate.build-logic.gradle.kts -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/floodgate.database-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("floodgate.shadow-conventions") 3 | } 4 | 5 | tasks { 6 | shadowJar { 7 | archiveBaseName.set(archiveBaseName.get() + "-database") 8 | } 9 | } -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/floodgate.publish-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("floodgate.shadow-conventions") 3 | id("net.kyori.indra.publishing") 4 | } 5 | 6 | indra { 7 | configurePublications { 8 | if (shouldAddBranchName()) { 9 | version = versionWithBranchName() 10 | } 11 | } 12 | 13 | publishSnapshotsTo("geysermc", "https://repo.opencollab.dev/maven-snapshots") 14 | publishReleasesTo("geysermc", "https://repo.opencollab.dev/maven-releases") 15 | } 16 | 17 | publishing { 18 | // skip shadow jar from publishing. Workaround for https://github.com/johnrengelman/shadow/issues/651 19 | val javaComponent = project.components["java"] as AdhocComponentWithVariants 20 | javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { skip() } 21 | } -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/floodgate.shadow-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar 2 | 3 | plugins { 4 | id("floodgate.base-conventions") 5 | id("com.github.johnrengelman.shadow") 6 | } 7 | 8 | tasks { 9 | named("jar") { 10 | archiveClassifier.set("unshaded") 11 | from(project.rootProject.file("LICENSE")) 12 | } 13 | val shadowJar = named("shadowJar") { 14 | archiveBaseName.set("floodgate-${project.name}") 15 | archiveVersion.set("") 16 | archiveClassifier.set("") 17 | 18 | val sJar: ShadowJar = this 19 | 20 | doFirst { 21 | providedDependencies[project.name]?.forEach { (name, notation) -> 22 | sJar.dependencies { 23 | println("Excluding $name from ${project.name}") 24 | exclude(dependency(notation)) 25 | } 26 | } 27 | 28 | // relocations made in included project dependencies are for whatever reason not 29 | // forwarded to the project implementing the dependency. 30 | // (e.g. a relocation in `core` will relocate for core. But when you include `core` in 31 | // for example Velocity, the relocation will be gone for Velocity) 32 | addRelocations(project, sJar) 33 | } 34 | 35 | val destinationDir = System.getenv("DESTINATION_DIRECTORY"); 36 | if (destinationDir != null) { 37 | destinationDirectory.set(file(destinationDir)) 38 | } 39 | } 40 | named("build") { 41 | dependsOn(shadowJar) 42 | } 43 | } 44 | 45 | fun addRelocations(project: Project, shadowJar: ShadowJar) { 46 | callAddRelocations(project.configurations.api.get(), shadowJar) 47 | callAddRelocations(project.configurations.implementation.get(), shadowJar) 48 | 49 | relocatedPackages[project.name]?.forEach { pattern -> 50 | println("Relocating $pattern for ${shadowJar.project.name}") 51 | shadowJar.relocate(pattern, "org.geysermc.floodgate.shadow.$pattern") 52 | } 53 | } 54 | 55 | fun callAddRelocations(configuration: Configuration, shadowJar: ShadowJar) = 56 | configuration.dependencies.forEach { 57 | if (it is ProjectDependency) 58 | addRelocations(it.dependencyProject, shadowJar) 59 | } -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | id("floodgate.build-logic") 4 | id("io.freefair.lombok") version "6.3.0" apply false 5 | } 6 | 7 | allprojects { 8 | group = "org.geysermc.floodgate" 9 | version = property("version")!! 10 | description = "Allows Bedrock players to join Java edition servers while keeping the server in online mode" 11 | } 12 | 13 | val deployProjects = setOf( 14 | projects.api, 15 | // for future Floodgate integration + Fabric 16 | projects.core, 17 | projects.bungee, 18 | projects.spigot, 19 | projects.velocity 20 | ).map { it.dependencyProject } 21 | 22 | //todo re-add checkstyle when we switch back to 2 space indention 23 | // and take a look again at spotbugs someday 24 | 25 | subprojects { 26 | apply { 27 | plugin("java-library") 28 | plugin("io.freefair.lombok") 29 | plugin("floodgate.build-logic") 30 | } 31 | 32 | val relativePath = projectDir.relativeTo(rootProject.projectDir).path 33 | 34 | if (relativePath.startsWith("database" + File.separator)) { 35 | group = rootProject.group as String + ".database" 36 | plugins.apply("floodgate.database-conventions") 37 | } 38 | 39 | when (this) { 40 | in deployProjects -> plugins.apply("floodgate.publish-conventions") 41 | else -> plugins.apply("floodgate.base-conventions") 42 | } 43 | } -------------------------------------------------------------------------------- /bungee/build.gradle.kts: -------------------------------------------------------------------------------- 1 | var bungeeVersion = "1.21-R0.1-SNAPSHOT" 2 | var gsonVersion = "2.8.0" 3 | var guavaVersion = "21.0" 4 | 5 | dependencies { 6 | api(projects.core) 7 | implementation("org.incendo", "cloud-bungee", Versions.cloudVersion) 8 | } 9 | 10 | relocate("com.google.inject") 11 | relocate("net.kyori") 12 | relocate("org.incendo.cloud") 13 | // used in cloud 14 | relocate("io.leangen.geantyref") 15 | // since 1.20 16 | relocate("org.yaml") 17 | 18 | // these dependencies are already present on the platform 19 | provided("net.md-5", "bungeecord-proxy", bungeeVersion) 20 | provided("com.google.code.gson", "gson", gsonVersion) 21 | provided("com.google.guava", "guava", guavaVersion) 22 | -------------------------------------------------------------------------------- /bungee/src/main/java/org/geysermc/floodgate/listener/BungeeListenerRegistration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.listener; 27 | 28 | import com.google.inject.Inject; 29 | import lombok.RequiredArgsConstructor; 30 | import net.md_5.bungee.api.ProxyServer; 31 | import net.md_5.bungee.api.plugin.Listener; 32 | import org.geysermc.floodgate.BungeePlugin; 33 | import org.geysermc.floodgate.platform.listener.ListenerRegistration; 34 | 35 | @RequiredArgsConstructor(onConstructor = @__(@Inject)) 36 | public final class BungeeListenerRegistration implements ListenerRegistration { 37 | private final BungeePlugin plugin; 38 | 39 | @Override 40 | public void register(Listener listener) { 41 | ProxyServer.getInstance().getPluginManager().registerListener(plugin, listener); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bungee/src/main/java/org/geysermc/floodgate/module/BungeeAddonModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.multibindings.ProvidesIntoSet; 31 | import org.geysermc.floodgate.addon.AddonManagerAddon; 32 | import org.geysermc.floodgate.addon.DebugAddon; 33 | import org.geysermc.floodgate.addon.PacketHandlerAddon; 34 | import org.geysermc.floodgate.addon.data.BungeeDataAddon; 35 | import org.geysermc.floodgate.api.inject.InjectorAddon; 36 | import org.geysermc.floodgate.register.AddonRegister; 37 | 38 | public final class BungeeAddonModule extends AbstractModule { 39 | @Override 40 | protected void configure() { 41 | bind(AddonRegister.class).asEagerSingleton(); 42 | } 43 | 44 | @Singleton 45 | @ProvidesIntoSet 46 | public InjectorAddon managerAddon() { 47 | return new AddonManagerAddon(); 48 | } 49 | 50 | @Singleton 51 | @ProvidesIntoSet 52 | public InjectorAddon dataAddon() { 53 | return new BungeeDataAddon(); 54 | } 55 | 56 | @Singleton 57 | @ProvidesIntoSet 58 | public InjectorAddon debugAddon() { 59 | return new DebugAddon(); 60 | } 61 | 62 | @Singleton 63 | @ProvidesIntoSet 64 | public InjectorAddon packetHandlerAddon() { 65 | return new PacketHandlerAddon(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /bungee/src/main/java/org/geysermc/floodgate/module/BungeeListenerModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.TypeLiteral; 31 | import com.google.inject.multibindings.ProvidesIntoSet; 32 | import net.md_5.bungee.api.plugin.Listener; 33 | import org.geysermc.floodgate.listener.BungeeListener; 34 | import org.geysermc.floodgate.platform.pluginmessage.PluginMessageUtils; 35 | import org.geysermc.floodgate.register.ListenerRegister; 36 | 37 | public final class BungeeListenerModule extends AbstractModule { 38 | @Override 39 | protected void configure() { 40 | bind(new TypeLiteral>() {}).asEagerSingleton(); 41 | } 42 | 43 | @Singleton 44 | @ProvidesIntoSet 45 | public Listener bungeeListener() { 46 | return new BungeeListener(); 47 | } 48 | 49 | @Singleton 50 | @ProvidesIntoSet 51 | public Listener pluginMessageListener(PluginMessageUtils handler) { 52 | return (Listener) handler; // Plugin message handler is also the listener 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /bungee/src/main/java/org/geysermc/floodgate/pluginmessage/BungeePluginMessageRegistration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.pluginmessage; 27 | 28 | import net.md_5.bungee.api.ProxyServer; 29 | 30 | public class BungeePluginMessageRegistration implements PluginMessageRegistration { 31 | @Override 32 | public void register(PluginMessageChannel channel) { 33 | ProxyServer.getInstance().registerChannel(channel.getIdentifier()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bungee/src/main/java/org/geysermc/floodgate/util/BungeePlatformUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.util; 27 | 28 | import java.lang.reflect.Field; 29 | import java.util.List; 30 | import net.md_5.bungee.api.ProxyServer; 31 | import net.md_5.bungee.protocol.ProtocolConstants; 32 | import org.geysermc.floodgate.platform.util.PlatformUtils; 33 | 34 | @SuppressWarnings("ConstantConditions") 35 | public final class BungeePlatformUtils extends PlatformUtils { 36 | private static final String LATEST_SUPPORTED_VERSION; 37 | private final ProxyServer proxyServer = ProxyServer.getInstance(); 38 | 39 | static { 40 | int protocolNumber = -1; 41 | String versionName = ""; 42 | 43 | for (Field field : ProtocolConstants.class.getFields()) { 44 | if (!field.getName().startsWith("MINECRAFT_")) { 45 | continue; 46 | } 47 | 48 | int fieldValue = ReflectionUtils.castedStaticValue(field); 49 | if (fieldValue > protocolNumber) { 50 | protocolNumber = fieldValue; 51 | versionName = field.getName().substring(10).replace('_', '.'); 52 | } 53 | } 54 | 55 | if (protocolNumber == -1) { 56 | List versions = ProtocolConstants.SUPPORTED_VERSIONS; 57 | versionName = versions.get(versions.size() - 1); 58 | } 59 | LATEST_SUPPORTED_VERSION = versionName; 60 | } 61 | 62 | @Override 63 | public AuthType authType() { 64 | return proxyServer.getConfig().isOnlineMode() ? AuthType.ONLINE : AuthType.OFFLINE; 65 | } 66 | 67 | @Override 68 | public String minecraftVersion() { 69 | return LATEST_SUPPORTED_VERSION; 70 | } 71 | 72 | @Override 73 | public String serverImplementationName() { 74 | return proxyServer.getName(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /bungee/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: ${name} 2 | description: ${description} 3 | version: ${version} 4 | author: ${author} 5 | main: org.geysermc.floodgate.BungeePlugin -------------------------------------------------------------------------------- /core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar 2 | 3 | plugins { 4 | id("floodgate.generate-templates") 5 | } 6 | 7 | dependencies { 8 | api(projects.api) 9 | api("org.geysermc.configutils", "configutils", Versions.configUtilsVersion) 10 | 11 | compileOnly(projects.ap) 12 | annotationProcessor(projects.ap) 13 | 14 | api("com.google.inject", "guice", Versions.guiceVersion) 15 | api("com.nukkitx.fastutil", "fastutil-short-object-maps", Versions.fastutilVersion) 16 | api("com.nukkitx.fastutil", "fastutil-int-object-maps", Versions.fastutilVersion) 17 | api("org.java-websocket", "Java-WebSocket", Versions.javaWebsocketVersion) 18 | api("org.incendo", "cloud-core", Versions.cloudCore) 19 | api("org.bstats", "bstats-base", Versions.bstatsVersion) 20 | } 21 | 22 | // present on all platforms 23 | provided("io.netty", "netty-transport", Versions.nettyVersion) 24 | provided("io.netty", "netty-codec", Versions.nettyVersion) 25 | 26 | relocate("org.bstats") 27 | 28 | tasks { 29 | templateSources { 30 | replaceToken("floodgateVersion", fullVersion()) 31 | replaceToken("branch", branchName()) 32 | replaceToken("buildNumber", buildNumber()) 33 | } 34 | named("jar") { 35 | archiveClassifier.set("") 36 | } 37 | named("shadowJar") { 38 | archiveClassifier.set("shaded") 39 | } 40 | } -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/addon/AddonManagerAddon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.addon; 27 | 28 | import com.google.inject.Inject; 29 | import io.netty.channel.Channel; 30 | import org.geysermc.floodgate.api.inject.InjectorAddon; 31 | import org.geysermc.floodgate.inject.CommonPlatformInjector; 32 | 33 | public final class AddonManagerAddon implements InjectorAddon { 34 | @Inject private CommonPlatformInjector injector; 35 | 36 | @Override 37 | public void onInject(Channel channel, boolean toServer) { 38 | channel.closeFuture().addListener(listener -> { 39 | injector.channelClosedCall(channel); 40 | injector.removeInjectedClient(channel); 41 | }); 42 | } 43 | 44 | @Override 45 | public void onRemoveInject(Channel channel) { 46 | } 47 | 48 | @Override 49 | public boolean shouldInject() { 50 | return true; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/addon/debug/State.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.addon.debug; 27 | 28 | public enum State { 29 | HANDSHAKE, STATUS, LOGIN, PLAY; 30 | 31 | private static final State[] VALUES = values(); 32 | 33 | public static State getById(int id) { 34 | return id < VALUES.length ? VALUES[id] : null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/addon/packethandler/ChannelInPacketHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.addon.packethandler; 27 | 28 | import io.netty.channel.ChannelHandlerContext; 29 | import io.netty.channel.SimpleChannelInboundHandler; 30 | import org.geysermc.floodgate.api.util.TriFunction; 31 | import org.geysermc.floodgate.packet.PacketHandlersImpl; 32 | 33 | public class ChannelInPacketHandler extends SimpleChannelInboundHandler { 34 | private final PacketHandlersImpl packetHandlers; 35 | private final boolean toServer; 36 | 37 | public ChannelInPacketHandler(PacketHandlersImpl packetHandlers, boolean toServer) { 38 | this.packetHandlers = packetHandlers; 39 | this.toServer = toServer; 40 | } 41 | 42 | @Override 43 | protected void channelRead0(ChannelHandlerContext ctx, Object msg) { 44 | Object packet = msg; 45 | for (TriFunction consumer : 46 | packetHandlers.getPacketHandlers(msg.getClass())) { 47 | 48 | Object res = consumer.apply(ctx, msg, toServer); 49 | if (!res.equals(msg)) { 50 | packet = res; 51 | } 52 | } 53 | 54 | ctx.fireChannelRead(packet); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/addon/packethandler/ChannelOutPacketHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.addon.packethandler; 27 | 28 | import io.netty.channel.ChannelHandlerContext; 29 | import io.netty.handler.codec.MessageToMessageEncoder; 30 | import java.util.List; 31 | import org.geysermc.floodgate.api.util.TriFunction; 32 | import org.geysermc.floodgate.packet.PacketHandlersImpl; 33 | 34 | public class ChannelOutPacketHandler extends MessageToMessageEncoder { 35 | private final PacketHandlersImpl packetHandlers; 36 | private final boolean toServer; 37 | 38 | public ChannelOutPacketHandler(PacketHandlersImpl packetHandlers, boolean toServer) { 39 | this.packetHandlers = packetHandlers; 40 | this.toServer = toServer; 41 | } 42 | 43 | @Override 44 | protected void encode(ChannelHandlerContext ctx, Object msg, List out) { 45 | Object packet = msg; 46 | for (TriFunction consumer : 47 | packetHandlers.getPacketHandlers(msg.getClass())) { 48 | 49 | Object res = consumer.apply(ctx, msg, toServer); 50 | if (!res.equals(msg)) { 51 | packet = res; 52 | } 53 | } 54 | 55 | out.add(packet); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/api/ProxyFloodgateApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api; 27 | 28 | import com.google.inject.Inject; 29 | import java.nio.charset.StandardCharsets; 30 | import org.geysermc.floodgate.crypto.FloodgateCipher; 31 | import org.geysermc.floodgate.util.BedrockData; 32 | 33 | public final class ProxyFloodgateApi extends SimpleFloodgateApi { 34 | @Inject 35 | private FloodgateCipher cipher; 36 | 37 | public byte[] createEncryptedData(BedrockData bedrockData) { 38 | try { 39 | return cipher.encryptFromString(bedrockData.toString()); 40 | } catch (Exception exception) { 41 | throw new IllegalStateException("We failed to create the encrypted data, " + 42 | "but creating encrypted data is mandatory!", exception); 43 | } 44 | } 45 | 46 | public String createEncryptedDataString(BedrockData bedrockData) { 47 | return new String(createEncryptedData(bedrockData), StandardCharsets.UTF_8); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/api/UnsafeFloodgateApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.api; 27 | 28 | import java.util.UUID; 29 | import org.geysermc.floodgate.api.unsafe.Unsafe; 30 | import org.geysermc.floodgate.pluginmessage.PluginMessageManager; 31 | import org.geysermc.floodgate.pluginmessage.channel.PacketChannel; 32 | 33 | public final class UnsafeFloodgateApi implements Unsafe { 34 | private final PacketChannel packetChannel; 35 | 36 | UnsafeFloodgateApi(PluginMessageManager pluginMessageManager) { 37 | StackTraceElement element = Thread.currentThread().getStackTrace()[2]; 38 | if (!SimpleFloodgateApi.class.getName().equals(element.getClassName())) { 39 | throw new IllegalStateException("Use the Floodgate api to get an instance"); 40 | } 41 | 42 | packetChannel = pluginMessageManager.getChannel(PacketChannel.class); 43 | } 44 | 45 | @Override 46 | public void sendPacket(UUID bedrockPlayer, int packetId, byte[] packetData) { 47 | byte[] fullData = new byte[packetData.length + 1]; 48 | fullData[0] = (byte) packetId; 49 | System.arraycopy(packetData, 0, fullData, 1, packetData.length); 50 | 51 | packetChannel.sendPacket(bedrockPlayer, fullData, this); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/command/CommonCommandMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.command; 27 | 28 | import lombok.Getter; 29 | import org.geysermc.floodgate.platform.command.TranslatableMessage; 30 | 31 | /** 32 | * Messages (or part of messages) that are used in two or more commands and thus are 'commonly 33 | * used' 34 | */ 35 | @Getter 36 | public enum CommonCommandMessage implements TranslatableMessage { 37 | LINKING_DISABLED("floodgate.commands.linking_disabled"), 38 | NOT_A_PLAYER("floodgate.commands.not_a_player"), 39 | CHECK_CONSOLE("floodgate.commands.check_console"), 40 | IS_LINKED_ERROR("floodgate.commands.is_linked_error"), 41 | LOCAL_LINKING_NOTICE("floodgate.commands.local_linking_notice"), 42 | GLOBAL_LINKING_NOTICE("floodgate.commands.global_linking_notice"); 43 | 44 | private final String rawMessage; 45 | private final String[] translateParts; 46 | 47 | CommonCommandMessage(String rawMessage) { 48 | this.rawMessage = rawMessage; 49 | this.translateParts = rawMessage.split(" "); 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return getRawMessage(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/command/TestCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.command; 27 | 28 | import org.geysermc.floodgate.api.FloodgateApi; 29 | import org.geysermc.floodgate.config.FloodgateConfig; 30 | import org.geysermc.floodgate.platform.command.FloodgateCommand; 31 | import org.geysermc.floodgate.player.UserAudience; 32 | import org.geysermc.floodgate.util.Constants; 33 | import org.incendo.cloud.Command; 34 | import org.incendo.cloud.CommandManager; 35 | import org.incendo.cloud.context.CommandContext; 36 | 37 | public class TestCommand implements FloodgateCommand { 38 | @Override 39 | public Command buildCommand(CommandManager commandManager) { 40 | return commandManager.commandBuilder("floodgate-test") 41 | .senderType(UserAudience.class) 42 | .handler(this::execute) 43 | .build(); 44 | } 45 | 46 | public void execute(CommandContext context) { 47 | int players = FloodgateApi.getInstance().getPlayers().size(); 48 | context.sender().sendMessage(String.valueOf(players)); 49 | } 50 | 51 | @Override 52 | public boolean shouldRegister(FloodgateConfig config) { 53 | return Constants.DEBUG_MODE; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/command/util/Permission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.command.util; 27 | 28 | import static org.geysermc.floodgate.command.util.PermissionDefault.OP; 29 | import static org.geysermc.floodgate.command.util.PermissionDefault.TRUE; 30 | 31 | public enum Permission { 32 | COMMAND_MAIN("floodgate.command.floodgate", TRUE), 33 | COMMAND_MAIN_FIREWALL(COMMAND_MAIN, "firewall", OP), 34 | COMMAND_MAIN_VERSION(COMMAND_MAIN, "version", OP), 35 | COMMAND_LINK("floodgate.command.linkaccount", TRUE), 36 | COMMAND_UNLINK("floodgate.command.unlinkaccount", TRUE), 37 | COMMAND_WHITELIST("floodgate.command.fwhitelist", OP), 38 | 39 | NEWS_RECEIVE("floodgate.news.receive", OP); 40 | 41 | private final String permission; 42 | private final PermissionDefault defaultValue; 43 | 44 | Permission(String permission, PermissionDefault defaultValue) { 45 | this.permission = permission; 46 | this.defaultValue = defaultValue; 47 | } 48 | 49 | Permission(Permission parent, String child, PermissionDefault defaultValue) { 50 | this(parent.get() + "." + child, defaultValue); 51 | } 52 | 53 | public String get() { 54 | return permission; 55 | } 56 | 57 | public PermissionDefault defaultValue() { 58 | return defaultValue; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/command/util/PermissionDefault.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.command.util; 27 | 28 | public enum PermissionDefault { 29 | TRUE, FALSE, OP, NOT_OP 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/config/ProxyFloodgateConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.config; 27 | 28 | import lombok.Getter; 29 | 30 | /** 31 | * The Floodgate configuration used by proxy platforms, currently Velocity and Bungeecord. 32 | */ 33 | @Getter 34 | public final class ProxyFloodgateConfig extends FloodgateConfig { 35 | private boolean sendFloodgateData; 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/database/config/DatabaseConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.database.config; 27 | 28 | /** 29 | * Base class for every database related configuration. 30 | */ 31 | public interface DatabaseConfig { 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/event/EventBus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.event; 27 | 28 | import com.google.inject.Singleton; 29 | import java.util.function.BiConsumer; 30 | import java.util.function.Consumer; 31 | import org.checkerframework.checker.nullness.qual.NonNull; 32 | import org.geysermc.event.PostOrder; 33 | import org.geysermc.event.bus.impl.EventBusImpl; 34 | import org.geysermc.event.subscribe.Subscribe; 35 | import org.geysermc.event.subscribe.Subscriber; 36 | import org.geysermc.floodgate.api.event.FloodgateEventBus; 37 | import org.geysermc.floodgate.api.event.FloodgateSubscriber; 38 | 39 | @Singleton 40 | @SuppressWarnings("unchecked") 41 | public final class EventBus extends EventBusImpl> 42 | implements FloodgateEventBus { 43 | @Override 44 | protected > B makeSubscription( 45 | @NonNull Class eventClass, 46 | @NonNull Subscribe subscribe, 47 | @NonNull H listener, 48 | @NonNull BiConsumer handler 49 | ) { 50 | return (B) new EventSubscriber<>( 51 | eventClass, subscribe.postOrder(), subscribe.ignoreCancelled(), listener, handler 52 | ); 53 | } 54 | 55 | @Override 56 | protected > B makeSubscription( 57 | @NonNull Class eventClass, 58 | @NonNull Consumer handler, 59 | @NonNull PostOrder postOrder 60 | ) { 61 | return (B) new EventSubscriber<>(eventClass, handler, postOrder); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/event/EventSubscriber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.event; 27 | 28 | import java.util.function.BiConsumer; 29 | import java.util.function.Consumer; 30 | import org.checkerframework.checker.nullness.qual.NonNull; 31 | import org.geysermc.event.PostOrder; 32 | import org.geysermc.event.subscribe.impl.SubscriberImpl; 33 | import org.geysermc.floodgate.api.event.FloodgateSubscriber; 34 | 35 | public final class EventSubscriber extends SubscriberImpl implements FloodgateSubscriber { 36 | EventSubscriber( 37 | @NonNull Class eventClass, 38 | @NonNull Consumer handler, 39 | @NonNull PostOrder postOrder 40 | ) { 41 | super(eventClass, handler, postOrder); 42 | } 43 | 44 | EventSubscriber( 45 | Class eventClass, 46 | PostOrder postOrder, 47 | boolean ignoreCancelled, 48 | H handlerInstance, 49 | BiConsumer handler 50 | ) { 51 | super(eventClass, postOrder, ignoreCancelled, handlerInstance, handler); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/event/lifecycle/PostEnableEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.event.lifecycle; 27 | 28 | public class PostEnableEvent { 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/event/lifecycle/ShutdownEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.event.lifecycle; 27 | 28 | public class ShutdownEvent { 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/event/skin/SkinApplyEventImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.event.skin; 27 | 28 | import java.util.Objects; 29 | import org.checkerframework.checker.nullness.qual.NonNull; 30 | import org.checkerframework.checker.nullness.qual.Nullable; 31 | import org.geysermc.event.util.AbstractCancellable; 32 | import org.geysermc.floodgate.api.event.skin.SkinApplyEvent; 33 | import org.geysermc.floodgate.api.player.FloodgatePlayer; 34 | 35 | public class SkinApplyEventImpl extends AbstractCancellable implements SkinApplyEvent { 36 | private final FloodgatePlayer player; 37 | private final SkinData currentSkin; 38 | private SkinData newSkin; 39 | 40 | public SkinApplyEventImpl( 41 | @NonNull FloodgatePlayer player, 42 | @Nullable SkinData currentSkin, 43 | @NonNull SkinData newSkin 44 | ) { 45 | this.player = Objects.requireNonNull(player); 46 | this.currentSkin = currentSkin; 47 | this.newSkin = Objects.requireNonNull(newSkin); 48 | } 49 | 50 | @Override 51 | public @NonNull FloodgatePlayer player() { 52 | return player; 53 | } 54 | 55 | public @Nullable SkinData currentSkin() { 56 | return currentSkin; 57 | } 58 | 59 | public @NonNull SkinData newSkin() { 60 | return newSkin; 61 | } 62 | 63 | public SkinApplyEventImpl newSkin(@NonNull SkinData skinData) { 64 | this.newSkin = Objects.requireNonNull(skinData); 65 | return this; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/event/util/ListenerAnnotationMatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.event.util; 27 | 28 | import com.google.inject.TypeLiteral; 29 | import com.google.inject.matcher.AbstractMatcher; 30 | import org.geysermc.event.Listener; 31 | 32 | public class ListenerAnnotationMatcher extends AbstractMatcher> { 33 | @Override 34 | public boolean matches(TypeLiteral typeLiteral) { 35 | Class rawType = typeLiteral.getRawType(); 36 | return rawType.isAnnotationPresent(Listener.class); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/link/LinkRequestImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.link; 27 | 28 | import java.time.Instant; 29 | import java.util.UUID; 30 | import lombok.Getter; 31 | import org.geysermc.floodgate.api.link.LinkRequest; 32 | 33 | @Getter 34 | public final class LinkRequestImpl implements LinkRequest { 35 | private final String javaUsername; 36 | private final UUID javaUniqueId; 37 | private final String linkCode; 38 | private final String bedrockUsername; 39 | private final long requestTime; 40 | 41 | public LinkRequestImpl(String javaUsername, UUID javaUniqueId, 42 | String linkCode, String bedrockUsername) { 43 | this.javaUniqueId = javaUniqueId; 44 | this.javaUsername = javaUsername; 45 | this.linkCode = linkCode; 46 | this.bedrockUsername = bedrockUsername; 47 | requestTime = Instant.now().getEpochSecond(); 48 | } 49 | 50 | public LinkRequestImpl(String javaUsername, UUID javaUniqueId, 51 | String linkCode, String bedrockUsername, long requestTime) { 52 | this.javaUniqueId = javaUniqueId; 53 | this.javaUsername = javaUsername; 54 | this.linkCode = linkCode; 55 | this.bedrockUsername = bedrockUsername; 56 | this.requestTime = requestTime; 57 | } 58 | 59 | @Override 60 | public boolean isExpired(long linkTimeout) { 61 | long timePassed = Instant.now().getEpochSecond() - requestTime; 62 | return timePassed > linkTimeout; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/module/AutoBindModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import org.geysermc.floodgate.util.AutoBind; 30 | import org.geysermc.floodgate.util.Utils; 31 | 32 | public class AutoBindModule extends AbstractModule { 33 | @Override 34 | protected void configure() { 35 | for (Class clazz : Utils.getGeneratedClassesForAnnotation(AutoBind.class)) { 36 | bind(clazz).asEagerSingleton(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/module/CommandModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.multibindings.ProvidesIntoSet; 31 | import org.geysermc.floodgate.command.LinkAccountCommand; 32 | import org.geysermc.floodgate.command.TestCommand; 33 | import org.geysermc.floodgate.command.UnlinkAccountCommand; 34 | import org.geysermc.floodgate.command.WhitelistCommand; 35 | import org.geysermc.floodgate.command.main.MainCommand; 36 | import org.geysermc.floodgate.platform.command.FloodgateCommand; 37 | import org.geysermc.floodgate.register.CommandRegister; 38 | 39 | public class CommandModule extends AbstractModule { 40 | @Override 41 | protected void configure() { 42 | bind(CommandRegister.class).asEagerSingleton(); 43 | } 44 | 45 | @Singleton 46 | @ProvidesIntoSet 47 | public FloodgateCommand linkAccountCommand() { 48 | return new LinkAccountCommand(); 49 | } 50 | 51 | @Singleton 52 | @ProvidesIntoSet 53 | public FloodgateCommand unlinkAccountCommand() { 54 | return new UnlinkAccountCommand(); 55 | } 56 | 57 | @Singleton 58 | @ProvidesIntoSet 59 | public FloodgateCommand whitelistCommand() { 60 | return new WhitelistCommand(); 61 | } 62 | 63 | @Singleton 64 | @ProvidesIntoSet 65 | public FloodgateCommand testCommand() { 66 | return new TestCommand(); 67 | } 68 | 69 | @Singleton 70 | @ProvidesIntoSet 71 | public FloodgateCommand mainCommand() { 72 | return new MainCommand(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/module/ConfigLoadedModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Provides; 30 | import com.google.inject.Singleton; 31 | import lombok.RequiredArgsConstructor; 32 | import org.geysermc.floodgate.config.FloodgateConfig; 33 | import org.geysermc.floodgate.config.ProxyFloodgateConfig; 34 | 35 | @RequiredArgsConstructor 36 | public final class ConfigLoadedModule extends AbstractModule { 37 | private final FloodgateConfig config; 38 | 39 | @Override 40 | protected void configure() { 41 | if (config instanceof ProxyFloodgateConfig) { 42 | bind(ProxyFloodgateConfig.class).toInstance((ProxyFloodgateConfig) config); 43 | } 44 | } 45 | 46 | @Provides 47 | @Singleton 48 | public FloodgateConfig floodgateConfig() { 49 | return config; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/module/PluginMessageModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.multibindings.ProvidesIntoSet; 31 | import org.geysermc.floodgate.pluginmessage.PluginMessageChannel; 32 | import org.geysermc.floodgate.pluginmessage.channel.FormChannel; 33 | import org.geysermc.floodgate.pluginmessage.channel.PacketChannel; 34 | import org.geysermc.floodgate.pluginmessage.channel.SkinChannel; 35 | import org.geysermc.floodgate.pluginmessage.channel.TransferChannel; 36 | import org.geysermc.floodgate.register.PluginMessageRegister; 37 | 38 | public final class PluginMessageModule extends AbstractModule { 39 | @Override 40 | protected void configure() { 41 | bind(PluginMessageRegister.class).asEagerSingleton(); 42 | } 43 | 44 | @Singleton 45 | @ProvidesIntoSet 46 | public PluginMessageChannel formChannel() { 47 | return new FormChannel(); 48 | } 49 | 50 | @Singleton 51 | @ProvidesIntoSet 52 | public PluginMessageChannel skinChannel() { 53 | return new SkinChannel(); 54 | } 55 | 56 | @Singleton 57 | @ProvidesIntoSet 58 | public PluginMessageChannel transferChannel() { 59 | return new TransferChannel(); 60 | } 61 | 62 | @Singleton 63 | @ProvidesIntoSet 64 | public PluginMessageChannel packetChannel() { 65 | return new PacketChannel(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/module/PostInitializeModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Module; 30 | import lombok.RequiredArgsConstructor; 31 | 32 | @RequiredArgsConstructor 33 | public final class PostInitializeModule extends AbstractModule { 34 | private final Module[] postInitializeModules; 35 | 36 | @Override 37 | protected void configure() { 38 | for (Module module : postInitializeModules) { 39 | install(module); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/module/ProxyCommonModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.Provides; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.name.Named; 31 | import java.nio.file.Path; 32 | import org.geysermc.floodgate.api.ProxyFloodgateApi; 33 | import org.geysermc.floodgate.api.SimpleFloodgateApi; 34 | import org.geysermc.floodgate.config.FloodgateConfig; 35 | import org.geysermc.floodgate.config.ProxyFloodgateConfig; 36 | 37 | public final class ProxyCommonModule extends CommonModule { 38 | public ProxyCommonModule(Path dataDirectory) { 39 | super(dataDirectory); 40 | } 41 | 42 | @Override 43 | protected void configure() { 44 | super.configure(); 45 | 46 | bind(SimpleFloodgateApi.class).to(ProxyFloodgateApi.class); 47 | bind(ProxyFloodgateApi.class).in(Singleton.class); 48 | } 49 | 50 | @Provides 51 | @Singleton 52 | public ProxyFloodgateConfig proxyFloodgateConfig(FloodgateConfig config) { 53 | return (ProxyFloodgateConfig) config; 54 | } 55 | 56 | @Provides 57 | @Singleton 58 | @Named("configClass") 59 | public Class floodgateConfigClass() { 60 | return ProxyFloodgateConfig.class; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/module/ServerCommonModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.Provides; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.name.Named; 31 | import java.nio.file.Path; 32 | import org.geysermc.configutils.file.template.TemplateReader; 33 | import org.geysermc.floodgate.api.SimpleFloodgateApi; 34 | import org.geysermc.floodgate.config.FloodgateConfig; 35 | 36 | public final class ServerCommonModule extends CommonModule { 37 | public ServerCommonModule(Path dataDirectory) { 38 | super(dataDirectory); 39 | } 40 | 41 | // Used in floodgate-fabric to provide it's own reader implementation 42 | public ServerCommonModule(Path dataDirectory, TemplateReader reader) { 43 | super(dataDirectory, reader); 44 | } 45 | 46 | @Override 47 | protected void configure() { 48 | super.configure(); 49 | bind(SimpleFloodgateApi.class).in(Singleton.class); 50 | } 51 | 52 | @Provides 53 | @Singleton 54 | @Named("configClass") 55 | public Class floodgateConfigClass() { 56 | return FloodgateConfig.class; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/platform/command/FloodgateCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.platform.command; 27 | 28 | import org.geysermc.floodgate.config.FloodgateConfig; 29 | import org.geysermc.floodgate.player.UserAudience; 30 | import org.incendo.cloud.Command; 31 | import org.incendo.cloud.CommandManager; 32 | 33 | /** The base class for every Floodgate command. */ 34 | public interface FloodgateCommand { 35 | /** 36 | * Called by the CommandRegister when it wants you to build the command which he can add. 37 | * 38 | * @param commandManager the manager to create a command 39 | * @return the command to register 40 | */ 41 | Command buildCommand(CommandManager commandManager); 42 | 43 | /** 44 | * Called by the CommandRegister to check if the command should be added given the config. 45 | * 46 | * @param config the config to check if a command should be added 47 | * @return true if it should be added 48 | */ 49 | default boolean shouldRegister(FloodgateConfig config) { 50 | return true; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/platform/command/FloodgateSubCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.platform.command; 27 | 28 | import org.geysermc.floodgate.command.util.Permission; 29 | import org.geysermc.floodgate.player.UserAudience; 30 | import org.incendo.cloud.context.CommandContext; 31 | 32 | public abstract class FloodgateSubCommand { 33 | public abstract String name(); 34 | 35 | public abstract String description(); 36 | 37 | public abstract Permission permission(); 38 | 39 | public abstract void execute(CommandContext context); 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/platform/command/SubCommands.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.platform.command; 27 | 28 | import com.google.inject.Inject; 29 | import com.google.inject.Injector; 30 | import java.util.Collections; 31 | import java.util.HashSet; 32 | import java.util.Set; 33 | 34 | public abstract class SubCommands { 35 | private final Set> toRegister = new HashSet<>(); 36 | private Set subCommands; 37 | 38 | public void defineSubCommand(Class subCommandClass) { 39 | toRegister.add(subCommandClass); 40 | } 41 | 42 | @Inject 43 | public void registerSubCommands(Injector injector) { 44 | Set subCommandSet = new HashSet<>(); 45 | for (Class subCommand : toRegister) { 46 | subCommandSet.add(injector.getInstance(subCommand)); 47 | } 48 | subCommands = Collections.unmodifiableSet(subCommandSet); 49 | } 50 | 51 | protected Set subCommands() { 52 | return subCommands; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/platform/command/TranslatableMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.platform.command; 27 | 28 | import org.geysermc.floodgate.util.LanguageManager; 29 | 30 | /** 31 | * TranslatableMessage is the interface for a message that can be translated. Messages are generally 32 | * implemented using enums. 33 | */ 34 | public interface TranslatableMessage { 35 | /** 36 | * Returns the message attached to the enum identifier 37 | */ 38 | String getRawMessage(); 39 | 40 | /** 41 | * Returns the parts of this message (getRawMessage() split on " ") 42 | */ 43 | String[] getTranslateParts(); 44 | 45 | default String translateMessage(LanguageManager manager, String locale, Object... args) { 46 | String[] translateParts = getTranslateParts(); 47 | if (translateParts.length == 1) { 48 | return manager.getString(getRawMessage(), locale, args); 49 | } 50 | // todo only works when one section has arguments 51 | StringBuilder builder = new StringBuilder(); 52 | for (int i = 0; i < translateParts.length; i++) { 53 | builder.append(manager.getString(translateParts[i], locale, args)); 54 | if (translateParts.length != i + 1) { 55 | builder.append(' '); 56 | } 57 | } 58 | return builder.toString(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/platform/listener/ListenerRegistration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.platform.listener; 27 | 28 | /** 29 | * This class is responsible for registering listeners to the listener manager of the platform that 30 | * is currently in use. Unfortunately due to the major differences between the platforms (when it 31 | * comes to listeners) every Floodgate platform has to implement their own listeners. 32 | * 33 | * @param the platform-specific listener class 34 | */ 35 | public interface ListenerRegistration { 36 | /** 37 | * This method will register the specified listener. 38 | * 39 | * @param listener the listener to register 40 | */ 41 | void register(T listener); 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/platform/pluginmessage/PluginMessageUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.platform.pluginmessage; 27 | 28 | import java.util.UUID; 29 | 30 | public class PluginMessageUtils { 31 | public boolean sendMessage(UUID player, String channel, byte[] data) { 32 | return sendMessage(player, false, channel, data); 33 | } 34 | 35 | public boolean sendMessage(UUID player, boolean toServer, String channel, byte[] data) { 36 | if (!toServer) { 37 | return sendMessage(player, channel, data); 38 | } 39 | throw new IllegalStateException( 40 | "Cannot send plugin message to server on a non-proxy platform"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/platform/util/PlatformUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.platform.util; 27 | 28 | import lombok.RequiredArgsConstructor; 29 | 30 | @RequiredArgsConstructor 31 | public abstract class PlatformUtils { 32 | /** 33 | * Returns the authentication type used on the platform 34 | */ 35 | public abstract AuthType authType(); 36 | 37 | /** 38 | * Returns the Minecraft version the server is based on (or the most recent supported version 39 | * for proxy platforms) 40 | */ 41 | public abstract String minecraftVersion(); 42 | 43 | public abstract String serverImplementationName(); 44 | 45 | public enum AuthType { 46 | ONLINE, 47 | PROXIED, 48 | OFFLINE 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/platform/util/PlayerType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.platform.util; 27 | 28 | public enum PlayerType { 29 | ALL_PLAYERS, 30 | ONLY_BEDROCK, 31 | ONLY_JAVA 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/player/FloodgateCommandPreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.player; 27 | 28 | import lombok.RequiredArgsConstructor; 29 | import org.checkerframework.checker.nullness.qual.NonNull; 30 | import org.geysermc.floodgate.platform.command.CommandUtil; 31 | import org.incendo.cloud.execution.preprocessor.CommandPreprocessingContext; 32 | import org.incendo.cloud.execution.preprocessor.CommandPreprocessor; 33 | 34 | /** 35 | * Command preprocessor which decorated incoming {@link org.incendo.cloud.context.CommandContext} 36 | * with Floodgate specific objects 37 | * 38 | * @param Command sender type 39 | * @since 2.0 40 | */ 41 | @RequiredArgsConstructor 42 | public final class FloodgateCommandPreprocessor implements CommandPreprocessor { 43 | private final CommandUtil commandUtil; 44 | 45 | @Override 46 | public void accept(@NonNull CommandPreprocessingContext context) { 47 | context.commandContext().store("CommandUtil", commandUtil); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/player/HostnameSeparationResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.player; 27 | 28 | public class HostnameSeparationResult { 29 | private final String floodgateData; 30 | private final int headerVersion; 31 | private final String hostnameRemainder; 32 | 33 | public HostnameSeparationResult( 34 | String floodgateData, int headerVersion, String hostnameRemainder) { 35 | this.floodgateData = floodgateData; 36 | this.headerVersion = headerVersion; 37 | this.hostnameRemainder = hostnameRemainder; 38 | } 39 | 40 | public String floodgateData() { 41 | return floodgateData; 42 | } 43 | 44 | public int headerVersion() { 45 | return headerVersion; 46 | } 47 | 48 | public String hostnameRemainder() { 49 | return hostnameRemainder; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/player/audience/FloodgateSenderMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2024 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.player.audience; 27 | 28 | 29 | import org.checkerframework.checker.nullness.qual.NonNull; 30 | import org.geysermc.floodgate.platform.command.CommandUtil; 31 | import org.geysermc.floodgate.player.UserAudience; 32 | import org.incendo.cloud.SenderMapper; 33 | 34 | public class FloodgateSenderMapper implements SenderMapper { 35 | 36 | private final CommandUtil commandUtil; 37 | 38 | public FloodgateSenderMapper(CommandUtil commandUtil) { 39 | this.commandUtil = commandUtil; 40 | } 41 | 42 | @Override 43 | public @NonNull UserAudience map(@NonNull T base) { 44 | return this.commandUtil.getUserAudience(base); 45 | } 46 | 47 | @SuppressWarnings("unchecked") 48 | @Override 49 | public @NonNull T reverse(@NonNull UserAudience mapped) { 50 | return (T) mapped.source(); 51 | } 52 | } -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/player/audience/InvalidPlayerIdentifierException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2024 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.player.audience; 27 | 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | 30 | public final class InvalidPlayerIdentifierException extends IllegalArgumentException { 31 | 32 | public InvalidPlayerIdentifierException(@NonNull String message) { 33 | super(message); 34 | } 35 | 36 | @Override 37 | public @NonNull Throwable fillInStackTrace() { 38 | return this; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/player/audience/ProfileAudience.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.player.audience; 27 | 28 | import java.util.UUID; 29 | import lombok.Getter; 30 | import lombok.experimental.Accessors; 31 | import org.checkerframework.checker.nullness.qual.Nullable; 32 | 33 | @Getter @Accessors(fluent = true) 34 | public final class ProfileAudience { 35 | private final @Nullable UUID uuid; 36 | private final @Nullable String username; 37 | 38 | public ProfileAudience(@Nullable UUID uuid, @Nullable String username) { 39 | this.uuid = uuid; 40 | this.username = username; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/pluginmessage/PluginMessageChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.pluginmessage; 27 | 28 | import java.util.UUID; 29 | import lombok.AccessLevel; 30 | import lombok.Getter; 31 | import lombok.RequiredArgsConstructor; 32 | 33 | public interface PluginMessageChannel { 34 | 35 | String getIdentifier(); 36 | 37 | Result handleProxyCall( 38 | byte[] data, 39 | UUID sourceUuid, 40 | String sourceUsername, 41 | Identity sourceIdentity 42 | ); 43 | 44 | Result handleServerCall(byte[] data, UUID playerUuid, String playerUsername); 45 | 46 | @Getter 47 | @RequiredArgsConstructor(access = AccessLevel.PRIVATE) 48 | final class Result { 49 | private static final Result FORWARD = new Result(true, null); 50 | private static final Result HANDLED = new Result(false, null); 51 | 52 | private final boolean allowed; 53 | private final String reason; 54 | 55 | public static Result forward() { 56 | return FORWARD; 57 | } 58 | 59 | public static Result handled() { 60 | return HANDLED; 61 | } 62 | 63 | public static Result kick(String reason) { 64 | return new Result(false, reason); 65 | } 66 | } 67 | 68 | enum Identity { 69 | UNKNOWN, 70 | SERVER, 71 | PLAYER 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/pluginmessage/PluginMessageManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.pluginmessage; 27 | 28 | import com.google.inject.Inject; 29 | import java.util.HashMap; 30 | import java.util.Map; 31 | import java.util.Set; 32 | 33 | public class PluginMessageManager { 34 | private final Map, PluginMessageChannel> classInstanceMap = new HashMap<>(); 35 | private final Map identifierInstanceMap = new HashMap<>(); 36 | 37 | @Inject 38 | public void addChannels(Set channels) { 39 | if (!classInstanceMap.isEmpty()) { 40 | return; 41 | } 42 | 43 | for (PluginMessageChannel channel : channels) { 44 | classInstanceMap.put(channel.getClass(), channel); 45 | identifierInstanceMap.put(channel.getIdentifier(), channel); 46 | } 47 | } 48 | 49 | @SuppressWarnings("unchecked") 50 | public T getChannel(Class channelType) { 51 | return (T) classInstanceMap.get(channelType); 52 | } 53 | 54 | public PluginMessageChannel getChannel(String identifier) { 55 | return identifierInstanceMap.get(identifier); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/pluginmessage/PluginMessageRegistration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.pluginmessage; 27 | 28 | public interface PluginMessageRegistration { 29 | void register(PluginMessageChannel channel); 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/pluginmessage/channel/PacketChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.pluginmessage.channel; 27 | 28 | import com.google.inject.Inject; 29 | import java.util.UUID; 30 | import org.geysermc.floodgate.api.UnsafeFloodgateApi; 31 | import org.geysermc.floodgate.platform.pluginmessage.PluginMessageUtils; 32 | import org.geysermc.floodgate.pluginmessage.PluginMessageChannel; 33 | 34 | public final class PacketChannel implements PluginMessageChannel { 35 | @Inject private PluginMessageUtils pluginMessageUtils; 36 | 37 | @Override 38 | public String getIdentifier() { 39 | return "floodgate:packet"; 40 | } 41 | 42 | @Override 43 | public Result handleProxyCall( 44 | byte[] data, 45 | UUID sourceUuid, 46 | String sourceUsername, 47 | Identity sourceIdentity 48 | ) { 49 | if (sourceIdentity == Identity.SERVER) { 50 | // send it to the client 51 | return Result.forward(); 52 | } 53 | 54 | if (sourceIdentity == Identity.PLAYER) { 55 | return handleServerCall(data, sourceUuid, sourceUsername); 56 | } 57 | 58 | return Result.handled(); 59 | } 60 | 61 | @Override 62 | public Result handleServerCall(byte[] data, UUID playerUuid, String playerUsername) { 63 | return Result.kick("Cannot send packets from Geyser/Floodgate to Floodgate"); 64 | } 65 | 66 | public boolean sendPacket(UUID player, byte[] packet, UnsafeFloodgateApi api) { 67 | if (api == null) { 68 | throw new IllegalArgumentException("Can only send a packet using the unsafe api"); 69 | } 70 | return pluginMessageUtils.sendMessage(player, getIdentifier(), packet); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/register/AddonRegister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.register; 27 | 28 | import com.google.inject.Inject; 29 | import com.google.inject.Injector; 30 | import java.util.Set; 31 | import org.geysermc.floodgate.api.inject.InjectorAddon; 32 | import org.geysermc.floodgate.api.inject.PlatformInjector; 33 | 34 | public final class AddonRegister { 35 | @Inject private Injector guice; 36 | @Inject private PlatformInjector injector; 37 | 38 | @Inject 39 | public void registerAddons(Set addons) { 40 | for (InjectorAddon addon : addons) { 41 | guice.injectMembers(addon); 42 | injector.addAddon(addon); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/register/CommandRegister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.register; 27 | 28 | import com.google.inject.Inject; 29 | import com.google.inject.Injector; 30 | import com.google.inject.Key; 31 | import java.util.Set; 32 | import org.geysermc.floodgate.config.FloodgateConfig; 33 | import org.geysermc.floodgate.platform.command.FloodgateCommand; 34 | import org.geysermc.floodgate.player.UserAudience; 35 | import org.incendo.cloud.CommandManager; 36 | 37 | /** 38 | * This class is responsible for registering commands to the command register of the platform that 39 | * is currently in use. So that the commands only have to be written once (in the common module) and 40 | * can be used across all platforms without the need of adding platform specific commands. 41 | */ 42 | public final class CommandRegister { 43 | private final CommandManager commandManager; 44 | private final FloodgateConfig config; 45 | private final Injector guice; 46 | 47 | @Inject 48 | public CommandRegister(Injector guice) { 49 | this.commandManager = guice.getInstance(new Key>() {}); 50 | this.config = guice.getInstance(FloodgateConfig.class); 51 | this.guice = guice; 52 | } 53 | 54 | @Inject 55 | public void registerCommands(Set foundCommands) { 56 | for (FloodgateCommand command : foundCommands) { 57 | guice.injectMembers(command); 58 | if (command.shouldRegister(config)) { 59 | commandManager.command(command.buildCommand(commandManager)); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/register/ListenerRegister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.register; 27 | 28 | import com.google.inject.Inject; 29 | import com.google.inject.Injector; 30 | import java.util.Set; 31 | import lombok.RequiredArgsConstructor; 32 | import org.geysermc.floodgate.platform.listener.ListenerRegistration; 33 | 34 | @RequiredArgsConstructor(onConstructor = @__(@Inject)) 35 | public final class ListenerRegister { 36 | private final ListenerRegistration registration; 37 | private final Injector guice; 38 | 39 | @Inject 40 | public void registerListeners(Set foundListeners) { 41 | for (T listener : foundListeners) { 42 | guice.injectMembers(listener); 43 | registration.register(listener); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/register/PluginMessageRegister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.register; 27 | 28 | import com.google.inject.Inject; 29 | import com.google.inject.Injector; 30 | import java.util.Set; 31 | import org.geysermc.floodgate.pluginmessage.PluginMessageChannel; 32 | import org.geysermc.floodgate.pluginmessage.PluginMessageManager; 33 | import org.geysermc.floodgate.pluginmessage.PluginMessageRegistration; 34 | 35 | public class PluginMessageRegister { 36 | @Inject private Injector guice; 37 | @Inject private PluginMessageManager manager; 38 | @Inject private PluginMessageRegistration registration; 39 | 40 | @Inject 41 | public void registerChannels(Set channels) { 42 | // we can safely add the channels this way 43 | guice.injectMembers(manager); 44 | 45 | for (PluginMessageChannel channel : channels) { 46 | guice.injectMembers(channel); 47 | registration.register(channel); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/skin/SkinApplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.skin; 27 | 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | import org.geysermc.floodgate.api.event.skin.SkinApplyEvent.SkinData; 30 | import org.geysermc.floodgate.api.player.FloodgatePlayer; 31 | 32 | public interface SkinApplier { 33 | /** 34 | * Apply a skin to a {@link FloodgatePlayer player} 35 | * 36 | * @param floodgatePlayer player to apply skin to 37 | * @param skinData data for skin to apply to player 38 | */ 39 | void applySkin(@NonNull FloodgatePlayer floodgatePlayer, @NonNull SkinData skinData); 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/skin/SkinDataImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.skin; 27 | 28 | import com.google.gson.JsonObject; 29 | import java.util.Objects; 30 | import org.checkerframework.checker.nullness.qual.NonNull; 31 | import org.geysermc.floodgate.api.event.skin.SkinApplyEvent.SkinData; 32 | import org.geysermc.floodgate.util.Constants; 33 | 34 | public class SkinDataImpl implements SkinData { 35 | public static final SkinData DEFAULT_SKIN = new SkinDataImpl( 36 | Constants.DEFAULT_MINECRAFT_JAVA_SKIN_TEXTURE, 37 | Constants.DEFAULT_MINECRAFT_JAVA_SKIN_SIGNATURE 38 | ); 39 | 40 | private final String value; 41 | private final String signature; 42 | 43 | public SkinDataImpl(@NonNull String value, @NonNull String signature) { 44 | this.value = Objects.requireNonNull(value); 45 | this.signature = Objects.requireNonNull(signature); 46 | } 47 | 48 | public static SkinData from(JsonObject data) { 49 | return new SkinDataImpl( 50 | data.get("value").getAsString(), 51 | data.get("signature").getAsString() 52 | ); 53 | } 54 | 55 | @Override 56 | public @NonNull String value() { 57 | return value; 58 | } 59 | 60 | @Override 61 | public @NonNull String signature() { 62 | return signature; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/skin/SkinUploadManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.skin; 27 | 28 | import com.google.inject.Inject; 29 | import com.google.inject.Singleton; 30 | import it.unimi.dsi.fastutil.ints.Int2ObjectMap; 31 | import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; 32 | import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; 33 | import org.geysermc.event.Listener; 34 | import org.geysermc.event.subscribe.Subscribe; 35 | import org.geysermc.floodgate.api.FloodgateApi; 36 | import org.geysermc.floodgate.api.logger.FloodgateLogger; 37 | import org.geysermc.floodgate.event.lifecycle.ShutdownEvent; 38 | 39 | @Listener 40 | @Singleton 41 | public final class SkinUploadManager { 42 | private final Int2ObjectMap connections = 43 | Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>()); 44 | 45 | @Inject private FloodgateApi api; 46 | @Inject private SkinApplier applier; 47 | @Inject private FloodgateLogger logger; 48 | 49 | public void addConnectionIfNeeded(int id, String verifyCode) { 50 | connections.computeIfAbsent(id, (ignored) -> { 51 | SkinUploadSocket socket = 52 | new SkinUploadSocket(id, verifyCode, this, api, applier, logger); 53 | socket.connect(); 54 | return socket; 55 | }); 56 | } 57 | 58 | public void removeConnection(int id, SkinUploadSocket socket) { 59 | connections.remove(id, socket); 60 | } 61 | 62 | public void closeAllSockets() { 63 | for (SkinUploadSocket socket : connections.values()) { 64 | socket.close(); 65 | } 66 | connections.clear(); 67 | } 68 | 69 | @Subscribe 70 | public void onShutdown(ShutdownEvent ignored) { 71 | closeAllSockets(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/util/AutoBind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.util; 27 | 28 | import java.lang.annotation.Retention; 29 | import java.lang.annotation.RetentionPolicy; 30 | 31 | /** 32 | * Automatically binds an instance of itself as an eager singleton during the post-initialise stage 33 | * of the FloodgatePlatform. Add the annotation to a class, and it should automatically create an 34 | * instance and inject it for you. 35 | */ 36 | @Retention(RetentionPolicy.RUNTIME) 37 | public @interface AutoBind { 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/util/BrigadierUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2024 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.util; 27 | 28 | /* 29 | Code taken from Brigadier's StringArgumentType and StringReader 30 | */ 31 | public final class BrigadierUtils { 32 | @SuppressWarnings("BooleanMethodIsAlwaysInverted") 33 | public static boolean isAllowedInUnquotedString(char c) { 34 | return c >= '0' && c <= '9' || 35 | c >= 'A' && c <= 'Z' || 36 | c >= 'a' && c <= 'z' || 37 | c == '_' || c == '-' || 38 | c == '.' || c == '+'; 39 | } 40 | 41 | public static String escapeIfRequired(String input, boolean quoted) { 42 | if (quoted) { 43 | return escape(input); 44 | } 45 | 46 | for (final char c : input.toCharArray()) { 47 | if (!isAllowedInUnquotedString(c)) { 48 | return "\"" + input + "\""; 49 | } 50 | } 51 | return input; 52 | } 53 | 54 | private static String escape(final String input) { 55 | final StringBuilder result = new StringBuilder("\""); 56 | 57 | for (int i = 0; i < input.length(); i++) { 58 | final char c = input.charAt(i); 59 | if (c == '\\' || c == '"') { 60 | result.append('\\'); 61 | } 62 | result.append(c); 63 | } 64 | 65 | result.append("\""); 66 | return result.toString(); 67 | } 68 | } -------------------------------------------------------------------------------- /core/src/main/java/org/geysermc/floodgate/util/InjectorHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.util; 27 | 28 | import com.google.inject.Injector; 29 | 30 | public class InjectorHolder { 31 | private Injector injector; 32 | 33 | public Injector get() { 34 | return injector; 35 | } 36 | 37 | public void set(Injector injector) { 38 | this.injector = injector; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/resources/proxy-config.yml: -------------------------------------------------------------------------------- 1 | >> config.yml 2 | >>| 16 3 | # Should the proxy send the bedrock player data to the servers it is connecting to? 4 | # This requires Floodgate to be installed on the servers. 5 | # You'll get kicked if you don't use the plugin. The default value is false because of it 6 | send-floodgate-data: false 7 | 8 | >>| 9 | >>* -------------------------------------------------------------------------------- /database/mongo/build.gradle.kts: -------------------------------------------------------------------------------- 1 | val mongoClientVersion = "4.4.1" 2 | 3 | dependencies { 4 | provided(projects.core) 5 | implementation("org.mongodb", "mongodb-driver-sync" , mongoClientVersion) 6 | } 7 | 8 | description = "The Floodgate database extension for MongoDB" 9 | 10 | relocate("com.mongodb") 11 | relocate("org.bson") -------------------------------------------------------------------------------- /database/mongo/src/main/java/org/geysermc/floodgate/database/config/MongoConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.database.config; 27 | 28 | import lombok.Getter; 29 | 30 | @Getter 31 | public class MongoConfig implements DatabaseConfig { 32 | private String hostname = "localhost"; 33 | private String database = "floodgate"; 34 | private String username = "floodgate"; 35 | private String password; 36 | private String mongouri = ""; 37 | } 38 | -------------------------------------------------------------------------------- /database/mongo/src/main/resources/init.json: -------------------------------------------------------------------------------- 1 | { 2 | "mainClass": "org.geysermc.floodgate.database.MongoDbDatabase", 3 | "config": "mongo.yml" 4 | } -------------------------------------------------------------------------------- /database/mongo/src/main/resources/mongo.yml: -------------------------------------------------------------------------------- 1 | hostname: "localhost" 2 | database: "floodgate" 3 | username: "floodgate" 4 | password: "" 5 | mongouri: "" -------------------------------------------------------------------------------- /database/mysql/.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_size = 2 3 | tab_width = 2 4 | ij_continuation_indent_size = 4 -------------------------------------------------------------------------------- /database/mysql/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | provided(projects.core) 3 | 4 | // update HikariCP when we move to Java 11+ 5 | implementation("com.zaxxer", "HikariCP", "4.0.3") 6 | 7 | implementation("com.mysql", "mysql-connector-j", "8.0.32") { 8 | exclude("com.google.protobuf", "protobuf-java") 9 | } 10 | } 11 | 12 | description = "The Floodgate database extension for MySQL" 13 | 14 | // relocate everything from mysql-connector-j and HikariCP 15 | relocate("com.mysql") 16 | relocate("com.zaxxer.hikari") 17 | relocate("org.slf4j") 18 | -------------------------------------------------------------------------------- /database/mysql/src/main/java/org/geysermc/floodgate/database/config/MysqlConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.database.config; 27 | 28 | import lombok.Getter; 29 | 30 | @Getter 31 | public class MysqlConfig implements DatabaseConfig { 32 | private String hostname = "localhost"; 33 | private String database = "floodgate"; 34 | private String username = "floodgate"; 35 | private String password; 36 | } 37 | -------------------------------------------------------------------------------- /database/mysql/src/main/resources/init.json: -------------------------------------------------------------------------------- 1 | { 2 | "mainClass": "org.geysermc.floodgate.database.MysqlDatabase", 3 | "config": "mysql.yml" 4 | } -------------------------------------------------------------------------------- /database/mysql/src/main/resources/mysql.yml: -------------------------------------------------------------------------------- 1 | hostname: "localhost" 2 | database: "floodgate" 3 | username: "floodgate" 4 | password: "" 5 | -------------------------------------------------------------------------------- /database/sqlite/build.gradle.kts: -------------------------------------------------------------------------------- 1 | val sqliteJdbcVersion = "3.36.0.3" 2 | 3 | dependencies { 4 | provided(projects.core) 5 | implementation("org.xerial", "sqlite-jdbc", sqliteJdbcVersion) 6 | } 7 | 8 | description = "The Floodgate database extension for SQLite" 9 | -------------------------------------------------------------------------------- /database/sqlite/src/main/resources/init.json: -------------------------------------------------------------------------------- 1 | { 2 | "mainClass": "org.geysermc.floodgate.database.SqliteDatabase" 3 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.configureondemand=true 2 | org.gradle.caching=true 3 | org.gradle.parallel=true 4 | 5 | version=2.2.4-SNAPSHOT -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeyserMC/Floodgate/0e3163c94220cdc516d1d1219557376c5216312b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeyserMC/Floodgate/0e3163c94220cdc516d1d1219557376c5216312b/gradlew -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | Floodgate Code ruleset 9 | 10 | 11 | 12 | .*/CommonPlayerLink.* 13 | 14 | .*/FloodgateConfig.* 15 | 16 | .*/PlayerLinkLoader.* 17 | 18 | .*/FloodgateHandshakeHandler.* 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 3 | 4 | dependencyResolutionManagement { 5 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 6 | repositories { 7 | mavenLocal() 8 | 9 | // Geyser, Cumulus etc. 10 | maven("https://repo.opencollab.dev/maven-releases") { 11 | mavenContent { releasesOnly() } 12 | } 13 | maven("https://repo.opencollab.dev/maven-snapshots") { 14 | mavenContent { snapshotsOnly() } 15 | } 16 | 17 | // Paper, Velocity 18 | // maven("https://repo.papermc.io/repository/maven-releases") { 19 | // mavenContent { releasesOnly() } 20 | // } 21 | // maven("https://repo.papermc.io/repository/maven-snapshots") { 22 | // mavenContent { snapshotsOnly() } 23 | // } 24 | maven("https://repo.papermc.io/repository/maven-public") 25 | // Spigot 26 | maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") { 27 | mavenContent { snapshotsOnly() } 28 | } 29 | 30 | // BungeeCord 31 | maven("https://oss.sonatype.org/content/repositories/snapshots") { 32 | mavenContent { snapshotsOnly() } 33 | } 34 | 35 | maven("https://libraries.minecraft.net") { 36 | name = "minecraft" 37 | mavenContent { releasesOnly() } 38 | } 39 | 40 | mavenCentral() 41 | 42 | maven("https://jitpack.io") { 43 | content { includeGroupByRegex("com\\.github\\..*") } 44 | } 45 | } 46 | } 47 | 48 | pluginManagement { 49 | repositories { 50 | gradlePluginPortal() 51 | } 52 | plugins { 53 | id("net.kyori.indra") 54 | id("net.kyori.indra.git") 55 | } 56 | includeBuild("build-logic") 57 | } 58 | 59 | rootProject.name = "floodgate-parent" 60 | 61 | include(":api") 62 | include(":ap") 63 | include(":core") 64 | include(":bungee") 65 | include(":spigot") 66 | include(":velocity") 67 | include(":sqlite") 68 | include(":mysql") 69 | include(":mongo") 70 | project(":sqlite").projectDir = file("database/sqlite") 71 | project(":mysql").projectDir = file("database/mysql") 72 | project(":mongo").projectDir = file("database/mongo") 73 | -------------------------------------------------------------------------------- /spigot/build.gradle.kts: -------------------------------------------------------------------------------- 1 | var authlibVersion = "1.5.21" 2 | var guavaVersion = "21.0" 3 | var gsonVersion = "2.8.5" 4 | 5 | indra { 6 | javaVersions { 7 | // For Folia 8 | target(8) 9 | minimumToolchain(17) 10 | } 11 | } 12 | 13 | dependencies { 14 | api(projects.core) 15 | 16 | //implementation("org.incendo", "cloud-paper", Versions.cloudVersion) 17 | // TODO change back after https://github.com/incendo/cloud-minecraft is merged 18 | implementation("com.github.onebeastchris.cloud-minecraft", "cloud-paper", "jitpack-SNAPSHOT") 19 | // hack to make pre 1.12 work 20 | implementation("com.google.guava", "guava", guavaVersion) 21 | 22 | compileOnlyApi("dev.folia", "folia-api", Versions.spigotVersion) { 23 | attributes { 24 | attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17) 25 | } 26 | } 27 | } 28 | 29 | relocate("com.google.inject") 30 | relocate("net.kyori") 31 | relocate("org.incendo.cloud") 32 | relocate("io.leangen.geantyref") // used in cloud 33 | // hack to make pre 1.12 work 34 | relocate("com.google.common") 35 | relocate("com.google.guava") 36 | // hack to make (old versions? of) Paper work 37 | relocate("it.unimi") 38 | // since 1.20 39 | relocate("org.yaml") 40 | 41 | // these dependencies are already present on the platform 42 | provided("com.mojang", "authlib", authlibVersion) 43 | provided("io.netty", "netty-transport", Versions.nettyVersion) 44 | provided("io.netty", "netty-codec", Versions.nettyVersion) 45 | provided("com.google.code.gson", "gson", gsonVersion) 46 | -------------------------------------------------------------------------------- /spigot/src/main/java/org/geysermc/floodgate/listener/SpigotListenerRegistration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.listener; 27 | 28 | import com.google.inject.Inject; 29 | import lombok.RequiredArgsConstructor; 30 | import org.bukkit.Bukkit; 31 | import org.bukkit.event.Listener; 32 | import org.bukkit.plugin.java.JavaPlugin; 33 | import org.geysermc.floodgate.platform.listener.ListenerRegistration; 34 | 35 | @RequiredArgsConstructor(onConstructor = @__(@Inject)) 36 | public final class SpigotListenerRegistration implements ListenerRegistration { 37 | private final JavaPlugin plugin; 38 | 39 | @Override 40 | public void register(Listener listener) { 41 | Bukkit.getServer().getPluginManager().registerEvents(listener, plugin); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spigot/src/main/java/org/geysermc/floodgate/module/PaperListenerModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.Singleton; 29 | import com.google.inject.TypeLiteral; 30 | import com.google.inject.multibindings.ProvidesIntoSet; 31 | import org.bukkit.event.Listener; 32 | import org.geysermc.floodgate.listener.PaperProfileListener; 33 | import org.geysermc.floodgate.register.ListenerRegister; 34 | 35 | public class PaperListenerModule extends SpigotListenerModule { 36 | @Override 37 | protected void configure() { 38 | bind(new TypeLiteral>() {}).asEagerSingleton(); 39 | } 40 | 41 | @Singleton 42 | @ProvidesIntoSet 43 | public Listener paperProfileListener() { 44 | return new PaperProfileListener(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spigot/src/main/java/org/geysermc/floodgate/module/SpigotAddonModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.multibindings.ProvidesIntoSet; 31 | import org.geysermc.floodgate.addon.AddonManagerAddon; 32 | import org.geysermc.floodgate.addon.DebugAddon; 33 | import org.geysermc.floodgate.addon.PacketHandlerAddon; 34 | import org.geysermc.floodgate.addon.data.SpigotDataAddon; 35 | import org.geysermc.floodgate.api.inject.InjectorAddon; 36 | import org.geysermc.floodgate.register.AddonRegister; 37 | 38 | public final class SpigotAddonModule extends AbstractModule { 39 | @Override 40 | protected void configure() { 41 | bind(AddonRegister.class).asEagerSingleton(); 42 | } 43 | 44 | @Singleton 45 | @ProvidesIntoSet 46 | public InjectorAddon managerAddon() { 47 | return new AddonManagerAddon(); 48 | } 49 | 50 | @Singleton 51 | @ProvidesIntoSet 52 | public InjectorAddon dataAddon() { 53 | return new SpigotDataAddon(); 54 | } 55 | 56 | @Singleton 57 | @ProvidesIntoSet 58 | public InjectorAddon debugAddon() { 59 | return new DebugAddon(); 60 | } 61 | 62 | @Singleton 63 | @ProvidesIntoSet 64 | public InjectorAddon packetHandlerAddon() { 65 | return new PacketHandlerAddon(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /spigot/src/main/java/org/geysermc/floodgate/module/SpigotListenerModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.TypeLiteral; 31 | import com.google.inject.multibindings.ProvidesIntoSet; 32 | import org.bukkit.event.Listener; 33 | import org.geysermc.floodgate.listener.SpigotListener; 34 | import org.geysermc.floodgate.register.ListenerRegister; 35 | 36 | public class SpigotListenerModule extends AbstractModule { 37 | @Override 38 | protected void configure() { 39 | bind(new TypeLiteral>() {}).asEagerSingleton(); 40 | } 41 | 42 | @Singleton 43 | @ProvidesIntoSet 44 | public Listener spigotListener() { 45 | return new SpigotListener(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spigot/src/main/java/org/geysermc/floodgate/pluginmessage/SpigotPluginMessageRegistration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.pluginmessage; 27 | 28 | import lombok.RequiredArgsConstructor; 29 | import org.bukkit.plugin.java.JavaPlugin; 30 | import org.bukkit.plugin.messaging.Messenger; 31 | 32 | @RequiredArgsConstructor 33 | public class SpigotPluginMessageRegistration implements PluginMessageRegistration { 34 | private final JavaPlugin plugin; 35 | 36 | @Override 37 | public void register(PluginMessageChannel channel) { 38 | Messenger messenger = plugin.getServer().getMessenger(); 39 | 40 | messenger.registerIncomingPluginChannel( 41 | plugin, 42 | channel.getIdentifier(), 43 | (channel1, player, message) -> 44 | channel.handleServerCall(message, player.getUniqueId(), player.getName())); 45 | 46 | messenger.registerOutgoingPluginChannel(plugin, channel.getIdentifier()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spigot/src/main/java/org/geysermc/floodgate/pluginmessage/SpigotPluginMessageUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.pluginmessage; 27 | 28 | import java.util.UUID; 29 | import lombok.RequiredArgsConstructor; 30 | import org.bukkit.Bukkit; 31 | import org.bukkit.plugin.java.JavaPlugin; 32 | import org.geysermc.floodgate.platform.pluginmessage.PluginMessageUtils; 33 | 34 | @RequiredArgsConstructor 35 | public class SpigotPluginMessageUtils extends PluginMessageUtils { 36 | private final JavaPlugin plugin; 37 | 38 | @Override 39 | public boolean sendMessage(UUID player, String channel, byte[] data) { 40 | try { 41 | Bukkit.getPlayer(player).sendPluginMessage(plugin, channel, data); 42 | } catch (Exception exception) { 43 | exception.printStackTrace(); 44 | return false; 45 | } 46 | return true; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spigot/src/main/java/org/geysermc/floodgate/util/ProxyUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.util; 27 | 28 | public final class ProxyUtils { 29 | 30 | public static boolean isProxyData() { 31 | return isBungeeData() || isVelocitySupport(); 32 | } 33 | 34 | private static boolean isBungeeData() { 35 | return ReflectionUtils.castedStaticBooleanValue(ClassNames.BUNGEE); 36 | } 37 | 38 | private static boolean isVelocitySupport() { 39 | if (ClassNames.PAPER_VELOCITY_SUPPORT == null) { 40 | return false; 41 | } 42 | 43 | return ClassNames.PAPER_VELOCITY_SUPPORT.getAsBoolean(); 44 | } 45 | } -------------------------------------------------------------------------------- /spigot/src/main/java/org/geysermc/floodgate/util/SpigotHandshakeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.util; 27 | 28 | import com.google.inject.Inject; 29 | import java.util.UUID; 30 | import org.geysermc.floodgate.api.handshake.HandshakeData; 31 | import org.geysermc.floodgate.api.handshake.HandshakeHandler; 32 | import org.geysermc.floodgate.api.logger.FloodgateLogger; 33 | 34 | public class SpigotHandshakeHandler implements HandshakeHandler { 35 | @Inject 36 | private FloodgateLogger logger; 37 | 38 | @Override 39 | public void handle(HandshakeData data) { 40 | // we never have to do anything when BedrockData is null. 41 | // BedrockData is null when something went wrong (e.g. invalid key / exception) 42 | if (data.getBedrockData() == null) { 43 | return; 44 | } 45 | 46 | BedrockData bedrockData = data.getBedrockData(); 47 | UUID correctUuid = data.getCorrectUniqueId(); 48 | 49 | // replace the ip and uuid with the Bedrock client IP and an uuid based of the xuid 50 | String[] split = data.getHostname().split("\0"); 51 | if (split.length >= 3) { 52 | if (logger.isDebug()) { 53 | logger.info("Replacing hostname arg1 '{}' with '{}' and arg2 '{}' with '{}'", 54 | split[1], bedrockData.getIp(), split[2], correctUuid.toString() 55 | ); 56 | } 57 | split[1] = bedrockData.getIp(); 58 | split[2] = correctUuid.toString(); 59 | } 60 | data.setHostname(String.join("\0", split)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spigot/src/main/java/org/geysermc/floodgate/util/SpigotPlatformUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.util; 27 | 28 | import org.bukkit.Bukkit; 29 | import org.geysermc.floodgate.platform.util.PlatformUtils; 30 | 31 | public class SpigotPlatformUtils extends PlatformUtils { 32 | @Override 33 | public AuthType authType() { 34 | if (Bukkit.getOnlineMode()) { 35 | return AuthType.ONLINE; 36 | } 37 | return ProxyUtils.isProxyData() ? AuthType.PROXIED : AuthType.OFFLINE; 38 | } 39 | 40 | @Override 41 | public String minecraftVersion() { 42 | return Bukkit.getServer().getVersion().split("\\(MC: ")[1].split("\\)")[0]; 43 | } 44 | 45 | @Override 46 | public String serverImplementationName() { 47 | return Bukkit.getServer().getName(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spigot/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: ${name} 2 | description: ${description} 3 | version: ${version} 4 | author: ${author} 5 | website: ${url} 6 | main: org.geysermc.floodgate.SpigotPlugin 7 | api-version: 1.13 8 | folia-supported: true -------------------------------------------------------------------------------- /velocity/build.gradle.kts: -------------------------------------------------------------------------------- 1 | var velocityVersion = "3.2.0-SNAPSHOT" 2 | var log4jVersion = "2.11.2" 3 | var gsonVersion = "2.8.8" 4 | var guavaVersion = "25.1-jre" 5 | 6 | indra { 7 | javaVersions { 8 | // For Velocity API 9 | target(11) 10 | } 11 | } 12 | 13 | dependencies { 14 | api(projects.core) 15 | implementation("org.incendo", "cloud-velocity", Versions.cloudVersion) 16 | } 17 | 18 | relocate("org.incendo.cloud") 19 | // used in cloud 20 | relocate("io.leangen.geantyref") 21 | 22 | 23 | // these dependencies are already present on the platform 24 | provided("com.google.code.gson", "gson", gsonVersion) 25 | provided("com.google.guava", "guava", guavaVersion) 26 | provided("com.google.inject", "guice", Versions.guiceVersion) 27 | provided("org.yaml", "snakeyaml", Versions.snakeyamlVersion) // included in Configurate 28 | provided("com.velocitypowered", "velocity-api", velocityVersion) 29 | provided("org.apache.logging.log4j", "log4j-core", log4jVersion) 30 | -------------------------------------------------------------------------------- /velocity/src/main/java/org/geysermc/floodgate/listener/VelocityListenerRegistration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.listener; 27 | 28 | import com.velocitypowered.api.event.EventManager; 29 | import lombok.RequiredArgsConstructor; 30 | import org.geysermc.floodgate.VelocityPlugin; 31 | import org.geysermc.floodgate.platform.listener.ListenerRegistration; 32 | 33 | @RequiredArgsConstructor 34 | public final class VelocityListenerRegistration implements ListenerRegistration { 35 | private final EventManager eventManager; 36 | private final VelocityPlugin plugin; 37 | 38 | @Override 39 | public void register(Object listener) { 40 | eventManager.register(plugin, listener); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /velocity/src/main/java/org/geysermc/floodgate/module/VelocityAddonModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.multibindings.ProvidesIntoSet; 31 | import org.geysermc.floodgate.addon.AddonManagerAddon; 32 | import org.geysermc.floodgate.addon.DebugAddon; 33 | import org.geysermc.floodgate.addon.PacketHandlerAddon; 34 | import org.geysermc.floodgate.addon.data.VelocityDataAddon; 35 | import org.geysermc.floodgate.api.inject.InjectorAddon; 36 | import org.geysermc.floodgate.register.AddonRegister; 37 | 38 | public final class VelocityAddonModule extends AbstractModule { 39 | @Override 40 | protected void configure() { 41 | bind(AddonRegister.class).asEagerSingleton(); 42 | } 43 | 44 | @Singleton 45 | @ProvidesIntoSet 46 | public InjectorAddon managerAddon() { 47 | return new AddonManagerAddon(); 48 | } 49 | 50 | @Singleton 51 | @ProvidesIntoSet 52 | public InjectorAddon dataAddon() { 53 | return new VelocityDataAddon(); 54 | } 55 | 56 | @Singleton 57 | @ProvidesIntoSet 58 | public InjectorAddon debugAddon() { 59 | return new DebugAddon(); 60 | } 61 | 62 | @Singleton 63 | @ProvidesIntoSet 64 | public InjectorAddon packetHandlerAddon() { 65 | return new PacketHandlerAddon(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /velocity/src/main/java/org/geysermc/floodgate/module/VelocityListenerModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.module; 27 | 28 | import com.google.inject.AbstractModule; 29 | import com.google.inject.Singleton; 30 | import com.google.inject.TypeLiteral; 31 | import com.google.inject.multibindings.ProvidesIntoSet; 32 | import org.geysermc.floodgate.listener.VelocityListener; 33 | import org.geysermc.floodgate.platform.pluginmessage.PluginMessageUtils; 34 | import org.geysermc.floodgate.register.ListenerRegister; 35 | 36 | public final class VelocityListenerModule extends AbstractModule { 37 | @Override 38 | protected void configure() { 39 | bind(new TypeLiteral>() {}).asEagerSingleton(); 40 | } 41 | 42 | @Singleton 43 | @ProvidesIntoSet 44 | public Object velocityListener() { 45 | return new VelocityListener(); 46 | } 47 | 48 | @Singleton 49 | @ProvidesIntoSet 50 | public Object pluginMessageListener(PluginMessageUtils handler) { 51 | return handler; // Plugin message handler is also the listener 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /velocity/src/main/java/org/geysermc/floodgate/pluginmessage/VelocityPluginMessageRegistration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.pluginmessage; 27 | 28 | import com.velocitypowered.api.proxy.ProxyServer; 29 | import com.velocitypowered.api.proxy.messages.ChannelIdentifier; 30 | import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; 31 | import lombok.RequiredArgsConstructor; 32 | 33 | @RequiredArgsConstructor 34 | public class VelocityPluginMessageRegistration implements PluginMessageRegistration { 35 | private final ProxyServer proxy; 36 | 37 | @Override 38 | public void register(PluginMessageChannel channel) { 39 | ChannelIdentifier identifier = MinecraftChannelIdentifier.from(channel.getIdentifier()); 40 | proxy.getChannelRegistrar().register(identifier); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /velocity/src/main/java/org/geysermc/floodgate/util/VelocityPlatformUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * @author GeyserMC 23 | * @link https://github.com/GeyserMC/Floodgate 24 | */ 25 | 26 | package org.geysermc.floodgate.util; 27 | 28 | import com.google.inject.Inject; 29 | import com.velocitypowered.api.network.ProtocolVersion; 30 | import com.velocitypowered.api.proxy.ProxyServer; 31 | import org.geysermc.floodgate.platform.util.PlatformUtils; 32 | 33 | public final class VelocityPlatformUtils extends PlatformUtils { 34 | @Inject 35 | private ProxyServer server; 36 | 37 | @Override 38 | public AuthType authType() { 39 | return server.getConfiguration().isOnlineMode() ? AuthType.ONLINE : AuthType.OFFLINE; 40 | } 41 | 42 | @Override 43 | public String minecraftVersion() { 44 | return ProtocolVersion.MAXIMUM_VERSION.getMostRecentSupportedVersion(); 45 | } 46 | 47 | @Override 48 | public String serverImplementationName() { 49 | return server.getVersion().getName(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /velocity/src/main/resources/velocity-plugin.json: -------------------------------------------------------------------------------- 1 | {"id": "${id}", "name": "${name}", "version": "${version}", "description": "${description}", "url": "${url}", "authors": ["${author}"], "main": "org.geysermc.floodgate.VelocityPlugin"} --------------------------------------------------------------------------------