From c5986c7a33a6496b81be6cc3b15584cb2152cbd7 Mon Sep 17 00:00:00 2001 From: Shynixn Date: Wed, 14 Aug 2024 21:13:47 +0200 Subject: [PATCH] #38,#36 Added support for 1.21.1 and added set placeholders. --- build.gradle.kts | 6 +++--- docs/wiki/docs/placeholders.md | 9 ++++++--- .../com/github/shynixn/mctennis/contract/TennisGame.kt | 5 +++++ .../github/shynixn/mctennis/enumeration/PlaceHolder.kt | 3 +++ .../com/github/shynixn/mctennis/impl/TennisGameImpl.kt | 7 +++++++ .../mctennis/impl/service/PlaceHolderServiceImpl.kt | 9 +++++++++ src/main/resources/plugin-legacy.yml | 2 +- src/main/resources/plugin.yml | 2 +- 8 files changed, 35 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 56fd9c6..e5c4830 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "com.github.shynixn" -version = "1.6.1" +version = "1.7.0" repositories { mavenCentral() @@ -38,9 +38,9 @@ dependencies { implementation("com.google.code.gson:gson:2.8.6") // Custom dependencies - implementation("com.github.shynixn.mcutils:common:2024.19") + implementation("com.github.shynixn.mcutils:common:2024.21") implementation("com.github.shynixn.mcutils:guice:2024.2") - implementation("com.github.shynixn.mcutils:packet:2024.32") + implementation("com.github.shynixn.mcutils:packet:2024.33") implementation("com.github.shynixn.mcutils:sign:2024.3") // Test diff --git a/docs/wiki/docs/placeholders.md b/docs/wiki/docs/placeholders.md index 22ea6c5..22efe53 100644 --- a/docs/wiki/docs/placeholders.md +++ b/docs/wiki/docs/placeholders.md @@ -12,9 +12,12 @@ The following placeholders are available in MCTennis and can also be used via Pl | %mctennis_game_isJoinAble% | true if the game can be joined, false if not | | %mctennis_game_isRunning% | true if the game is running, false if not | | %mctennis_game_displayName% | DisplayName of a game. | -| %mctennis_game_rawScoreTeamRed% | Score of team red | -| %mctennis_game_rawScoreTeamBlue% | Score of team blue | -| %mctennis_game_score% | Overall game score | +| %mctennis_game_score% | Score of both teams with text | +| %mctennis_game_rawScoreTeamRed% | Numeric score of team red | +| %mctennis_game_rawScoreTeamBlue% | Numeric score of team blue | +| %mctennis_game_currentSet% | The current set | +| %mctennis_game_wonSetsTeamRed% | Number of won sets of team red | +| %mctennis_game_wonSetsTeamBlue% | Number of won sets of team blue | | %mctennis_game_state% | State of the game: DISABLED, JOINABLE, RUNNING | | %mctennis_game_stateDisplayName% | State of the game with color codes | | %mctennis_game_players% | Current amount of players in the game | diff --git a/src/main/kotlin/com/github/shynixn/mctennis/contract/TennisGame.kt b/src/main/kotlin/com/github/shynixn/mctennis/contract/TennisGame.kt index 65fc160..e76f36e 100644 --- a/src/main/kotlin/com/github/shynixn/mctennis/contract/TennisGame.kt +++ b/src/main/kotlin/com/github/shynixn/mctennis/contract/TennisGame.kt @@ -59,6 +59,11 @@ interface TennisGame { */ val teamBlueSetScore: Int + /** + * The index number of the current set. + */ + val currentSet : Int + /** * Gets the team who is serving. */ diff --git a/src/main/kotlin/com/github/shynixn/mctennis/enumeration/PlaceHolder.kt b/src/main/kotlin/com/github/shynixn/mctennis/enumeration/PlaceHolder.kt index 72a2307..68d2c61 100644 --- a/src/main/kotlin/com/github/shynixn/mctennis/enumeration/PlaceHolder.kt +++ b/src/main/kotlin/com/github/shynixn/mctennis/enumeration/PlaceHolder.kt @@ -9,6 +9,9 @@ enum class PlaceHolder(val fullPlaceHolder: String) { GAME_RAWSCORETEAMRED("%mctennis_game_rawScoreTeamRed%"), GAME_RAWSCORETEAMBLUE("%mctennis_game_rawScoreTeamBlue%"), GAME_SCORE("%mctennis_game_score%"), + GAME_CURRENT_SET("%mctennis_game_currentSet%"), + GAME_WON_SETS_TEAM_RED("%mctennis_game_wonSetsTeamRed%"), + GAME_WON_SETS_TEAM_BLUE("%mctennis_game_wonSetsTeamBlue%"), GAME_STATE("%mctennis_game_state%"), GAME_STATE_DISPLAYNAME("%mctennis_game_stateDisplayName%"), GAME_PLAYER_AMOUNT("%mctennis_game_players%"), diff --git a/src/main/kotlin/com/github/shynixn/mctennis/impl/TennisGameImpl.kt b/src/main/kotlin/com/github/shynixn/mctennis/impl/TennisGameImpl.kt index d530bc0..9f4bfa9 100644 --- a/src/main/kotlin/com/github/shynixn/mctennis/impl/TennisGameImpl.kt +++ b/src/main/kotlin/com/github/shynixn/mctennis/impl/TennisGameImpl.kt @@ -96,6 +96,11 @@ class TennisGameImpl( */ override var teamBlueSetScore: Int = 0 + /** + * The index number of the current set. + */ + override var currentSet: Int = 1 + /** * Gets the team who is serving. */ @@ -450,6 +455,8 @@ class TennisGameImpl( */ private suspend fun winSet(team: Team) { gameState = GameState.ENDING + currentSet++ + when (team) { Team.RED -> { teamRedSetScore++ diff --git a/src/main/kotlin/com/github/shynixn/mctennis/impl/service/PlaceHolderServiceImpl.kt b/src/main/kotlin/com/github/shynixn/mctennis/impl/service/PlaceHolderServiceImpl.kt index da8adee..b0bd0f2 100644 --- a/src/main/kotlin/com/github/shynixn/mctennis/impl/service/PlaceHolderServiceImpl.kt +++ b/src/main/kotlin/com/github/shynixn/mctennis/impl/service/PlaceHolderServiceImpl.kt @@ -108,6 +108,15 @@ class PlaceHolderServiceImpl @Inject constructor(private val gameService: GameSe "0" } } + gamePlayerHolderFunctions[PlaceHolder.GAME_CURRENT_SET] = { g -> + g.currentSet.toString() + } + gamePlayerHolderFunctions[PlaceHolder.GAME_WON_SETS_TEAM_BLUE] = { g -> + g.teamBlueSetScore.toString() + } + gamePlayerHolderFunctions[PlaceHolder.GAME_WON_SETS_TEAM_RED] = { g -> + g.teamRedSetScore.toString() + } // Game and Player gameAndPlayerHolderFunctions[PlaceHolder.GAME_ISTEAMBLUEPLAYER] = diff --git a/src/main/resources/plugin-legacy.yml b/src/main/resources/plugin-legacy.yml index 5817150..6eb6f0e 100644 --- a/src/main/resources/plugin-legacy.yml +++ b/src/main/resources/plugin-legacy.yml @@ -1,5 +1,5 @@ name: MCTennis -version: 1.6.1 +version: 1.7.0 author: Shynixn website: https://www.spigotmc.org/members/shynixn.63455/ main: com.github.shynixn.mctennis.MCTennisPlugin diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7aedcc6..b3f70fb 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: MCTennis -version: 1.6.1 +version: 1.7.0 author: Shynixn website: https://www.spigotmc.org/members/shynixn.63455/ main: com.github.shynixn.mctennis.MCTennisPlugin