PlayerBucketEmptyEvent help

Discussion in 'Spigot Plugin Development' started by Syanko, Jun 9, 2018.

  1. i wanna make when place lava or water it will remove in 10 seconds why it is not working i dont know [​IMG]
     
  2. What it is actually doing?
    Does it set any block to air or it is not even doing it?
     
  3. it does nothing
     
  4. Btw you can use
    Code (Text):
    event.getBucket() == Material.LAVA_BUCKET
     
  5. im not good at english i saved to imports
     
  6. JanTuck

    Supporter

    [​IMG]
    What are these class names?


    [​IMG]
    This isn't good, please put your stuff in a subpackage of your original package, that way your future plugins won't conflict.


    [​IMG]
    This will set the BLOCK CLICKED to air, not the actual placed lava.


    [​IMG]
    You can use == for enums, which is preferred on here.


    Also, you forgot to register your listener.
     
    • Agree Agree x 1
  7. how to register listener ? Jantuck please make this i need
     
    #9 Syanko, Jun 9, 2018
    Last edited by a moderator: Jun 10, 2018
  8. Your listener class should not extend JavaPlugin. This is only for the main class. To register a listener, in your main class do this:
    Code (Java):
    getServer().getPluginManager().registerEvent(new elo(), this);
    Put that inside your onEnable(). Sorry to spoonfeed everyone else but he may be able to learn by reading established code.
     
  9. pff I think you haven't done that much plugins or used listeners

    in your case is e.getBucket() since you have decided to use e as a variable name of your event

    public void onPlace3(PlayerBucketEmptyEvent e)

    To Register a listener:

    in your onEnable()

    Code (Text):
    Bukkit.getServer().getPluginManager().registerEvents(new Elo(), this);
    Btw change your class name to start with upperCase in Java classes starts with UpperCase
     
  10. still not working[​IMG]
     
  11. JanTuck

    Supporter

    JavaPlugin
    Code (Text):
    Bukkit.getServer().getPluginManager().registerEvents(this, this);
     
  12. it working but doesnt do anything
     
  13. You did it but wrongly.

    You put @EventHandler inside onEnable wtf

    Please, follow the instructions with the two links I send you to create a plugin. Otherwise you will never do it correctly.

    This error is firing due to the fact that you are creating a new instance with new elo() at onEnable which is stupid.
    Then you have to register the listener in the same class with this, this instead of using a new.

    Btw i told you to change the class name to start with UpperCase.

    If you do not have the patience to learn at least the most basic of java how do you expect to create a plugin?