├── .gitattributes ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── .gitignore ├── gradle.properties ├── src └── main │ ├── resources │ ├── mixins.trampoline.json │ └── fabric.mod.json │ └── java │ └── me │ └── i509 │ └── fabric │ └── trampoline │ ├── mixin │ ├── accessors │ │ └── HandshakeC2SPacketAccessor.java │ ├── MinecraftServerMixin.java │ ├── HandshakeC2SPacketMixin.java │ ├── ServerConfigHandlerMixin.java │ ├── ClientConnectionMixin.java │ ├── ServerLoginNetworkHandlerMixin.java │ └── ServerHandshakeNetworkHandlerMixin.java │ └── impl │ ├── ClientConnectionExtensions.java │ ├── TrampolineServerMod.java │ └── TrampolineCommands.java ├── README.md ├── LICENSE ├── gradlew.bat └── gradlew /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/i509VCB/Trampoline/HEAD/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-6.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | jcenter() 4 | maven { 5 | name = 'Fabric' 6 | url = 'https://maven.fabricmc.net/' 7 | } 8 | gradlePluginPortal() 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | 8 | # idea 9 | 10 | .idea/ 11 | *.iml 12 | *.ipr 13 | *.iws 14 | 15 | # vscode 16 | 17 | .settings/ 18 | .vscode/ 19 | bin/ 20 | .classpath 21 | .project 22 | 23 | # fabric 24 | 25 | run/ -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1G 2 | 3 | minecraft_version=1.16-rc1 4 | yarn_build=5 5 | loader_version=0.8.8+build.201 6 | 7 | mod_version=2.0.0 8 | maven_group=me.i509 9 | archives_base_name=Trampoline 10 | 11 | fabric_api_version=0.12.5+build.367-1.16 12 | -------------------------------------------------------------------------------- /src/main/resources/mixins.trampoline.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "me.i509.fabric.trampoline.mixin", 4 | "compatibilityLevel": "JAVA_8", 5 | "server": [ 6 | "ClientConnectionMixin", 7 | "HandshakeC2SPacketMixin", 8 | "MinecraftServerMixin", 9 | "ServerConfigHandlerMixin", 10 | "ServerHandshakeNetworkHandlerMixin", 11 | "ServerLoginNetworkHandlerMixin", 12 | "accessors.HandshakeC2SPacketAccessor" 13 | ], 14 | "injectors": { 15 | "defaultRequire": 1 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/mixin/accessors/HandshakeC2SPacketAccessor.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.mixin.accessors; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Accessor; 5 | 6 | import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; 7 | 8 | @Mixin(HandshakeC2SPacket.class) 9 | public interface HandshakeC2SPacketAccessor { 10 | @Accessor 11 | String getAddress(); 12 | 13 | @Accessor 14 | void setAddress(String address); 15 | 16 | @Accessor 17 | int getPort(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/mixin/MinecraftServerMixin.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.mixin; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.Overwrite; 5 | 6 | import net.minecraft.server.MinecraftServer; 7 | 8 | @Mixin(MinecraftServer.class) 9 | public abstract class MinecraftServerMixin { 10 | /** 11 | * @author i509VCB 12 | * @reason Return offline mode for server messages 13 | */ 14 | @Overwrite 15 | public boolean isOnlineMode() { 16 | return false; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/impl/ClientConnectionExtensions.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.impl; 2 | 3 | import java.net.InetSocketAddress; 4 | import java.util.UUID; 5 | 6 | import com.mojang.authlib.properties.Property; 7 | 8 | public interface ClientConnectionExtensions { 9 | void setRealAddress(InetSocketAddress inetSocketAddress); 10 | 11 | void setSpoofedUUID(UUID uuid); 12 | 13 | void setSpoofedProfile(Property[] spoofedProfile); 14 | 15 | UUID getSpoofedUUID(); 16 | 17 | Property[] getSpoofedProfile(); 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Trampoline 2 | IP-Forwarding support for Fabric servers connected via Bungeecord. 3 | 4 | Why would you use this? It's because of how Bungeecord is setup where it requires the servers to be in offline mode, but this doesn't give the player's real UUID or skin. IP-Forwarding fixes this but requires some server modifications to work. 5 | 6 | How do I use this. First make sure people can't join your server and bypass the Bungee proxy by following the tutorial here, otherwise others could log in as others: 7 | https://www.spigotmc.org/wiki/firewall-guide/ 8 | 9 | Then just drop it into the mods folder and restart your server. The mod will automatically configure the server into offline mode to work with Bungeecord. 10 | -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "trampoline", 4 | "version": "${version}", 5 | "name": "Trampoline", 6 | "description": "Adds support for Bungeecord IP-Forwarding on fabric servers", 7 | "authors": [ 8 | "i509VCB" 9 | ], 10 | "contact": { 11 | "homepage": "https://github.com/i509VCB/Trampoline", 12 | "sources": "https://github.com/i509VCB/Trampoline" 13 | }, 14 | "license": "MIT", 15 | "icon": "assets/trampoline/icon.png", 16 | "environment": "server", 17 | "entrypoints": { 18 | "server": [ 19 | "me.i509.fabric.trampoline.impl.TrampolineServerMod" 20 | ] 21 | }, 22 | "mixins": [ 23 | "mixins.trampoline.json" 24 | ], 25 | "depends": { 26 | "fabricloader": ">=0.7.4", 27 | "fabric-api-base": "*", 28 | "fabric-command-api-v1": "*" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/mixin/HandshakeC2SPacketMixin.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.mixin; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.At; 5 | import org.spongepowered.asm.mixin.injection.Redirect; 6 | 7 | import net.minecraft.network.PacketByteBuf; 8 | import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; 9 | 10 | @Mixin(HandshakeC2SPacket.class) 11 | public abstract class HandshakeC2SPacketMixin { 12 | /** 13 | * @author i509VCB 14 | * @reason Bungee sends a much larger handshake address than 255 characters, so we must read further for profile data. 15 | */ 16 | @Redirect(method = "read", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;readString(I)Ljava/lang/String;")) 17 | public String read(PacketByteBuf buf, int i) { 18 | return buf.readString(Short.MAX_VALUE); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/mixin/ServerConfigHandlerMixin.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.mixin; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.At; 5 | import org.spongepowered.asm.mixin.injection.Redirect; 6 | 7 | import net.minecraft.server.MinecraftServer; 8 | import net.minecraft.server.ServerConfigHandler; 9 | 10 | @Mixin(ServerConfigHandler.class) 11 | public abstract class ServerConfigHandlerMixin { 12 | /** 13 | * @author i509VCB 14 | * @reason Use online mode for profile lookups. 15 | */ 16 | @Redirect(at = @At(value = "INVOKE", target = "net/minecraft/server/MinecraftServer.isOnlineMode()Z"), method = "lookupProfile(Lnet/minecraft/server/MinecraftServer;Ljava/util/Collection;Lcom/mojang/authlib/ProfileLookupCallback;)V") 17 | private static boolean useOnlineProfileChecks(MinecraftServer server) { 18 | return true; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/impl/TrampolineServerMod.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.impl; 2 | 3 | import net.fabricmc.api.DedicatedServerModInitializer; 4 | import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; 5 | import org.apache.logging.log4j.LogManager; 6 | import org.apache.logging.log4j.Logger; 7 | 8 | public final class TrampolineServerMod implements DedicatedServerModInitializer { 9 | public static final Logger LOGGER = LogManager.getLogger("Trampoline-Forwarding"); 10 | 11 | @Override 12 | public void onInitializeServer() { 13 | LOGGER.info("Enabling Trampoline"); 14 | LOGGER.warn("The server is in offline mode to allow connection to Bungeecord. Please secure your server using the tutorial below, otherwise anyone can join the server:"); 15 | LOGGER.warn("https://www.spigotmc.org/wiki/firewall-guide/"); 16 | CommandRegistrationCallback.EVENT.register(TrampolineCommands::registerCommands); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 i509VCB 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 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/mixin/ClientConnectionMixin.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.mixin; 2 | 3 | import java.net.InetSocketAddress; 4 | import java.net.SocketAddress; 5 | import java.util.UUID; 6 | 7 | import com.mojang.authlib.properties.Property; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Overwrite; 10 | import org.spongepowered.asm.mixin.Unique; 11 | 12 | import net.minecraft.network.ClientConnection; 13 | 14 | import me.i509.fabric.trampoline.impl.ClientConnectionExtensions; 15 | 16 | @Mixin(ClientConnection.class) 17 | public abstract class ClientConnectionMixin implements ClientConnectionExtensions { 18 | @Unique private java.util.UUID spoofedUUID; 19 | @Unique private com.mojang.authlib.properties.Property[] spoofedProfile; 20 | @Unique private InetSocketAddress realAddress; 21 | 22 | @Override 23 | public UUID getSpoofedUUID() { 24 | return this.spoofedUUID; 25 | } 26 | 27 | @Override 28 | public void setSpoofedUUID(UUID uuid) { 29 | this.spoofedUUID = uuid; 30 | } 31 | 32 | @Override 33 | public Property[] getSpoofedProfile() { 34 | return this.spoofedProfile; 35 | } 36 | 37 | @Override 38 | public void setSpoofedProfile(Property[] spoofedProfile) { 39 | this.spoofedProfile = spoofedProfile; 40 | } 41 | 42 | @Override 43 | public void setRealAddress(InetSocketAddress inetSocketAddress) { 44 | this.realAddress = inetSocketAddress; 45 | } 46 | 47 | /** 48 | * @author i509VCB 49 | * @reason Pass real address to connection 50 | */ 51 | @Overwrite 52 | public SocketAddress getAddress() { 53 | return this.realAddress; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/mixin/ServerLoginNetworkHandlerMixin.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.mixin; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | import me.i509.fabric.trampoline.impl.TrampolineServerMod; 5 | import me.i509.fabric.trampoline.impl.ClientConnectionExtensions; 6 | import net.minecraft.network.ClientConnection; 7 | import net.minecraft.server.network.ServerLoginNetworkHandler; 8 | import net.minecraft.server.network.ServerPlayerEntity; 9 | import net.minecraft.text.Text; 10 | import org.objectweb.asm.Opcodes; 11 | import org.spongepowered.asm.mixin.Final; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.Shadow; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | 18 | import java.util.UUID; 19 | 20 | @Mixin(ServerLoginNetworkHandler.class) 21 | public abstract class ServerLoginNetworkHandlerMixin { 22 | @Shadow public abstract void disconnect(Text reason); 23 | @Shadow private GameProfile profile; 24 | @Shadow @Final public ClientConnection connection; 25 | 26 | @Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerLoginNetworkHandler$State;READY_TO_ACCEPT:Lnet/minecraft/server/network/ServerLoginNetworkHandler$State;", opcode = Opcodes.GETSTATIC), method = "onHello(Lnet/minecraft/network/packet/c2s/login/LoginHelloC2SPacket;)V", cancellable = true) 27 | public void onHello(CallbackInfo ci) { 28 | UUID uuid; 29 | ClientConnectionExtensions bungeeConnection = (ClientConnectionExtensions) connection; 30 | 31 | if (bungeeConnection.getSpoofedUUID() != null) { 32 | uuid = bungeeConnection.getSpoofedUUID(); 33 | } else { 34 | uuid = ServerPlayerEntity.getOfflinePlayerUuid(this.profile.getName()); 35 | } 36 | 37 | this.profile = new GameProfile(uuid, this.profile.getName()); 38 | 39 | if (bungeeConnection.getSpoofedProfile() != null) { 40 | for (com.mojang.authlib.properties.Property property : bungeeConnection.getSpoofedProfile()) { 41 | this.profile.getProperties().put(property.getName(), property); 42 | } 43 | } 44 | 45 | TrampolineServerMod.LOGGER.info("Connecting player player {} with uuid {}", profile.getName(), profile.getId()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/mixin/ServerHandshakeNetworkHandlerMixin.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.mixin; 2 | 3 | import me.i509.fabric.trampoline.mixin.accessors.HandshakeC2SPacketAccessor; 4 | import me.i509.fabric.trampoline.impl.ClientConnectionExtensions; 5 | 6 | import net.minecraft.network.ClientConnection; 7 | import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; 8 | import net.minecraft.network.packet.s2c.login.LoginDisconnectS2CPacket; 9 | import net.minecraft.server.network.ServerHandshakeNetworkHandler; 10 | import net.minecraft.text.LiteralText; 11 | import net.minecraft.text.Text; 12 | 13 | import com.google.gson.Gson; 14 | import org.spongepowered.asm.mixin.Final; 15 | import org.spongepowered.asm.mixin.Mixin; 16 | import org.spongepowered.asm.mixin.Shadow; 17 | import org.spongepowered.asm.mixin.Unique; 18 | import org.spongepowered.asm.mixin.injection.At; 19 | import org.spongepowered.asm.mixin.injection.At.Shift; 20 | import org.spongepowered.asm.mixin.injection.Inject; 21 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 22 | 23 | @Mixin(ServerHandshakeNetworkHandler.class) 24 | public abstract class ServerHandshakeNetworkHandlerMixin { 25 | @Shadow @Final private ClientConnection connection; 26 | 27 | @Unique private static final Gson GSON = new Gson(); 28 | 29 | @Inject(at = @At(value = "INVOKE", target = "net/minecraft/network/ClientConnection.setPacketListener(Lnet/minecraft/network/listener/PacketListener;)V", ordinal = 0, shift = Shift.AFTER), method = "onHandshake(Lnet/minecraft/network/packet/c2s/handshake/HandshakeC2SPacket;)V") 30 | public void onHandshake(HandshakeC2SPacket handshakePacket, CallbackInfo ci) { 31 | ClientConnectionExtensions connectionExtensions = (ClientConnectionExtensions) connection; 32 | 33 | HandshakeC2SPacketAccessor packetAccessor = (HandshakeC2SPacketAccessor) handshakePacket; 34 | 35 | String[] split = packetAccessor.getAddress().split("\00"); 36 | 37 | if (split.length == 3 || split.length == 4) { 38 | packetAccessor.setAddress(split[0]); 39 | connectionExtensions.setRealAddress(new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) connection.getAddress()).getPort())); 40 | connectionExtensions.setSpoofedUUID(com.mojang.util.UUIDTypeAdapter.fromString(split[2])); 41 | } else { 42 | Text text = new LiteralText("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!"); 43 | connection.send(new LoginDisconnectS2CPacket(text)); 44 | connection.disconnect(text); 45 | return; 46 | } 47 | 48 | if (split.length == 4) { 49 | connectionExtensions.setSpoofedProfile(GSON.fromJson(split[3], com.mojang.authlib.properties.Property[].class)); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /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 init 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 init 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 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /src/main/java/me/i509/fabric/trampoline/impl/TrampolineCommands.java: -------------------------------------------------------------------------------- 1 | package me.i509.fabric.trampoline.impl; 2 | 3 | import static net.minecraft.command.arguments.EntityArgumentType.getPlayer; 4 | import static net.minecraft.command.arguments.EntityArgumentType.player; 5 | import static net.minecraft.server.command.CommandManager.*; 6 | import static net.minecraft.server.command.CommandManager.argument; 7 | 8 | import com.mojang.authlib.GameProfile; 9 | import com.mojang.brigadier.CommandDispatcher; 10 | import com.mojang.brigadier.context.CommandContext; 11 | import com.mojang.brigadier.exceptions.CommandSyntaxException; 12 | import com.mojang.brigadier.tree.ArgumentCommandNode; 13 | import com.mojang.brigadier.tree.LiteralCommandNode; 14 | import com.mojang.brigadier.tree.RootCommandNode; 15 | 16 | import net.minecraft.command.EntitySelector; 17 | import net.minecraft.entity.player.PlayerEntity; 18 | import net.minecraft.server.command.ServerCommandSource; 19 | import net.minecraft.server.network.ServerPlayerEntity; 20 | import net.minecraft.text.ClickEvent; 21 | import net.minecraft.text.LiteralText; 22 | import net.minecraft.text.Text; 23 | import net.minecraft.text.TextColor; 24 | import net.minecraft.util.Formatting; 25 | 26 | final class TrampolineCommands { 27 | static void registerCommands(CommandDispatcher dispatcher, boolean dedicated) { 28 | final RootCommandNode root = dispatcher.getRoot(); 29 | final LiteralCommandNode bungee = literal("bungee-trampoline") 30 | .executes(TrampolineCommands::aboutThis) 31 | .build(); 32 | final LiteralCommandNode trampoline = literal("trampoline") 33 | .executes(TrampolineCommands::aboutThis) 34 | .redirect(bungee) 35 | .build(); 36 | final LiteralCommandNode info = literal("info") 37 | .requires(s -> s.hasPermissionLevel(4)) 38 | .executes(TrampolineCommands::getInfoSelf) 39 | .build(); 40 | final ArgumentCommandNode otherTarget = argument("player", player()) 41 | .requires(s -> s.hasPermissionLevel(4)) 42 | .executes(TrampolineCommands::getInfoTargetted) 43 | .build(); 44 | 45 | info.addChild(otherTarget); 46 | 47 | bungee.addChild(info); 48 | 49 | root.addChild(bungee); 50 | root.addChild(trampoline); 51 | } 52 | 53 | private static int getInfoSelf(CommandContext context) throws CommandSyntaxException { 54 | final ServerCommandSource source = context.getSource(); 55 | return getInfo(source, source.getPlayer()); 56 | } 57 | 58 | private static int getInfoTargetted(CommandContext context) throws CommandSyntaxException { 59 | final ServerCommandSource source = context.getSource(); 60 | final ServerPlayerEntity target = getPlayer(context, "player"); 61 | 62 | return getInfo(source, target); 63 | } 64 | 65 | private static int getInfo(ServerCommandSource source, ServerPlayerEntity target) { 66 | final GameProfile profile = target.getGameProfile(); 67 | 68 | source.sendFeedback(TrampolineCommands.createUsernameText(target), false); 69 | source.sendFeedback(TrampolineCommands.createDisplayNameText(target), false); 70 | source.sendFeedback(TrampolineCommands.createAddressText(target), false); 71 | source.sendFeedback(TrampolineCommands.createOnlineUuidText(profile), false); 72 | source.sendFeedback(TrampolineCommands.createOfflineUuidText(profile), false); 73 | return 1; 74 | } 75 | 76 | private static String getOfflineUUID(GameProfile profile) { 77 | return PlayerEntity.getOfflinePlayerUuid(profile.getName()).toString(); 78 | } 79 | 80 | private static Text createDisplayNameText(ServerPlayerEntity player) { 81 | return new LiteralText("Display Name: ").append(player.getDisplayName()); 82 | } 83 | 84 | private static Text createUsernameText(ServerPlayerEntity player) { 85 | return new LiteralText("Username: ").formatted(Formatting.GOLD) 86 | .append(player.getEntityName()); 87 | } 88 | 89 | private static Text createAddressText(ServerPlayerEntity player) { 90 | return new LiteralText("Connected IP Address: ").formatted(Formatting.GOLD) 91 | .append(new LiteralText(player.getIp())); 92 | } 93 | 94 | private static Text createOnlineUuidText(GameProfile profile) { 95 | return new LiteralText("Online-Mode/Current UUID:").formatted(Formatting.GOLD) 96 | .append(new LiteralText(profile.getId().toString())); 97 | } 98 | 99 | private static Text createOfflineUuidText(GameProfile profile) { 100 | return new LiteralText("Calculated Offline-Mode UUID: ").formatted(Formatting.GOLD) 101 | .append(new LiteralText(TrampolineCommands.getOfflineUUID(profile))); 102 | } 103 | 104 | private static int aboutThis(CommandContext context) { 105 | final ServerCommandSource source = context.getSource(); 106 | 107 | source.sendFeedback(new LiteralText("Trampoline").styled(style -> { 108 | return style.withColor(TextColor.parse("#FFA500")) 109 | .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/i509VCB/Trampoline")); 110 | }), false); 111 | 112 | source.sendFeedback(new LiteralText("Allows IP-Forwarding to Fabric servers connected via a Bungeecord proxy.") 113 | .formatted(Formatting.GRAY), false); 114 | source.sendFeedback(new LiteralText("By i509VCB") 115 | .styled(style -> style.withColor(TextColor.parse("#FFA500"))), false); 116 | return 1; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | --------------------------------------------------------------------------------