From 9ab6d23f94135da8555faaf8ef36f29d70029ceb Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Tue, 27 Jun 2023 22:28:21 +0200 Subject: Add joinServer command (#738) --- .../notenoughupdates/commands/dev/DevTestCommand.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt') diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt index 3292a9cf..e72a1ed4 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt @@ -36,6 +36,7 @@ import io.github.moulberry.notenoughupdates.util.brigadier.* import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen import net.minecraft.command.ICommandSender +import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.player.EntityPlayer import net.minecraft.launchwrapper.Launch import net.minecraft.util.ChatComponentText @@ -45,7 +46,6 @@ import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.function.Predicate import kotlin.math.floor -import kotlin.math.nextDown @NEUAutoSubscribe class DevTestCommand { @@ -106,6 +106,23 @@ class DevTestCommand { requires { canPlayerExecute(it) } + thenLiteral("joinServer") { + thenArgument("serverId", RestArgumentType) { serverId -> + thenExecute { + try { + MC.sessionService.joinServer( + MC.session.profile, + MC.session.token, + get(serverId) + ) + reply("Joined server ${get(serverId)}") + } catch (e: Exception) { + e.printStackTrace() + reply("Failed to join server") + } + } + }.withHelp("Send a joinServer request to mojang (to test authentication with the cape server)") + } thenLiteral("testsearch") { thenArgument("name", RestArgumentType) { arg -> thenExecute { -- cgit