SHARE
TWEET

Untitled

a guest Jun 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Collection;
  2. import java.util.List;
  3.  
  4. import net.nathan.zlobby.Hub;
  5. import org.apache.commons.lang.Validate;
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandExecutor;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12.  
  13. import com.google.common.collect.ImmutableList;
  14.  
  15. public class ListCommand implements CommandExecutor {
  16.     public ListCommand() {
  17.     }
  18.  
  19.     @Override
  20.     public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
  21.  
  22.         StringBuilder online = new StringBuilder();
  23.  
  24.         final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
  25.  
  26.         for (Player player : players) {
  27.             // If a player is hidden from the sender don't show them in the list
  28.             if (commandSender instanceof Player && !((Player) commandSender).canSee(player))
  29.                 continue;
  30.  
  31.             if (online.length() > 0) {
  32.                 online.append(ChatColor.GRAY + ", ");
  33.             }
  34.  
  35.             String perms = Hub.instance.permission.getPrimaryGroup(player);
  36.             if (perms.equalsIgnoreCase("Owner")) {
  37.                 online.append(ChatColor.DARK_RED + player.getDisplayName());
  38.             }
  39.             if (perms.equalsIgnoreCase("Manager")) {
  40.                 online.append(ChatColor.AQUA + player.getDisplayName());
  41.             }
  42.             if (perms.equalsIgnoreCase("PAdmin")) {
  43.                 online.append(ChatColor.RED.toString() + ChatColor.ITALIC + player.getDisplayName());
  44.             }
  45.             if (perms.equalsIgnoreCase("SrAdmin")) {
  46.                 online.append(ChatColor.RED + player.getDisplayName());
  47.             }
  48.             if (perms.equalsIgnoreCase("Admin")) {
  49.                 online.append(ChatColor.RED + player.getDisplayName());
  50.             }
  51.             if (perms.equalsIgnoreCase("SrMod")) {
  52.                 online.append(ChatColor.DARK_PURPLE.toString() + ChatColor.ITALIC + player.getDisplayName());
  53.             }
  54.             if (perms.equalsIgnoreCase("Mod")) {
  55.                 online.append(ChatColor.DARK_PURPLE + player.getDisplayName());
  56.             }
  57.             if (perms.equalsIgnoreCase("TMod")) {
  58.                 online.append(ChatColor.LIGHT_PURPLE + player.getDisplayName());
  59.             }
  60.             if (perms.equalsIgnoreCase("Dev")) {
  61.                 online.append(ChatColor.GOLD + player.getDisplayName());
  62.             }
  63.             if (perms.equalsIgnoreCase("Media")) {
  64.                 online.append(ChatColor.BLUE + player.getDisplayName());
  65.             }
  66.             if (perms.equalsIgnoreCase("User")) {
  67.                 online.append(ChatColor.GREEN + player.getDisplayName());
  68.             }
  69.             if (perms.equalsIgnoreCase("Titan")) {
  70.                 online.append(ChatColor.DARK_RED + "✺" + ChatColor.RED.toString() + ChatColor.BOLD + player.getDisplayName());
  71.             }
  72.             if (perms.equalsIgnoreCase("Elite")) {
  73.                 online.append(ChatColor.DARK_PURPLE + "✷" + ChatColor.LIGHT_PURPLE.toString() + ChatColor.BOLD + player.getDisplayName());
  74.             }
  75.             if (perms.equalsIgnoreCase("Ultra")) {
  76.                 online.append(ChatColor.DARK_AQUA + "✹" + ChatColor.AQUA.toString() + ChatColor.BOLD + player.getDisplayName());
  77.             }
  78.             if (perms.equalsIgnoreCase("Hero")) {
  79.                 online.append(ChatColor.BLUE + "✦" + ChatColor.GRAY.toString() + ChatColor.BOLD + player.getDisplayName());
  80.             }
  81.         }
  82.  
  83.         commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&',
  84.                 "&4Owner&7, &bManager&7, &6Developer&7, &c&oPlatform Admin&7, &cSenior Admin&7, &cAdmin&7, \n&5&oSenior Mod&7, &5Mod&7, &dTrial Mod&7, &9Media&7, &4✺&c&lTitan&7, &5✷&d&lElite&7, &3✹&b&lUltra&7, &9✦&7&lHero&7, \n&aUser"));
  85.         commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&',
  86.                 "&e(" + players.size() + "/" + Bukkit.getMaxPlayers() + "): " + online.toString()));
  87.  
  88.         return true;
  89.     }
  90.  
  91.  
  92.     public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
  93.         Validate.notNull(sender, "Sender cannot be null");
  94.         Validate.notNull(args, "Arguments cannot be null");
  95.         Validate.notNull(alias, "Alias cannot be null");
  96.  
  97.         return ImmutableList.of();
  98.     }
  99. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top