// Path: src/main/java/com/github/duke605/dce/DiscordCE.java
// @Mod(
//         modid = Reference.MODID,
//         name = Reference.NAME,
//         version = Reference.VERSION,
//         clientSideOnly = true,
//         guiFactory = "com.github.duke605.dce.gui.factory.GuiFactoryDiscordConfig"
// )
// public class DiscordCE
// {
// 
//     @Mod.Instance(Reference.MODID)
//     public static DiscordCE instance;
// 
//     // Mod start time
//     public static long startTime = System.currentTimeMillis();
// 
//     // Will be set when ready event called
//     public static volatile JDAClient client;
// 
//     // Keybindings
//     public static KeyBinding test;
// 
//     @Mod.EventHandler
//     public void preInit(FMLPreInitializationEvent e)
//     {
//         Config.load(e.getSuggestedConfigurationFile());
//         Preferences.load(new File(e.getModConfigurationDirectory(), "dce.json.tar.gz"));
//     }
// 
//     @Mod.EventHandler
//     public void init(FMLInitializationEvent e)
//     {
//         String token = null;
// 
//         // Checking if we have their token
//         try
//         {
//             File tokenFile = new File("tokens.json");
//             String tempToken;
// 
//             // Checking if the file exists
//             if (!tokenFile.exists())
//                 throw new FileNotFoundException();
// 
//             // Reading from the file
//             try (JsonReader in = new JsonReader(new InputStreamReader(new FileInputStream(tokenFile))))
//             {
//                 // Getting the tokens object
//                 JsonObject tokens = new JsonParser().parse(in).getAsJsonObject();
// 
//                 // Checking if it contains the current players email
//                 if (tokens.has(Config.email))
//                     tempToken = tokens.get(Config.email).getAsString();
//                 else
//                     throw new FileNotFoundException();
// 
//                 // Checking if token is valid
//                 HttpResponse r = Unirest.get(Requester.DISCORD_API_PREFIX+"users/@me/guilds")
//                         .header("authorization", tempToken)
//                         .header("user-agent", Requester.USER_AGENT)
//                         .asString();
// 
//                 // Checking if good
//                 if (HttpUtil.isOk(r.getStatus()))
//                     token = tempToken;
//             }
//         }
//         catch (FileNotFoundException ex) {}
//         catch (Exception ex)
//         {
//             ex.printStackTrace();
//         }
// 
//         // Connecting
//         try
//         {
//             // Building client
//             JDAClientBuilder b = new JDAClientBuilder()
//                     .addListener(new DiscordEventHandler())
//                     .setAudioEnabled(false);
// 
//             // Checking if MFA code is needed
//             if (token == null)
//             {
//                 String email = null;
// 
//                 // Setting email
//                 b.setEmail(Config.email.trim().isEmpty()
//                     ? email = JOptionPane.showInputDialog(null, "Please enter your email address.")
//                     : Config.email);
// 
//                 // Getting user password
//                 b.setPassword(JOptionPane.showInputDialog(null, "Please enter your password for " + Config.email));
// 
//                 // Getting MFA Code
//                 b.setCode(JOptionPane.showInputDialog(null, "Please enter the token from your two-factor " +
//                         "authentication mobile app.\nIf you do not use two-factor authentication please press \"OK.\""));
// 
//                 // Saving email in config
//                 if (email != null)
//                 {
//                     Config.emailProp.set(email);
//                     Config.emailHash = Config.hash(email);
//                     Config.instance.save();
//                 }
//             }
// 
//             // Token already gotten no need to get MFA code or password
//             else
//                 b.setClientToken(token);
// 
//             b.buildAsync();
//         }
//         catch (Exception ex)
//         {
//             ex.printStackTrace();
//             ConcurrentUtil.executor.execute(() ->
//                     JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE));
//         }
//     }
// 
//     @Mod.EventHandler
//     public void postInit(FMLPostInitializationEvent e)
//     {
//         ClientCommandHandler.instance.registerCommand(new CommandChat());
//         ClientCommandHandler.instance.registerCommand(new CommandSwitchChannel());
//         ClientCommandHandler.instance.registerCommand(new CommandBlock());
//         ClientCommandHandler.instance.registerCommand(new CommandUnblock());
//         ClientCommandHandler.instance.registerCommand(new CommandAddFriend());
//         ClientCommandHandler.instance.registerCommand(new CommandDeleteFriend());
//         ClientCommandHandler.instance.registerCommand(new CommandFocus());
//         ClientCommandHandler.instance.registerCommand(new CommandDM());
// 
//         ClientRegistry.registerKeyBinding(test = new KeyBinding("Open DiscordCE menu", Keyboard.KEY_Y, "DiscordCE"));
// 
//         MinecraftForge.EVENT_BUS.register(new MinecraftEventHandler());
// 
//         // Tracking game start
//         MixpanelUtil.setStartGameEvent(true);
//     }
// }
// 
// Path: src/main/java/com/github/duke605/dce/contract/CustomListenerAdapter.java
// public class CustomListenerAdapter extends ListenerAdapter {
//     public void onRelationshipAdd(RelationshipAddEvent e) {}
//     public void onRelationshipRemove(RelationshipRemoveEvent e) {}
// }


