Search in sources :

Example 51 with CommandSender

use of net.md_5.bungee.api.CommandSender in project Minigames by AddstarMC.

the class MessageManager method sendClickedCommandMessage.

public static void sendClickedCommandMessage(CommandSender target, String command, String identifier, String key, Object... args) {
    BaseComponent init = getMessageStart(MinigameMessageType.INFO);
    TextComponent message = new TextComponent(getMessage(identifier, key, args));
    message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
    sendMessage(target, init, message);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent)

Example 52 with CommandSender

use of net.md_5.bungee.api.CommandSender in project Minigames by AddstarMC.

the class MessageManager method sendMessage.

public static void sendMessage(CommandSender target, MinigameMessageType type, String identifier, String key, Object... args) {
    BaseComponent init = getMessageStart(type);
    TextComponent message = new TextComponent(getMessage(identifier, key, args));
    sendMessage(target, init, message);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent)

Example 53 with CommandSender

use of net.md_5.bungee.api.CommandSender in project DiscordBot by LXGaming.

the class DiscordChatCommand method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    StringBuilder stringBuilder = new StringBuilder();
    for (String arg : args) {
        stringBuilder.append(arg + " ");
    }
    if (stringBuilder.toString().trim().length() == 0) {
        sender.sendMessage(new ComponentBuilder("Message cannot be blank!").color(ChatColor.RED).create());
        return;
    }
    Message message = new Message().setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get(this.name).getChannel()).setFormat(DiscordBotCore.getInstance().getConfiguration().getChannelFormat().get(this.name)).setName(sender.getName()).setNick("").setServer("Unknown").setMessage(stringBuilder.toString().trim()).setDiscord(true).setMinecraft(true).setConsole(true).setRedis(true);
    if (sender instanceof ProxiedPlayer) {
        ProxiedPlayer player = (ProxiedPlayer) sender;
        if (DiscordBotCore.getInstance().getDatabaseManager().checkDatabase(player.getUniqueId())) {
            player.sendMessage(new ComponentBuilder("DiscordChat disabled. '/DiscordBot Toggle' to enable").color(ChatColor.RED).create());
            return;
        }
        message.setName(player.getName()).setNick(player.getDisplayName());
        if (player.getServer() != null && player.getServer().getInfo() != null) {
            message.setServer(player.getServer().getInfo().getName());
        }
    }
    DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Message(io.github.lxgaming.discordbot.entries.Message) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 54 with CommandSender

use of net.md_5.bungee.api.CommandSender in project DiscordBot by LXGaming.

the class DiscordBotCommand method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    if (args.length == 0) {
        sender.sendMessage(new ComponentBuilder("===== ").color(ChatColor.GOLD).append("DiscordBot - Bungeecord Edition").color(ChatColor.GREEN).append(" =====").color(ChatColor.GOLD).create());
        sender.sendMessage(new ComponentBuilder("Version - ").color(ChatColor.GOLD).append(DiscordBotCore.getInstance().getConfiguration().getDiscordBotVersion()).color(ChatColor.AQUA).create());
        sender.sendMessage(new ComponentBuilder("JDA - ").color(ChatColor.GOLD).append(DiscordBotCore.getInstance().getConfiguration().getJDAVersion()).color(ChatColor.AQUA).create());
        sender.sendMessage(new ComponentBuilder("Author - ").color(ChatColor.GOLD).append("LX_Gaming").color(ChatColor.AQUA).create());
        return;
    }
    if (args.length == 1 && args[0].equalsIgnoreCase("reload") && sender.hasPermission("DiscordBot.Reload")) {
        DiscordBot.getInstance().reloadDiscordBot();
        sender.sendMessage(new ComponentBuilder("DiscordBot reloaded.").color(ChatColor.GREEN).create());
        return;
    }
    if (!(sender instanceof ProxiedPlayer)) {
        sender.sendMessage(new ComponentBuilder("Command cannot be run from Console").color(ChatColor.RED).create());
        return;
    }
    ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender;
    if (args.length == 1 && (args[0].equalsIgnoreCase("toggle") || args[0].equalsIgnoreCase("t")) && proxiedPlayer.hasPermission("DiscordBot.Toggle")) {
        DiscordBotCore.getInstance().getDatabaseManager().togglePlayerDatabase(proxiedPlayer.getUniqueId());
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 55 with CommandSender

use of net.md_5.bungee.api.CommandSender in project VotingPlugin by Ben12345rocks.

the class VotingPluginBungeeCommand method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    if (sender.hasPermission("votingplugin.admin")) {
        if (args.length > 0) {
            if (args[0].equalsIgnoreCase("reload")) {
                bungee.reload(false);
                sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee"));
            }
            if (args[0].equalsIgnoreCase("reloadmysql")) {
                bungee.reload(true);
                sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee with MySQL"));
            }
            if (args[0].equalsIgnoreCase("vote")) {
                if (args.length >= 2) {
                    String user = args[1];
                    String site = args[2];
                    bungee.vote(user, site, false);
                    sender.sendMessage(new TextComponent("Sending vote"));
                }
            }
            if (args[0].equalsIgnoreCase("status")) {
                if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
                    sender.sendMessage(new TextComponent("&aChecking status, waiting for response, check console, method: sockets"));
                    bungee.status(sender);
                } else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
                    sender.sendMessage(new TextComponent("&aChecking status, waiting for response, check console, method: plugin messaging"));
                    bungee.status(sender);
                } else {
                    sender.sendMessage(new TextComponent("&aNot using socket/pluginmessage method, command unavailable"));
                }
            }
            if (args[0].equalsIgnoreCase("help")) {
                TextComponent[] msg = new TextComponent[4];
                msg[0] = new TextComponent("&avotingpluginbungee reload - Reload plugin");
                msg[1] = new TextComponent("&avotingpluginbungee reloadmysql - Reload plugin including mysql");
                msg[2] = new TextComponent("&avotingpluginbungee vote (player) (servicesite) - Send bungee vote");
                msg[3] = new TextComponent("&avotingpluginbungee status - Check socket connection status");
                sender.sendMessage(msg);
            }
        }
    } else {
        sender.sendMessage(new TextComponent("&cYou do not have permission to do this!"));
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent)

Aggregations

TextComponent (net.md_5.bungee.api.chat.TextComponent)44 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)24 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)23 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)21 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)18 Player (org.bukkit.entity.Player)17 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)15 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)10 CommandSender (net.md_5.bungee.api.CommandSender)9 ArrayList (java.util.ArrayList)7 ChatColor (net.md_5.bungee.api.ChatColor)6 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)6 CommandSender (org.bukkit.command.CommandSender)5 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)4 ISoliniaRace (com.solinia.solinia.Interfaces.ISoliniaRace)4 HashMap (java.util.HashMap)4 ISoliniaClass (com.solinia.solinia.Interfaces.ISoliniaClass)3 ChatSender (at.pcgamingfreaks.Bungee.Message.Sender.ChatSender)2 SendMethod (at.pcgamingfreaks.Bungee.Message.Sender.SendMethod)2 CommandHandler (com.Ben12345rocks.AdvancedCore.Objects.CommandHandler)2