Make debug mode configurable

This commit is contained in:
Telesphoreo 2022-03-04 16:46:45 -06:00
parent 16f75ea299
commit e617d94b8f
2 changed files with 15 additions and 2 deletions

View file

@ -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.ClientboundUpdateMobEffectPacket;
import net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket; import net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket;
import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; 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; import org.bukkit.plugin.java.JavaPlugin;
public class Blackout extends JavaPlugin public class Blackout extends JavaPlugin
@ -17,18 +19,27 @@ public class Blackout extends JavaPlugin
@Getter @Getter
private static Blackout plugin; private static Blackout plugin;
private static FileConfiguration config;
@Getter @Getter
private PacketManager packetManager; private PacketManager packetManager;
private static boolean debugEnabled;
public static void debug(String message) 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 @Override
public void onLoad() public void onLoad()
{ {
plugin = this; plugin = this;
config = this.getConfig();
debugEnabled = config.getBoolean("debug");
debug("Loading"); debug("Loading");
} }
@ -41,7 +52,6 @@ public class Blackout extends JavaPlugin
this.packetManager.registerListener(ServerboundUseItemOnPacket.class, new KnowledgeBookPatch()); this.packetManager.registerListener(ServerboundUseItemOnPacket.class, new KnowledgeBookPatch());
this.packetManager.registerListener(ServerboundSetCreativeModeSlotPacket.class, new SkullOwnerPatch()); this.packetManager.registerListener(ServerboundSetCreativeModeSlotPacket.class, new SkullOwnerPatch());
this.packetManager.registerListener(ClientboundUpdateMobEffectPacket.class, new EndermanPotionPatch()); this.packetManager.registerListener(ClientboundUpdateMobEffectPacket.class, new EndermanPotionPatch());
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this); this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
} }
} }

View file

@ -0,0 +1,3 @@
# Blackout configuration file
debug: false