geforkt von Mirrors/Velocity
Store players in VelocityRegisteredServer by UUID instead.
Fixes an issue where players would be repeated in /glist and the like.
Dieser Commit ist enthalten in:
Ursprung
cc89a2a1e5
Commit
fb888c3b8a
@ -32,7 +32,8 @@ import io.netty.channel.ChannelInitializer;
|
|||||||
import io.netty.channel.EventLoop;
|
import io.netty.channel.EventLoop;
|
||||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
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;
|
||||||
@ -45,7 +46,7 @@ public class VelocityRegisteredServer implements RegisteredServer, ForwardingAud
|
|||||||
|
|
||||||
private final @Nullable VelocityServer server;
|
private final @Nullable VelocityServer server;
|
||||||
private final ServerInfo serverInfo;
|
private final ServerInfo serverInfo;
|
||||||
private final Set<ConnectedPlayer> players = ConcurrentHashMap.newKeySet();
|
private final Map<UUID, ConnectedPlayer> players = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public VelocityRegisteredServer(@Nullable VelocityServer server, ServerInfo serverInfo) {
|
public VelocityRegisteredServer(@Nullable VelocityServer server, ServerInfo serverInfo) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
@ -59,7 +60,7 @@ public class VelocityRegisteredServer implements RegisteredServer, ForwardingAud
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Player> getPlayersConnected() {
|
public Collection<Player> getPlayersConnected() {
|
||||||
return ImmutableList.copyOf(players);
|
return ImmutableList.copyOf(players.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -111,11 +112,11 @@ public class VelocityRegisteredServer implements RegisteredServer, ForwardingAud
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(ConnectedPlayer player) {
|
public void addPlayer(ConnectedPlayer player) {
|
||||||
players.add(player);
|
players.put(player.getUniqueId(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(ConnectedPlayer player) {
|
public void removePlayer(ConnectedPlayer player) {
|
||||||
players.remove(player);
|
players.remove(player.getUniqueId(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -130,7 +131,7 @@ public class VelocityRegisteredServer implements RegisteredServer, ForwardingAud
|
|||||||
* @return whether or not the message was sent
|
* @return whether or not the message was sent
|
||||||
*/
|
*/
|
||||||
public boolean sendPluginMessage(ChannelIdentifier identifier, ByteBuf data) {
|
public boolean sendPluginMessage(ChannelIdentifier identifier, ByteBuf data) {
|
||||||
for (ConnectedPlayer player : players) {
|
for (ConnectedPlayer player : players.values()) {
|
||||||
VelocityServerConnection connection = player.getConnectedServer();
|
VelocityServerConnection connection = player.getConnectedServer();
|
||||||
if (connection != null && connection.getServerInfo().equals(serverInfo)) {
|
if (connection != null && connection.getServerInfo().equals(serverInfo)) {
|
||||||
return connection.sendPluginMessage(identifier, data);
|
return connection.sendPluginMessage(identifier, data);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren