// Path: src/main/java/uk/kihira/tails/common/network/PlayerDataMapMessage.java
// public class PlayerDataMapMessage 
// {
//     private Map<UUID, Outfit> outfitMap;
// 
//     public PlayerDataMapMessage() {}
//     public PlayerDataMapMessage(Map<UUID, Outfit> outfitMap) 
//     {
//         this.outfitMap = outfitMap;
//     }
// 
//     public PlayerDataMapMessage(PacketBuffer buf) 
//     {
//         String tailInfoJson = buf.readString();
//         try 
//         {
//             this.outfitMap = Tails.GSON.fromJson(tailInfoJson, new TypeToken<Map<UUID, Outfit>>() {}.getType());
//         } catch (JsonSyntaxException e) 
//         {
//             Tails.LOGGER.catching(e);
//         }
//     }
// 
//     public void encode(PacketBuffer buf)
//     {
//         String tailInfoJson = Tails.GSON.toJson(this.outfitMap);
//         buf.writeString(tailInfoJson);
//     }
// 
//     public void handle(Supplier<Context> ctx) 
//     {
//         ctx.get().enqueueWork(() -> 
//         {
//             for (Map.Entry<UUID, Outfit> entry : outfitMap.entrySet()) 
//             {
//                 Tails.proxy.setActiveOutfit(entry.getKey(), entry.getValue());
//             }
//         });
//         ctx.get().setPacketHandled(true);
//     }
// }
// 
// Path: src/main/java/uk/kihira/tails/common/network/ServerCapabilitiesMessage.java
// 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));
//         ctx.get().setPacketHandled(true);
//     }
// }
// 
// Path: src/main/java/uk/kihira/tails/common/network/TailsPacketHandler.java
// public final class TailsPacketHandler 
// {
//     private static final String PROTOCOL_VERSION = "1";
// 
//     public static final SimpleChannel networkWrapper = NetworkRegistry.newSimpleChannel(
//         new ResourceLocation(Tails.MOD_ID, "main"),
//         () -> PROTOCOL_VERSION,
//         PROTOCOL_VERSION::equals,
//         TailsPacketHandler::versionCheck);
// 
//     private static boolean versionCheck(String serverVersion) 
//     {
//         if (serverVersion.equals(NetworkRegistry.ABSENT) || serverVersion.equals(NetworkRegistry.ACCEPTVANILLA))
//         {
//             Tails.LOGGER.info("Connecting to vanilla server, or mod is missing from server");
//             Tails.hasRemote = false; // TODO better pattern
//         }
//         else if (serverVersion.equals(PROTOCOL_VERSION))
//         {
//             Tails.LOGGER.info("Connecting to server that has Tails mod installed and acceptable version");
//             Tails.hasRemote = true;
//         }
//         else
//         {
//             Tails.LOGGER.warn("Unknown server version %s!", serverVersion);
//         }
// 
//         return true;
//     }
// }


import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.network.PacketDistributor;
import uk.kihira.tails.common.network.PlayerDataMapMessage;
import uk.kihira.tails.common.network.ServerCapabilitiesMessage;
import uk.kihira.tails.common.network.TailsPacketHandler;
package uk.kihira.tails.common;


public class ServerEventHandler 
{
    @SubscribeEvent
    public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) 
    {
        //Send current known tails to client
// Path: src/main/java/uk/kihira/tails/common/network/PlayerDataMapMessage.java
// public class PlayerDataMapMessage 
// {
//     private Map<UUID, Outfit> outfitMap;
// 
//     public PlayerDataMapMessage() {}
//     public PlayerDataMapMessage(Map<UUID, Outfit> outfitMap) 
//     {
//         this.outfitMap = outfitMap;
//     }
// 
//     public PlayerDataMapMessage(PacketBuffer buf) 
//     {
//         String tailInfoJson = buf.readString();
//         try 
//         {
//             this.outfitMap = Tails.GSON.fromJson(tailInfoJson, new TypeToken<Map<UUID, Outfit>>() {}.getType());
//         } catch (JsonSyntaxException e) 
//         {
//             Tails.LOGGER.catching(e);
//         }
//     }
// 
//     public void encode(PacketBuffer buf)
//     {
//         String tailInfoJson = Tails.GSON.toJson(this.outfitMap);
//         buf.writeString(tailInfoJson);
//     }
// 
//     public void handle(Supplier<Context> ctx) 
//     {
//         ctx.get().enqueueWork(() -> 
//         {
//             for (Map.Entry<UUID, Outfit> entry : outfitMap.entrySet()) 
//             {
//                 Tails.proxy.setActiveOutfit(entry.getKey(), entry.getValue());
//             }
//         });
//         ctx.get().setPacketHandled(true);
//     }
// }
// 
// Path: src/main/java/uk/kihira/tails/common/network/ServerCapabilitiesMessage.java
// 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));
//         ctx.get().setPacketHandled(true);
//     }
// }
// 
// Path: src/main/java/uk/kihira/tails/common/network/TailsPacketHandler.java
// public final class TailsPacketHandler 
// {
//     private static final String PROTOCOL_VERSION = "1";
// 
//     public static final SimpleChannel networkWrapper = NetworkRegistry.newSimpleChannel(
//         new ResourceLocation(Tails.MOD_ID, "main"),
//         () -> PROTOCOL_VERSION,
//         PROTOCOL_VERSION::equals,
//         TailsPacketHandler::versionCheck);
// 
//     private static boolean versionCheck(String serverVersion) 
//     {
//         if (serverVersion.equals(NetworkRegistry.ABSENT) || serverVersion.equals(NetworkRegistry.ACCEPTVANILLA))
//         {
//             Tails.LOGGER.info("Connecting to vanilla server, or mod is missing from server");
//             Tails.hasRemote = false; // TODO better pattern
//         }
//         else if (serverVersion.equals(PROTOCOL_VERSION))
//         {
//             Tails.LOGGER.info("Connecting to server that has Tails mod installed and acceptable version");
//             Tails.hasRemote = true;
//         }
//         else
//         {
//             Tails.LOGGER.warn("Unknown server version %s!", serverVersion);
//         }
// 
//         return true;
//     }
// }


// Path: src/main/java/uk/kihira/tails/common/ServerEventHandler.java
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.network.PacketDistributor;
import uk.kihira.tails.common.network.PlayerDataMapMessage;
import uk.kihira.tails.common.network.ServerCapabilitiesMessage;
import uk.kihira.tails.common.network.TailsPacketHandler;

package uk.kihira.tails.common;


public class ServerEventHandler 
{
    @SubscribeEvent
    public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) 
    {
        //Send current known tails to client
        TailsPacketHandler.networkWrapper.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer()), new PlayerDataMapMessage(Tails.proxy.getActiveOutfits()));