mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-07 04:18:09 +02:00
This simply provides the base API to create the objects. Further commits will come that adds adds usage of this API to existing GameProfile based API's, as well as new API's.
69 lines
3.1 KiB
Diff
69 lines
3.1 KiB
Diff
From 0b99c5bb088b5a88f180704eb53797a34bac74c3 Mon Sep 17 00:00:00 2001
|
|
From: willies952002 <admin@domnian.com>
|
|
Date: Fri, 5 May 2017 18:59:22 -0400
|
|
Subject: [PATCH] Allow Changing of Player Sample in ServerListPingEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketStatusListener.java b/src/main/java/net/minecraft/server/PacketStatusListener.java
|
|
index 313bb0007..45d6984f7 100644
|
|
--- a/src/main/java/net/minecraft/server/PacketStatusListener.java
|
|
+++ b/src/main/java/net/minecraft/server/PacketStatusListener.java
|
|
@@ -5,6 +5,7 @@ import com.mojang.authlib.GameProfile;
|
|
import io.netty.channel.ChannelFutureListener;
|
|
import java.net.InetSocketAddress;
|
|
import java.util.Iterator;
|
|
+import java.util.UUID;
|
|
|
|
import org.bukkit.craftbukkit.util.CraftIconCache;
|
|
import org.bukkit.entity.Player;
|
|
@@ -97,23 +98,44 @@ public class PacketStatusListener implements PacketStatusInListener {
|
|
}
|
|
}
|
|
|
|
+ // Paper start
|
|
+ java.util.List<String> sample = new java.util.ArrayList<>(players.length);
|
|
+ for (Object player : players) {
|
|
+ if (player != null) sample.add(((EntityPlayer) player).getName());
|
|
+ }
|
|
+ if (!sample.isEmpty()) {
|
|
+ java.util.Collections.shuffle(sample);
|
|
+ sample = sample.subList(0, Math.min(sample.size(), org.spigotmc.SpigotConfig.playerSample));
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
ServerListPingEvent event = new ServerListPingEvent();
|
|
+ event.setSampleText(sample); // Paper
|
|
this.minecraftServer.server.getPluginManager().callEvent(event);
|
|
-
|
|
java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length);
|
|
+ // Paper start
|
|
+ if (event.getSampleText() != sample) sample = event.getSampleText();
|
|
+ sample.forEach(line -> profiles.add(new GameProfile(UUID.randomUUID(), line)));
|
|
+ /*
|
|
for (Object player : players) {
|
|
if (player != null) {
|
|
profiles.add(((EntityPlayer) player).getProfile());
|
|
}
|
|
}
|
|
+ */
|
|
+ // Paper end
|
|
|
|
- ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size());
|
|
+ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), minecraftServer.getPlayerList().getPlayerCount()); // Paper
|
|
// Spigot Start
|
|
+ // Paper start - Move up
|
|
+ /*
|
|
if ( !profiles.isEmpty() )
|
|
{
|
|
java.util.Collections.shuffle( profiles ); // This sucks, its inefficient but we have no simple way of doing it differently
|
|
profiles = profiles.subList( 0, Math.min( profiles.size(), org.spigotmc.SpigotConfig.playerSample ) ); // Cap the sample to n (or less) displayed players, ie: Vanilla behaviour
|
|
}
|
|
+ */
|
|
+ // Paper end
|
|
// Spigot End
|
|
playerSample.a(profiles.toArray(new GameProfile[profiles.size()]));
|
|
|
|
--
|
|
2.15.1
|
|
|