package tc.oc.commons.bukkit.chat;

import java.net.URI;
import java.net.URISyntaxException;

import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TranslatableComponent;
import tc.oc.api.docs.PlayerId;
import tc.oc.commons.core.chat.Component;
import tc.oc.commons.core.util.ExceptionUtils;

public class Links {
    private Links() {}

    public static final String HOST = "localhost"; // TODO: configurable

    public static URI homeUri(String path) throws URISyntaxException {
        return new URI("http", HOST, path, null);
    }

    public static URI homeUriSafe(String path) {
        return ExceptionUtils.propagate(() -> homeUri(path));
    }

    public static BaseComponent homeLink(String path, boolean compact) throws URISyntaxException {
        return new LinkComponent(homeUri(path), compact);
    }

    public static BaseComponent homeLinkSafe(String path) {
        return homeLinkSafe(path, true);
    }

    public static BaseComponent homeLinkSafe(String path, boolean compact) {
        return ExceptionUtils.propagate(() -> homeLink(path, compact));
    }

    public static BaseComponent homeLink() {
        return homeLinkSafe("/");
    }

    public static BaseComponent shopLink() {
        return homeLinkSafe("/shop");
    }

    public static BaseComponent appealLink() {
        return homeLinkSafe("/appeal");
    }

    public static BaseComponent rulesLink() {
        return homeLinkSafe("/rules");
    }

    public static BaseComponent shopPlug(String perk, Object... with) {
        return new Component(ChatColor.LIGHT_PURPLE)
            .extra(new TranslatableComponent(perk, with))
            .extra(new Component(" "))
            .extra(shopLink());
    }

    public static URI profileUri(String username) {
        return homeUriSafe("/" + username);
    }

    public static URI profileUri(PlayerId playerId) {
        return homeUriSafe(playerId.username());
    }

    public static BaseComponent profileLink(String username) {
        return homeLinkSafe("/" + username);
    }

    public static BaseComponent profileLink(PlayerId playerId) {
        return profileLink(playerId.username());
    }
}

@@ -437,41 +437,99 @@
  = %22
-localhost%22; // TODO: configurable
+stratus.network%22;%0A    public static final String SHOP_HOST = %22stratusnetwork.buycraft.net%22;
 %0A%0A  
@@ -646,32 +646,154 @@
 , null);%0A    %7D%0A%0A
+    public static URI shopUri() throws URISyntaxException %7B%0A        return new URI(%22http%22, SHOP_HOST, null, null);%0A    %7D%0A%0A
     public stati
@@ -1453,47 +1453,219 @@
 ink(
-) %7B%0A        return homeLinkSafe(%22/shop%22
+boolean compact) throws URISyntaxException %7B%0A        return new LinkComponent(shopUri(), compact);%0A    %7D%0A%0A    public static BaseComponent shopLink() %7B%0A        return ExceptionUtils.propagate(() -%3E shopLink(true)
 );%0A 

Update shop link to stratus buycraft