diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 50dd3a05c..442e0e9d9 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - viaversion + viaversion-parent us.myles 1.0.0-ALPHA-16w38a diff --git a/bukkit/src/main/java/us/myles/ViaVersion/api/ViaListener.java b/bukkit/src/main/java/us/myles/ViaVersion/api/ViaListener.java index 48453d862..e7953a31a 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/api/ViaListener.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/api/ViaListener.java @@ -37,8 +37,8 @@ public abstract class ViaListener implements Listener { * @return The UserConnection */ protected UserConnection getUserConnection(@NonNull UUID uuid) { - if (!plugin.isPorted(uuid)) return null; - return plugin.getConnection(uuid); + if (!Via.getAPI().isPorted(uuid)) return null; + return Via.getManager().getConnection(uuid); } /** diff --git a/bukkit/src/main/java/us/myles/ViaVersion/api/ViaVersion.java b/bukkit/src/main/java/us/myles/ViaVersion/api/ViaVersion.java index 99655a2fe..c6dff9729 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/api/ViaVersion.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/api/ViaVersion.java @@ -13,7 +13,7 @@ public class ViaVersion { public static void setInstance(ViaVersionPlugin plugin) { Validate.isTrue(instance == null, "Instance is already set"); - ViaVersion.instance = plugin; + ViaVersion.instance = (ViaVersionAPI) plugin.getApi(); ViaVersion.config = plugin.getConf(); } } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/BukkitViaInjector.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/BukkitViaInjector.java index f53ece720..fe389fee0 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/BukkitViaInjector.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/BukkitViaInjector.java @@ -6,6 +6,7 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; import org.bukkit.plugin.PluginDescriptionFile; import us.myles.ViaVersion.api.Pair; +import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.platform.ViaInjector; import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.handlers.ViaVersionInitializer; @@ -23,12 +24,11 @@ public class BukkitViaInjector implements ViaInjector { private List> injectedLists = new ArrayList<>(); @Override - public void inject() { + public void inject() throws Exception { try { Object connection = getServerConnection(); if (connection == null) { - getLogger().warning("We failed to find the core component 'ServerConnection', please file an issue on our GitHub."); - return; + throw new Exception("We failed to find the core component 'ServerConnection', please file an issue on our GitHub."); } for (Field field : connection.getClass().getDeclaredFields()) { field.setAccessible(true); @@ -40,7 +40,11 @@ public class BukkitViaInjector implements ViaInjector { public synchronized void handleAdd(Object o) { synchronized (this) { if (o instanceof ChannelFuture) { - injectChannelFuture((ChannelFuture) o); + try { + injectChannelFuture((ChannelFuture) o); + } catch (Exception e) { + e.printStackTrace(); + } } } } @@ -61,12 +65,12 @@ public class BukkitViaInjector implements ViaInjector { } } catch (Exception e) { - getLogger().severe("Unable to inject ViaVersion, please post these details on our GitHub and ensure you're using a compatible server version."); - e.printStackTrace(); + Via.getPlatform().getLogger().severe("Unable to inject ViaVersion, please post these details on our GitHub and ensure you're using a compatible server version."); + throw e; } } - private void injectChannelFuture(ChannelFuture future) { + private void injectChannelFuture(ChannelFuture future) throws Exception { try { ChannelHandler bootstrapAcceptor = future.channel().pipeline().first(); try { @@ -87,8 +91,8 @@ public class BukkitViaInjector implements ViaInjector { } } catch (Exception e) { - getLogger().severe("We failed to inject ViaVersion, have you got late-bind enabled with something else?"); - e.printStackTrace(); + Via.getPlatform().getLogger().severe("We failed to inject ViaVersion, have you got late-bind enabled with something else?"); + throw e; } } @@ -123,7 +127,7 @@ public class BukkitViaInjector implements ViaInjector { } @Override - public int getServerProtocolVersion() { + public int getServerProtocolVersion() throws Exception { try { Class serverClazz = ReflectionUtil.nms("MinecraftServer"); Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer"); @@ -164,9 +168,9 @@ public class BukkitViaInjector implements ViaInjector { } } } catch (Exception e) { - e.printStackTrace(); - // We couldn't work it out... We'll just use ping and hope for the best... + throw new Exception("Failed to get server", e); } + throw new Exception("Failed to get server"); } public static Object getServerConnection() throws Exception { @@ -188,7 +192,7 @@ public class BukkitViaInjector implements ViaInjector { public static void patchLists() throws Exception { Object connection = getServerConnection(); if (connection == null) { - getLogger().warning("We failed to find the core component 'ServerConnection', please file an issue on our GitHub."); + Via.getPlatform().getLogger().warning("We failed to find the core component 'ServerConnection', please file an issue on our GitHub."); return; } for (Field field : connection.getClass().getDeclaredFields()) { diff --git a/bungee/pom.xml b/bungee/pom.xml index 613d7bb07..ec14a3b79 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - viaversion + viaversion-parent us.myles 1.0.0-ALPHA-16w38a diff --git a/common/pom.xml b/common/pom.xml index 427ec7ce4..5debfe016 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - viaversion + viaversion-parent us.myles 1.0.0-ALPHA-16w38a @@ -11,5 +11,4 @@ 4.0.0 viaversion-common - \ No newline at end of file diff --git a/common/src/main/java/us/myles/ViaVersion/ViaManager.java b/common/src/main/java/us/myles/ViaVersion/ViaManager.java index 6f9227270..23e098783 100644 --- a/common/src/main/java/us/myles/ViaVersion/ViaManager.java +++ b/common/src/main/java/us/myles/ViaVersion/ViaManager.java @@ -44,8 +44,13 @@ public class ViaManager { if (platform.getConf().isCheckForUpdates()) UpdateUtil.sendUpdateMessage(); // Inject - // TODO: Get errors - injector.inject(); + try { + injector.inject(); + } catch (Exception e) { + getPlatform().getLogger().severe("ViaVersion failed to inject:"); + e.printStackTrace(); + return; + } // Mark as injected System.setProperty("ViaVersion", getPlatform().getPluginVersion()); // If successful @@ -58,9 +63,15 @@ public class ViaManager { }); } + public void onServerLoaded() { // Load Server Protocol - ProtocolRegistry.SERVER_PROTOCOL = injector.getServerProtocolVersion(); + try { + ProtocolRegistry.SERVER_PROTOCOL = injector.getServerProtocolVersion(); + } catch (Exception e) { + getPlatform().getLogger().severe("ViaVersion failed to get the server protocol!"); + e.printStackTrace(); + } // Check if there are any pipes to this version if (ProtocolRegistry.SERVER_PROTOCOL != -1) { getPlatform().getLogger().info("ViaVersion detected server version: " + ProtocolVersion.getProtocol(ProtocolRegistry.SERVER_PROTOCOL)); @@ -81,7 +92,12 @@ public class ViaManager { public void destroy() { // Uninject getPlatform().getLogger().info("ViaVersion is disabling, if this is a reload and you experience issues consider rebooting."); - injector.uninject(); + try { + injector.uninject(); + } catch (Exception e) { + getPlatform().getLogger().severe("ViaVersion failed to uninject:"); + e.printStackTrace(); + } } public void addPortedClient(UserConnection info) { diff --git a/common/src/main/java/us/myles/ViaVersion/api/platform/ViaInjector.java b/common/src/main/java/us/myles/ViaVersion/api/platform/ViaInjector.java index e39b73cab..38d5ffc45 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/platform/ViaInjector.java +++ b/common/src/main/java/us/myles/ViaVersion/api/platform/ViaInjector.java @@ -1,9 +1,9 @@ package us.myles.ViaVersion.api.platform; public interface ViaInjector { - public void inject(); + public void inject() throws Exception; - public void uninject(); + public void uninject() throws Exception; - public int getServerProtocolVersion(); + public int getServerProtocolVersion() throws Exception; } diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java index 2b6aeb7a0..7c1f6c9b6 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java @@ -63,7 +63,7 @@ public class ProtocolRegistry { if (Via.getPlatform().isPluginEnabled()) { protocol.registerListeners(); - protocol.registerProviders(Via.getManager().getProviders()); + protocol.register(Via.getManager().getProviders()); refreshVersions(); } else { registerList.add(protocol); @@ -110,7 +110,7 @@ public class ProtocolRegistry { public static void onServerLoaded() { for (Protocol protocol : registerList) { protocol.registerListeners(); - protocol.registerProviders(Via.getManager().getProviders()); + protocol.register(Via.getManager().getProviders()); } registerList.clear(); } diff --git a/jar/pom.xml b/jar/pom.xml index 00754e50d..a58022ad7 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -35,17 +35,6 @@ - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - ${jdkVersion} - ${jdkVersion} - - - org.javassist @@ -114,4 +114,18 @@ + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + ${maven.compiler.source} + ${maven.compiler.target} + + + +