Welcome to the BukkitWiki!

This Wiki is home to Bukkit's documentation and regulations surrounding the Bukkit Project and it's services. Want to help out? We would love to have you! Signup to get started!

We have begun migration of most wikis to our new host, Amazon Web Services. All but the top 100 wikis are in read-only mode until the migration is complete. Estimated completion: End of Week.

Talk:Event API Reference

From BukkitWiki
Jump to: navigation, search

Request for Comments: Details about Event Registration using Self-Registering Listeners[edit source]

One of the provided examples shows that classes which implement Listener can be registered by calling registerEvents() from the constructor, then simply creating an instance of the class. However, the example doesn't show this instance being created in onEnable(), but rather when the main Plugin object is created. What happens if the server is reloaded? Will registerEvents() need to be called again or does the registration only need to happen once? Can someone please verify the information in the article is correct, and add some text which explains this? --4am 15:26, 22 January 2012 (EST)

When the server reloads a new plugin instance is created, which will in turn create a new listener......... Give me a bit to think on something --Feildmaster 09:43, 21 February 2012 (EST)
I was wrong. That should have never been an example. Thank you 4am. --Feildmaster 09:50, 21 February 2012 (EST)

Consolidated List of Events[edit source]

I'm recently gotten into hooking events and there does not seem to be a consolidated list of events with their associated triggers. Looking through the #include files has been my only way of guessing what I want, but this does not always work out. For example - right now I am trying to find events that would let me modify/prevent villagers from trading. I am able to hook various ones, but still haven't found the one that fires off when the player right-clicks the villagers.

Rename[edit source]

It's been long enough, let's rename this to Event API -mbaxter 20:21, 29 August 2012 (EST)

Custom Events Example[edit source]

I think people would love an example of a cancellable event being made.. I am not 100% sure how one is made myself... I had an idea of just listening form my own plugin on monitor level...

But an example of proper usage would prob fit the bill nicely..

--Coaster4321 16:08, 25 November 2012 (EST)

Done. --Feildmaster (talk) 04:26, 22 September 2013 (UTC)

New-user Friendliness[edit source]

I've got to say that, while this page may be quite nice for people who have used previous versions of craftbukkit - and maybe even for people who have never used it but know Java - it is not as helpful for a person who is new to Java (me). More explanation, I think, would be very welcome, and particularly in the Custom Events section. Thank you in advance!

--axle12693 08:07, 29 November 2012 (EST)

For the most part, the content on this wiki requires that you understand how to use Java effectively. Otherwise the length of each article would be quite long and repeating what can be found elsewhere. The wiki has links to some helpful Java references. --Sagacious Zed 17:46, 1 December 2012 (EST)

Listener method[edit source]

As stated in the Adding Listener section, the name of the method is not important.

If so, what's the behavior if I write two methods in my Listener, having different names, but accept the same event?

If you use the methode you said, both listeners will be called, the listener closest to the top will have the most chance to be called first (it depends on the order of the methodes inside the compiled class file and how the jvm reads them) Ferrybig 10:06, 12 April 2013 (EST)

Wiki merge issue[edit source]

Seems a merge of the wiki to another system broke syntax highlighting... hehe.. Any idea's on what we should do to fix this? I don't think links to pastebin post's are an option... (Meaning no its not an option) Wonder how this could be handled.. Coaster4321 (talk) 17:15, 28 June 2013 (UTC)

Seems fixed now.. --Coaster4321 (talk) 15:10, 29 June 2013 (UTC)

Talk about how Listeners need to be registered before they can work[edit source]

As stated. I thought my listener would simply work without registering, took me a while to figure out.. I think this should be explicitly stated in the first section. Potentially saving people time