From 882090141df85bb739625dfeb84501b4dcd773f4 Mon Sep 17 00:00:00 2001 From: MCMDEV Date: Tue, 12 Apr 2022 14:03:25 +0200 Subject: [PATCH] Fixed skin values and NPE on ping. --- .../hostprofiles/common/connection/ConnectionHandler.java | 4 ++-- .../mcmdev/hostprofiles/paper/listener/PaperListener.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hostprofiles-common/src/main/java/de/mcmdev/hostprofiles/common/connection/ConnectionHandler.java b/hostprofiles-common/src/main/java/de/mcmdev/hostprofiles/common/connection/ConnectionHandler.java index 72bf167..51a5bfb 100644 --- a/hostprofiles-common/src/main/java/de/mcmdev/hostprofiles/common/connection/ConnectionHandler.java +++ b/hostprofiles-common/src/main/java/de/mcmdev/hostprofiles/common/connection/ConnectionHandler.java @@ -23,9 +23,9 @@ public boolean handleLogin(ConnectionEvent connectionEvent) { connectionEvent.setUuid(profile.getUuid()); connectionEvent.setName(profile.getName()); connectionEvent.setSkinCopy(profile.isSkinCopy()); - if (connectionEvent.getSkinValue() != null) { + if (profile.getSkinValue() != null) { connectionEvent.setSkinValue(profile.getSkinValue()); - if (connectionEvent.getSkinSignature() != null) { + if (profile.getSkinSignature() != null) { connectionEvent.setSkinSignature(profile.getSkinSignature()); } } diff --git a/hostprofiles-paper/src/main/java/de/mcmdev/hostprofiles/paper/listener/PaperListener.java b/hostprofiles-paper/src/main/java/de/mcmdev/hostprofiles/paper/listener/PaperListener.java index a6c82ae..8cfa0c2 100644 --- a/hostprofiles-paper/src/main/java/de/mcmdev/hostprofiles/paper/listener/PaperListener.java +++ b/hostprofiles-paper/src/main/java/de/mcmdev/hostprofiles/paper/listener/PaperListener.java @@ -14,6 +14,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import java.net.InetSocketAddress; + @RequiredArgsConstructor public class PaperListener implements Listener { @@ -54,7 +56,9 @@ private void onAsyncLogin(AsyncPlayerPreLoginEvent event) { @EventHandler public void onPing(PaperServerListPingEvent event) { - String hostname = event.getClient().getVirtualHost().getHostName(); + InetSocketAddress virtualHost = event.getClient().getVirtualHost(); + if (virtualHost == null) return; + String hostname = virtualHost.getHostName(); PingEvent pingEvent = new PingEvent(hostname); connectionHandler.handlePing(pingEvent); if (pingEvent.getMotd() != null) {