13
0
geforkt von Mirrors/Velocity

ProxyServer#broadcast()

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-20 22:43:58 -04:00
Ursprung 0e901e2843
Commit d06028e0f8
2 geänderte Dateien mit 16 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -8,6 +8,7 @@ import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo; import com.velocitypowered.api.proxy.server.ServerInfo;
import com.velocitypowered.api.scheduler.Scheduler; import com.velocitypowered.api.scheduler.Scheduler;
import net.kyori.text.Component;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Collection; import java.util.Collection;
@ -32,6 +33,12 @@ public interface ProxyServer {
*/ */
Optional<Player> getPlayer(UUID uuid); 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 * Retrieves all players currently connected to this proxy. This call may or may not be a snapshot of all players
* online. * online.

Datei anzeigen

@ -26,6 +26,7 @@ import com.velocitypowered.proxy.network.ConnectionManager;
import com.velocitypowered.proxy.network.http.NettyHttpClient; import com.velocitypowered.proxy.network.http.NettyHttpClient;
import com.velocitypowered.proxy.plugin.VelocityEventManager; import com.velocitypowered.proxy.plugin.VelocityEventManager;
import com.velocitypowered.proxy.plugin.VelocityPluginManager; import com.velocitypowered.proxy.plugin.VelocityPluginManager;
import com.velocitypowered.proxy.protocol.packet.Chat;
import com.velocitypowered.proxy.protocol.util.FaviconSerializer; import com.velocitypowered.proxy.protocol.util.FaviconSerializer;
import com.velocitypowered.proxy.scheduler.VelocityScheduler; import com.velocitypowered.proxy.scheduler.VelocityScheduler;
import com.velocitypowered.proxy.server.ServerMap; import com.velocitypowered.proxy.server.ServerMap;
@ -253,6 +254,14 @@ public class VelocityServer implements ProxyServer {
return Optional.ofNullable(connectionsByUuid.get(uuid)); 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 @Override
public Collection<Player> getAllPlayers() { public Collection<Player> getAllPlayers() {
return ImmutableList.copyOf(connectionsByUuid.values()); return ImmutableList.copyOf(connectionsByUuid.values());