Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(commands): Add commands to easily manage games #3

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1c72487
feat(commands): Add commands to easily manage games
cizetux Mar 30, 2024
4a43712
feat(commands): add permission checks to subcommands
cizetux Apr 12, 2024
1a769a4
feat: add new unwanted events
cizetux May 29, 2024
1cb6aeb
feat: add kit feature system for custom items
cizetux May 29, 2024
e06140e
chore: update commandAPIVersion
cizetux Jun 2, 2024
a3ea84e
feat: update map config with minPlayers and mapCuboid settings
cizetux Jun 3, 2024
d256c0e
refactor: use getGame instead of getByWorld
cizetux Jun 3, 2024
5473c1b
feat: add minPlayers and mapCuboid
cizetux Jun 3, 2024
f33ccc7
refactor: improve world object copying
cizetux Jun 3, 2024
e64d99c
refactor: update kit sending method
cizetux Jun 3, 2024
292d84d
feat: add respawnState and initial coins
cizetux Jul 3, 2024
10ee0da
chore: add some translations
cizetux Jul 3, 2024
cd7278c
feat: initial commit
cizetux Jul 3, 2024
73b0a41
feat: add feedback messages
cizetux Jul 3, 2024
20c22b6
chore: add some kits
cizetux Jul 3, 2024
ee9725e
chore: change world border location
cizetux Jul 3, 2024
0f21f77
chore: update commandAPI version
cizetux Jul 3, 2024
fc885ec
feat: add register kit feature
cizetux Jul 3, 2024
b73014d
feat: add support for kit features
cizetux Jul 9, 2024
0f1c4b8
refactor: change game state name
cizetux Jul 9, 2024
3234d4d
feat: add new subcommands and permissions
cizetux Jul 9, 2024
35e0a54
refactor: enhance with state handling and data updates
cizetux Jul 9, 2024
cec627c
feat: start game automatically when minimum players are reached
cizetux Jul 9, 2024
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
52 changes: 43 additions & 9 deletions src/main/kotlin/com/github/rushyverse/rtf/commands/RTFCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,54 @@ class RTFCommand(
suspend fun register() {
commandAPICommand("rtf") {

subcommand("spectate") {

withArguments(IntegerArgument("game"))

subcommand("create") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'create' subcommand is not permission secured.

withArguments(IntegerArgument("gameID"))
playerExecutor { player, args ->
val gameIndex = args[0] as Int
var game = games.getGame(gameIndex)

plugin.launch {

if (game == null && gameIndex == 1) {
if (game == null) {
game = games.createAndSave(gameIndex)
} else {
player.sendMessage("game.already.exists")
}

game?.clientSpectate(clients.getClient(player) as ClientRTF)
}
}
}

subcommand("list") {
playerExecutor { player, _ ->
val length = games.games.size
player.sendMessage("List of games ($length):")
for (game in games.games) {
player.sendMessage("#${game.id} - ${game.players.size}/${game.config.game.maxGames} - ${game.state()}")
}
}
}

subcommand("spectate") {
withArguments(IntegerArgument("gameID"))
playerExecutor { player, args ->
val gameIndex = args[0] as Int
var game = games.getGame(gameIndex)

if (game == null) {
player.sendMessage("game.not.exists")
} else {
plugin.launch {

game = games.createAndSave(gameIndex)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'spectate' subcommand is not correct because it re-creates an already existing game. You can delete this line.
This means that it will be necessary to review the game creation logic from the main Hub menu.


game?.clientSpectate(clients.getClient(player) as ClientRTF)
}
}
}
}

subcommand("join") {
playerExecutor { player, _ ->
val game = games.getByWorld(player.world) ?: return@playerExecutor
Expand Down Expand Up @@ -105,10 +134,15 @@ class RTFCommand(

subcommand("end") {
withPermission("rtf.end")
playerExecutor { player, _ ->
val game = games.getByWorld(player.world) ?: return@playerExecutor

plugin.launch { game.end(null) }
withArguments(IntegerArgument("gameID"))
playerExecutor { player, args ->
val gameId = args[0] as Int
player.sendMessage("game.ask.delete")
val game = games.getGame(gameId)
plugin.launch {
game?.end(null)
player.sendMessage("game.deleted")
}
}
}
}
Expand Down