geforkt von Mirrors/Paper
Deprecate PlayerPreLoginEvent. Addresses BUKKIT-2600
PlayerPreLoginEvent was originally implemented with the intention that putting synchronized blocks on the plugin manager made it thread safe. Unintentionally, this causes the event to be executed when a plugin would otherwise expect no events to be firing. It is now deprecated. By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Ursprung
29abc65308
Commit
74f83f3098
@ -11,14 +11,14 @@ import org.bukkit.event.HandlerList;
|
|||||||
*/
|
*/
|
||||||
public class AsyncPlayerPreLoginEvent extends Event {
|
public class AsyncPlayerPreLoginEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private PlayerPreLoginEvent.Result result;
|
private Result result;
|
||||||
private String message;
|
private String message;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final InetAddress ipAddress;
|
private final InetAddress ipAddress;
|
||||||
|
|
||||||
public AsyncPlayerPreLoginEvent(final String name, final InetAddress ipAddress) {
|
public AsyncPlayerPreLoginEvent(final String name, final InetAddress ipAddress) {
|
||||||
super(true);
|
super(true);
|
||||||
this.result = PlayerPreLoginEvent.Result.ALLOWED;
|
this.result = Result.ALLOWED;
|
||||||
this.message = "";
|
this.message = "";
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.ipAddress = ipAddress;
|
this.ipAddress = ipAddress;
|
||||||
@ -29,19 +29,43 @@ public class AsyncPlayerPreLoginEvent extends Event {
|
|||||||
*
|
*
|
||||||
* @return Current Result of the login
|
* @return Current Result of the login
|
||||||
*/
|
*/
|
||||||
public PlayerPreLoginEvent.Result getResult() {
|
public Result getLoginResult() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current result of the login, as an enum
|
||||||
|
*
|
||||||
|
* @return Current Result of the login
|
||||||
|
* @deprecated This method uses a deprecated enum from {@link PlayerPreLoginEvent}
|
||||||
|
* @see #getLoginResult()
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public PlayerPreLoginEvent.Result getResult() {
|
||||||
|
return result == null ? null : result.old();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the new result of the login, as an enum
|
* Sets the new result of the login, as an enum
|
||||||
*
|
*
|
||||||
* @param result New result to set
|
* @param result New result to set
|
||||||
*/
|
*/
|
||||||
public void setResult(final PlayerPreLoginEvent.Result result) {
|
public void setLoginResult(final Result result) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the new result of the login, as an enum
|
||||||
|
*
|
||||||
|
* @param result New result to set
|
||||||
|
* @deprecated This method uses a deprecated enum from {@link PlayerPreLoginEvent}
|
||||||
|
* @see #setLoginResult(Result)
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void setResult(final PlayerPreLoginEvent.Result result) {
|
||||||
|
this.result = result == null ? null : Result.valueOf(result.name());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current kick message that will be used if getResult() != Result.ALLOWED
|
* Gets the current kick message that will be used if getResult() != Result.ALLOWED
|
||||||
*
|
*
|
||||||
@ -64,7 +88,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
|
|||||||
* Allows the player to log in
|
* Allows the player to log in
|
||||||
*/
|
*/
|
||||||
public void allow() {
|
public void allow() {
|
||||||
result = PlayerPreLoginEvent.Result.ALLOWED;
|
result = Result.ALLOWED;
|
||||||
message = "";
|
message = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,11 +98,25 @@ public class AsyncPlayerPreLoginEvent extends Event {
|
|||||||
* @param result New result for disallowing the player
|
* @param result New result for disallowing the player
|
||||||
* @param message Kick message to display to the user
|
* @param message Kick message to display to the user
|
||||||
*/
|
*/
|
||||||
public void disallow(final PlayerPreLoginEvent.Result result, final String message) {
|
public void disallow(final Result result, final String message) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disallows the player from logging in, with the given reason
|
||||||
|
*
|
||||||
|
* @param result New result for disallowing the player
|
||||||
|
* @param message Kick message to display to the user
|
||||||
|
* @deprecated This method uses a deprecated enum from {@link PlayerPreLoginEvent}
|
||||||
|
* @see #disallow(Result, String)
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void disallow(final PlayerPreLoginEvent.Result result, final String message) {
|
||||||
|
this.result = result == null ? null : Result.valueOf(result.name());
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player's name.
|
* Gets the player's name.
|
||||||
*
|
*
|
||||||
@ -105,4 +143,36 @@ public class AsyncPlayerPreLoginEvent extends Event {
|
|||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic kick reasons for communicating to plugins
|
||||||
|
*/
|
||||||
|
public enum Result {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The player is allowed to log in
|
||||||
|
*/
|
||||||
|
ALLOWED,
|
||||||
|
/**
|
||||||
|
* The player is not allowed to log in, due to the server being full
|
||||||
|
*/
|
||||||
|
KICK_FULL,
|
||||||
|
/**
|
||||||
|
* The player is not allowed to log in, due to them being banned
|
||||||
|
*/
|
||||||
|
KICK_BANNED,
|
||||||
|
/**
|
||||||
|
* The player is not allowed to log in, due to them not being on the white list
|
||||||
|
*/
|
||||||
|
KICK_WHITELIST,
|
||||||
|
/**
|
||||||
|
* The player is not allowed to log in, for reasons undefined
|
||||||
|
*/
|
||||||
|
KICK_OTHER;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
private PlayerPreLoginEvent.Result old() {
|
||||||
|
return PlayerPreLoginEvent.Result.valueOf(name());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package org.bukkit.event.player;
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
import org.bukkit.Warning;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores details for players attempting to log in
|
* Stores details for players attempting to log in
|
||||||
|
* @deprecated This event causes synchronization from the login thread; {@link AsyncPlayerPreLoginEvent} is preferred to keep the secondary threads asynchronous.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Warning(reason="This event causes a login thread to synchronize with the main thread")
|
||||||
public class PlayerPreLoginEvent extends Event {
|
public class PlayerPreLoginEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private Result result;
|
private Result result;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren