MyChatChannel

Discussion in 'Plugin Development' started by calebbfmv, Oct 19, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    calebbfmv

    OK, I have been at this for some time and I still cannot get it. I cannot create functioning chat channels. It seems so easy, but I can't seem to enable them!
    Code:
    
    public class AsyncPlayerChat implements Listener {
    
        @EventHandler(priority=EventPriority.MONITOR)
        public void onChat(AsyncPlayerChatEvent e) {
            Player sender = e.getPlayer();
            for (Player senGroup : Groups.getGroup(sender)){
                
            }
        }
    }
    
    What would I check for after the for() loop?
    Code:
       // Mod Chat, Admin Chat, Builder Chat, GM Chat)
    
        public static List<Player> admin = new ArrayList<Player>();
        public static List<Player> local = new ArrayList<Player>();
        public static List<Player> builder = new ArrayList<Player>();
        public static List<Player> dev = new ArrayList<Player>();
        public static List<Player> mod = new ArrayList<Player>();
        public static List<Player> gm = new ArrayList<Player>();
    
        public static Groups isAdmin(Player p) {
            admin.contains(p);
            return null;
        }
    
        public static void isDev(Player p) {
            dev.contains(p);
        }
    
        public static List<Player> getGroup(Player p) {
            if (admin.contains(p)) {
                return admin;
            }
            if (local.contains(p)) {
                return local;
            }
            if (gm.contains(p)) {
                return gm;
            }
            if (dev.contains(p)) {
                return dev;
            }
            if (mod.contains(p)) {
                return mod;
            }
            if (builder.contains(p)) {
                return builder;
            }
            return null;
        }
          public static void setGroup(String name){
    }
    
    How would I set the the group via permissions?

    I don't know if I am missing something here or what, but I need some help.

    Thanks in advance!
     
  2. Offline

    Shzylo

    so you want the message to be sent to only certain players?

    What I would do is when a player sends a message, I would:
    1. Store message in a string
    2. Cancel event
    3. Check their group/permission
    4. Check for other current players with same group/permission that are online (with for loop)
    5. send message to those players.
     
  3. Offline

    1Rogue

    Use bukkit's built in "broadcast" method, it's a lot easier:

    Code:java
    1. Bukkit.broadcast("message", "perm.to.see");


    This makes all your channels permission-based.
     
  4. Offline

    calebbfmv

    Could you do this in code? I have an idea, just not sure.

    Hmmm, how would this work for multiple channels? I can't see it doing it.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  5. Offline

    1Rogue


    Code:java
    1. Bukkit.broadcast("message", "plugin.channels.admin");
    2. Bukkit.broadcast("message", "plugin.channels.trade");


    etc...

    Just use a hashmap to track what channel the users are in.
     
    calebbfmv and Shzylo like this.
  6. Offline

    Shzylo

    I forgot about Bukkit's broadcast permission thing, considering I never use it :p
     
Thread Status:
Not open for further replies.

Share This Page