// Path: src/main/java/me/dmillerw/remoteio/core/frequency/FrequencyRegistry.java
// public class FrequencyRegistry {
// 
//     private static Map<Integer, String> savedFrequencies = Maps.newHashMap();
// 
//     public static void saveFrequency(int frequency, String name) {
//         savedFrequencies.put(frequency, name);
//     }
// 
//     public static void deleteFrequency(int frequency) {
//         savedFrequencies.remove(frequency);
//     }
// 
//     public static Map<Integer, String> getSavedFrequencies() {
//         ImmutableMap.Builder<Integer, String> builder = ImmutableMap.builder();
//         builder.putAll(savedFrequencies);
//         return builder.build();
//     }
// 
//     public static void load(File file) {
//         if (!file.exists())
//             return;
// 
//         savedFrequencies.clear();
// 
//         try {
//             BufferedReader reader = new BufferedReader(new FileReader(file));
// 
//             String line;
//             while ((line = reader.readLine()) != null) {
//                 String[] split = line.split(";");
//                 int frequency;
//                 try {
//                      frequency = Integer.parseInt(split[0]);
//                 } catch (NumberFormatException ex) {
//                     continue;
//                 }
//                 savedFrequencies.put(frequency, split[1]);
//             }
//         } catch (IOException ex) {
//             ex.printStackTrace();
//         }
//     }
// 
//     public static void save(File file) {
//         if (file.exists())
//             file.delete();
// 
//         savedFrequencies.put(1, "Test");
//         savedFrequencies.put(2, "Banana");
// 
//         try {
//             BufferedWriter writer = new BufferedWriter(new FileWriter(file));
// 
//             for(Map.Entry<Integer, String> entry : savedFrequencies.entrySet()) {
//                 writer.write(Integer.toString(entry.getKey()));
//                 writer.write(";");
//                 writer.write(entry.getValue());
//                 writer.write("\n");
//             }
// 
//             writer.close();
//         } catch (IOException ex) {
//             ex.printStackTrace();
//         }
//     }
// }
// 
// Path: src/main/java/me/dmillerw/remoteio/network/PacketHandler.java
// public class PacketHandler {
// 
//     public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(ModInfo.MOD_ID);
// 
//     public static void addScheduledTask(INetHandler netHandler, Runnable runnable) {
//         FMLCommonHandler.instance().getWorldThread(netHandler).addScheduledTask(runnable);
//     }
// 
//     public static void initialize() {
//         INSTANCE.registerMessage(CActivateBlock.Handler.class, CActivateBlock.class, -1, Side.CLIENT);
//         INSTANCE.registerMessage(CBulkFrequencyUpdate.Handler.class, CBulkFrequencyUpdate.class, -2, Side.CLIENT);
//         INSTANCE.registerMessage(CFrequencyUpdate.Handler.class, CFrequencyUpdate.class, -3, Side.CLIENT);
// 
//         INSTANCE.registerMessage(SFrequencyUpdate.Handler.class, SFrequencyUpdate.class, 1, Side.SERVER);
//         INSTANCE.registerMessage(SSetFrequency.Handler.class, SSetFrequency.class, 2, Side.SERVER);
//     }
// }
// 
// Path: src/main/java/me/dmillerw/remoteio/network/packet/client/CBulkFrequencyUpdate.java
// public class CBulkFrequencyUpdate implements IMessage {
// 
//     protected Map<Integer, String> map;
// 
//     public CBulkFrequencyUpdate() {
// 
//     }
// 
//     public CBulkFrequencyUpdate(Map<Integer, String> map) {
//         this.map = map;
//     }
// 
//     @Override
//     public void toBytes(ByteBuf buf) {
//         buf.writeInt(map.size());
//         for(Map.Entry<Integer, String> entry : map.entrySet()) {
//             buf.writeInt(entry.getKey());
//             ByteBufUtils.writeUTF8String(buf, entry.getValue());
//         }
//     }
// 
//     @Override
//     public void fromBytes(ByteBuf buf) {
//         int length = buf.readInt();
// 
//         map = Maps.newHashMap();
//         for (int i=0; i<length; i++) {
//             map.put(buf.readInt(), ByteBufUtils.readUTF8String(buf));
//         }
//     }
// 
//     public static class Handler implements IMessageHandler<CBulkFrequencyUpdate, IMessage> {
// 
//         @Override
//         public IMessage onMessage(CBulkFrequencyUpdate message, MessageContext ctx) {
//             PacketHandler.addScheduledTask(ctx.netHandler, () -> handleMessage(message, ctx));
//             return null;
//         }
// 
//         public void handleMessage(CBulkFrequencyUpdate message, MessageContext ctx) {
//             GuiFrequency.frequencies.clear();
//             GuiFrequency.frequencies.putAll(message.map);
//         }
//     }
// }


import me.dmillerw.remoteio.core.frequency.FrequencyRegistry;
import me.dmillerw.remoteio.network.PacketHandler;
import me.dmillerw.remoteio.network.packet.client.CBulkFrequencyUpdate;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
package me.dmillerw.remoteio.core.handler;


/**
 * Created by dmillerw
 */
public class PlayerEventHandler {

    public static void initialize() {
        MinecraftForge.EVENT_BUS.register(new PlayerEventHandler());
    }

