Chat Cooldown Plugin (AsyncPlayerChatEvent event)

Discussion in 'Plugin Development' started by stantheman68, Nov 12, 2012.

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

    stantheman68

    Hi,

    I need some help with a plugin that I creating. So, the basic line is that every time a player time's something into chat, he has to wait a certain amount of seconds ( Which I know how to do ), though I don't know how make the actual Cooldown itself from where the player type's something into chat.
    If you have any suggestions or link's that will be helpful, feel free to post them below.
     
  2. Offline

    JazzaG

    Code:
    List<String> cooling = new ArrayList<String>();
     
    @EventHandler
    public void onChat(AsyncPlayerChatEvent e) {
        // TODO: event checks
     
        String name = e.getPlayer().getDisplayName();
     
        // Cancel event if player is cooling down
        if(cooling.contains(name) {
            e.getPlayer().sendMessage("Thou shall not speak!");
            e.setCancelled(true);
        } else {
            cooling.add(name);
            // TODO: add timer that removes player from list after x amount of seconds
        } 
    }
    
     
    stantheman68 likes this.
  3. Offline

    fireblast709

    Make sure that you make it thread safe!
     
Thread Status:
Not open for further replies.

Share This Page