// Path: src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsPlugin.java
// public class AdvancedPortalsPlugin extends Plugin {
// 
//     public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();
//     // key: UUID (string)
//     // value: [0] targetServer, [1] targetDestination
// 
//     @Override
//     public void onEnable() {
//         getProxy().registerChannel(BungeeMessages.CHANNEL_NAME);
// 
//         if(BungeeMessages.CHANNEL_NAME != null)
// 
//         getProxy().getPluginManager().registerListener(this, new PluginMessageReceiver(this));
//         getProxy().getPluginManager().registerListener(this, new EventListener(this));
// 
//         getLogger().info("\u00A7aAdvanced portals have been successfully enabled!");
// }
// 
//     @Override
//     public void onDisable() {
//         getLogger().info("\\u00A7cAdvanced portals are being disabled!");
//     }
// }
// 
// Path: src/main/java/com/sekwah/advancedportals/bungee/BungeeMessages.java
// public class BungeeMessages {
// 
//     /**
//      * String in
//      * string bungee server
//      * string desti name
//      * string uuid (of what the server thinks it is)
//      *
//      * String out (to recieving server)
//      * string destination
//      * string uuid
//      * string offline uuid
//      *
//      * String out
//      */
//     public static String ENTER_PORTAL = "PortalEnter";
// 
//     public static String CHANNEL_NAME = "advancedportals:warp";
// 
// 
//     public static String SERVER_DESTI = "BungeePortal";
// 
//     /**
//      * Same in and out. This is read by the bungee
//      * String containing command
//      */
//     public static String BUNGEE_COMMAND = "BungeeCommand";
// }


import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bungee.BungeeMessages;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import java.util.concurrent.TimeUnit;
package com.sekwah.advancedportals.bungee.listener;



public class PluginMessageReceiver implements Listener {
    private final AdvancedPortalsPlugin plugin;

    public PluginMessageReceiver(AdvancedPortalsPlugin plugin) { this.plugin = plugin; }

    @EventHandler
    public void onMessageReceived(PluginMessageEvent event) {
        if(!event.getTag().equalsIgnoreCase(BungeeMessages.CHANNEL_NAME) || !(event.getSender() instanceof Server)) return;

        ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
        String subChannel = in.readUTF();

// Path: src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsPlugin.java
// public class AdvancedPortalsPlugin extends Plugin {
// 
//     public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();
//     // key: UUID (string)
//     // value: [0] targetServer, [1] targetDestination
// 
//     @Override
//     public void onEnable() {
//         getProxy().registerChannel(BungeeMessages.CHANNEL_NAME);
// 
//         if(BungeeMessages.CHANNEL_NAME != null)
// 
//         getProxy().getPluginManager().registerListener(this, new PluginMessageReceiver(this));
//         getProxy().getPluginManager().registerListener(this, new EventListener(this));
// 
//         getLogger().info("\u00A7aAdvanced portals have been successfully enabled!");
// }
// 
//     @Override
//     public void onDisable() {
//         getLogger().info("\\u00A7cAdvanced portals are being disabled!");
//     }
// }
// 
// Path: src/main/java/com/sekwah/advancedportals/bungee/BungeeMessages.java
// public class BungeeMessages {
// 
//     /**
//      * String in
//      * string bungee server
//      * string desti name
//      * string uuid (of what the server thinks it is)
//      *
//      * String out (to recieving server)
//      * string destination
//      * string uuid
//      * string offline uuid
//      *
//      * String out
//      */
//     public static String ENTER_PORTAL = "PortalEnter";
// 
//     public static String CHANNEL_NAME = "advancedportals:warp";
// 
// 
//     public static String SERVER_DESTI = "BungeePortal";
// 
//     /**
//      * Same in and out. This is read by the bungee
//      * String containing command
//      */
//     public static String BUNGEE_COMMAND = "BungeeCommand";
// }


// Path: src/main/java/com/sekwah/advancedportals/bungee/listener/PluginMessageReceiver.java
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bungee.BungeeMessages;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import java.util.concurrent.TimeUnit;

package com.sekwah.advancedportals.bungee.listener;



public class PluginMessageReceiver implements Listener {
    private final AdvancedPortalsPlugin plugin;

    public PluginMessageReceiver(AdvancedPortalsPlugin plugin) { this.plugin = plugin; }

    @EventHandler
    public void onMessageReceived(PluginMessageEvent event) {
        if(!event.getTag().equalsIgnoreCase(BungeeMessages.CHANNEL_NAME) || !(event.getSender() instanceof Server)) return;

        ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
        String subChannel = in.readUTF();

        if (subChannel.equalsIgnoreCase(BungeeMessages.ENTER_PORTAL)) {