Skip to content

Commit

Permalink
game checks amount of players, fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
MylesAndMore committed Aug 9, 2024
1 parent 8bea7b6 commit 83a2a5e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Scroll down for more options to configure your game.
| `/tumble setkillylevel <arenaName>` | Set the arena's Y-level to kill players at to current Y coordinate. | `tumble.setkillylevel` |
| `/tumble setlobby <arenaName>` | Set the arena's lobby to current location. | `tumble.setlobby` |
| `/tumble setwaitarea <arenaName>` | Set the arena's wait area to the current location. | `tumble.setwaitarea` |
| `/tumble setwinnerlobby <arenaName>` | Set the arena's lobby to the current location. | `tumble.setwinnerlobby` |
| `/tumble setwinnerlobby <arenaName>` | Set the arena's winner lobby to the current location. | `tumble.setwinnerlobby` |

Note that the `/tmbl` command can be used as a shorter alias to `/tumble`.

Expand All @@ -77,8 +77,8 @@ Each arena can contain the following locations:
|--------------------------|-------------------------------------------------------------------------------------|
| `game-spawn` **Required* | The location where players will be teleported, and the layers will generate around. |
| `wait-area` | The location where players will be teleported to before the game begins. |
| `lobby` | The location where players will be teleported to after the game. |
| `winner-lobby` | The location where the winner will be teleported after the game. |
| `lobby` | The location where players will be teleported to after the game ends. |
| `winner-lobby` | The location where the winner will be teleported after the game ends. |

Locations are stored using the following format:
```yaml
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/MylesAndMore/Tumble/commands/Join.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return false;
}

game.addPlayer((Player)sender);
if (!game.addPlayer((Player)sender)) {
p.sendMessage(LanguageManager.fromKey("game-full"));
return false;
}
sender.sendMessage(LanguageManager.fromKey("join-success")
.replace("%type%", game.type.toString())
.replace("%arena%", arena.name));
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/MylesAndMore/Tumble/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ public Game(@NotNull Arena arena, @NotNull GameType type) {
* Adds a player to the wait area. Called from /tumble join
* Precondition: the game is in state WAITING
* @param p Player to add
* @return Whether the player was successfully added
*/
public void addPlayer(Player p) {
public boolean addPlayer(Player p) {
if (gamePlayers.size() > 8) { return false; }
gamePlayers.add(p);

if (arena.waitArea != null) {
Expand All @@ -65,6 +67,7 @@ public void addPlayer(Player p) {
} else {
displayActionbar(Collections.singletonList(p), LanguageManager.fromKeyNoPrefix("waiting-for-players"));
}
return true;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ invalid-arena: "&cArena '%arena%' does not exist!"
invalid-type: "&cInvalid game type!"
no-game-in-arena: "&cNo game is currently running in this arena!"
player-not-in-game: "&cYou are not in a game!"
game-full: "&cThis game is full!"
not-for-console: "&cThis cannot be run by the console!"
game-in-progress: "&cThis game is still in progress! &7Wait until it finishes or join another game."
another-type-in-arena: "A game of '%type%' is currently taking place in this arena! &7Choose another arena or join it with '/tumble join %arena% %type%'."
Expand Down

0 comments on commit 83a2a5e

Please sign in to comment.