3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-09-29 06:30:16 +02:00

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.Collection;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import net.kyori.adventure.audience.MultiAudience;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
/** /**
* Provides an interface to a Minecraft server proxy. * 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 * 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 com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import java.util.Collection; import java.util.Collection;
import java.util.concurrent.CompletableFuture; 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 * 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 * a {@code RegisteredServer} represent all players on the server connected to this proxy and do not
* interact with the server in any way. * 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. * 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.concurrent.atomic.AtomicBoolean;
import java.util.function.IntFunction; import java.util.function.IntFunction;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.text.Component; import net.kyori.text.Component;
import net.kyori.text.TextComponent; import net.kyori.text.TextComponent;
@ -605,11 +606,8 @@ public class VelocityServer implements ProxyServer {
} }
@Override @Override
public void sendMessage(net.kyori.adventure.text.@NonNull Component message) { public @NonNull Iterable<? extends Audience> audiences() {
Preconditions.checkNotNull(message, "message"); return this.getAllPlayers();
for (ConnectedPlayer player : connectionsByUuid.values()) {
player.sendMessage(message);
}
} }
public static Gson getGsonInstance(ProtocolVersion version) { 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.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
@ -149,9 +150,7 @@ public class VelocityRegisteredServer implements RegisteredServer {
} }
@Override @Override
public void sendMessage(@NonNull Component message) { public @NonNull Iterable<? extends Audience> audiences() {
for (ConnectedPlayer player : players) { return this.getPlayersConnected();
player.sendMessage(message);
}
} }
} }