Blackout/src/main/java/dev/plex/Blackout.java

58 lines
2.1 KiB
Java
Raw Normal View History

package dev.plex;
import dev.plex.listener.PlayerListener;
import dev.plex.packet.PacketManager;
import dev.plex.packet.impl.*;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
2022-03-04 01:54:57 +00:00
import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket;
2022-03-04 02:00:06 +00:00
import net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket;
2022-03-04 01:54:57 +00:00
import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket;
2022-03-04 22:46:45 +00:00
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
public class Blackout extends JavaPlugin
{
@Getter
private static Blackout plugin;
2022-03-04 22:46:45 +00:00
private static FileConfiguration config;
@Getter
private PacketManager packetManager;
2022-03-04 22:46:45 +00:00
private static boolean debugEnabled;
2022-03-04 01:54:57 +00:00
public static void debug(String message)
{
2022-03-04 22:46:45 +00:00
if (debugEnabled)
{
Blackout.getPlugin().getServer().getConsoleSender().sendMessage(Component.text("[Blackout Debug] ").color(NamedTextColor.GOLD).append(LegacyComponentSerializer.legacyAmpersand().deserialize(message)));
}
2022-03-04 01:54:57 +00:00
}
@Override
public void onLoad()
{
plugin = this;
2022-03-04 22:46:45 +00:00
config = this.getConfig();
debugEnabled = config.getBoolean("debug");
debug("Loading");
}
@Override
public void onEnable()
{
this.packetManager = new PacketManager();
this.packetManager.registerListener(ServerboundUseItemOnPacket.class, new PaintingPatch());
this.packetManager.registerListener(ServerboundUseItemOnPacket.class, new LecternPatch());
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);
}
}