title: Player Chat event in minecraft java plugin doesnt do what its suposed to do
body: <p>So I have coded the following code:</p>
  
  <pre><code>package com.ste999.firstplugin;
  
  import org.bukkit.plugin.java.JavaPlugin;
  
  import org.bukkit.entity.Player;
  import org.bukkit.event.EventHandler;
  import org.bukkit.Bukkit;
  import org.bukkit.command.Command;
  import org.bukkit.command.CommandSender;
  import org.bukkit.event.player.AsyncPlayerChatEvent;
  
  public class Main extends JavaPlugin {
  
      public Main() {}
  
      @Override
      public void onEnable() {
          getLogger().info("Stefan's first plugin enabled");
      }
  
          private volatile boolean chatEnabled = true;
  
      @EventHandler
      public void onPlayerChat(AsyncPlayerChatEvent event) {
          Player pli = event.getPlayer();
          if (!chatEnabled) {
              if (!pli.hasPermission("ste.chat.bypass")) {
                  pli.sendMessage("§4Chat is disabled!");
                  event.setCancelled(true);
                  //return true;
              }
          }
      }
  
          @Override
      public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) 
      {
          Player p = (Player)sender;
  
          if (cmd.getName().equalsIgnoreCase("mutechat")) {
              chatEnabled = !chatEnabled;
              sender.sendMessage(chatEnabled ? "§aUnmuted the chat" : "§aMuted the chat");
              return true;
          }
          return true;
      }
  
      @Override
      public void onDisable() {
          getLogger().info("Stefan's first plugin disabled");
      }
  }
  </code></pre>
  
  <p>with the following plugin.yml:</p>
  
  <pre><code>name: Stefans_Helper
  main: com.ste999.firstplugin.Main
  version: 1.0
  load: startup
  description: this is my first plugin
  commands:
    mutechat:
      description: mute the chat
      usage: /&lt;command&gt;
  </code></pre>
  
  <p>When I use this plugin in my Minecraft server, it shows up and if I do <code>/mutechat</code> it says <code>Muted the chat</code> en when I do <code>/mutechat</code> again it says <code>Unmuted the chat</code></p>
  
  <p>What I expect this code to do is when the chat is "Muted" no users can talk, unless they have the <code>ste.chat.bypass</code> permission node.</p>
  
  <p>But a user without op and the <code>ste.chat.bypass</code> can still talk in chat after someone did <code>/mutechat</code> and the chat said <code>Muted the chat</code>.</p>
  
  <p>I've tried putting <code>getServer().getPluginManager().registerEvents(this, this);</code> in the <code>public void onEnable</code> but then I get an error in eclipse that says: <code>The method registerEvents(Listener, Plugin) in the type PluginManager is not applicable for the arguments (Main, Main)</code></p>
  
  <p>Uhh help pls</p>