import com.github.duke605.dce.DiscordCE;
import com.github.duke605.dce.contract.CustomListenerAdapter;
import org.json.JSONObject;
package com.github.duke605.dce.event;


public class RelationshipRemoveEvent
{
    public String id;
    public int type;

    public RelationshipRemoveEvent(JSONObject o) {
        id = o.getString("id");
        type = o.getInt("type");
    }

    public void post()
    {
        DiscordCE.client
                .getRegisteredListeners()
                .stream()
                .filter(o -> o instanceof CustomListenerAdapter)
// Path: src/main/java/com/github/duke605/dce/DiscordCE.java
// @Mod(
//         modid = Reference.MODID,
//         name = Reference.NAME,
//         version = Reference.VERSION,
//         clientSideOnly = true,
//         guiFactory = "com.github.duke605.dce.gui.factory.GuiFactoryDiscordConfig"
// )
// public class DiscordCE
// {
// 
//     @Mod.Instance(Reference.MODID)
//     public static DiscordCE instance;
// 
//     // Mod start time
//     public static long startTime = System.currentTimeMillis();
// 
//     // Will be set when ready event called
//     public static volatile JDAClient client;
// 
//     // Keybindings
//     public static KeyBinding test;
// 
//     @Mod.EventHandler
//     public void preInit(FMLPreInitializationEvent e)
//     {
//         Config.load(e.getSuggestedConfigurationFile());
//         Preferences.load(new File(e.getModConfigurationDirectory(), "dce.json.tar.gz"));
//     }
// 
//     @Mod.EventHandler
//     public void init(FMLInitializationEvent e)
//     {
//         String token = null;
// 
//         // Checking if we have their token
//         try
//         {
//             File tokenFile = new File("tokens.json");
//             String tempToken;
// 
//             // Checking if the file exists
//             if (!tokenFile.exists())
//                 throw new FileNotFoundException();
// 
//             // Reading from the file
//             try (JsonReader in = new JsonReader(new InputStreamReader(new FileInputStream(tokenFile))))
//             {
//                 // Getting the tokens object
//                 JsonObject tokens = new JsonParser().parse(in).getAsJsonObject();
// 
//                 // Checking if it contains the current players email
//                 if (tokens.has(Config.email))
//                     tempToken = tokens.get(Config.email).getAsString();
//                 else
//                     throw new FileNotFoundException();
// 
//                 // Checking if token is valid
//                 HttpResponse r = Unirest.get(Requester.DISCORD_API_PREFIX+"users/@me/guilds")
//                         .header("authorization", tempToken)
//                         .header("user-agent", Requester.USER_AGENT)
//                         .asString();
// 
//                 // Checking if good
//                 if (HttpUtil.isOk(r.getStatus()))
//                     token = tempToken;
//             }
//         }
//         catch (FileNotFoundException ex) {}
//         catch (Exception ex)
//         {
//             ex.printStackTrace();
//         }
// 
//         // Connecting
//         try
//         {
//             // Building client
//             JDAClientBuilder b = new JDAClientBuilder()
//                     .addListener(new DiscordEventHandler())
//                     .setAudioEnabled(false);
// 
//             // Checking if MFA code is needed
//             if (token == null)
//             {
//                 String email = null;
// 
//                 // Setting email
//                 b.setEmail(Config.email.trim().isEmpty()
//                     ? email = JOptionPane.showInputDialog(null, "Please enter your email address.")
//                     : Config.email);
// 
//                 // Getting user password
//                 b.setPassword(JOptionPane.showInputDialog(null, "Please enter your password for " + Config.email));
// 
//                 // Getting MFA Code
//                 b.setCode(JOptionPane.showInputDialog(null, "Please enter the token from your two-factor " +
//                         "authentication mobile app.\nIf you do not use two-factor authentication please press \"OK.\""));
// 
//                 // Saving email in config
//                 if (email != null)
//                 {
//                     Config.emailProp.set(email);
//                     Config.emailHash = Config.hash(email);
//                     Config.instance.save();
//                 }
//             }
// 
//             // Token already gotten no need to get MFA code or password
//             else
//                 b.setClientToken(token);
// 
//             b.buildAsync();
//         }
//         catch (Exception ex)
//         {
//             ex.printStackTrace();
//             ConcurrentUtil.executor.execute(() ->
//                     JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE));
//         }
//     }
// 
//     @Mod.EventHandler
//     public void postInit(FMLPostInitializationEvent e)
//     {
//         ClientCommandHandler.instance.registerCommand(new CommandChat());
//         ClientCommandHandler.instance.registerCommand(new CommandSwitchChannel());
//         ClientCommandHandler.instance.registerCommand(new CommandBlock());
//         ClientCommandHandler.instance.registerCommand(new CommandUnblock());
//         ClientCommandHandler.instance.registerCommand(new CommandAddFriend());
//         ClientCommandHandler.instance.registerCommand(new CommandDeleteFriend());
//         ClientCommandHandler.instance.registerCommand(new CommandFocus());
//         ClientCommandHandler.instance.registerCommand(new CommandDM());
// 
//         ClientRegistry.registerKeyBinding(test = new KeyBinding("Open DiscordCE menu", Keyboard.KEY_Y, "DiscordCE"));
// 
//         MinecraftForge.EVENT_BUS.register(new MinecraftEventHandler());
// 
//         // Tracking game start
//         MixpanelUtil.setStartGameEvent(true);
//     }
// }
// 
// Path: src/main/java/com/github/duke605/dce/contract/CustomListenerAdapter.java
// public class CustomListenerAdapter extends ListenerAdapter {
//     public void onRelationshipAdd(RelationshipAddEvent e) {}
//     public void onRelationshipRemove(RelationshipRemoveEvent e) {}
// }


// Path: src/main/java/com/github/duke605/dce/event/RelationshipRemoveEvent.java
import com.github.duke605.dce.DiscordCE;
import com.github.duke605.dce.contract.CustomListenerAdapter;
import org.json.JSONObject;

package com.github.duke605.dce.event;


public class RelationshipRemoveEvent
{
    public String id;
    public int type;

    public RelationshipRemoveEvent(JSONObject o) {
        id = o.getString("id");
        type = o.getInt("type");
    }

    public void post()
    {
        DiscordCE.client
                .getRegisteredListeners()
                .stream()
                .filter(o -> o instanceof CustomListenerAdapter)
                .forEach(o -> ((CustomListenerAdapter) o).onRelationshipRemove(this));