mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-28 05:05:14 +01:00
Fix npe after register.
This commit is contained in:
parent
4af4d424ee
commit
029214c080
@ -117,8 +117,11 @@ public class LimboCache {
|
||||
* @param name String
|
||||
*/
|
||||
public void deleteLimboPlayer(String name) {
|
||||
if(cache.containsKey(name)) {
|
||||
cache.get(name).clearTask();
|
||||
cache.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getLimboPlayer.
|
||||
@ -148,8 +151,9 @@ public class LimboCache {
|
||||
* @param player Player
|
||||
*/
|
||||
public void updateLimboPlayer(Player player) {
|
||||
if (this.hasLimboPlayer(player.getName().toLowerCase())) {
|
||||
this.deleteLimboPlayer(player.getName().toLowerCase());
|
||||
String name = player.getName().toLowerCase();
|
||||
if (hasLimboPlayer(name)) {
|
||||
deleteLimboPlayer(name);
|
||||
}
|
||||
addLimboPlayer(player);
|
||||
}
|
||||
|
@ -108,8 +108,9 @@ public class LimboPlayer {
|
||||
* @param i BukkitTask
|
||||
*/
|
||||
public void setTimeoutTaskId(BukkitTask i) {
|
||||
if (this.timeoutTaskId != null)
|
||||
if (this.timeoutTaskId != null) {
|
||||
this.timeoutTaskId.cancel();
|
||||
}
|
||||
this.timeoutTaskId = i;
|
||||
}
|
||||
|
||||
@ -128,11 +129,27 @@ public class LimboPlayer {
|
||||
* @param messageTaskId BukkitTask
|
||||
*/
|
||||
public void setMessageTaskId(BukkitTask messageTaskId) {
|
||||
if (this.messageTaskId != null)
|
||||
if (this.messageTaskId != null) {
|
||||
this.messageTaskId.cancel();
|
||||
}
|
||||
this.messageTaskId = messageTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method clearTask.
|
||||
*
|
||||
*/
|
||||
public void clearTask() {
|
||||
if (messageTaskId != null) {
|
||||
messageTaskId.cancel();
|
||||
}
|
||||
messageTaskId = null;
|
||||
if (timeoutTaskId != null) {
|
||||
timeoutTaskId.cancel();
|
||||
}
|
||||
timeoutTaskId = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isFlying.
|
||||
*
|
||||
|
@ -50,14 +50,12 @@ public class AsynchronousJoin {
|
||||
}
|
||||
|
||||
public void process() {
|
||||
if (AuthMePlayerListener.gameMode.containsKey(name))
|
||||
AuthMePlayerListener.gameMode.remove(name);
|
||||
AuthMePlayerListener.gameMode.putIfAbsent(name, player.getGameMode());
|
||||
|
||||
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
|
||||
if (Utils.isUnrestricted(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AuthMePlayerListener.gameMode.put(name, player.getGameMode());
|
||||
|
||||
if (plugin.ess != null && Settings.disableSocialSpy) {
|
||||
plugin.ess.getUser(player).setSocialSpyEnabled(false);
|
||||
}
|
||||
|
@ -41,15 +41,13 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
protected void forceCommands() {
|
||||
private void forceCommands() {
|
||||
for (String command : Settings.forceRegisterCommands) {
|
||||
try {
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
for (String command : Settings.forceRegisterCommandsAsConsole) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.replace("%p", player.getName()));
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
command.replace("%p", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,20 +56,21 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
protected void forceLogin(Player player) {
|
||||
private void forceLogin(Player player) {
|
||||
Utils.teleportToSpawn(player);
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
LimboCache cache = LimboCache.getInstance();
|
||||
cache.updateLimboPlayer(player);
|
||||
int delay = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
BukkitTask task;
|
||||
if (delay != 0) {
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
task = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
|
||||
cache.getLimboPlayer(name).setTimeoutTaskId(task);
|
||||
}
|
||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.retrieve(MessageKey.LOGIN_MESSAGE), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
task = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name,
|
||||
m.retrieve(MessageKey.LOGIN_MESSAGE), interval));
|
||||
cache.getLimboPlayer(name).setMessageTaskId(task);
|
||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||
player.getVehicle().eject();
|
||||
}
|
||||
@ -97,33 +96,39 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
limbo.getTimeoutTaskId().cancel();
|
||||
limbo.getMessageTaskId().cancel();
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
|
||||
if (!Settings.getRegisteredGroup.isEmpty()) {
|
||||
Utils.setGroup(player, Utils.GroupType.REGISTERED);
|
||||
}
|
||||
|
||||
m.send(player, MessageKey.REGISTER_SUCCESS);
|
||||
if (!Settings.getmailAccount.isEmpty())
|
||||
|
||||
if (!Settings.getmailAccount.isEmpty()) {
|
||||
m.send(player, MessageKey.ADD_EMAIL_MESSAGE);
|
||||
}
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
}
|
||||
if (Settings.applyBlindEffect)
|
||||
|
||||
if (Settings.applyBlindEffect) {
|
||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
}
|
||||
|
||||
if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) {
|
||||
player.setWalkSpeed(0.2f);
|
||||
player.setFlySpeed(0.1f);
|
||||
}
|
||||
|
||||
// The LoginEvent now fires (as intended) after everything is processed
|
||||
plugin.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
|
||||
if (!Settings.noConsoleSpam)
|
||||
if (!Settings.noConsoleSpam) {
|
||||
ConsoleLogger.info(player.getName() + " registered " + plugin.getIP(player));
|
||||
}
|
||||
|
||||
// Kick Player after Registration is enabled, kick the player
|
||||
if (Settings.forceRegKick) {
|
||||
@ -138,7 +143,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
}
|
||||
|
||||
// Register is finish and player is logged, display welcome message
|
||||
if (Settings.useWelcomeMessage)
|
||||
if (Settings.useWelcomeMessage) {
|
||||
if (Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
plugin.getServer().broadcastMessage(plugin.replaceAllInfo(s, player));
|
||||
@ -148,6 +153,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
player.sendMessage(plugin.replaceAllInfo(s, player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register is now finish , we can force all commands
|
||||
forceCommands();
|
||||
|
Loading…
Reference in New Issue
Block a user