// 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.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.google.inject.Inject;
import com.sekwah.advancedportals.bungee.BungeeMessages;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import org.slf4j.Logger;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;

package com.sekwah.advancedportals.velocity;



/**
 * While there may be a better way to do this for now we are keeping the behavior so it also works with Bungee's horrible API.
 */
@Plugin(id = "advancedportals", name = "Advanced Portals",
        url = "https://www.spigotmc.org/resources/advanced-portals.14356/",
        version = "0.9.2")
public class AdvancedPortalsPlugin {

    public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();

    private final Logger logger;
    private final ProxyServer proxy;
    private LegacyChannelIdentifier AP_CHANNEL;

    @Inject
    public AdvancedPortalsPlugin(ProxyServer proxy, Logger logger) {

        this.proxy = proxy;
        this.logger = logger;

        logger.info("\u00A7aAdvanced portals have been successfully enabled!");

    }

    @Subscribe
    public void onProxyInitialize(ProxyInitializeEvent event) {

        String[] splitChannel = BungeeMessages.CHANNEL_NAME.split(":");
        AP_CHANNEL = new LegacyChannelIdentifier(BungeeMessages.CHANNEL_NAME);


// 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/velocity/AdvancedPortalsPlugin.java
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.google.inject.Inject;
import com.sekwah.advancedportals.bungee.BungeeMessages;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import org.slf4j.Logger;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;

package com.sekwah.advancedportals.velocity;



/**
 * While there may be a better way to do this for now we are keeping the behavior so it also works with Bungee's horrible API.
 */
@Plugin(id = "advancedportals", name = "Advanced Portals",
        url = "https://www.spigotmc.org/resources/advanced-portals.14356/",
        version = "0.9.2")
public class AdvancedPortalsPlugin {

    public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();

    private final Logger logger;
    private final ProxyServer proxy;
    private LegacyChannelIdentifier AP_CHANNEL;

    @Inject
    public AdvancedPortalsPlugin(ProxyServer proxy, Logger logger) {

        this.proxy = proxy;
        this.logger = logger;

        logger.info("\u00A7aAdvanced portals have been successfully enabled!");

    }

    @Subscribe
    public void onProxyInitialize(ProxyInitializeEvent event) {

        String[] splitChannel = BungeeMessages.CHANNEL_NAME.split(":");
        AP_CHANNEL = new LegacyChannelIdentifier(BungeeMessages.CHANNEL_NAME);


        proxy.getChannelRegistrar().register(AP_CHANNEL);
