-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: swap to brigadier commands
- Loading branch information
Showing
5 changed files
with
38 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
group=com.mineinabyss | ||
version=0.23 | ||
idofrontVersion=0.25.5 | ||
idofrontVersion=0.25.17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[versions] | ||
geary = "0.30.17" | ||
geary = "0.31.0" | ||
|
||
[libraries] | ||
geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "geary" } |
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/com/mineinabyss/staminaclimb/StaminaAddon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.mineinabyss.staminaclimb | ||
|
||
import com.mineinabyss.geary.addons.dsl.createAddon | ||
import com.mineinabyss.geary.autoscan.autoscan | ||
|
||
val StaminaAddon = createAddon("StaminaClimb", configuration = { | ||
autoscan(StaminaClimbPlugin::class.java.classLoader, "com.mineinabyss.staminaclimb") { | ||
all() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 21 additions & 49 deletions
70
src/main/kotlin/com/mineinabyss/staminaclimb/StaminaCommands.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,36 @@ | ||
package com.mineinabyss.staminaclimb | ||
|
||
import com.mineinabyss.idofront.commands.execution.IdofrontCommandExecutor | ||
import com.mineinabyss.idofront.commands.extensions.actions.playerAction | ||
import com.mineinabyss.idofront.commands.brigadier.commands | ||
import com.mineinabyss.idofront.messaging.info | ||
import com.mineinabyss.idofront.messaging.success | ||
import com.mineinabyss.staminaclimb.climbing.ClimbBehaviour | ||
import com.mineinabyss.staminaclimb.modules.stamina | ||
import com.mineinabyss.staminaclimb.nms.Tags | ||
import com.mineinabyss.staminaclimb.stamina.StaminaBar | ||
import org.bukkit.command.Command | ||
import org.bukkit.command.CommandSender | ||
import org.bukkit.command.TabCompleter | ||
|
||
class StaminaCommands : IdofrontCommandExecutor(), TabCompleter { | ||
override val commands = commands(stamina.plugin) { | ||
"climb" { | ||
permission = "staminaclimb.toggle" | ||
playerAction { | ||
player.climbEnabled = !player.climbEnabled | ||
if (player.climbEnabled) Tags.enableClimb(player) | ||
else Tags.disableClimb(player) | ||
player.info("Stamina and climbing system: ${if (player.climbEnabled) "ON" else "OFF"}!") | ||
} | ||
} | ||
"staminaclimb" { | ||
"reload" { | ||
action { | ||
stamina.staminaTask.cancel() | ||
stamina.plugin.createClimbContext() | ||
stamina.staminaTask.runTaskTimer(stamina.plugin, 0, 1) | ||
StaminaBar.conf = stamina.config | ||
ClimbBehaviour.conf = stamina.config | ||
sender.success("Config has been reloaded!") | ||
object StaminaCommands { | ||
fun registerCommands() { | ||
stamina.plugin.commands { | ||
"climb" { | ||
requiresPermission("") | ||
playerExecutes { | ||
player.climbEnabled = !player.climbEnabled | ||
if (player.climbEnabled) Tags.enableClimb(player) | ||
else Tags.disableClimb(player) | ||
player.info("Stamina and climbing system: ${if (player.climbEnabled) "ON" else "OFF"}!") | ||
} | ||
} | ||
"tags" { | ||
action { | ||
// stamina.emptyClimbableMap.entries.find { it.key == BlockTags.CLIMBABLE.location }?.let { | ||
// sender.info("Empty climbable tag: ${it.value.joinToString { BuiltInRegistries.BLOCK.getHolder(it).getOrNull()?.registeredName.toString() }}") | ||
// } | ||
// stamina.normalClimbableMap.entries.find { it.key == BlockTags.CLIMBABLE.location }?.let { | ||
// sender.info("Normal Climbable Tag: ${it.value.joinToString { BuiltInRegistries.BLOCK.getHolder(it).getOrNull()?.registeredName.toString() }}") | ||
// } | ||
"reload" { | ||
requiresPermission("staminaclimb.reload") | ||
executes { | ||
stamina.staminaTask.cancel() | ||
stamina.plugin.createClimbContext() | ||
stamina.staminaTask.runTaskTimer(stamina.plugin, 0, 1) | ||
StaminaBar.conf = stamina.config | ||
ClimbBehaviour.conf = stamina.config | ||
sender.success("Config has been reloaded!") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onTabComplete( | ||
sender: CommandSender, | ||
command: Command, | ||
label: String, | ||
args: Array<out String> | ||
): List<String> { | ||
return if (command.name == "staminaclimb") { | ||
when (args.size) { | ||
1 -> listOf("reload") | ||
else -> emptyList() | ||
} | ||
} else emptyList() | ||
} | ||
|
||
} |