Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<UUID> channel = new ArrayList<>();
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if(label.equalsIgnoreCase("channel")) {
- if(sender instanceof Player) {
- Player player = (Player) sender;
- if(player.hasPermission("echat.channel")) {
- if(args[0].equalsIgnoreCase("join")) {
- if(!(channel.contains(player.getUniqueId()))) {
- channel.add(player.getUniqueId());
- player.sendMessage("You has been connected to the channel");
- } else {
- player.sendMessage("You're already connected to the channel");
- }
- }
- if(args[0].equlsIgnoreCase("leave")) {
- if(channel.contains(player.getUniqueId())) {
- channel.remove(player.getUniqueId());
- player.sendMessage("You has been disconnected from the channel");
- } else {
- player.sendMessage("You're not connected to any channel");
- }
- }
- } else {
- player.sendMessage("You don't have permission to this");
- }
- } else {
- sender.sendMessage("This command can be used only from in-game state");
- }
- return true;
- }
- }
- @EventHandler
- public void chatEvent(AsyncPlayerChatEvent e) {
- if(channel.contains(e.getPlayer().getUniqueId())) {
- e.setCancelled(true);
- for(Player player : Bukkit.getServer().getOnlinePlayers()) {
- if(player.hasPermission("echat.channel.admin")) {
- player.sendMessage(e.getMessage());
- } else {
- if(channel.contains(player.getUniqueId())) {
- player.sendMessage(e.getMessage());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment