// Path: src/main/java/uk/kihira/tails/common/Config.java
// public final class Config 
// {
//     public static BooleanValue forceLegacyRendering;
//     public static BooleanValue libraryEnabled;
//     public static ConfigValue<Outfit> localOutfit;
// 
//     public static ForgeConfigSpec configuration;
// 
//     public static void loadConfig() 
//     {
//         ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
// 
//         forceLegacyRendering = builder
//                 .comment("Forces the legacy renderer which may have better compatibility with other mods")
//                 .define("forceLegacyRenderer", false);
// 
//         libraryEnabled = builder
//                 .comment("Whether to enable the library system for sharing tails. This mostly matters on servers.")
//                 .define("enableLibrary", true);
// 
//         localOutfit = builder
//                 .comment("Local Players outfit. Delete to remove all customisation data. Do not try to edit manually")
//                 .define("localPlayerOutfit", new Outfit());
//         
//         //Load default if none exists
//         if (localOutfit == null) 
//         {
//             Tails.setLocalOutfit(new Outfit());
//         }
//         // todo
// /*        try
//         {
//             localOutfit = Gson.fromJson(Tails.configuration.getString("Local Player Outfit",
//                     Configuration.CATEGORY_GENERAL, "{}", "Local Players outfit. Delete to remove all customisation data. Do not try to edit manually"), Outfit.class);
// 
//         } catch (JsonSyntaxException e) {
//             Tails.configuration.getCategory(Configuration.CATEGORY_GENERAL).remove("Local Player Data");
//             Tails.LOGGER.error("Failed to load local player data: Invalid JSON syntax! Invalid data being removed");
//         }*/
// 
//         configuration = builder.build();
//         //configuration.save();
//     }
// }
// 
// Path: src/main/java/uk/kihira/tails/common/Tails.java
// @Mod(Tails.MOD_ID)
// public class Tails 
// {
//     public static final String MOD_ID = "tails";
//     public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
//     public static final Gson GSON = new GsonBuilder().create();
//     public static final boolean DEBUG = true;
// 
//     public static boolean hasRemote;
// 
//     public static CommonProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
// 
//     public Tails()
//     {
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onConfigChange);
//         MinecraftForge.EVENT_BUS.addListener(this::addReloadListener);
//     }
// 
//     private void setup(final FMLCommonSetupEvent event)
//     {
//         proxy.preInit();
//         Config.loadConfig();
// 
//         PartRegistry.loadAllPartsFromResources();
//     }
// 
//     private void addReloadListener(final AddReloadListenerEvent event)
//     {
//         event.addListener((stage, resourceManager, preparationsProfiler, reloadProfiler, backgroundExecutor, gameExecutor) ->
//                 CompletableFuture.runAsync(() -> proxy.onResourceManagerReload()));
//     }
// 
//     public void onConfigChange(final ModConfigEvent event)
//     {
//         if (event.getConfig().getModId().equals(Tails.MOD_ID)) 
//         {
//             Config.loadConfig();
//         }
//     }
// 
//     public static void setLocalOutfit(final Outfit outfit)
//     {
//         Config.localOutfit.set(outfit);
//         Config.configuration.save();
//     }
// }


import java.util.function.Supplier;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.network.NetworkEvent.Context;
import uk.kihira.tails.common.Config;
import uk.kihira.tails.common.Tails;
package uk.kihira.tails.common.network;



public class ServerCapabilitiesMessage 
{
    private final boolean library;

    public ServerCapabilitiesMessage(boolean library)
    {
        this.library = library;
    }

    public ServerCapabilitiesMessage(PacketBuffer buf) 
    {
        library = buf.readBoolean();
    }

    public void encode(PacketBuffer buf) 
    {
        buf.writeBoolean(library);
    }

    public void handle(Supplier<Context> ctx) 
    {
// Path: src/main/java/uk/kihira/tails/common/Config.java
// public final class Config 
// {
//     public static BooleanValue forceLegacyRendering;
//     public static BooleanValue libraryEnabled;
//     public static ConfigValue<Outfit> localOutfit;
// 
//     public static ForgeConfigSpec configuration;
// 
//     public static void loadConfig() 
//     {
//         ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
// 
//         forceLegacyRendering = builder
//                 .comment("Forces the legacy renderer which may have better compatibility with other mods")
//                 .define("forceLegacyRenderer", false);
// 
//         libraryEnabled = builder
//                 .comment("Whether to enable the library system for sharing tails. This mostly matters on servers.")
//                 .define("enableLibrary", true);
// 
//         localOutfit = builder
//                 .comment("Local Players outfit. Delete to remove all customisation data. Do not try to edit manually")
//                 .define("localPlayerOutfit", new Outfit());
//         
//         //Load default if none exists
//         if (localOutfit == null) 
//         {
//             Tails.setLocalOutfit(new Outfit());
//         }
//         // todo
// /*        try
//         {
//             localOutfit = Gson.fromJson(Tails.configuration.getString("Local Player Outfit",
//                     Configuration.CATEGORY_GENERAL, "{}", "Local Players outfit. Delete to remove all customisation data. Do not try to edit manually"), Outfit.class);
// 
//         } catch (JsonSyntaxException e) {
//             Tails.configuration.getCategory(Configuration.CATEGORY_GENERAL).remove("Local Player Data");
//             Tails.LOGGER.error("Failed to load local player data: Invalid JSON syntax! Invalid data being removed");
//         }*/
// 
//         configuration = builder.build();
//         //configuration.save();
//     }
// }
// 
// Path: src/main/java/uk/kihira/tails/common/Tails.java
// @Mod(Tails.MOD_ID)
// public class Tails 
// {
//     public static final String MOD_ID = "tails";
//     public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
//     public static final Gson GSON = new GsonBuilder().create();
//     public static final boolean DEBUG = true;
// 
//     public static boolean hasRemote;
// 
//     public static CommonProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
// 
//     public Tails()
//     {
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onConfigChange);
//         MinecraftForge.EVENT_BUS.addListener(this::addReloadListener);
//     }
// 
//     private void setup(final FMLCommonSetupEvent event)
//     {
//         proxy.preInit();
//         Config.loadConfig();
// 
//         PartRegistry.loadAllPartsFromResources();
//     }
// 
//     private void addReloadListener(final AddReloadListenerEvent event)
//     {
//         event.addListener((stage, resourceManager, preparationsProfiler, reloadProfiler, backgroundExecutor, gameExecutor) ->
//                 CompletableFuture.runAsync(() -> proxy.onResourceManagerReload()));
//     }
// 
//     public void onConfigChange(final ModConfigEvent event)
//     {
//         if (event.getConfig().getModId().equals(Tails.MOD_ID)) 
//         {
//             Config.loadConfig();
//         }
//     }
// 
//     public static void setLocalOutfit(final Outfit outfit)
//     {
//         Config.localOutfit.set(outfit);
//         Config.configuration.save();
//     }
// }


// Path: src/main/java/uk/kihira/tails/common/network/ServerCapabilitiesMessage.java
import java.util.function.Supplier;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.network.NetworkEvent.Context;
import uk.kihira.tails.common.Config;
import uk.kihira.tails.common.Tails;

package uk.kihira.tails.common.network;



public class ServerCapabilitiesMessage 
{
    private final boolean library;

    public ServerCapabilitiesMessage(boolean library)
    {
        this.library = library;
    }

    public ServerCapabilitiesMessage(PacketBuffer buf) 
    {
        library = buf.readBoolean();
    }

    public void encode(PacketBuffer buf) 
    {
        buf.writeBoolean(library);
    }

    public void handle(Supplier<Context> ctx) 
    {
        ctx.get().enqueueWork(() -> Config.libraryEnabled.set(this.library));