summaryrefslogtreecommitdiff
path: root/src/main/kotlin/io/dico/parcels2/command/CommandsDebug.kt
blob: 8f7f6ba62f7743682cbc274ade8e5889c160f817 (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
package io.dico.parcels2.command

import io.dico.dicore.command.CommandException
import io.dico.dicore.command.annotation.Cmd
import io.dico.parcels2.ParcelsPlugin
import org.bukkit.Bukkit
import org.bukkit.entity.Player

class CommandsDebug(val plugin: ParcelsPlugin) {

    @Cmd("reloadoptions")
    fun reloadOptions() {
        plugin.loadOptions()
    }

    @Cmd("tpworld")
    fun tpWorld(sender: Player, worldName: String): String {
        if (worldName == "list") {
            return Bukkit.getWorlds().joinToString("\n- ", "- ", "")
        }
        val world = Bukkit.getWorld(worldName) ?: throw CommandException("World $worldName is not loaded")
        sender.teleport(world.spawnLocation)
        return "Teleported you to $worldName spawn"
    }

}