From 3ef1ac06df52a9c19e081fab5ffdbe898d6657bf Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Mon, 12 Nov 2018 14:21:48 -0200 Subject: [PATCH] fix version, detect velocity implementation, fix npe, fix detectorservice --- velocity/pom.xml | 2 +- .../java/us/myles/ViaVersion/VelocityPlugin.java | 6 ++++-- .../velocity/platform/VelocityViaLoader.java | 14 ++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/velocity/pom.xml b/velocity/pom.xml index 232fc97a4..50d9a28d5 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.6.1-18w43c + 1.6.1-SNAPSHOT 4.0.0 diff --git a/velocity/src/main/java/us/myles/ViaVersion/VelocityPlugin.java b/velocity/src/main/java/us/myles/ViaVersion/VelocityPlugin.java index d01d0e6c5..f16cad720 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/VelocityPlugin.java +++ b/velocity/src/main/java/us/myles/ViaVersion/VelocityPlugin.java @@ -87,12 +87,14 @@ public class VelocityPlugin implements ViaPlatform { @Override public String getPlatformName() { - return "Velocity"; + String proxyImpl = ProxyServer.class.getPackage().getImplementationTitle(); + return (proxyImpl != null) ? proxyImpl : "Velocity"; } @Override public String getPlatformVersion() { - return ProxyServer.class.getPackage().getImplementationVersion(); + String version = ProxyServer.class.getPackage().getImplementationVersion(); + return (version != null) ? version : "Unknown"; } @Override diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaLoader.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaLoader.java index ff2ff10f1..f81447437 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaLoader.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaLoader.java @@ -27,15 +27,17 @@ public class VelocityViaLoader implements ViaPlatformLoader { Via.getManager().getProviders().use(VersionProvider.class, new VelocityVersionProvider()); // We probably don't need a EntityIdProvider because velocity sends a Join packet on server change - VelocityPlugin.PROXY.getEventManager().register( - plugin, - new UpdateListener()); - Via.getPlatform().runRepeatingSync( - new ProtocolDetectorService(), - ((VelocityViaConfig) Via.getPlatform().getConf()).getVelocityPingInterval() * 50L); + VelocityPlugin.PROXY.getEventManager().register(plugin, new UpdateListener()); VelocityPlugin.PROXY.getEventManager().register(plugin, new VelocityServerHandler()); VelocityPlugin.PROXY.getEventManager().register(plugin, new MainHandPatch()); VelocityPlugin.PROXY.getEventManager().register(plugin, new ElytraPatch()); + + int pingInterval = ((VelocityViaConfig) Via.getPlatform().getConf()).getVelocityPingInterval(); + if (pingInterval > 0) { + Via.getPlatform().runRepeatingSync( + new ProtocolDetectorService(), + pingInterval * 20L); + } } @Override