From 7ee37ae4cbf945a8cf60c3895d5f5b76ae940124 Mon Sep 17 00:00:00 2001 From: Tux Date: Sun, 6 Dec 2015 23:14:53 -0500 Subject: [PATCH] Don't create an entirely new ServerPing object. --- .../redisbungee/RedisBungeeListener.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java index 259e965..dda2122 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java @@ -159,25 +159,13 @@ public class RedisBungeeListener implements Listener { plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() { @Override public void run() { - ServerPing old = event.getResponse(); - ServerPing reply = new ServerPing(); - reply.setPlayers(new ServerPing.Players(old.getPlayers().getMax(), plugin.getCount(), old.getPlayers().getSample())); - reply.setDescription(old.getDescription()); - reply.setFavicon(old.getFaviconObject()); - reply.setVersion(old.getVersion()); - event.setResponse(reply); + event.getResponse().getPlayers().setOnline(plugin.getCount()); event.completeIntent(plugin); } }); } else { // Async ping event will not work as an async-hostile plugin was found, so perform the ping modification synchronously. - ServerPing old = event.getResponse(); - ServerPing reply = new ServerPing(); - reply.setPlayers(new ServerPing.Players(old.getPlayers().getMax(), plugin.getCount(), old.getPlayers().getSample())); - reply.setDescription(old.getDescription()); - reply.setFavicon(old.getFaviconObject()); - reply.setVersion(old.getVersion()); - event.setResponse(reply); + event.getResponse().getPlayers().setOnline(plugin.getCount()); } }