Skip to content

Commit

Permalink
Merge pull request #590 from Shynixn/development
Browse files Browse the repository at this point in the history
Merge changes to master --release
  • Loading branch information
Shynixn authored Dec 20, 2024
2 parents 50421fe + ed788f9 commit 2eb4e7f
Show file tree
Hide file tree
Showing 19 changed files with 200 additions and 67 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BlockBall is a spigot plugin to play soccer games in Minecraft.

* Uses blocks as balls in minecraft
* Games are completely customizable
* Version support 1.8.R3 - 1.21.R2
* Version support 1.8.R3 - 1.21.R3
* Check out the [BlockBall-Spigot-Page](https://www.spigotmc.org/resources/15320/) to get more information.

## Installation
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "com.github.shynixn"
version = "7.8.0"
version = "7.9.0"

repositories {
mavenLocal()
Expand Down Expand Up @@ -251,7 +251,7 @@ tasks.register("languageFile") {
implContents.add("")
implContents.add("class BlockBallLanguageImpl : Language, LanguageProviderImpl() {")
implContents.add(" override val names: List<String>\n" +
" get() = listOf(\"en_us\", \"es_es\")")
" get() = listOf(\"en_us\", \"es_es\", \"zh_cn\")")

for (i in 0 until lines.size) {
val key = lines[i]
Expand Down
13 changes: 8 additions & 5 deletions docs/wiki/docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,26 @@ Enables or disables your game. If a game is disabled, nobody can join.
### /blockball join

```
/blockball join <name> [team]
/blockball join <name> [team] [player]
```

Lets the player executing the command join the game. The optional team argument allows to directly join a specific team.
If the team is full, the other team will be chosen. If no team is specified, a random team will be selected.
Lets the player executing the command join the game. If no team is specified, a random team will be selected.
If the player has already joined a game, this command can also be used to switch teams.

* Name: Identifier of a game
* Team: Name of the team. Is always red or blue.
* Team: Optional name of the team. Is ``red``, ``blue`` or ``referee``.
* Player: Optional name of the player to join. Requires the ``blockball.edit`` permission to use.

### /blockball leave

```
/blockball leave
/blockball leave [player]
```

Lets the player executing the command leave the game.

* Player: Optional name of the player to leave. Requires the ``blockball.edit`` permission to use.

### /blockball axe

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.github.shynixn.blockball.contract.Language

class BlockBallLanguageImpl : Language, LanguageProviderImpl() {
override val names: List<String>
get() = listOf("en_us", "es_es")
get() = listOf("en_us", "es_es", "zh_cn")
override var gameAlreadyExistsMessage = LanguageItem("&0&l[&f&lBlockBall&0&l]&c Game %1$1s already exists.")

override var commandUsage = LanguageItem("&0&l[&f&lBlockBall&0&l]&7 Use /blockball help to see more info about the plugin.")
Expand Down Expand Up @@ -103,7 +103,7 @@ class BlockBallLanguageImpl : Language, LanguageProviderImpl() {

override var commandToggleToolTip = LanguageItem("Enables or disables your game. If a game is disabled, nobody can join.")

override var commandJoinToolTip = LanguageItem("Lets the player executing the command join the game. The optional team argument allows to directly join a specific team. If the team is full, the other team will be chosen. If no team is specified, a random team will be selected.")
override var commandJoinToolTip = LanguageItem("Lets the player executing the command join the game. If no team is specified, a random team will be selected. If the player has already joined a game, this command can also be used to switch teams.")

override var commandLeaveToolTip = LanguageItem("Lets the player executing the command leave the game.")

Expand Down Expand Up @@ -190,4 +190,8 @@ class BlockBallLanguageImpl : Language, LanguageProviderImpl() {
override var commandPlaceHolderToolTip = LanguageItem("Resolves a given placeholder.")

override var commandPlaceHolderMessage = LanguageItem("Evaluated placeholder: %1$1s")

override var playerNotFoundMessage = LanguageItem("&0&l[&f&lBlockBall&0&l]&c Player %1$1s not found.")

override var queueTimeOutMessage = LanguageItem("&0&l[&f&lBlockBall&0&l]&c Not enough players joined in time to start the game.")
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,8 @@ interface Language : LanguageProvider {
var commandPlaceHolderToolTip: LanguageItem

var commandPlaceHolderMessage: LanguageItem

var playerNotFoundMessage: LanguageItem

var queueTimeOutMessage: LanguageItem
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ class CustomizationMeta{
* Should the players keep their health when they join a game?
*/
var keepHealthEnabled: Boolean = true

/**
* If set to true, the goal size can be arbitrary.
*/
var ignoreGoalSize: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class MinigameLobbyMeta {
/** Duration the match will max last. */
var lobbyDuration: Int = 20

/** Message being played in the action bar displaying the joined players how many players are remaining to start. */
var playersRequiredToStartMessage: String =
"%blockball_lang_miniGameRemainingPlayers%"

init {
val firstPeriod = MatchTimeMeta()
firstPeriod.duration = 150
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class SoccerArena : Selection(), Element{
/** Is the soccerArena ready to be placed. */
var enabled: Boolean = false

/**
* Amount of seconds until the queue timeouts.
*/
var queueTimeOutSec: Int = 30

/** [gameType] of the soccerArena */
var gameType: GameType = GameType.HUBGAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class SoccerBallSettings {
val soundEffects: MutableMap<BallActionType, SoundMeta> = HashMap()

/** Spawning delay. */
var delayInTicks: Int = 0
var delayInTicks: Int = 60

/** Spawnpoint of the ball. */
var spawnpoint: Vector3d? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,14 +796,13 @@ abstract class SoccerGameImpl(
* Teleports all players and ball back to their spawnpoint if [game] has got back teleport enabled.
*/
private fun relocatePlayersAndBall() {
respawnBall()

if (!arena.meta.customizingMeta.backTeleport) {
respawnBall()
return
}

val tickDelay = 20 * arena.meta.customizingMeta.backTeleportDelay

respawnBall(tickDelay)
plugin.launch {
delay(tickDelay.ticks)
var redTeamSpawnpoint = arena.meta.redTeamMeta.spawnpoint
Expand Down Expand Up @@ -934,8 +933,13 @@ abstract class SoccerGameImpl(
return
}

if (ball != null) {
ball!!.remove()
ball = null
}

ballSpawning = true
ballSpawnCounter = delayInTicks / 20
ballSpawnCounter = delayInTicks
}

fun getTeamMetaFromTeam(team: Team): TeamMeta {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ class SoccerHubGameImpl(

// Handle SoccerBall.
this.fixBallPositionSpawn()
if (ticks >= 20) {
this.handleBallSpawning()
}

this.handleBallSpawning()
// TODO: Minigame essentials. Update signs and protections.
super.handleMiniGameEssentials(ticks)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ open class SoccerMiniGameImpl constructor(
private val bossBarService: BossBarService,
private val chatMessageService: ChatMessageService,
private val soundService: SoundService,
language: Language,
private val language: Language,
packetService: PacketService,
scoreboardService: ScoreboardService,
commandService: CommandService,
Expand All @@ -45,6 +45,8 @@ open class SoccerMiniGameImpl constructor(
language,
playerDataRepository
), SoccerMiniGame {
private var currentQueueTime = arena.queueTimeOutSec
private var isQueueTimeRunning = false

/**
* Is the lobby countdown active.
Expand Down Expand Up @@ -85,6 +87,7 @@ open class SoccerMiniGameImpl constructor(
return JoinResult.GAME_FULL
}

queueTimeOut()
return super.join(player, team)
}

Expand Down Expand Up @@ -116,6 +119,8 @@ open class SoccerMiniGameImpl constructor(

if (ticks >= 20) {
if (lobbyCountDownActive) {
isQueueTimeRunning = false

if (lobbyCountdown > 10) {
val amountPlayers = arena.meta.blueTeamMeta.maxAmount + arena.meta.redTeamMeta.maxAmount

Expand Down Expand Up @@ -164,14 +169,6 @@ open class SoccerMiniGameImpl constructor(
if (canStartLobbyCountdown()) {
lobbyCountDownActive = true
lobbyCountdown = arena.meta.minigameMeta.lobbyDuration
} else if (!playing) {
ingamePlayersStorage.keys.toTypedArray().forEach { p ->
chatMessageService.sendActionBarMessage(
p, placeHolderService.replacePlaceHolders(
arena.meta.minigameMeta.playersRequiredToStartMessage, p, this
)
)
}
}
}

Expand Down Expand Up @@ -204,10 +201,7 @@ open class SoccerMiniGameImpl constructor(

// Handle SoccerBall.
this.fixBallPositionSpawn()
if (ticks >= 20) {
this.handleBallSpawning()
}

this.handleBallSpawning()
// Update signs and protections.
super.handleMiniGameEssentials(ticks)
}
Expand Down Expand Up @@ -346,4 +340,32 @@ open class SoccerMiniGameImpl constructor(

return false
}


private fun queueTimeOut() {
currentQueueTime = arena.queueTimeOutSec // Reset queue timer each time someone joins.

if (isQueueTimeRunning) {
return
}

isQueueTimeRunning = true
plugin.launch {
while (isQueueTimeRunning && status == GameState.JOINABLE) {
currentQueueTime -= 1

if (currentQueueTime <= 0) {
isQueueTimeRunning = false
for (player in ingamePlayersStorage.keys.toTypedArray()) {
language.sendMessage(language.queueTimeOutMessage, player)
leave(player)
}
status = GameState.JOINABLE
return@launch
}

delay(20.ticks)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,7 @@ class SoccerRefereeGameImpl constructor(

// Handle SoccerBall.
this.fixBallPositionSpawn()
if (ticks >= 20) {
this.handleBallSpawning()
}

this.handleBallSpawning()
// Update signs and protections.
super.handleMiniGameEssentials(ticks)
}
Expand Down
Loading

0 comments on commit 2eb4e7f

Please sign in to comment.