Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform-bukkit: fix ViaVersion softDepend occurring too late #80

Merged
merged 3 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ static BukkitAudiences instanceFor(final @NotNull Plugin plugin) {
BukkitAudiencesImpl(final @NotNull Plugin plugin, final @NotNull ComponentRenderer<Pointered> componentRenderer) {
super(componentRenderer);
this.plugin = requireNonNull(plugin, "plugin");
this.softDepend("ViaVersion");

final CommandSender console = this.plugin.getServer().getConsoleSender();
this.addViewer(console);
Expand Down Expand Up @@ -134,6 +133,7 @@ static BukkitAudiences instanceFor(final @NotNull Plugin plugin) {

@Override
protected @NotNull BukkitAudience createAudience(final @NotNull Collection<CommandSender> viewers) {
this.softDepend("ViaVersion");
TehBrian marked this conversation as resolved.
Show resolved Hide resolved
return new BukkitAudience(this.plugin, this, viewers);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public abstract class FacetAudienceProvider<V, A extends FacetAudience<V>>
protected final Map<V, A> viewers;
private final Map<UUID, A> players;
private final Set<A> consoles;
private final A empty;
private A empty;
private volatile boolean closed;

protected FacetAudienceProvider(final @NotNull ComponentRenderer<Pointered> componentRenderer) {
Expand All @@ -96,7 +96,6 @@ protected FacetAudienceProvider(final @NotNull ComponentRenderer<Pointered> comp
}
};
this.player = Audience.audience(this.players.values());
this.empty = this.createAudience(Collections.emptyList());
this.closed = false;
}

Expand Down Expand Up @@ -184,7 +183,14 @@ public void refreshViewer(final @NotNull V viewer) {

@Override
public @NotNull Audience player(final @NotNull UUID playerId) {
return this.players.getOrDefault(playerId, this.empty);
return this.players.getOrDefault(playerId, this.empty());
}

private @NotNull A empty() {
if (this.empty == null) {
this.empty = this.createAudience(Collections.emptyList());
}
return this.empty;
}

/**
Expand Down