-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameViewImpl.java
More file actions
55 lines (45 loc) · 1.56 KB
/
Copy pathGameViewImpl.java
File metadata and controls
55 lines (45 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package net.onelitefeather.cygnus.view;
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.text.Component;
import net.minestom.server.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
import java.util.function.Consumer;
public final class GameViewImpl implements GameView {
private final BossBar bossBar;
public GameViewImpl() {
this.bossBar = BossBar.bossBar(Component.empty(), 1f, BossBar.Color.WHITE, BossBar.Overlay.PROGRESS);
}
@Override
public void updateView(Component component) {
this.bossBar.name(component);
}
@Override
public void addPlayer(Player player, @Nullable Consumer<Player> consumer) {
player.showBossBar(this.bossBar);
if (consumer == null) return;
consumer.accept(player);
}
@Override
public void addPlayers(Set<Player> set, @Nullable Consumer<Player> consumer) {
set.forEach(player -> {
player.showBossBar(this.bossBar);
if (consumer == null) return;
consumer.accept(player);
});
}
@Override
public void removePlayer(Player player, @Nullable Consumer<Player> consumer) {
player.hideBossBar(this.bossBar);
if (consumer == null) return;
consumer.accept(player);
}
@Override
public void removePlayers(Set<Player> set, @Nullable Consumer<Player> consumer) {
set.forEach(player -> {
player.hideBossBar(this.bossBar);
if (consumer == null) return;
consumer.accept(player);
});
}
}