diff --git a/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/FoundationCorePlugin.kt b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/FoundationCorePlugin.kt index 3e42990..51e2301 100644 --- a/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/FoundationCorePlugin.kt +++ b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/FoundationCorePlugin.kt @@ -62,7 +62,9 @@ class FoundationCorePlugin : JavaPlugin(), Listener { registerCommandExecutor(listOf("adventure", "a"), GamemodeCommand(GameMode.ADVENTURE)) registerCommandExecutor(listOf("spectator", "sp"), GamemodeCommand(GameMode.SPECTATOR)) registerCommandExecutor(listOf("leaderboard", "lb"), LeaderboardCommand()) - registerCommandExecutor(listOf("pstore"), PersistentStoreCommand(this)) + registerCommandExecutor("pstore", PersistentStoreCommand(this)) + registerCommandExecutor("setspawn", SetSpawnCommand()) + registerCommandExecutor("spawn", SpawnCommand()) val log = slF4JLogger log.info("Features:") diff --git a/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/command/SetSpawnCommand.kt b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/command/SetSpawnCommand.kt new file mode 100644 index 0000000..85abd01 --- /dev/null +++ b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/command/SetSpawnCommand.kt @@ -0,0 +1,27 @@ +package cloud.kubelet.foundation.core.command + +import org.bukkit.command.Command +import org.bukkit.command.CommandExecutor +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player + +class SetSpawnCommand : CommandExecutor { + override fun onCommand( + sender: CommandSender, + command: Command, + label: String, + args: Array + ): Boolean { + if (sender !is Player) { + sender.sendMessage("You are not a player.") + return true + } + + val loc = sender.location + sender.world.setSpawnLocation(loc.blockX, loc.blockY, loc.blockZ) + + sender.sendMessage("World spawn point set.") + + return true + } +} diff --git a/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/command/SpawnCommand.kt b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/command/SpawnCommand.kt new file mode 100644 index 0000000..bf5c81b --- /dev/null +++ b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/command/SpawnCommand.kt @@ -0,0 +1,24 @@ +package cloud.kubelet.foundation.core.command + +import org.bukkit.command.Command +import org.bukkit.command.CommandExecutor +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player + +class SpawnCommand : CommandExecutor { + override fun onCommand( + sender: CommandSender, + command: Command, + label: String, + args: Array + ): Boolean { + if (sender !is Player) { + sender.sendMessage("You are not a player.") + return true + } + + sender.teleport(sender.world.spawnLocation) + + return true + } +} diff --git a/foundation-core/src/main/resources/plugin.yml b/foundation-core/src/main/resources/plugin.yml index 088f596..529c5eb 100644 --- a/foundation-core/src/main/resources/plugin.yml +++ b/foundation-core/src/main/resources/plugin.yml @@ -49,3 +49,11 @@ commands: description: Persistent Store Manager usage: /pstore permission: foundation.command.pstore + setspawn: + description: Set the spawn of the current world. + usage: /setspawn + permission: foundation.command.setspawn + spawn: + description: Teleport to the spawn of the current world. + usage: /spawn + permission: foundation.command.spawn