Skip to content

Commit

Permalink
#521 Fixed minigame creation and docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Aug 11, 2024
1 parent ff22262 commit 3a2c21b
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/wiki/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

BlockBall is a spigot plugin to play soccer/football games in Minecraft.

Are you looking for the 6.x.x wiki? You can access it via [the WayBackMachine](https://web.archive.org/web/20240811125048/https://shynixn.github.io/BlockBall/build/html/index.html).

## Features

* Adds a new playable soccer/football lobby game or standalone minigame
Expand Down
12 changes: 12 additions & 0 deletions docs/wiki/docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ Copies the armor inventory of the player executing the command. This copy will b
* Name: Identifier of a game
* Team: Name of the team. Is always red or blue.

### /blockball gamerule

```
/blockball gamerule <key> <name> <value>
```

Sets a gamerule of BlockBall.

* Key: The name of the gamerule.
* Name: Identifier of a game
* Value: Value of a gamerule. See tab completions for all values.

### /blockball sign

```
Expand Down
45 changes: 44 additions & 1 deletion docs/wiki/docs/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ Output:
game1 [My first game] [enabled]
```

You can join the game by running into the arena or executing the ``/blockball join game1`` command.

## Optional steps

The following steps are not necessary but allow you to further customize the experience.
Expand Down Expand Up @@ -137,7 +139,48 @@ Move to the second location and execute:
/blockball location game1 blue_spawnpoint
```

### Changing more options
## Creating a Minigame

### Converting the HUBGAME to a MINIGAME

* Currently, players can join and leave a game at any time. The timespan of a game is also infinity. In order to convert it to a standard Minecraft minigame, with a lobby
and a max time, you should execute the following command.
* If your arena has been enabled before, you may encounter and error message. You can ignore that because we will fix it in the next steps.

```
/blockball gamerule gameType game1 minigame
```

### Setting the team-lobby-spawnpoints

Move to the lobby spawnpoints of your teams and execute the corresponding commands.

```
/blockball location game1 red_lobby
```

```
/blockball location game1 blue_lobby
```

### Enabling the game

If your game is disabled in the game list, you should now be able to enable it with the toggle command.

```
/blockball list
```


```
/blockball toggle game1
```

## Half-time, over-time

You can configure periods like half-times, breaks and overtimes in your ``game1.yml`` file. See the further customization section below.

## Further Customizations

Further customization options can be found in the ``plugins/BlockBall/arena/<name>.yml`` file.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ object BlockBallLanguageImpl : BlockBallLanguage {
/** 20 **/
override var scoreRedFadeOut : String = "20"

/** &f&lLeave **/
override var leaveSignLine2 : String = "&f&lLeave"
/** &fLeave **/
override var leaveSignLine2 : String = "&fLeave"

/** %blockball_game_players%/%blockball_game_maxPlayers% **/
override var leaveSignLine3 : String = "%blockball_game_players%/%blockball_game_maxPlayers%"
Expand All @@ -129,6 +129,9 @@ object BlockBallLanguageImpl : BlockBallLanguage {
/** 60 **/
override var winRedStay : String = "60"

/** &0&l[&f&lBlockBall&0&l]&7 Updated a gamerule. **/
override var gameRuleChangedMessage : String = "&0&l[&f&lBlockBall&0&l]&7 Updated a gamerule."

/** Enables the player to add a specific sign by right-clicking any sign. You can remove signs by simply breaking the block. **/
override var commandSignToolTip : String = "Enables the player to add a specific sign by right-clicking any sign. You can remove signs by simply breaking the block."

Expand All @@ -138,6 +141,9 @@ object BlockBallLanguageImpl : BlockBallLanguage {
/** Copies the inventory of the player executing the command. This copy will be applied to players when they join a game. **/
override var commandInventoryToolTip : String = "Copies the inventory of the player executing the command. This copy will be applied to players when they join a game."

/** &0&l[&f&lBlockBall&0&l]&c GameType %1$1s does not exist. **/
override var gameTypeNotExistMessage : String = "&0&l[&f&lBlockBall&0&l]&c GameType %1$1s does not exist."

/** Enables or disables your game. If a game is disabled, nobody can join. **/
override var commandToggleToolTip : String = "Enables or disables your game. If a game is disabled, nobody can join."

Expand Down Expand Up @@ -216,6 +222,9 @@ object BlockBallLanguageImpl : BlockBallLanguage {
/** Allows to reload all games or a specific single one. **/
override var commandReloadToolTip : String = "Allows to reload all games or a specific single one."

/** Sets a gamerule in BlockBall. **/
override var commandGameRuleToolTip : String = "Sets a gamerule in BlockBall."

/** &4Disabled **/
override var gameStatusDisabled : String = "&4Disabled"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ interface BlockBallLanguage {
/** 20 **/
var scoreRedFadeOut : String

/** &f&lLeave **/
/** &fLeave **/
var leaveSignLine2 : String

/** %blockball_game_players%/%blockball_game_maxPlayers% **/
Expand All @@ -127,6 +127,9 @@ interface BlockBallLanguage {
/** 60 **/
var winRedStay : String

/** &0&l[&f&lBlockBall&0&l]&7 Updated a gamerule. **/
var gameRuleChangedMessage : String

/** Enables the player to add a specific sign by right-clicking any sign. You can remove signs by simply breaking the block. **/
var commandSignToolTip : String

Expand All @@ -136,6 +139,9 @@ interface BlockBallLanguage {
/** Copies the inventory of the player executing the command. This copy will be applied to players when they join a game. **/
var commandInventoryToolTip : String

/** &0&l[&f&lBlockBall&0&l]&c GameType %1$1s does not exist. **/
var gameTypeNotExistMessage : String

/** Enables or disables your game. If a game is disabled, nobody can join. **/
var commandToggleToolTip : String

Expand Down Expand Up @@ -214,6 +220,9 @@ interface BlockBallLanguage {
/** Allows to reload all games or a specific single one. **/
var commandReloadToolTip : String

/** Sets a gamerule in BlockBall. **/
var commandGameRuleToolTip : String

/** &4Disabled **/
var gameStatusDisabled : String

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.github.shynixn.blockball.enumeration

enum class GameRuleType {
GAME_TYPE
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ enum class LocationType {
LEAVE_SPAWNPOINT,
RED_SPAWNPOINT,
BLUE_SPAWNPOINT,
BALL
BALL,
RED_LOBBY,
BLUE_LOBBY,
}
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ abstract class SoccerGameImpl(
player.isFlying = false
player.walkSpeed = stats.walkingSpeed.toFloat()
player.level = stats.level
player.scoreboard = Bukkit.getScoreboardManager()!!.newScoreboard
player.exp = stats.exp.toFloat()
player.foodLevel = stats.hunger

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ class BlockBallCommandExecutor @Inject constructor(
}
}

private val gameTypeValidator = object : Validator<GameType> {
override suspend fun transform(
sender: CommandSender, prevArgs: List<Any>, openArgs: List<String>
): GameType? {
return GameType.values().firstOrNull { e -> e.name.equals(openArgs[0], true) }
}

override suspend fun message(sender: CommandSender, prevArgs: List<Any>, openArgs: List<String>): String {
return language.gameTypeNotExistMessage
}
}

private val locationTypeValidator = object : Validator<LocationType> {
override suspend fun transform(
sender: CommandSender,
Expand Down Expand Up @@ -262,6 +274,28 @@ class BlockBallCommandExecutor @Inject constructor(
setLocation(player, arena, locationType)
}
}
subCommand("gamerule") {
permission(Permission.EDIT_GAME)
toolTip { language.commandGameRuleToolTip }
subCommand("gameType") {
toolTip { language.commandGameRuleToolTip }
permission(Permission.EDIT_GAME)
builder().argument("name").validator(gameMustExistValidator).tabs(arenaTabs).argument("value")
.validator(gameTypeValidator)
.tabs {
GameType.values().map { e ->
e.name.lowercase(
Locale.ENGLISH
)
}
}.execute { sender, arena, gameType ->
arena.gameType = gameType
arenaRepository.save(arena)
sender.sendMessage(language.gameRuleChangedMessage)
reloadArena(sender, arena)
}
}
}
subCommand("highlight") {
permission(Permission.EDIT_GAME)
toolTip { language.commandHighlightToolTip }
Expand Down Expand Up @@ -315,6 +349,7 @@ class BlockBallCommandExecutor @Inject constructor(
mcCart.build()
}


private suspend fun createArena(sender: CommandSender, name: String, displayName: String) {
val arena = SoccerArena()
arena.name = name
Expand Down Expand Up @@ -491,6 +526,10 @@ class BlockBallCommandExecutor @Inject constructor(
arena.meta.blueTeamMeta.spawnpoint = player.location.toVector3d()
} else if (locationType == LocationType.RED_SPAWNPOINT) {
arena.meta.redTeamMeta.spawnpoint = player.location.toVector3d()
} else if (locationType == LocationType.RED_LOBBY) {
arena.meta.redTeamMeta.lobbySpawnpoint = player.location.toVector3d()
} else if (locationType == LocationType.BLUE_LOBBY) {
arena.meta.blueTeamMeta.lobbySpawnpoint = player.location.toVector3d()
}

player.sendMessage(language.selectionSetMessage.format(locationType.name.lowercase()))
Expand Down Expand Up @@ -713,6 +752,28 @@ class BlockBallCommandExecutor @Inject constructor(
)
}

if (arena.meta.redTeamMeta.lobbySpawnpoint != null) {
highLights.add(
AreaHighlight(
arena.meta.redTeamMeta.lobbySpawnpoint!!,
null,
Color.RED.rgb,
"Red Lobby"
)
)
}

if (arena.meta.blueTeamMeta.lobbySpawnpoint != null) {
highLights.add(
AreaHighlight(
arena.meta.blueTeamMeta.lobbySpawnpoint!!,
null,
Color.BLUE.rgb,
"Blue Lobby"
)
)
}

highLights
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/lang/en_us.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ gameAlreadyExistsMessage=&0&l[&f&lBlockBall&0&l]&c Game %1$1s already exists.
maxLength20Characters=&0&l[&f&lBlockBall&0&l]&c The text length has to be less than 20 characters.
gameDoesNotExistMessage=&0&l[&f&lBlockBall&0&l]&c Game %1$1s does not exist.
teamDoesNotExistMessage=&0&l[&f&lBlockBall&0&l]&c Team %1$1s does not exist.
gameTypeNotExistMessage=&0&l[&f&lBlockBall&0&l]&c GameType %1$1s does not exist.
selectionTypeDoesNotExistMessage=&0&l[&f&lBlockBall&0&l]&c This selection type is not known.
signTypeDoesNotExistMessage=&0&l[&f&lBlockBall&0&l]&c This sign type is not known.
noPermissionForGameMessage=&0&l[&f&lBlockBall&0&l]&c You do not have permission to join game %1$1s.
Expand All @@ -21,6 +22,7 @@ reloadedAllGamesMessage=&0&l[&f&lBlockBall&0&l]&7 Reloaded all games.
reloadedGameMessage=&0&l[&f&lBlockBall&0&l]&7 Reloaded game %1$1s.
updatedInventoryMessage=&0&l[&f&lBlockBall&0&l]&7 Updated inventory of game.
updatedArmorMessage=&0&l[&f&lBlockBall&0&l]&7 Updated armor of game.
gameRuleChangedMessage=&0&l[&f&lBlockBall&0&l]&7 Updated a gamerule.
rightClickOnSignMessage=&0&l[&f&lBlockBall&0&l]&7 RightClick on a sign to convert it into a game sign.
addedSignMessage=&0&l[&f&lBlockBall&0&l]&7 A sign was added to the game.
noLeftClickSelectionMessage=&0&l[&f&lBlockBall&0&l]&c You need to select a location using the BlockBall axe with left click.
Expand Down Expand Up @@ -74,6 +76,7 @@ commandReloadToolTip=Allows to reload all games or a specific single one.
commandAxeToolTip=Gives you the BlockBall selection axe.
commandHighlightToolTip=Toggles highlighting the important areas of your arena.
commandSelectToolTip=Sets a selected location for your arena.
commandGameRuleToolTip=Sets a gamerule in BlockBall.
joinSignLine1=&0&l[&f&lBlockBall&0&l]&7
joinSignLine2=%blockball_game_stateDisplayName%
joinSignLine3=%blockball_game_players%/%blockball_game_maxPlayers%
Expand Down

0 comments on commit 3a2c21b

Please sign in to comment.