|
8 | 8 | import net.minestom.server.entity.Player;
|
9 | 9 | import net.minestom.server.instance.Instance;
|
10 | 10 |
|
| 11 | +import java.util.stream.Collectors; |
| 12 | + |
11 | 13 | public record MeetingSession(
|
12 | 14 | String title,
|
13 | 15 | String inviteCode,
|
14 | 16 | boolean persistent,
|
15 | 17 | Instance instance
|
16 |
| - ) { |
17 |
| - public void greet(Player player) { |
18 |
| - player.sendMessage( |
19 |
| - Component.text("Welcome! ") //huh, over-engineered api, isn't it? |
20 |
| - .color(NamedTextColor.GREEN) |
21 |
| - .style(Style.style(TextDecoration.BOLD)) |
22 |
| - .append( |
23 |
| - Component.text("You just joined ") |
24 |
| - .append( |
25 |
| - Component.text(title()) |
26 |
| - .style(Style.style(TextDecoration.UNDERLINED)) |
27 |
| - ) |
28 |
| - ) |
29 |
| - ); |
30 |
| - instance.getPlayers().forEach(p -> { |
31 |
| - p.sendMessage( |
32 |
| - Component.text(player.getUsername()).color(NamedTextColor.AQUA) |
33 |
| - .append(Component.text(" joined the meeting!").color(NamedTextColor.WHITE)) |
34 |
| - ); |
35 |
| - }); |
36 |
| - player.sendMessage(Component.text("Here are " + instance.getPlayers().size() + " players in the meeting, including ") |
| 18 | +) { |
| 19 | + public void greet(Player player) { |
| 20 | + player.sendMessage( |
| 21 | + Component.text("Welcome! ") //huh, over-engineered api, isn't it? |
| 22 | + .color(NamedTextColor.GREEN) |
| 23 | + .style(Style.style(TextDecoration.BOLD)) |
37 | 24 | .append(
|
38 |
| - instance.getPlayers().stream() |
39 |
| - .map(it -> Component.text(it.getUsername()).color(NamedTextColor.AQUA)) |
40 |
| - .reduce(ScopedComponent::append) |
41 |
| - .get() |
42 |
| - )); |
43 |
| - } |
| 25 | + Component.text("You just joined ") |
| 26 | + .append( |
| 27 | + Component.text(title()) |
| 28 | + .style(Style.style(TextDecoration.UNDERLINED)) |
| 29 | + ) |
| 30 | + ) |
| 31 | + ); |
| 32 | + instance.getPlayers().forEach(p -> { |
| 33 | + p.sendMessage( |
| 34 | + Component.text(player.getUsername()).color(NamedTextColor.AQUA) |
| 35 | + .append(Component.text(" joined the meeting!").color(NamedTextColor.WHITE)) |
| 36 | + ); |
| 37 | + }); |
| 38 | + player.sendMessage(Component.text("Here are " + instance.getPlayers().size() + " players in the meeting, including ") |
| 39 | + .append( |
| 40 | + Component.text(instance.getPlayers().stream() |
| 41 | + .map(it -> it.getUsername()) |
| 42 | + .collect(Collectors.joining(", "))).color(NamedTextColor.AQUA) |
| 43 | + )); |
| 44 | + } |
44 | 45 | }
|
0 commit comments