Guest User

Poboczna klasa

a guest
Jul 15th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. List<UUID> channel = new ArrayList<>();
  2.  
  3. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  4.   if(label.equalsIgnoreCase("channel")) {
  5.     if(sender instanceof Player) {
  6.       Player player = (Player) sender;
  7.       if(player.hasPermission("echat.channel")) {
  8.         if(args[0].equalsIgnoreCase("join")) {
  9.           if(!(channel.contains(player.getUniqueId()))) {
  10.             channel.add(player.getUniqueId());
  11.             player.sendMessage("You has been connected to the channel");
  12.           } else {
  13.             player.sendMessage("You're already connected to the channel");
  14.           }
  15.         }
  16.         if(args[0].equlsIgnoreCase("leave")) {
  17.           if(channel.contains(player.getUniqueId())) {
  18.             channel.remove(player.getUniqueId());
  19.             player.sendMessage("You has been disconnected from the channel");
  20.           } else {
  21.             player.sendMessage("You're not connected to any channel");
  22.           }
  23.         }
  24.       } else {
  25.         player.sendMessage("You don't have permission to this");
  26.       }
  27.     } else {
  28.       sender.sendMessage("This command can be used only from in-game state");
  29.     }
  30.     return true;
  31.   }
  32. }
  33.  
  34. @EventHandler
  35. public void chatEvent(AsyncPlayerChatEvent e) {
  36.   if(channel.contains(e.getPlayer().getUniqueId())) {
  37.     e.setCancelled(true);
  38.     for(Player player : Bukkit.getServer().getOnlinePlayers()) {
  39.       if(player.hasPermission("echat.channel.admin")) {
  40.         player.sendMessage(e.getMessage());
  41.       } else {
  42.         if(channel.contains(player.getUniqueId())) {
  43.           player.sendMessage(e.getMessage());
  44.         }
  45.       }
  46.     }
  47.   }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment