From e617d94b8f08adfd517ba232587510a2bf4dded7 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Fri, 4 Mar 2022 16:46:45 -0600 Subject: [PATCH] Make debug mode configurable --- src/main/java/dev/plex/Blackout.java | 14 ++++++++++++-- src/main/resources/config.yml | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/config.yml diff --git a/src/main/java/dev/plex/Blackout.java b/src/main/java/dev/plex/Blackout.java index 5b0176d..1c3f201 100644 --- a/src/main/java/dev/plex/Blackout.java +++ b/src/main/java/dev/plex/Blackout.java @@ -10,6 +10,8 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket; import net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket; import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; public class Blackout extends JavaPlugin @@ -17,18 +19,27 @@ public class Blackout extends JavaPlugin @Getter private static Blackout plugin; + private static FileConfiguration config; + @Getter private PacketManager packetManager; + private static boolean debugEnabled; + public static void debug(String message) { - Blackout.getPlugin().getServer().getConsoleSender().sendMessage(Component.text("[Blackout Debug] ").color(NamedTextColor.GOLD).append(LegacyComponentSerializer.legacyAmpersand().deserialize(message))); + if (debugEnabled) + { + Blackout.getPlugin().getServer().getConsoleSender().sendMessage(Component.text("[Blackout Debug] ").color(NamedTextColor.GOLD).append(LegacyComponentSerializer.legacyAmpersand().deserialize(message))); + } } @Override public void onLoad() { plugin = this; + config = this.getConfig(); + debugEnabled = config.getBoolean("debug"); debug("Loading"); } @@ -41,7 +52,6 @@ public class Blackout extends JavaPlugin this.packetManager.registerListener(ServerboundUseItemOnPacket.class, new KnowledgeBookPatch()); this.packetManager.registerListener(ServerboundSetCreativeModeSlotPacket.class, new SkullOwnerPatch()); this.packetManager.registerListener(ClientboundUpdateMobEffectPacket.class, new EndermanPotionPatch()); - this.getServer().getPluginManager().registerEvents(new PlayerListener(), this); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..4677927 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,3 @@ +# Blackout configuration file + +debug: false \ No newline at end of file