BungeeMain / src / main / java / com / lifeknight / relaymcbungeemain / commands / links / YouTubeCommand.java
YouTubeCommand.java
Raw
package com.lifeknight.relaymcbungeemain.commands.links;

import com.lifeknight.relaymcbungeemain.player.SmartPlayer;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.hover.content.Text;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;

public class YouTubeCommand extends Command {
    public YouTubeCommand() {
        super ("youtube", null, "yt");
    }

    @Override
    public void execute(CommandSender sender, String[] arguments) {
        if (!(sender instanceof ProxiedPlayer)) return;

        SmartPlayer smartPlayer = SmartPlayer.getSmartPlayer((ProxiedPlayer) sender);

        smartPlayer.sendSuccessMessage("Subscribe our YouTube channel!");

        TextComponent link = new TextComponent(ChatColor.RED + ChatColor.UNDERLINE.toString() + "https://www.youtube.com/channel/UCDU2_nAhVxApfkWhm8EI0eA");
        link.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.youtube.com/channel/UCDU2_nAhVxApfkWhm8EI0eA"));
        link.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(ChatColor.AQUA + "Subscribe to our YouTube Channel.")));

        smartPlayer.sendMessage(link);
    }
}