diff options
author | nea <nea@nea.moe> | 2023-02-01 10:37:22 +0100 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-02-01 10:37:22 +0100 |
commit | 081345492c6817aef4eed855985b857c6ca2ec21 (patch) | |
tree | ca771f95952d7faa924a9beaae1626ec29bd5b01 /src/main/kotlin | |
parent | 4dd2232839a3f68833e5c7b36c7bd9b07fca1867 (diff) | |
download | NotEnoughUpdates-081345492c6817aef4eed855985b857c6ca2ec21.tar.gz NotEnoughUpdates-081345492c6817aef4eed855985b857c6ca2ec21.tar.bz2 NotEnoughUpdates-081345492c6817aef4eed855985b857c6ca2ec21.zip |
wip
Diffstat (limited to 'src/main/kotlin')
3 files changed, 64 insertions, 4 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/SimpleDevCommands.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/SimpleDevCommands.kt index 51e00c02..a42fc412 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/SimpleDevCommands.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/SimpleDevCommands.kt @@ -19,15 +19,17 @@ package io.github.moulberry.notenoughupdates.commands.dev +import com.mojang.brigadier.arguments.FloatArgumentType.floatArg import com.mojang.brigadier.arguments.StringArgumentType.string import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe import io.github.moulberry.notenoughupdates.dungeons.DungeonWin import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent -import io.github.moulberry.notenoughupdates.util.brigadier.get -import io.github.moulberry.notenoughupdates.util.brigadier.reply -import io.github.moulberry.notenoughupdates.util.brigadier.thenArgumentExecute -import io.github.moulberry.notenoughupdates.util.brigadier.thenExecute +import io.github.moulberry.notenoughupdates.miscfeatures.NullzeeSphere +import io.github.moulberry.notenoughupdates.util.brigadier.* +import net.minecraft.client.entity.EntityPlayerSP +import net.minecraft.event.ClickEvent +import net.minecraft.util.BlockPos import net.minecraft.util.ResourceLocation import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -50,5 +52,48 @@ class SimpleDevCommands { reply("Changed the dungeon win display") } } + event.command("neuenablestorage") { + thenLiteralExecute("disable") { + NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3 = true + NotEnoughUpdates.INSTANCE.saveConfig() + reply("Disabled the NEU storage overlay. Click here to enable again") { + chatStyle.chatClickEvent = ClickEvent( + ClickEvent.Action.SUGGEST_COMMAND, + "/neuenablestorage" + ) + } + } + thenExecute { + NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3 = true + NotEnoughUpdates.INSTANCE.saveConfig() + reply("Enabled the NEU storage overlay. Click here to disable again") { + chatStyle.chatClickEvent = ClickEvent( + ClickEvent.Action.SUGGEST_COMMAND, + "/neuenablestorage disable" + ) + } + } + } + event.command("neuzeesphere") { + thenLiteralExecute("on") { + NullzeeSphere.enabled = true + reply("Enabled nullzee sphere") + } + thenLiteralExecute("off") { + NullzeeSphere.enabled = false + reply("Disabled nullzee sphere") + } + thenLiteralExecute("setcenter") { + val p = source as EntityPlayerSP + NullzeeSphere.centerPos = BlockPos(p.posX, p.posY, p.posZ) + NullzeeSphere.overlayVBO = null + reply("Set center to ${NullzeeSphere.centerPos}") + } + thenArgumentExecute("radius", floatArg(0F)) { size -> + NullzeeSphere.size = this[size] + NullzeeSphere.overlayVBO = null + reply("Set size to ${this[size]}") + } + } } } diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.kt index a3e730cf..0b7ad503 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.kt @@ -19,10 +19,13 @@ package io.github.moulberry.notenoughupdates.commands.help +import com.mojang.brigadier.arguments.StringArgumentType.string import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent +import io.github.moulberry.notenoughupdates.util.brigadier.get import io.github.moulberry.notenoughupdates.util.brigadier.reply +import io.github.moulberry.notenoughupdates.util.brigadier.thenArgumentExecute import io.github.moulberry.notenoughupdates.util.brigadier.thenExecute import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -74,6 +77,14 @@ class HelpCommand { @SubscribeEvent fun onCommands(event: RegisterBrigadierCommandEvent) { event.command("neuhelp") { + thenArgumentExecute("command", string()) { commandName -> + val commandNode = event.dispatcher.root.getChild(this[commandName]) + if (commandNode == null) { + reply("Could not find NEU command with name ${this[commandName]}") + return@thenArgumentExecute + } + reply(event.dispatcher.getAllUsage(commandNode, source, true).joinToString("\n")) + } thenExecute { neuHelpMessages.forEach(::reply) if (NotEnoughUpdates.INSTANCE.config.hidden.dev) diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt index 841322b5..5c802c64 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt @@ -83,6 +83,10 @@ fun <T : ICommandSender, C : CommandContext<T>> C.reply(text: String) { source.addChatMessage(ChatComponentText(text)) } +fun <T : ICommandSender, C : CommandContext<T>> C.reply(text: String, block: ChatComponentText.() -> Unit) { + source.addChatMessage(ChatComponentText(text).also(block)) +} + operator fun <T : Any, C : CommandContext<*>> C.get(arg: TypeSafeArg<T>): T { return arg.get(this) } |