mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Added onPlayerLogin
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
3a968aa90a
commit
695bda59ee
3 changed files with 109 additions and 0 deletions
|
@ -57,4 +57,12 @@ public class PlayerListener implements Listener {
|
||||||
*/
|
*/
|
||||||
public void onPlayerTeleport(PlayerMoveEvent event) {
|
public void onPlayerTeleport(PlayerMoveEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player attempts to log in to the server
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
98
paper-api/src/org/bukkit/event/player/PlayerLoginEvent.java
Normal file
98
paper-api/src/org/bukkit/event/player/PlayerLoginEvent.java
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
|
||||||
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores details for players attempting to log in
|
||||||
|
*/
|
||||||
|
public class PlayerLoginEvent extends PlayerEvent {
|
||||||
|
private Result result;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public PlayerLoginEvent(final Type type, final Player player, final Result result, final String message) {
|
||||||
|
super(type, player);
|
||||||
|
this.result = result;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current result of the login, as an enum
|
||||||
|
*
|
||||||
|
* @return Current Result of the login
|
||||||
|
*/
|
||||||
|
public Result getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the new result of the login, as an enum
|
||||||
|
*
|
||||||
|
* @param result New result to set
|
||||||
|
*/
|
||||||
|
public void setResult(final Result result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current kick message that will be used if getResult() != Result.ALLOWED
|
||||||
|
*
|
||||||
|
* @return Current kick message
|
||||||
|
*/
|
||||||
|
public String getKickMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the kick message to display if getResult() != Result.ALLOWED
|
||||||
|
*
|
||||||
|
* @param message New kick message
|
||||||
|
*/
|
||||||
|
public void setKickMessage(final String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the player to log in
|
||||||
|
*/
|
||||||
|
public void allow() {
|
||||||
|
result = Result.ALLOWED;
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
public void disallow(final Result result, final String message) {
|
||||||
|
this.result = result;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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, for reasons undefined
|
||||||
|
*/
|
||||||
|
KICK_OTHER
|
||||||
|
}
|
||||||
|
}
|
|
@ -99,6 +99,9 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||||
case PLAYER_TELEPORT:
|
case PLAYER_TELEPORT:
|
||||||
trueListener.onPlayerTeleport((PlayerMoveEvent)event);
|
trueListener.onPlayerTeleport((PlayerMoveEvent)event);
|
||||||
break;
|
break;
|
||||||
|
case PLAYER_LOGIN:
|
||||||
|
trueListener.onPlayerLogin((PlayerLoginEvent)event);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue