From d773800a0d41f0e66fc35a4c3bc06fd7870662d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Mart=C3=ADnez=20Rinc=C3=B3n?= Date: Fri, 15 Sep 2017 17:49:57 +0200 Subject: [PATCH] Handle configuration exceptions too --- setup.bat | 1 + setup.sh | 4 +- .../playerbalancer/PlayerBalancer.java | 56 +++++++++---------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/setup.bat b/setup.bat index 95d57f8..15f9294 100644 --- a/setup.bat +++ b/setup.bat @@ -2,5 +2,6 @@ mkdir libs cd libs + powershell -Command "Invoke-WebRequest https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar -OutFile BungeeCord.jar" mvn install:install-file -Dfile=BungeeCord.jar -DgroupId=net.md-5 -DartifactId=bungeecord-proxy -Dversion=local -Dpackaging=jar \ No newline at end of file diff --git a/setup.sh b/setup.sh index 51ff563..8b9e33a 100644 --- a/setup.sh +++ b/setup.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash -mkdir libs && cd "$_" +mkdir libs +cd libs + wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar mvn install:install-file -Dfile=BungeeCord.jar -DgroupId=net.md-5 -DartifactId=bungeecord-proxy -Dversion=local -Dpackaging=jar \ No newline at end of file diff --git a/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java b/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java index f74dfac..f8b07a3 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java +++ b/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java @@ -71,33 +71,29 @@ public class PlayerBalancer extends Plugin { try { CommentedConfigurationNode node = loader.load(); settings = node.getValue(TypeToken.of(SettingsHolder.class)); - } catch (Exception e) { - e.printStackTrace(); - } - mainCommand = new MainCommand(this); - getProxy().getPluginManager().registerCommand(this, mainCommand); + mainCommand = new MainCommand(this); + getProxy().getPluginManager().registerCommand(this, mainCommand); - if (settings.getGeneralProps().isEnabled()) { - if (settings.getGeneralProps().isSilent()) { - getLogger().setLevel(Level.WARNING); - } + if (settings.getGeneralProps().isEnabled()) { + if (settings.getGeneralProps().isSilent()) { + getLogger().setLevel(Level.WARNING); + } - if (settings.getGeneralProps().isAutoReload()) { - reloadListener = new ProxyReloadListener(this); - getProxy().getPluginManager().registerListener(this, reloadListener); - } + if (settings.getGeneralProps().isAutoReload()) { + reloadListener = new ProxyReloadListener(this); + getProxy().getPluginManager().registerListener(this, reloadListener); + } - try { - new BungeeUpdater(this, 10788); - } catch (IOException e) { - e.printStackTrace(); - } + try { + new BungeeUpdater(this, 10788); + } catch (IOException e) { + e.printStackTrace(); + } - networkManager = new NetworkManager(this); - sectionManager = new SectionManager(this); + networkManager = new NetworkManager(this); - try { + sectionManager = new SectionManager(this); sectionManager.load(); statusManager = new StatusManager(this); @@ -131,16 +127,16 @@ public class PlayerBalancer extends Plugin { } getLogger().info("The plugin has finished loading without any problems"); - } catch (RuntimeException e) { - this.failed = true; - getLogger().severe("The plugin could not continue loading due to an unexpected exception"); - e.printStackTrace(); + } else { + getLogger().warning("-----------------------------------------------------"); + getLogger().warning("WARNING: This plugin is disabled, do not forget to set enabled on the config to true"); + getLogger().warning("Nothing is going to work until you do that, you can reload me by using the /balancer command"); + getLogger().warning("-----------------------------------------------------"); } - } else { - getLogger().warning("-----------------------------------------------------"); - getLogger().warning("WARNING: This plugin is disabled, do not forget to set enabled on the config to true"); - getLogger().warning("Nothing is going to work until you do that, you can reload me by using the /balancer command"); - getLogger().warning("-----------------------------------------------------"); + } catch (Exception e) { + this.failed = true; + getLogger().severe("The plugin could not continue loading due to an unexpected exception"); + e.printStackTrace(); } }