Add Warning API and settings for Deprecated events

By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
Bukkit/Spigot
2012-08-07 00:16:57 -05:00
parent 32052e63e2
commit cef9873c0c
6 changed files with 126 additions and 6 deletions

View File

@@ -10,7 +10,10 @@ import org.bukkit.event.HandlerList;
/**
* This event will sometimes fire synchronously, depending on how it was triggered.
* The constructor provides a boolean to indicate if the event was fired synchronously or asynchronously.
* If a plugin causes a Player to chat with {@link Player#chat(String)} or by other general means, this event will be synchronous.<br>
* When asynchronous, this event can be called from any thread, but the main thread, and has limited access to the API.<br>
* <br>
* If a player is the direct cause of this event by incoming packet, this event will be asynchronous.
* If a plugin triggers this event by compelling a player to chat, this event will be synchronous.<br>
* <br>
* <b>Care should be taken to check {@link #isAsynchronous()} and treat the event appropriately.</b>
*/

View File

@@ -5,17 +5,20 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.Warning;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Holds information for player chat and commands
* @deprecated This event was broken in 1.3, where chat should be asynchronous.
* It is deprecated because listening for it is detrimental to server performance.
* {@link AsyncPlayerChatEvent} is the encouraged alternative.
* @deprecated This event will fire from the main thread and allows the use of all of the Bukkit API, unlike the {@link AsyncPlayerChatEvent}.<br>
* <br>
* Listening to this event forces chat to wait for the main thread which causes delays for chat.<br>
* {@link AsyncPlayerChatEvent} is the encouraged alternative for thread safe implementations.
*/
@Deprecated
@Warning(reason="Listening to this event forces chat to wait for the main thread, delaying chat messages.")
public class PlayerChatEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;