Skip to content

Commit d773800

Browse files
committed
Handle configuration exceptions too
1 parent 5dd49b4 commit d773800

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

setup.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
mkdir libs
44
cd libs
5+
56
powershell -Command "Invoke-WebRequest https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar -OutFile BungeeCord.jar"
67
mvn install:install-file -Dfile=BungeeCord.jar -DgroupId=net.md-5 -DartifactId=bungeecord-proxy -Dversion=local -Dpackaging=jar

setup.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3-
mkdir libs && cd "$_"
3+
mkdir libs
4+
cd libs
5+
46
wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar
57
mvn install:install-file -Dfile=BungeeCord.jar -DgroupId=net.md-5 -DartifactId=bungeecord-proxy -Dversion=local -Dpackaging=jar

src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,29 @@ private void enable() {
7171
try {
7272
CommentedConfigurationNode node = loader.load();
7373
settings = node.getValue(TypeToken.of(SettingsHolder.class));
74-
} catch (Exception e) {
75-
e.printStackTrace();
76-
}
7774

78-
mainCommand = new MainCommand(this);
79-
getProxy().getPluginManager().registerCommand(this, mainCommand);
75+
mainCommand = new MainCommand(this);
76+
getProxy().getPluginManager().registerCommand(this, mainCommand);
8077

81-
if (settings.getGeneralProps().isEnabled()) {
82-
if (settings.getGeneralProps().isSilent()) {
83-
getLogger().setLevel(Level.WARNING);
84-
}
78+
if (settings.getGeneralProps().isEnabled()) {
79+
if (settings.getGeneralProps().isSilent()) {
80+
getLogger().setLevel(Level.WARNING);
81+
}
8582

86-
if (settings.getGeneralProps().isAutoReload()) {
87-
reloadListener = new ProxyReloadListener(this);
88-
getProxy().getPluginManager().registerListener(this, reloadListener);
89-
}
83+
if (settings.getGeneralProps().isAutoReload()) {
84+
reloadListener = new ProxyReloadListener(this);
85+
getProxy().getPluginManager().registerListener(this, reloadListener);
86+
}
9087

91-
try {
92-
new BungeeUpdater(this, 10788);
93-
} catch (IOException e) {
94-
e.printStackTrace();
95-
}
88+
try {
89+
new BungeeUpdater(this, 10788);
90+
} catch (IOException e) {
91+
e.printStackTrace();
92+
}
9693

97-
networkManager = new NetworkManager(this);
98-
sectionManager = new SectionManager(this);
94+
networkManager = new NetworkManager(this);
9995

100-
try {
96+
sectionManager = new SectionManager(this);
10197
sectionManager.load();
10298

10399
statusManager = new StatusManager(this);
@@ -131,16 +127,16 @@ private void enable() {
131127
}
132128

133129
getLogger().info("The plugin has finished loading without any problems");
134-
} catch (RuntimeException e) {
135-
this.failed = true;
136-
getLogger().severe("The plugin could not continue loading due to an unexpected exception");
137-
e.printStackTrace();
130+
} else {
131+
getLogger().warning("-----------------------------------------------------");
132+
getLogger().warning("WARNING: This plugin is disabled, do not forget to set enabled on the config to true");
133+
getLogger().warning("Nothing is going to work until you do that, you can reload me by using the /balancer command");
134+
getLogger().warning("-----------------------------------------------------");
138135
}
139-
} else {
140-
getLogger().warning("-----------------------------------------------------");
141-
getLogger().warning("WARNING: This plugin is disabled, do not forget to set enabled on the config to true");
142-
getLogger().warning("Nothing is going to work until you do that, you can reload me by using the /balancer command");
143-
getLogger().warning("-----------------------------------------------------");
136+
} catch (Exception e) {
137+
this.failed = true;
138+
getLogger().severe("The plugin could not continue loading due to an unexpected exception");
139+
e.printStackTrace();
144140
}
145141
}
146142

0 commit comments

Comments
 (0)