using common interface instead of individual methods in displayname appliance
This commit is contained in:
parent
ceca038b27
commit
49eeb646ea
@ -19,6 +19,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -30,21 +31,21 @@ public class DisplayName extends Appliance {
|
|||||||
|
|
||||||
public void update(Player player) {
|
public void update(Player player) {
|
||||||
TextColor playerColor = this.queryAppliance(AdminMarker.class).getPlayerColor(player);
|
TextColor playerColor = this.queryAppliance(AdminMarker.class).getPlayerColor(player);
|
||||||
List<Supplier<Component>> prefixes = List.of(
|
List<Supplier<Prefixed>> prefixes = List.of(
|
||||||
() -> this.queryAppliance(Outlawed.class).getNamePrefix(player),
|
() -> this.queryAppliance(Outlawed.class),
|
||||||
() -> this.queryAppliance(YearRank.class).getNamePrefix(player),
|
() -> this.queryAppliance(YearRank.class),
|
||||||
() -> this.queryAppliance(AfkTag.class).getNamePrefix(player),
|
() -> this.queryAppliance(AfkTag.class),
|
||||||
() -> this.queryAppliance(SleepTag.class).getNamePrefix(player)
|
() -> this.queryAppliance(SleepTag.class)
|
||||||
);
|
);
|
||||||
|
|
||||||
ComponentBuilder<TextComponent, TextComponent.Builder> playerName = Component.text();
|
ComponentBuilder<TextComponent, TextComponent.Builder> playerName = Component.text();
|
||||||
prefixes.forEach(supplier -> {
|
prefixes.stream()
|
||||||
Component prefix = supplier.get();
|
.map(prefixed -> prefixed.get().getNamePrefix(player))
|
||||||
if(prefix == null) return;
|
.filter(Objects::nonNull)
|
||||||
playerName
|
.forEach(prefix -> playerName
|
||||||
.append(prefix)
|
.append(prefix)
|
||||||
.append(ComponentUtil.clearedSpace());
|
.append(ComponentUtil.clearedSpace())
|
||||||
});
|
);
|
||||||
|
|
||||||
if(Floodgate.isBedrock(player)) {
|
if(Floodgate.isBedrock(player)) {
|
||||||
playerName
|
playerName
|
||||||
|
Loading…
x
Reference in New Issue
Block a user