Skip to content

Commit 91a0a47

Browse files
feat: add lobby command with reload functionality and update permissions
1 parent 4a1babb commit 91a0a47

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/main/kotlin/dev/slne/surf/lobby/PaperMain.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.slne.surf.lobby
22

33
import com.github.shynixn.mccoroutine.folia.SuspendingJavaPlugin
4+
import dev.slne.surf.lobby.command.lobbyCommand
45
import dev.slne.surf.lobby.config.LobbyConfig
56
import dev.slne.surf.lobby.hologram.SurfHologramHook
67
import dev.slne.surf.lobby.listener.DoubleJumpListener
@@ -28,6 +29,8 @@ class PaperMain : SuspendingJavaPlugin() {
2829
SpawnLocationListener.register()
2930
GameModeListener.register()
3031
WorldProtectionListener.register()
32+
33+
lobbyCommand()
3134
}
3235
}
3336

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package dev.slne.surf.lobby.command
2+
3+
import dev.jorel.commandapi.kotlindsl.anyExecutor
4+
import dev.jorel.commandapi.kotlindsl.commandTree
5+
import dev.jorel.commandapi.kotlindsl.literalArgument
6+
import dev.slne.surf.lobby.config.LobbyConfig
7+
import dev.slne.surf.lobby.utils.PermissionRegistry
8+
import dev.slne.surf.surfapi.core.api.messages.adventure.sendText
9+
10+
fun lobbyCommand() = commandTree("lobby") {
11+
withPermission(PermissionRegistry.COMMAND_LOBBY)
12+
13+
literalArgument("reload") {
14+
withPermission(PermissionRegistry.COMMAND_LOBBY_RELOAD)
15+
anyExecutor { executor, _ ->
16+
LobbyConfig.reloadFromFile()
17+
18+
executor.sendText {
19+
appendPrefix()
20+
success("Lobby configuration reloaded successfully.")
21+
}
22+
}
23+
}
24+
}

src/main/kotlin/dev/slne/surf/lobby/utils/PermissionRegistry.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ object PermissionRegistry : PermissionRegistry() {
77
private const val PREFIX = "surf.lobby"
88
private const val COMMAND_PREFIX = "$PREFIX.command"
99

10-
val LOBBY = create("$COMMAND_PREFIX.lobby")
10+
val COMMAND_LOBBY = create("$COMMAND_PREFIX.lobby")
11+
val COMMAND_LOBBY_RELOAD = create("$COMMAND_PREFIX.lobby.reload")
1112

1213
val PUSHBACK_ATTACK = create("$PREFIX.pushback.attack")
1314
val PUSHBACK_ITEM = create("$PREFIX.pushback.item")

0 commit comments

Comments
 (0)