Skip to content

Commit 4e42d62

Browse files
committed
Add a bit of extra logging/documentation
1 parent 6964ea6 commit 4e42d62

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

blcmodapibungee/src/main/java/net/badlion/blcmodapibungee/BlcModApiBungee.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.io.FileWriter;
1313
import java.io.IOException;
1414
import java.io.Reader;
15+
import java.util.logging.Level;
1516

1617
public class BlcModApiBungee extends Plugin {
1718

@@ -23,29 +24,34 @@ public class BlcModApiBungee extends Plugin {
2324
@Override
2425
public void onEnable() {
2526
if (!this.getDataFolder().exists()) {
26-
this.getDataFolder().mkdir();
27+
if (!this.getDataFolder().mkdir()) {
28+
this.getLogger().log(Level.SEVERE, "Failed to create plugin directory.");
29+
}
2730
}
31+
2832
try {
2933
this.conf = loadConf(new File(this.getDataFolder(), "config.json"));
34+
35+
// Only register the listener if the config loads successfully
36+
this.getProxy().getPluginManager().registerListener(this, new PlayerListener(this));
37+
38+
this.getLogger().log(Level.INFO, "Successfully setup BadlionClientModAPI plugin.");
3039
} catch (IOException e) {
40+
this.getLogger().log(Level.SEVERE, "Error with config for BadlionClientModAPI plugin.");
3141
e.printStackTrace();
3242
}
33-
34-
this.getProxy().getPluginManager().registerListener(this, new PlayerListener(this));
3543
}
3644

37-
3845
@Override
3946
public void onDisable() {
4047

4148
}
4249

43-
4450
public Conf loadConf(File file) throws IOException {
4551
try (Reader reader = new BufferedReader(new FileReader(file))) {
4652
return BlcModApiBungee.GSON_NON_PRETTY.fromJson(reader, Conf.class);
4753
} catch (FileNotFoundException ex) {
48-
this.getLogger().info("No Config Found: Saving default...");
54+
this.getLogger().log(Level.INFO,"No Config Found: Saving default...");
4955
Conf conf = new Conf();
5056
this.saveConf(conf, new File(this.getDataFolder(), "config.json"));
5157
return conf;

blcmodapibungee/src/main/java/net/badlion/blcmodapibungee/listener/PlayerListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public PlayerListener(BlcModApiBungee plugin) {
1818

1919
@EventHandler
2020
public void onLogin(PostLoginEvent event) {
21+
// Send the disallowed mods to players when they login to the proxy. A notification will appear on the Badlion Client so they know the mod was disabled
2122
ProxiedPlayer player = event.getPlayer();
2223
player.unsafe().sendPacket(new PluginMessage("BLC|M", BlcModApiBungee.GSON_NON_PRETTY.toJson(this.plugin.getConf().getModsDisallowed()).getBytes(), false));
2324
}

0 commit comments

Comments
 (0)