Search in sources :

Example 66 with CommandSender

use of net.md_5.bungee.api.CommandSender in project solinia3-core by mixxit.

the class CommandWho method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    String filter = "";
    if (args.length > 0)
        filter = args[0];
    Player ply = null;
    if (sender instanceof Player)
        ply = (Player) sender;
    sender.sendMessage("Current Online Players:");
    sender.sendMessage("---------------------------------");
    for (Player currentplayer : Bukkit.getServer().getOnlinePlayers()) {
        String hidden = "";
        if (currentplayer.hasPermission("essentials.silentjoin"))
            hidden = "<HIDDEN>";
        if (currentplayer.hasPermission("essentials.silentjoin") && !sender.isOp()) {
            continue;
        }
        if (ply != null)
            if (!ply.canSee(currentplayer))
                hidden = "<HIDDEN>";
        if (ply != null)
            if (!ply.canSee(currentplayer) && !sender.isOp()) {
                continue;
            }
        if (!filter.equals(""))
            if (!currentplayer.getDisplayName().contains(filter) && !currentplayer.getName().contains(filter))
                continue;
        try {
            ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(currentplayer);
            if (solPlayer == null)
                continue;
            String zone = "";
            SoliniaZone solZone = solPlayer.getZone();
            if (solZone != null)
                zone = solZone.getName();
            Tuple<String, TextComponent> characterText = PlayerUtils.GetCharacterText(solPlayer, hidden, currentplayer.getName(), currentplayer.getWorld().getName(), zone, false);
            if (sender instanceof Player) {
                sender.spigot().sendMessage(characterText.b());
            } else {
                sender.sendMessage(characterText.a());
            }
        } catch (CoreStateInitException e) {
        }
    }
    try {
        if (ply != null) {
            ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(ply);
            if (solPlayer.getPersonality().getBondId() == 0 || solPlayer.getPersonality().getFirstTraitId() == 0 || solPlayer.getPersonality().getSecondTraitId() == 0 || solPlayer.getPersonality().getFlawId() == 0 || solPlayer.getPersonality().getIdealId() == 0) {
                ply.sendMessage(ChatColor.GRAY + "* You have not set your personality. Please see /personality" + ChatColor.RESET);
            }
            if (solPlayer.getClassObj() != null && solPlayer.getClassObj().getOaths().size() > 0 && solPlayer.getOathId() == 0) {
                ply.sendMessage(ChatColor.GRAY + "* You have not set your Oath. Please see /oath" + ChatColor.RESET);
            }
            if (solPlayer.getBackStory() == null && solPlayer.getBackStory().equals("")) {
                ply.sendMessage("- You have no backstory set - set with /personality backstory <backstory>");
            }
        }
    } catch (CoreStateInitException e) {
    }
    return true;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) SoliniaZone(com.solinia.solinia.Models.SoliniaZone)

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