-
Notifications
You must be signed in to change notification settings - Fork 1
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
cizetux
wants to merge
23
commits into
main
Choose a base branch
from
feat/add_commands
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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 4a43712
feat(commands): add permission checks to subcommands
cizetux 1a769a4
feat: add new unwanted events
cizetux 1cb6aeb
feat: add kit feature system for custom items
cizetux e06140e
chore: update commandAPIVersion
cizetux a3ea84e
feat: update map config with minPlayers and mapCuboid settings
cizetux d256c0e
refactor: use getGame instead of getByWorld
cizetux 5473c1b
feat: add minPlayers and mapCuboid
cizetux f33ccc7
refactor: improve world object copying
cizetux e64d99c
refactor: update kit sending method
cizetux 292d84d
feat: add respawnState and initial coins
cizetux 10ee0da
chore: add some translations
cizetux cd7278c
feat: initial commit
cizetux 73b0a41
feat: add feedback messages
cizetux 20c22b6
chore: add some kits
cizetux ee9725e
chore: change world border location
cizetux 0f21f77
chore: update commandAPI version
cizetux fc885ec
feat: add register kit feature
cizetux b73014d
feat: add support for kit features
cizetux 0f1c4b8
refactor: change game state name
cizetux 3234d4d
feat: add new subcommands and permissions
cizetux 35e0a54
refactor: enhance with state handling and data updates
cizetux cec627c
feat: start game automatically when minimum players are reached
cizetux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -30,25 +30,54 @@ class RTFCommand( | |
suspend fun register() { | ||
commandAPICommand("rtf") { | ||
|
||
subcommand("spectate") { | ||
|
||
withArguments(IntegerArgument("game")) | ||
|
||
subcommand("create") { | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
game?.clientSpectate(clients.getClient(player) as ClientRTF) | ||
} | ||
} | ||
} | ||
} | ||
|
||
subcommand("join") { | ||
playerExecutor { player, _ -> | ||
val game = games.getByWorld(player.world) ?: return@playerExecutor | ||
|
@@ -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") | ||
} | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.