Listeners Not listening.

Discussion in 'Plugin Development' started by NoMansLand, Feb 25, 2013.

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


    Hello Again Bukkit,

    I have been writing this plugin for 2 days now, fixed a prior issue by doing a re-write and now I can't get my event listeners to listen.

    there's 2 java files: &

    This is
    This is

    Thank you for your help.
  2. Offline


    Listener class shouldn't extend JavaPlugin.
  3. Offline


    With out it, log.getLogger() doesnt work.
  4. Offline


    So use an instance of your main class passed via the constructor to call JavaPlugin methods
  5. Offline


    1:24:04 PM
    [SEVERE] [GL] GL v0.1 attempted to register an invalid EventHandler method signature "public void,org.bukkit.command.Command) throws java.sql.SQLException" in class
    any idea why I would get this then onPlayerCommandPreprocess?
  6. Offline


    Why do you have the @EventHandler annotation on a method that is not an event listener (onPlayerCommandPreprocess)?

    NoMansLand Oh and what Tirelessly is saying:
    1. //In your Listeners class:
    2. private Main plugin;
    3. public Listeners(Main plugin){
    4. this.plugin = plugin;
    5. }

    And then the logger can be accessed with:
    1. plugin.getLogger().info("Hello");

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 31, 2016
  7. Offline


    I figured that out afterwards and then repeatedly banged my head into the desk for being an idiot..

    Didn't help much.. but now i'm getting this:

    2013-02-25 21:32:54 [SEVERE] Could not pass event PlayerJoinEvent to GL v0.1
    at org.bukkit.plugin.RegisteredListener.callEvent(
    at org.bukkit.plugin.SimplePluginManager.fireEvent(
    at org.bukkit.plugin.SimplePluginManager.callEvent(
    at net.minecraft.server.v1_4_R1.PlayerList.c(
    at net.minecraft.server.v1_4_R1.PlayerList.a(
    at net.minecraft.server.v1_4_R1.PendingConnection.d(
    at net.minecraft.server.v1_4_R1.PendingConnection.c(
    at net.minecraft.server.v1_4_R1.DedicatedServerConnectionThread.a(
    at net.minecraft.server.v1_4_R1.DedicatedServerConnection.b(SourceFile:29)
    at net.minecraft.server.v1_4_R1.MinecraftServer.r(
    at net.minecraft.server.v1_4_R1.DedicatedServer.r(
    at net.minecraft.server.v1_4_R1.MinecraftServer.q(
    Caused by: java.lang.NullPointerException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    ... 14 more

    The exact same Player joinPlayer = player.getEvent(); works in other plugins that i've developed..
  8. Offline


    player.getEvent()? *event.getPlayer()
  9. Offline


    Sorry typo, but that's what I have in the script and it's giving the the null error.

    Line 24: plugin.getLogger().info("[GL] - A player has joined the server. Performing Integrity Tests.");

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 31, 2016
  10. Offline


    In onEnable() it should be like this:

    getServer().getPluginManager().registerEvents(new Listeners(this), this);​

    In Listeners it should be like this:

    private Main plugin;
    public Listeners(Main plugin){
    this.plugin = plugin;​

    Oh and:

    public class Main extends JavaPlugin implements Listener {
  11. Offline


    I replaced all the "" with System.out.Print() and it works now, but do I have to set the commands I want submitted with " public void onPlayerCommandPreprocess(Player player, Command cmd) throws SQLException {" or is there a way to log every command done?
  12. Offline


    It happens because you have a syntax error in your SQL. You might want to get the query where it happens and see where exactly you made that mistake.
  13. Offline


    If I had a Syntax error or any error in my SQL it would come up with something, would it not? I'd like to think so.. or even print out the line that a command has been sent.

    Here's the java:

    The plugin.yml

    The only issue now is that it wont get the commands
  14. Offline


    Does anyone have any idea how to get all the commands listened to?
Thread Status:
Not open for further replies.

Share This Page