Skip to content

Commit

Permalink
Add classes and scoreboards to default arenas
Browse files Browse the repository at this point in the history
  • Loading branch information
Redned235 committed Jul 13, 2024
1 parent 1eb3f1b commit acae0c6
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 28 deletions.
2 changes: 1 addition & 1 deletion module/classes/src/main/resources/classes.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -----------------
# Classes configuration for BattleArena
#
# Documentation: https://docs.battleplugins.org/docs/ba/customization/teams
# Documentation: https://docs.battleplugins.org/books/user-guide/page/classes
# Support: https://discord.gg/tMVPVJf
# GitHub: https://github.com/BattlePlugins/BattleArena
# -----------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import net.kyori.adventure.text.format.TextColor;
import org.battleplugins.arena.ArenaPlayer;
import org.battleplugins.arena.config.ArenaOption;
import org.battleplugins.arena.options.Lives;
import org.battleplugins.arena.stat.ArenaStats;
import org.battleplugins.arena.util.Version;

import java.util.ArrayList;
Expand All @@ -18,6 +20,9 @@ public class PlayerListLineCreator implements ScoreboardLineCreator {
@ArenaOption(name = "show-team-color", description = "Whether to show the team color of the player.")
private boolean showTeamColor;

@ArenaOption(name = "require-alive", description = "Whether to only show alive players.")
private boolean requireAlive;

@Override
public List<Component> createLines(ArenaPlayer player) {
List<Component> lines = new ArrayList<>(this.maxEntries);
Expand All @@ -26,6 +31,17 @@ public List<Component> createLines(ArenaPlayer player) {
.limit(this.maxEntries)
.toList();

if (this.requireAlive) {
players = players.stream().filter(entry -> {
Lives lives = entry.getArena().getLives();
if (lives == null || !lives.isEnabled()) {
return entry.stat(ArenaStats.DEATHS).orElse(0) == 0;
}

return entry.stat(ArenaStats.LIVES).orElse(0) > 0;
}).toList();
}

for (ArenaPlayer arenaPlayer : players) {
Component component = Component.text(arenaPlayer.getPlayer().getName());
if (this.showTeamColor && arenaPlayer.getTeam() != null) {
Expand Down
18 changes: 17 additions & 1 deletion module/scoreboards/src/main/resources/scoreboards.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -----------------
# Scoreboards configuration for BattleArena
#
# Documentation: https://docs.battleplugins.org/docs/ba/customization/teams
# Documentation: https://docs.battleplugins.org/books/user-guide/page/scoreboards
# Support: https://discord.gg/tMVPVJf
# GitHub: https://github.com/BattlePlugins/BattleArena
# -----------------
Expand Down Expand Up @@ -34,6 +34,21 @@ templates:
- " "
- "<white>battleplugins.org"
ingame-list:
title: "<gold>%arena%"
refresh-time: 1s
lines:
- simple:
lines:
- " "
- "<yellow>Map: <white>%map%"
- "<yellow>Players:"
- player-list:
max-entries: 10
- simple:
lines:
- " "
- "<white>battleplugins.org"
ingame-list-alive:
title: "<gold>%arena%"
refresh-time: 1s
lines:
Expand All @@ -44,6 +59,7 @@ templates:
- "<yellow>Alive players:"
- player-list:
max-entries: 10
require-alive: true
- simple:
lines:
- " "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -----------------
# Tournament configuration for BattleArena
#
# Documentation: https://docs.battleplugins.org/docs/ba/customization/teams
# Documentation: https://docs.battleplugins.org/books/user-guide/page/tournaments
# Support: https://discord.gg/tMVPVJf
# GitHub: https://github.com/BattlePlugins/BattleArena
# -----------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void list(CommandSender sender) {
return;
}

Messages.HEADER.sendCentered(sender, "Competitions");
this.sendHeader(sender);
for (Map.Entry<CompetitionMap, List<Competition<?>>> entry : competitionMap.entrySet()) {
CompetitionMap map = entry.getKey();
List<Competition<?>> competitions = entry.getValue();
Expand Down
25 changes: 21 additions & 4 deletions plugin/src/main/resources/arenas/arena.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ team-options:
team-size: 1
team-amount: 2
team-selection: none
modules:
- arena-restoration
- classes
- scoreboards
lives:
enabled: false
victory-conditions:
Expand All @@ -26,6 +30,7 @@ events:
on-leave:
- clear-effects
- restore{types=all}
- remove-scoreboard
on-death:
- clear-inventory
- respawn
Expand All @@ -38,13 +43,18 @@ options:
- damage-entities{option=never}
- keep-inventory{enabled=true}
- keep-experience{enabled=true}
- class-equip-only-selects{enabled=true}
initial-phase: waiting
phases:
waiting:
allow-join: true
next-phase: countdown
options:
- damage-players{option=never}
- class-equipping{enabled=true}
events:
on-join:
- apply-scoreboard{scoreboard=waiting}
countdown:
allow-join: false
allow-spectate: true
Expand All @@ -53,17 +63,23 @@ phases:
countdown-time: 5s
options:
- damage-players{option=never}
- class-equipping{enabled=true}
events:
on-complete:
- teleport{location=team_spawn}
- give-effects{effects=[speed{duration=300;amplifier=1}]}
- play-sound{sound=block.note_block.pling;pitch=2;volume=1}
on-start:
- apply-scoreboard{scoreboard=countdown}
ingame:
allow-join: false
allow-spectate: true
next-phase: victory
options:
- damage-players{option=other_team}
events:
on-start:
- equip-class{class=warrior}
- teleport{location=team_spawn}
- give-effects{effects=[speed{duration=300;amplifier=1}]}
- play-sound{sound=block.note_block.pling;pitch=2;volume=1}
- apply-scoreboard{scoreboard=ingame-list}
victory:
allow-join: false
allow-spectate: false
Expand All @@ -72,6 +88,7 @@ phases:
events:
on-complete:
- leave
- remove-scoreboard
on-victory:
- send-message{message=<green>Congrats, you won!</green>}
- play-sound{sound=entity.player.levelup;pitch=1;volume=1}
Expand Down
27 changes: 23 additions & 4 deletions plugin/src/main/resources/arenas/battlegrounds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ team-options:
team-size: 1
team-amount: 2+
team-selection: none
modules:
- arena-restoration
- classes
- scoreboards
lives:
enabled: false
victory-conditions:
Expand All @@ -28,6 +32,7 @@ events:
on-leave:
- clear-effects
- restore{types=all}
- remove-scoreboard
on-death:
- respawn
on-respawn:
Expand All @@ -39,13 +44,18 @@ options:
- damage-entities{option=never}
- keep-inventory{enabled=true}
- keep-experience{enabled=true}
- class-equip-only-selects{enabled=true}
initial-phase: waiting
phases:
waiting:
allow-join: true
next-phase: countdown
options:
- damage-players{option=never}
- class-equipping{enabled=true}
events:
on-join:
- apply-scoreboard{scoreboard=waiting}
countdown:
allow-join: true
allow-spectate: true
Expand All @@ -54,17 +64,25 @@ phases:
countdown-time: 60s
options:
- damage-players{option=never}
- class-equipping{enabled=true}
events:
on-complete:
- teleport{location=team_spawn}
- give-effects{effects=[speed{duration=300;amplifier=1}]}
- play-sound{sound=block.note_block.pling;pitch=2;volume=1}
on-join:
- apply-scoreboard{scoreboard=countdown}
on-start:
- apply-scoreboard{scoreboard=countdown}
ingame:
allow-join: false
allow-spectate: true
next-phase: victory
options:
- damage-players{option=other_team}
events:
on-start:
- equip-class{class=warrior}
- teleport{location=team_spawn}
- give-effects{effects=[speed{duration=300;amplifier=1}]}
- play-sound{sound=block.note_block.pling;pitch=2;volume=1}
- apply-scoreboard{scoreboard=ingame-top-kills}
victory:
allow-join: false
allow-spectate: false
Expand All @@ -73,6 +91,7 @@ phases:
events:
on-complete:
- leave
- remove-scoreboard
on-victory:
- send-message{message=<green>Congrats, you won!</green>}
- play-sound{sound=entity.player.levelup;pitch=1;volume=1}
Expand Down
26 changes: 22 additions & 4 deletions plugin/src/main/resources/arenas/colosseum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ team-options:
team-size: 4
team-amount: 4
team-selection: pick
shared-spawn-points: true
modules:
- arena-restoration
- classes
- scoreboards
lives:
enabled: false
victory-conditions:
Expand All @@ -28,6 +33,7 @@ events:
on-leave:
- clear-effects
- restore{types=all}
- remove-scoreboard
on-death:
- clear-inventory
- respawn
Expand All @@ -40,13 +46,18 @@ options:
- damage-entities{option=never}
- keep-inventory{enabled=true}
- keep-experience{enabled=true}
- class-equip-only-selects{enabled=true}
initial-phase: waiting
phases:
waiting:
allow-join: true
next-phase: countdown
options:
- damage-players{option=never}
- class-equipping{enabled=true}
events:
on-join:
- apply-scoreboard{scoreboard=waiting}
countdown:
allow-join: false
allow-spectate: true
Expand All @@ -55,17 +66,23 @@ phases:
countdown-time: 5s
options:
- damage-players{option=never}
- class-equipping{enabled=true}
events:
on-complete:
- teleport{location=team_spawn}
- give-effects{effects=[speed{duration=300;amplifier=1}]}
- play-sound{sound=block.note_block.pling;pitch=2;volume=1}
on-start:
- apply-scoreboard{scoreboard=countdown}
ingame:
allow-join: false
allow-spectate: true
next-phase: victory
options:
- damage-players{option=other_team}
events:
on-start:
- equip-class{class=warrior}
- teleport{location=team_spawn}
- give-effects{effects=[speed{duration=300;amplifier=1}]}
- play-sound{sound=block.note_block.pling;pitch=2;volume=1}
- apply-scoreboard{scoreboard=ingame-list-alive}
victory:
allow-join: false
allow-spectate: false
Expand All @@ -74,6 +91,7 @@ phases:
events:
on-complete:
- leave
- remove-scoreboard
on-victory:
- send-message{message=<green>Congrats, you won!</green>}
- play-sound{sound=entity.player.levelup;pitch=1;volume=1}
Expand Down
Loading

0 comments on commit acae0c6

Please sign in to comment.