Listen for ALL events

Discussion in 'Plugin Development' started by Alex5657, Jun 15, 2013.

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

    Alex5657

    Hello,

    I am making a plugin and I need it to listen for every single event that occurs. However this:
    Code:java
    1. @EventHandler
    2. public void eventOccured(Event event){
    3. //Code
    4. }

    Does not work. Here is what I get:
    Code:
    org.bukkit.plugin.IllegalPluginAccessException: Unable to find handler list for event org.bukkit.event.Event
    Any help?
     
  2. Offline

    Hoolean

    Alex5657

    Good question! :)

    What are you trying to accomplish? As in, why do you need to listen to all events? I'm intrigued :D
     
  3. Offline

    Alex5657

    Hoolean

    It is a very big project I am making. I can not tell about it to anyone yet.

    However, an idea just came to my mind. Java has a really neat little feature: reflection. Do you know which variables are set, methods called, etc. when an event is triggered? Or just anywhere I can get the event object from?
     
  4. Offline

    metalhedd

    I can't think of a good reason to blindly hook every single event in the game. this has bad idea written all over it... that being said, I have no idea how you would accomplish it short of reflection or manually writing handlers for every event. I would STRONGLY urge you to reconsider, this can't be a good idea.
     
  5. Offline

    Alex5657

    metalhedd

    Dont worry, it may sound crazy now. However, you will see that there is no way around it when I release the plugin. Should I keep you updated on my progress?

    Well, I guess since nothing has been suggested I will just have to write a handler for every event. Sigh... was trying to avoid that so hard!
     
  6. Offline

    metalhedd


    No thanks, I'm not really interested in the plugin, because you've given me no reason to be... why is it so special that you can't explain it? it still sounds like a poorly thought out idea. even things like prism, logblock etc. don't blindly hook all events, its senseless.
     
    CaptainBern likes this.
  7. You know that an event is called about every tick? (EntitySpawnEvent, EntityDeathEvent, EntityDamageEvent, ...)
    If you use this I would just suggest you to run a repeating taks since I can't think of a valid reason to listen for every event...
     
  8. Offline

    Alex5657

    metalhedd
    It is special, very special. Please dont judge it yet. I dont need you to tell me of how bad and poorly thought out my idea is. All I asked for is how to accomplish it. I got my answer. Thank you.
     
  9. Offline

    metalhedd

    too late, already judged... honestly the vagueness doesn't help. telling me it's 'special' just makes me think you're a complete noob to all of this. Myself and everyone else here all know that our plugin ideas aren't 'special' in any way. a plugin is a plugin, and someone is always better than you. You should just discuss it and get feedback instead of continuing on with what might be the worst idea ever, and you'll never know because you're keeping it 'top secret', presumably because you dont want someone to steal your idea. I'm not going to argue it with you anymore, you're free to do what you like, but I'll be avoiding your plugin like the plague until you can tell my why you want to do what you're doing.
     
    Pew446 likes this.
  10. Offline

    bitWolfy

    * marks Alex5657 as "has no idea what he is doing" for future reference *

    The only reason for catching every single event that I can think of is collecting some kind of statistics... Which is a bad way of doing it, but I honestly cannot think of other reasons for doing something that bizzarre.
     
  11. metalhedd bitWolfy don't be so hard for him... But really Alex5657 they are kinda right because there surely is a better way of doing it without having to listen for every event...Juts tell us what you are trying...
     
  12. Offline

    Hoolean

    @Alex5647

    PluginManager.callEvent() is the method called when an event is done if that helps you :)

    Good luck with whatever you're doing :p
     
  13. Offline

    Rprrr

    I don't see why people ask for help if they don't want to tell what they're doing.

    Also, I agree with everyone else, this is just a stupid idea and I'm pretty sure there's better ways to do whatever kind of special & vague thing you're trying to accomplish.
     
    Minnymin3 likes this.
  14. Offline

    Alex5657

    I dont see why people go hating on others when they just ask for help.

    Also, I do not need to tell you anything from my idea for you to be able to help me here. I clearly told you what I need help with. It is none of your business what for. I NEED AN EVENT OBJECT FOR EVERY EVENT, thats all you need to know. I am not dumb, highly doubt you are either, so would you please go mind your own thing? Your comment is off topic.

    Thank you :)

    Trust me, I do know. Dont go hating on me yet. You will see :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  15. Offline

    metalhedd

    I thought of ONE use of such a technique that wouldn't make me barf... some sort of tool for new plugin developers to log event data. not sure how useful it would be, but its about the only reason i can think to hook every event.
     
  16. Offline

    GreySwordz

    Rprrr metalhedd bitWolfy CaptainBern

    He really does know what he's doing. He explained to me what he want's to do, and it's basically not possible without calling all events. He was a developer on a server I used to be a moderator on, and he really does have lots of experience. No hate, please. :)

    EDIT: By hate, I mean general dislike, and comments like "marks Alex5657 down for future reference".
     
  17. Offline

    Hoolean

    Adding to what GreySwordz said, hate helps nobody.
     
  18. Offline

    Lolmewn

    I suggest doing it the normal way (Yes, this does cost some more team but the code is cleaner and you'll have all methods of the corresponding event), and simply passing the event variable to some method that handles it.
     
  19. Offline

    GreySwordz

    Lolmewn By the "normal way" do you mean getting each event in a seperate event? There are about 180 events in the bukkit code.
     
  20. Offline

    Alex5657

    Yeah, thats what I have come down to.
     
  21. Offline

    toothplck1

    It would be nice if he gave even the vaguest hint as to what he is doing, if it does indeed require reflection to make it work, that limits the number of people who COULD actually steal the idea and do it to the people who know what they are doing... And those are the people who wouldn't steal an idea....
     
    Hoolean likes this.
  22. Offline

    Lolmewn

    Yep! Guess how my Stats plugin does it ;)
     
  23. Offline

    GreySwordz

  24. Offline

    Lolmewn

    GreySwordz Did you just hijack this thread for no obvious reason? :O
     
  25. Offline

    GreySwordz

    Lolmewn probably shouldn't have done the second edit. I guess this thread can float into oblivion since no one is able to answer/wants to answer this. Alex5657 maybe you could use nms code for this?
     
  26. Offline

    Alex5657

  27. Offline

    Hoolean

    For the sake of others who may be in the same position, please could you post it?
     
  28. Offline

    finalblade1234

    I might be able to help, although What do you need to build off the event? do you need event.getEventName();? event.setCanceled();? or something else? or Both?
     
  29. Offline

    metalhedd


    With all due respect, I'm not going to take your word for it that he knows what he's doing any more than I'm going to take his word for it. Frankly it's entirely possible that neither of you know what you're talking about.

    Being a moderator doesn't imply that one has any skills as a plugin developer. There are no admins or moderators on my server that I would trust to write a single line of code except for myself.. the 2 skills have absolutely nothing in common. the only thing I can truly base my judgement on is the code he's written, of which I've seen none. He also has no posting history on these forums that would imply programming experience.

    All I'm trying to do is help him avoid investing time in what most likely isn't the right way to accomplish his goals. I never hated on anyone.
     
  30. Offline

    Alex5657

    The object of the event
     
Thread Status:
Not open for further replies.

Share This Page