aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt
blob: 3e5405a7b8c886e965b4bf9384afbb3a5eebdf0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package dulkirmod.command

import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.Config
import net.minecraft.client.Minecraft
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
import net.minecraft.util.ChatComponentText
import net.minecraft.util.EnumChatFormatting

class JoinDungeonCommand : ClientCommandBase("joindungeon") {
    @Throws(CommandException::class)
    override fun processCommand(sender: ICommandSender, args: Array<String>) {
        var arguments = args.contentToString().replace("[", "").replace("]", "").replace(",","")
        println(arguments)
        var type = ""
        var num = ""
        println(args[0])
        if (args[0] == "master_catacombs") {
            type = "M"
        }
        else if (args[0] == "catacombs") {
            type = "F"
        }

        // Try statement so message is consistent if user gives bad input
        try {
            if (args[1].toInt() in 1..7) {
                num = args[1]
            }
        } catch (e: NumberFormatException) { }

        if(Config.dungeonCommandConfirm) {
            mc.thePlayer.addChatMessage(
                ChatComponentText(
                    EnumChatFormatting.GOLD.toString() + "" + EnumChatFormatting.BOLD + "Running command: $type$num"
                )
            )
        }
        mc.thePlayer.sendChatMessage("/joindungeon $arguments")
    }
}