    @SubscribeEvent
    public void playerLogin(PlayerEvent.PlayerLoggedInEvent event) {
        if (!event.player.worldObj.isRemote) {
// Path: src/main/java/me/dmillerw/remoteio/core/frequency/FrequencyRegistry.java
// public class FrequencyRegistry {
// 
//     private static Map<Integer, String> savedFrequencies = Maps.newHashMap();
// 
//     public static void saveFrequency(int frequency, String name) {
//         savedFrequencies.put(frequency, name);
//     }
// 
//     public static void deleteFrequency(int frequency) {
//         savedFrequencies.remove(frequency);
//     }
// 
//     public static Map<Integer, String> getSavedFrequencies() {
//         ImmutableMap.Builder<Integer, String> builder = ImmutableMap.builder();
//         builder.putAll(savedFrequencies);
//         return builder.build();
//     }
// 
//     public static void load(File file) {
//         if (!file.exists())
//             return;
// 
//         savedFrequencies.clear();
// 
//         try {
//             BufferedReader reader = new BufferedReader(new FileReader(file));
// 
//             String line;
//             while ((line = reader.readLine()) != null) {
//                 String[] split = line.split(";");
//                 int frequency;
//                 try {
//                      frequency = Integer.parseInt(split[0]);
//                 } catch (NumberFormatException ex) {
//                     continue;
//                 }
//                 savedFrequencies.put(frequency, split[1]);
//             }
//         } catch (IOException ex) {
//             ex.printStackTrace();
//         }
//     }
// 
//     public static void save(File file) {
//         if (file.exists())
//             file.delete();
// 
//         savedFrequencies.put(1, "Test");
//         savedFrequencies.put(2, "Banana");
// 
//         try {
//             BufferedWriter writer = new BufferedWriter(new FileWriter(file));
// 
//             for(Map.Entry<Integer, String> entry : savedFrequencies.entrySet()) {
//                 writer.write(Integer.toString(entry.getKey()));
//                 writer.write(";");
//                 writer.write(entry.getValue());
//                 writer.write("\n");
//             }
// 
//             writer.close();
//         } catch (IOException ex) {
//             ex.printStackTrace();
//         }
//     }
// }
// 
// Path: src/main/java/me/dmillerw/remoteio/network/PacketHandler.java
// public class PacketHandler {
// 
//     public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(ModInfo.MOD_ID);
// 
//     public static void addScheduledTask(INetHandler netHandler, Runnable runnable) {
//         FMLCommonHandler.instance().getWorldThread(netHandler).addScheduledTask(runnable);
//     }
// 
//     public static void initialize() {
//         INSTANCE.registerMessage(CActivateBlock.Handler.class, CActivateBlock.class, -1, Side.CLIENT);
//         INSTANCE.registerMessage(CBulkFrequencyUpdate.Handler.class, CBulkFrequencyUpdate.class, -2, Side.CLIENT);
//         INSTANCE.registerMessage(CFrequencyUpdate.Handler.class, CFrequencyUpdate.class, -3, Side.CLIENT);
// 
//         INSTANCE.registerMessage(SFrequencyUpdate.Handler.class, SFrequencyUpdate.class, 1, Side.SERVER);
//         INSTANCE.registerMessage(SSetFrequency.Handler.class, SSetFrequency.class, 2, Side.SERVER);
//     }
// }
// 
// Path: src/main/java/me/dmillerw/remoteio/network/packet/client/CBulkFrequencyUpdate.java
// public class CBulkFrequencyUpdate implements IMessage {
// 
//     protected Map<Integer, String> map;
// 
//     public CBulkFrequencyUpdate() {
// 
//     }
// 
//     public CBulkFrequencyUpdate(Map<Integer, String> map) {
//         this.map = map;
//     }
// 
//     @Override
//     public void toBytes(ByteBuf buf) {
//         buf.writeInt(map.size());
//         for(Map.Entry<Integer, String> entry : map.entrySet()) {
//             buf.writeInt(entry.getKey());
//             ByteBufUtils.writeUTF8String(buf, entry.getValue());
//         }
//     }
// 
//     @Override
//     public void fromBytes(ByteBuf buf) {
//         int length = buf.readInt();
// 
//         map = Maps.newHashMap();
//         for (int i=0; i<length; i++) {
//             map.put(buf.readInt(), ByteBufUtils.readUTF8String(buf));
//         }
//     }
// 
//     public static class Handler implements IMessageHandler<CBulkFrequencyUpdate, IMessage> {
// 
//         @Override
//         public IMessage onMessage(CBulkFrequencyUpdate message, MessageContext ctx) {
//             PacketHandler.addScheduledTask(ctx.netHandler, () -> handleMessage(message, ctx));
//             return null;
//         }
// 
//         public void handleMessage(CBulkFrequencyUpdate message, MessageContext ctx) {
//             GuiFrequency.frequencies.clear();
//             GuiFrequency.frequencies.putAll(message.map);
//         }
//     }
// }


// Path: src/main/java/me/dmillerw/remoteio/core/handler/PlayerEventHandler.java
import me.dmillerw.remoteio.core.frequency.FrequencyRegistry;
import me.dmillerw.remoteio.network.PacketHandler;
import me.dmillerw.remoteio.network.packet.client.CBulkFrequencyUpdate;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;

package me.dmillerw.remoteio.core.handler;


/**
 * Created by dmillerw
 */
public class PlayerEventHandler {

    public static void initialize() {
        MinecraftForge.EVENT_BUS.register(new PlayerEventHandler());
    }

    @SubscribeEvent
    public void playerLogin(PlayerEvent.PlayerLoggedInEvent event) {
        if (!event.player.worldObj.isRemote) {
            CBulkFrequencyUpdate packet = new CBulkFrequencyUpdate(FrequencyRegistry.getSavedFrequencies());