geforkt von Mirrors/Velocity
ProxyServer#broadcast()
Dieser Commit ist enthalten in:
Ursprung
0e901e2843
Commit
d06028e0f8
@ -8,6 +8,7 @@ import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||
import com.velocitypowered.api.scheduler.Scheduler;
|
||||
import net.kyori.text.Component;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collection;
|
||||
@ -32,6 +33,12 @@ public interface ProxyServer {
|
||||
*/
|
||||
Optional<Player> getPlayer(UUID uuid);
|
||||
|
||||
/**
|
||||
* Broadcasts a message to all players currently online.
|
||||
* @param component the message to send
|
||||
*/
|
||||
void broadcast(Component component);
|
||||
|
||||
/**
|
||||
* Retrieves all players currently connected to this proxy. This call may or may not be a snapshot of all players
|
||||
* online.
|
||||
|
@ -26,6 +26,7 @@ import com.velocitypowered.proxy.network.ConnectionManager;
|
||||
import com.velocitypowered.proxy.network.http.NettyHttpClient;
|
||||
import com.velocitypowered.proxy.plugin.VelocityEventManager;
|
||||
import com.velocitypowered.proxy.plugin.VelocityPluginManager;
|
||||
import com.velocitypowered.proxy.protocol.packet.Chat;
|
||||
import com.velocitypowered.proxy.protocol.util.FaviconSerializer;
|
||||
import com.velocitypowered.proxy.scheduler.VelocityScheduler;
|
||||
import com.velocitypowered.proxy.server.ServerMap;
|
||||
@ -253,6 +254,14 @@ public class VelocityServer implements ProxyServer {
|
||||
return Optional.ofNullable(connectionsByUuid.get(uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(Component component) {
|
||||
Chat chat = Chat.createClientbound(component);
|
||||
for (ConnectedPlayer player : connectionsByUuid.values()) {
|
||||
player.getConnection().write(chat);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Player> getAllPlayers() {
|
||||
return ImmutableList.copyOf(connectionsByUuid.values());
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren