Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/basics-suicide/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| Command | Permission |
|------------|----------------|
| `/suicide` | basics.suicide |
3 changes: 3 additions & 0 deletions modules/basics-suicide/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id("basics.module")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.github.spigotbasics.modules.basicssuicide

import com.github.spigotbasics.core.command.parsed.CommandContextExecutor
import com.github.spigotbasics.core.command.parsed.context.MapContext
import com.github.spigotbasics.core.module.AbstractBasicsModule
import com.github.spigotbasics.core.module.loader.ModuleInstantiationContext
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player

class BasicsSuicideModule(context: ModuleInstantiationContext) : AbstractBasicsModule(context) {
private val permission =
permissionManager.createSimplePermission(
"basics.suicide",
"Allows the player to kill themself",
)

private fun msgSuicide(player: Player) = messages.getMessage("suicide").concerns(player)

override fun onEnable() {
commandFactory.parsedCommandBuilder("suicide", permission).mapContext {
description("Kills yourself")

path {
playerOnly()
}
}.executor(
object : CommandContextExecutor<MapContext> {
override fun execute(
sender: CommandSender,
context: MapContext,
) {
val player = sender as Player
player.health = 0.0
msgSuicide(player).sendToAllPlayers()
}
},
).register()
}
}
3 changes: 3 additions & 0 deletions modules/basics-suicide/src/main/resources/basics-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main-class: com.github.spigotbasics.modules.basicssuicide.BasicsSuicideModule
name: basics-suicide
version: ${moduleVersion}
1 change: 1 addition & 0 deletions modules/basics-suicide/src/main/resources/messages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
suicide: "<dark_text><player-dm> took their own life.</dark_text>"
Loading