From d950d8eb2229e2277f6d8d20f59000411456211b Mon Sep 17 00:00:00 2001 From: Daniil Date: Sun, 19 Jul 2020 04:09:41 +0300 Subject: [PATCH] better check for bungeecord support For some custom forks like Tuinity and such. Also this next warning is enormous and just annoying. I think there's should be some configurable option in the config to disable it. Can make a PR for this too if needed. --- .../advancedportals/bukkit/AdvancedPortalsPlugin.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsPlugin.java b/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsPlugin.java index c8a421b..345dd33 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsPlugin.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/AdvancedPortalsPlugin.java @@ -109,7 +109,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin { // Enables very basic bungee support if not setup right this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); if(this.checkIfBungee()) { - this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this)); this.getServer().getMessenger().registerOutgoingPluginChannel(this, channelName); @@ -124,12 +123,14 @@ public class AdvancedPortalsPlugin extends JavaPlugin { private boolean checkIfBungee() { // we check if the server is Spigot/Paper (because of the spigot.yml file) - if ( !getServer().getVersion().contains( "Spigot" ) && !getServer().getVersion().contains( "Paper" ) ) - { + try { + Class.forName("org.spigotmc.SpigotConfig"); + } catch (ClassNotFoundException e) { this.getServer().getConsoleSender().sendMessage( "\u00A7ePossibly unsupported version for bungee messages detected, channels won't be enabled." ); getLogger().info("If you believe this shouldn't be the case please contact us on discord https://discord.gg/fAJ3xJg"); return false; } + if ( !getServer().spigot().getConfig().getConfigurationSection("settings").getBoolean( "bungeecord" ) ) { this.getServer().getConsoleSender().sendMessage( "\n\n\u00A7eThis server does not have BungeeCord enabled.\n" + @@ -141,6 +142,7 @@ public class AdvancedPortalsPlugin extends JavaPlugin { getLogger().warning( "Advanced bungee features disabled for Advanced Portals as bungee isn't enabled on the server (spigot.yml)" ); return false; } + return true; }