Initial support for BungeeCord 1.7 server list ping changes.

This commit is contained in:
Tux 2013-10-28 22:42:26 -04:00
parent bce3f0ffb7
commit 23944f7313
3 changed files with 15 additions and 6 deletions

View File

@ -14,7 +14,7 @@
<groupId>com.imaginarycode.minecraft</groupId> <groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId> <artifactId>RedisBungee</artifactId>
<version>0.2-SNAPSHOT</version> <version>0.2.1-SNAPSHOT</version>
<repositories> <repositories>
<repository> <repository>
@ -106,7 +106,7 @@
<dependency> <dependency>
<groupId>net.md-5</groupId> <groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId> <artifactId>bungeecord-api</artifactId>
<version>1.6.2-SNAPSHOT</version> <version>1.7-SNAPSHOT</version>
<type>jar</type> <type>jar</type>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -319,8 +319,17 @@ public class RedisBungee extends Plugin implements Listener {
@EventHandler @EventHandler
public void onPing(ProxyPingEvent event) { public void onPing(ProxyPingEvent event) {
ServerPing old = event.getResponse(); ServerPing old = event.getResponse();
int players = getCount(); List<ServerPing.PlayerInfo> players = new ArrayList<>();
ServerPing newResponse = new ServerPing(old.getProtocolVersion(), old.getGameVersion(), old.getMotd(), players, old.getMaxPlayers()); for (String player : getPlayers()) {
event.setResponse(newResponse); // TODO: Find a better way of doing the UUIDs - right now I'm simply flunking it rather badly.
players.add(new ServerPing.PlayerInfo(player, new UUID(player.hashCode() + System.currentTimeMillis(), player.hashCode() + System.nanoTime()).toString()));
}
ServerPing reply = new ServerPing();
reply.setPlayers(new ServerPing.Players(players.size(), old.getPlayers().getMax()));
reply.setSample((ServerPing.PlayerInfo[]) players.toArray());
reply.setDescription(old.getDescription());
reply.setFavicon(old.getFavicon());
reply.setVersion(old.getVersion());
event.setResponse(reply);
} }
} }

View File

@ -1,4 +1,4 @@
name: RedisBungee name: RedisBungee
main: com.imaginarycode.minecraft.redisbungee.RedisBungee main: com.imaginarycode.minecraft.redisbungee.RedisBungee
version: 0.2 version: 0.2.1
author: tuxed author: tuxed