use of com.viaversion.viaversion.api.command.ViaCommandSender in project ViaVersion by ViaVersion.
the class ViaVersionPlugin method getOnlinePlayers.
@Override
public ViaCommandSender[] getOnlinePlayers() {
ViaCommandSender[] array = new ViaCommandSender[Bukkit.getOnlinePlayers().size()];
int i = 0;
for (Player player : Bukkit.getOnlinePlayers()) {
array[i++] = new BukkitCommandSender(player);
}
return array;
}
use of com.viaversion.viaversion.api.command.ViaCommandSender in project ViaVersion by ViaVersion.
the class SpongePlugin method getOnlinePlayers.
@Override
public ViaCommandSender[] getOnlinePlayers() {
Collection<ServerPlayer> players = game.server().onlinePlayers();
ViaCommandSender[] array = new ViaCommandSender[players.size()];
int i = 0;
for (ServerPlayer player : players) {
array[i++] = new SpongePlayer(player);
}
return array;
}
use of com.viaversion.viaversion.api.command.ViaCommandSender in project ViaVersion by ViaVersion.
the class ListSubCmd method execute.
@Override
public boolean execute(ViaCommandSender sender, String[] args) {
Map<ProtocolVersion, Set<String>> playerVersions = new TreeMap<>((o1, o2) -> ProtocolVersion.getIndex(o2) - ProtocolVersion.getIndex(o1));
for (ViaCommandSender p : Via.getPlatform().getOnlinePlayers()) {
int playerVersion = Via.getAPI().getPlayerVersion(p.getUUID());
ProtocolVersion key = ProtocolVersion.getProtocol(playerVersion);
playerVersions.computeIfAbsent(key, s -> new HashSet<>()).add(p.getName());
}
for (Map.Entry<ProtocolVersion, Set<String>> entry : playerVersions.entrySet()) {
sendMessage(sender, "&8[&6%s&8] (&7%d&8): &b%s", entry.getKey().getName(), entry.getValue().size(), entry.getValue());
}
playerVersions.clear();
return true;
}
use of com.viaversion.viaversion.api.command.ViaCommandSender in project ViaVersion by ViaVersion.
the class BungeePlugin method getOnlinePlayers.
@Override
public ViaCommandSender[] getOnlinePlayers() {
Collection<ProxiedPlayer> players = getProxy().getPlayers();
ViaCommandSender[] array = new ViaCommandSender[players.size()];
int i = 0;
for (ProxiedPlayer player : players) {
array[i++] = new BungeeCommandSender(player);
}
return array;
}
use of com.viaversion.viaversion.api.command.ViaCommandSender in project ViaVersion by ViaVersion.
the class PPSSubCmd method execute.
@Override
public boolean execute(ViaCommandSender sender, String[] args) {
Map<Integer, Set<String>> playerVersions = new HashMap<>();
int totalPackets = 0;
int clients = 0;
long max = 0;
for (ViaCommandSender p : Via.getPlatform().getOnlinePlayers()) {
int playerVersion = Via.getAPI().getPlayerVersion(p.getUUID());
if (!playerVersions.containsKey(playerVersion))
playerVersions.put(playerVersion, new HashSet<>());
UserConnection uc = Via.getManager().getConnectionManager().getConnectedClient(p.getUUID());
if (uc != null && uc.getPacketTracker().getPacketsPerSecond() > -1) {
playerVersions.get(playerVersion).add(p.getName() + " (" + uc.getPacketTracker().getPacketsPerSecond() + " PPS)");
totalPackets += uc.getPacketTracker().getPacketsPerSecond();
if (uc.getPacketTracker().getPacketsPerSecond() > max) {
max = uc.getPacketTracker().getPacketsPerSecond();
}
clients++;
}
}
Map<Integer, Set<String>> sorted = new TreeMap<>(playerVersions);
sendMessage(sender, "&4Live Packets Per Second");
if (clients > 1) {
sendMessage(sender, "&cAverage: &f" + (totalPackets / clients));
sendMessage(sender, "&cHighest: &f" + max);
}
if (clients == 0) {
sendMessage(sender, "&cNo clients to display.");
}
for (Map.Entry<Integer, Set<String>> entry : sorted.entrySet()) sendMessage(sender, "&8[&6%s&8]: &b%s", ProtocolVersion.getProtocol(entry.getKey()).getName(), entry.getValue());
sorted.clear();
return true;
}
Aggregations