13
0
geforkt von Mirrors/Velocity

RegisteredServer and ProxyServer now implement MultiAudience

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-06-28 22:01:45 -04:00
Ursprung 8ef2835a47
Commit 5c02d6b007
4 geänderte Dateien mit 10 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -17,13 +17,14 @@ import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Optional;
import java.util.UUID;
import net.kyori.adventure.audience.MultiAudience;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Provides an interface to a Minecraft server proxy.
*/
public interface ProxyServer extends ProxyAudience {
public interface ProxyServer extends MultiAudience {
/**
* Retrieves the player currently connected to this proxy by their Minecraft username. The search

Datei anzeigen

@ -5,13 +5,14 @@ import com.velocitypowered.api.proxy.ProxyAudience;
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
import net.kyori.adventure.audience.MultiAudience;
/**
* Represents a server that has been registered with the proxy. The {@code Audience} associated with
* a {@code RegisteredServer} represent all players on the server connected to this proxy and do not
* interact with the server in any way.
*/
public interface RegisteredServer extends ChannelMessageSink, ProxyAudience {
public interface RegisteredServer extends ChannelMessageSink, MultiAudience {
/**
* Returns the {@link ServerInfo} for this server.

Datei anzeigen

@ -69,6 +69,7 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.IntFunction;
import java.util.stream.Collectors;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
@ -605,11 +606,8 @@ public class VelocityServer implements ProxyServer {
}
@Override
public void sendMessage(net.kyori.adventure.text.@NonNull Component message) {
Preconditions.checkNotNull(message, "message");
for (ConnectedPlayer player : connectionsByUuid.values()) {
player.sendMessage(message);
}
public @NonNull Iterable<? extends Audience> audiences() {
return this.getAllPlayers();
}
public static Gson getGsonInstance(ProtocolVersion version) {

Datei anzeigen

@ -37,6 +37,7 @@ import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -149,9 +150,7 @@ public class VelocityRegisteredServer implements RegisteredServer {
}
@Override
public void sendMessage(@NonNull Component message) {
for (ConnectedPlayer player : players) {
player.sendMessage(message);
}
public @NonNull Iterable<? extends Audience> audiences() {
return this.getPlayersConnected();
}
}