aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/io/github
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/io/github')
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt19
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/util/mcaccessor.kt24
2 files changed, 42 insertions, 1 deletions
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 {
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/mcaccessor.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/mcaccessor.kt
new file mode 100644
index 00000000..6d0c72cf
--- /dev/null
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/mcaccessor.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2023 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.util
+
+import net.minecraft.client.Minecraft
+
+inline val MC get() = Minecraft.getMinecraft()