1.15.2 Help on event listeners

Discussion in 'Spigot Plugin Development' started by Skipperius, Feb 17, 2020.

Thread Status:
Not open for further replies.
  1. So I have read the docs on event listeners and tried some of the examples myself, but none of them worked. I have this little piece of code right here that should do the trick according to the docs but it does literally nothing:

    public void AsyncPlayerChatEvent(AsyncPlayerChatEvent e) {
    String msg = e.getMessage();

    Can anyone help me here? The plugin / server version is latest (1.15.2)
  2. Is your class implementing Listener?
    Did you register the Listener?
  3. If the main is in that class, implement Listener in this way:
    Code (Text):
    public class Main extends JavaPlugin implements Listener{

    if it is a different class you must put it in that class and also in the onEnable of the main class put:
    Code (Text):
    getServer().getPluginManager().registerEvents(new <CLASSNAME>(), this);
  4. DevSnx

    DevSnx Previously Snx

    why broadcast it? set se format is better in my opinion :p
  5. I think it's an example.

    And the method name should be in camel case notation.
  6. It was just for testing purposes, id change that later
  7. its in the same class, just nothing happens when i type in chat
  8. getServer().getPluginManager().registerEvents(this, this);
  9. That fixed it, much thancc
Thread Status:
Not open for further replies.