Code Refactor - Whitespace Refactor
This commit is contained in:
@@ -12,7 +12,8 @@ import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @authors Xephi59, <a href="http://dev.bukkit.org/profiles/Possible/">Possible</a>
|
||||
* @authors Xephi59, <a
|
||||
* href="http://dev.bukkit.org/profiles/Possible/">Possible</a>
|
||||
*
|
||||
*/
|
||||
public class Management extends Thread {
|
||||
@@ -30,11 +31,15 @@ public class Management extends Thread {
|
||||
public void run() {
|
||||
}
|
||||
|
||||
public void performLogin(final Player player, final String password, final boolean forceLogin) {
|
||||
new AsyncronousLogin(player, password, forceLogin, plugin, database).process();
|
||||
public void performLogin(final Player player, final String password,
|
||||
final boolean forceLogin) {
|
||||
new AsyncronousLogin(player, password, forceLogin, plugin, database)
|
||||
.process();
|
||||
}
|
||||
|
||||
public void performRegister(final Player player, final String password, final String email) {
|
||||
new AsyncronousRegister(player, password, email, plugin, database).process();
|
||||
public void performRegister(final Player player, final String password,
|
||||
final String email) {
|
||||
new AsyncronousRegister(player, password, email, plugin, database)
|
||||
.process();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ public class AsyncronousLogin {
|
||||
private static RandomString rdm = new RandomString(Settings.captchaLength);
|
||||
private Messages m = Messages.getInstance();
|
||||
|
||||
public AsyncronousLogin(Player player, String password, boolean forceLogin, AuthMe plugin, DataSource data) {
|
||||
public AsyncronousLogin(Player player, String password, boolean forceLogin,
|
||||
AuthMe plugin, DataSource data) {
|
||||
this.player = player;
|
||||
this.password = password;
|
||||
name = player.getName().toLowerCase();
|
||||
@@ -43,8 +44,9 @@ public class AsyncronousLogin {
|
||||
}
|
||||
|
||||
protected String getIP() {
|
||||
return plugin.getIP(player);
|
||||
return plugin.getIP(player);
|
||||
}
|
||||
|
||||
protected boolean needsCaptcha() {
|
||||
if (Settings.useCaptcha) {
|
||||
if (!plugin.captcha.containsKey(name)) {
|
||||
@@ -54,13 +56,17 @@ public class AsyncronousLogin {
|
||||
plugin.captcha.remove(name);
|
||||
plugin.captcha.put(name, i);
|
||||
}
|
||||
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
if (plugin.captcha.containsKey(name)
|
||||
&& plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
plugin.cap.put(name, rdm.nextString());
|
||||
for (String s : m._("usage_captcha")) {
|
||||
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name)).replace("<theCaptcha>", plugin.cap.get(name)));
|
||||
player.sendMessage(s.replace("THE_CAPTCHA",
|
||||
plugin.cap.get(name)).replace("<theCaptcha>",
|
||||
plugin.cap.get(name)));
|
||||
}
|
||||
return true;
|
||||
} else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
} else if (plugin.captcha.containsKey(name)
|
||||
&& plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
try {
|
||||
plugin.captcha.remove(name);
|
||||
plugin.cap.remove(name);
|
||||
@@ -72,41 +78,52 @@ public class AsyncronousLogin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the precondition for authentication (like user known) and returns the playerAuth-State
|
||||
* Checks the precondition for authentication (like user known) and returns
|
||||
* the playerAuth-State
|
||||
*/
|
||||
protected PlayerAuth preAuth() {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
m._(player, "logged_in");
|
||||
m._(player, "logged_in");
|
||||
return null;
|
||||
}
|
||||
if (!database.isAuthAvailable(name)) {
|
||||
m._(player, "user_unknown");
|
||||
if(LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId());
|
||||
String[] msg;
|
||||
if(Settings.emailRegistration) {
|
||||
msg = m._("reg_email_msg");
|
||||
m._(player, "user_unknown");
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
Bukkit.getScheduler().cancelTask(
|
||||
LimboCache.getInstance().getLimboPlayer(name)
|
||||
.getMessageTaskId());
|
||||
String[] msg;
|
||||
if (Settings.emailRegistration) {
|
||||
msg = m._("reg_email_msg");
|
||||
} else {
|
||||
msg = m._("reg_msg");
|
||||
msg = m._("reg_msg");
|
||||
}
|
||||
int msgT = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, msg, Settings.getWarnMessageInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
}
|
||||
int msgT = Bukkit.getScheduler().scheduleSyncDelayedTask(
|
||||
plugin,
|
||||
new MessageTask(plugin, name, msg,
|
||||
Settings.getWarnMessageInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name)
|
||||
.setMessageTaskId(msgT);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (Settings.getMaxLoginPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
|
||||
if (plugin.isLoggedIp(realName, getIP())) {
|
||||
m._(player, "logged_in");
|
||||
return null;
|
||||
}
|
||||
if (Settings.getMaxLoginPerIp > 0
|
||||
&& !plugin.authmePermissible(player, "authme.allow2accounts")
|
||||
&& !getIP().equalsIgnoreCase("127.0.0.1")
|
||||
&& !getIP().equalsIgnoreCase("localhost")) {
|
||||
if (plugin.isLoggedIp(realName, getIP())) {
|
||||
m._(player, "logged_in");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
PlayerAuth pAuth = database.getAuth(name);
|
||||
if (pAuth == null) {
|
||||
m._(player, "user_unknown");
|
||||
m._(player, "user_unknown");
|
||||
return null;
|
||||
}
|
||||
if (!Settings.getMySQLColumnGroup.isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
|
||||
m._(player, "vb_nonActiv");
|
||||
if (!Settings.getMySQLColumnGroup.isEmpty()
|
||||
&& pAuth.getGroupId() == Settings.getNonActivatedGroup) {
|
||||
m._(player, "vb_nonActiv");
|
||||
return null;
|
||||
}
|
||||
return pAuth;
|
||||
@@ -114,22 +131,22 @@ public class AsyncronousLogin {
|
||||
|
||||
public void process() {
|
||||
PlayerAuth pAuth = preAuth();
|
||||
if (pAuth == null || needsCaptcha())
|
||||
return;
|
||||
if (pAuth == null || needsCaptcha()) return;
|
||||
|
||||
String hash = pAuth.getHash();
|
||||
String email = pAuth.getEmail();
|
||||
boolean passwordVerified = true;
|
||||
if (!forceLogin)
|
||||
try {
|
||||
passwordVerified = PasswordSecurity.comparePasswordWithHash(password, hash, realName);
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
m._(player, "error");
|
||||
return;
|
||||
}
|
||||
if (!forceLogin) try {
|
||||
passwordVerified = PasswordSecurity.comparePasswordWithHash(
|
||||
password, hash, realName);
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
m._(player, "error");
|
||||
return;
|
||||
}
|
||||
if (passwordVerified && player.isOnline()) {
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email, realName);
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(),
|
||||
new Date().getTime(), email, realName);
|
||||
database.updateSession(auth);
|
||||
|
||||
if (Settings.useCaptcha) {
|
||||
@@ -146,11 +163,12 @@ public class AsyncronousLogin {
|
||||
|
||||
displayOtherAccounts(auth, player);
|
||||
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " logged in!");
|
||||
if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName()
|
||||
+ " logged in!");
|
||||
|
||||
if (plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged in!"));
|
||||
plugin.notifications.showNotification(new Notification(
|
||||
"[AuthMe] " + player.getName() + " logged in!"));
|
||||
}
|
||||
|
||||
// makes player isLoggedin via API
|
||||
@@ -158,36 +176,53 @@ public class AsyncronousLogin {
|
||||
database.setLogged(name);
|
||||
plugin.otherAccounts.addPlayer(player.getUniqueId());
|
||||
|
||||
// As the scheduling executes the Task most likely after the current task, we schedule it in the end
|
||||
// so that we can be sure, and have not to care if it might be processed in other order.
|
||||
ProcessSyncronousPlayerLogin syncronousPlayerLogin = new ProcessSyncronousPlayerLogin(player, plugin, database);
|
||||
// As the scheduling executes the Task most likely after the current
|
||||
// task, we schedule it in the end
|
||||
// so that we can be sure, and have not to care if it might be
|
||||
// processed in other order.
|
||||
ProcessSyncronousPlayerLogin syncronousPlayerLogin = new ProcessSyncronousPlayerLogin(
|
||||
player, plugin, database);
|
||||
if (syncronousPlayerLogin.getLimbo() != null) {
|
||||
player.getServer().getScheduler().cancelTask(syncronousPlayerLogin.getLimbo().getTimeoutTaskId());
|
||||
player.getServer().getScheduler().cancelTask(syncronousPlayerLogin.getLimbo().getMessageTaskId());
|
||||
player.getServer()
|
||||
.getScheduler()
|
||||
.cancelTask(
|
||||
syncronousPlayerLogin.getLimbo()
|
||||
.getTimeoutTaskId());
|
||||
player.getServer()
|
||||
.getScheduler()
|
||||
.cancelTask(
|
||||
syncronousPlayerLogin.getLimbo()
|
||||
.getMessageTaskId());
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, syncronousPlayerLogin);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
syncronousPlayerLogin);
|
||||
} else if (player.isOnline()) {
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " used the wrong password");
|
||||
if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName()
|
||||
+ " used the wrong password");
|
||||
if (Settings.isKickOnWrongPasswordEnabled) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (AuthMePlayerListener.gameMode != null && AuthMePlayerListener.gameMode.containsKey(name)) {
|
||||
player.setGameMode(AuthMePlayerListener.gameMode.get(name));
|
||||
}
|
||||
player.kickPlayer(m._("wrong_pwd")[0]);
|
||||
}
|
||||
});
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (AuthMePlayerListener.gameMode != null
|
||||
&& AuthMePlayerListener.gameMode
|
||||
.containsKey(name)) {
|
||||
player.setGameMode(AuthMePlayerListener.gameMode
|
||||
.get(name));
|
||||
}
|
||||
player.kickPlayer(m._("wrong_pwd")[0]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
m._(player, "wrong_pwd");
|
||||
m._(player, "wrong_pwd");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ConsoleLogger.showError("Player " + name + " wasn't online during login process, aborted... ");
|
||||
ConsoleLogger.showError("Player " + name
|
||||
+ " wasn't online during login process, aborted... ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void displayOtherAccounts(PlayerAuth auth, Player p) {
|
||||
if (!Settings.displayOtherAccounts) {
|
||||
return;
|
||||
@@ -196,7 +231,8 @@ public class AsyncronousLogin {
|
||||
return;
|
||||
}
|
||||
List<String> auths = this.database.getAllAuthsByName(auth);
|
||||
//List<String> uuidlist = plugin.otherAccounts.getAllPlayersByUUID(player.getUniqueId());
|
||||
// List<String> uuidlist =
|
||||
// plugin.otherAccounts.getAllPlayersByUUID(player.getUniqueId());
|
||||
if (auths.isEmpty() || auths == null) {
|
||||
return;
|
||||
}
|
||||
@@ -204,7 +240,8 @@ public class AsyncronousLogin {
|
||||
return;
|
||||
}
|
||||
String message = "[AuthMe] ";
|
||||
//String uuidaccounts = "[AuthMe] PlayerNames has %size% links to this UUID : ";
|
||||
// String uuidaccounts =
|
||||
// "[AuthMe] PlayerNames has %size% links to this UUID : ";
|
||||
int i = 0;
|
||||
for (String account : auths) {
|
||||
i++;
|
||||
@@ -215,23 +252,19 @@ public class AsyncronousLogin {
|
||||
message = message + ".";
|
||||
}
|
||||
}
|
||||
/*TODO: Active uuid system
|
||||
i = 0;
|
||||
for (String account : uuidlist) {
|
||||
i++;
|
||||
uuidaccounts = uuidaccounts + account;
|
||||
if (i != auths.size()) {
|
||||
uuidaccounts = uuidaccounts + ", ";
|
||||
} else {
|
||||
uuidaccounts = uuidaccounts + ".";
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* TODO: Active uuid system i = 0; for (String account : uuidlist) {
|
||||
* i++; uuidaccounts = uuidaccounts + account; if (i != auths.size()) {
|
||||
* uuidaccounts = uuidaccounts + ", "; } else { uuidaccounts =
|
||||
* uuidaccounts + "."; } }
|
||||
*/
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (plugin.authmePermissible(player, "authme.seeOtherAccounts")) {
|
||||
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has "
|
||||
+ auths.size() + " accounts");
|
||||
player.sendMessage("[AuthMe] The player " + auth.getNickname()
|
||||
+ " has " + auths.size() + " accounts");
|
||||
player.sendMessage(message);
|
||||
//player.sendMessage(uuidaccounts.replace("%size%", ""+uuidlist.size()));
|
||||
// player.sendMessage(uuidaccounts.replace("%size%",
|
||||
// ""+uuidlist.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,11 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
private PluginManager pm;
|
||||
private FileCache playerCache = new FileCache();
|
||||
|
||||
public ProcessSyncronousPlayerLogin(Player player, AuthMe plugin, DataSource data) {
|
||||
this.plugin = plugin;
|
||||
this.database = data;
|
||||
this.pm = plugin.getServer().getPluginManager();
|
||||
public ProcessSyncronousPlayerLogin(Player player, AuthMe plugin,
|
||||
DataSource data) {
|
||||
this.plugin = plugin;
|
||||
this.database = data;
|
||||
this.pm = plugin.getServer().getPluginManager();
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
@@ -49,18 +50,21 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
|
||||
protected void restoreOpState() {
|
||||
player.setOp(limbo.getOperator());
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE
|
||||
&& !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
}
|
||||
}
|
||||
|
||||
protected void packQuitLocation() {
|
||||
Utils.getInstance().packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
||||
Utils.getInstance().packCoords(auth.getQuitLocX(), auth.getQuitLocY(),
|
||||
auth.getQuitLocZ(), auth.getWorld(), player);
|
||||
}
|
||||
|
||||
protected void teleportBackFromSpawn() {
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player,
|
||||
limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
Location fLoc = tpEvent.getTo();
|
||||
@@ -73,7 +77,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
|
||||
protected void teleportToSpawn() {
|
||||
Location spawnL = plugin.getSpawnLocation(player);
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player,
|
||||
player.getLocation(), spawnL, true);
|
||||
pm.callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
Location fLoc = tpEvent.getTo();
|
||||
@@ -85,49 +90,57 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
}
|
||||
|
||||
protected void restoreInventory() {
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player,
|
||||
limbo.getInventory(), limbo.getArmour());
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
API.setPlayerInventory(player, event.getInventory(), event.getArmor());
|
||||
API.setPlayerInventory(player, event.getInventory(),
|
||||
event.getArmor());
|
||||
}
|
||||
}
|
||||
|
||||
protected void forceCommands() {
|
||||
for (String command : Settings.forceCommands) {
|
||||
try {
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
for (String command : Settings.forceCommandsAsConsole) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.replace("%p", player.getName()));
|
||||
}
|
||||
for (String command : Settings.forceCommands) {
|
||||
try {
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
for (String command : Settings.forceCommandsAsConsole) {
|
||||
Bukkit.getServer().dispatchCommand(
|
||||
Bukkit.getServer().getConsoleSender(),
|
||||
command.replace("%p", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Limbo contains the State of the Player before /login
|
||||
// Limbo contains the State of the Player before /login
|
||||
if (limbo != null) {
|
||||
// Op & Flying
|
||||
restoreOpState();
|
||||
|
||||
/*
|
||||
* Restore Inventories and GameMode
|
||||
* We need to restore them before teleport the player
|
||||
* Cause in AuthMePlayerListener, we call ProtectInventoryEvent after Teleporting
|
||||
* Also it's the current world inventory !
|
||||
* Restore Inventories and GameMode We need to restore them before
|
||||
* teleport the player Cause in AuthMePlayerListener, we call
|
||||
* ProtectInventoryEvent after Teleporting Also it's the current
|
||||
* world inventory !
|
||||
*/
|
||||
if (!Settings.forceOnlyAfterLogin) {
|
||||
player.setGameMode(limbo.getGameMode());
|
||||
// Inventory - Make it after restore GameMode , cause we need to restore the
|
||||
player.setGameMode(limbo.getGameMode());
|
||||
// Inventory - Make it after restore GameMode , cause we need to
|
||||
// restore the
|
||||
// right inventory in the right gamemode
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
if (Settings.protectInventoryBeforeLogInEnabled
|
||||
&& player.hasPlayedBefore()) {
|
||||
restoreInventory();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Inventory - Make it before force the survival GameMode to cancel all
|
||||
// inventory problem
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
} else {
|
||||
// Inventory - Make it before force the survival GameMode to
|
||||
// cancel all
|
||||
// inventory problem
|
||||
if (Settings.protectInventoryBeforeLogInEnabled
|
||||
&& player.hasPlayedBefore()) {
|
||||
restoreInventory();
|
||||
}
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
@@ -135,25 +148,32 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
|
||||
if (!Settings.noTeleport) {
|
||||
// Teleport
|
||||
if (Settings.isTeleportToSpawnEnabled && !Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||
if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
|
||||
if (Settings.isTeleportToSpawnEnabled
|
||||
&& !Settings.isForceSpawnLocOnJoinEnabled
|
||||
&& Settings.getForcedWorlds.contains(player.getWorld()
|
||||
.getName())) {
|
||||
if (Settings.isSaveQuitLocationEnabled
|
||||
&& auth.getQuitLocY() != 0) {
|
||||
packQuitLocation();
|
||||
} else {
|
||||
teleportBackFromSpawn();
|
||||
}
|
||||
} else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||
} else if (Settings.isForceSpawnLocOnJoinEnabled
|
||||
&& Settings.getForcedWorlds.contains(player.getWorld()
|
||||
.getName())) {
|
||||
teleportToSpawn();
|
||||
} else if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
|
||||
} else if (Settings.isSaveQuitLocationEnabled
|
||||
&& auth.getQuitLocY() != 0) {
|
||||
packQuitLocation();
|
||||
} else {
|
||||
teleportBackFromSpawn();
|
||||
}
|
||||
}
|
||||
|
||||
// Re-Force Survival GameMode if we need due to world change specification
|
||||
if (Settings.isForceSurvivalModeEnabled)
|
||||
Utils.forceGM(player);
|
||||
|
||||
// Re-Force Survival GameMode if we need due to world change
|
||||
// specification
|
||||
if (Settings.isForceSurvivalModeEnabled) Utils.forceGM(player);
|
||||
|
||||
// Restore Permission Group
|
||||
Utils.getInstance().setGroup(player, groupType.LOGGEDIN);
|
||||
|
||||
@@ -165,32 +185,35 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
}
|
||||
|
||||
// We can now display the join message
|
||||
if (AuthMePlayerListener.joinMessage.containsKey(name) && AuthMePlayerListener.joinMessage.get(name) != null && !AuthMePlayerListener.joinMessage.get(name).isEmpty()) {
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.isOnline())
|
||||
p.sendMessage(AuthMePlayerListener.joinMessage.get(name));
|
||||
}
|
||||
AuthMePlayerListener.joinMessage.remove(name);
|
||||
if (AuthMePlayerListener.joinMessage.containsKey(name)
|
||||
&& AuthMePlayerListener.joinMessage.get(name) != null
|
||||
&& !AuthMePlayerListener.joinMessage.get(name).isEmpty()) {
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.isOnline()) p
|
||||
.sendMessage(AuthMePlayerListener.joinMessage.get(name));
|
||||
}
|
||||
AuthMePlayerListener.joinMessage.remove(name);
|
||||
}
|
||||
|
||||
if (Settings.applyBlindEffect)
|
||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
if (Settings.applyBlindEffect) player
|
||||
.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
|
||||
// The Loginevent now fires (as intended) after everything is processed
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
|
||||
// Login is finish, display welcome message
|
||||
if(Settings.useWelcomeMessage)
|
||||
if(Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
if (Settings.useWelcomeMessage) if (Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
Bukkit.getServer().broadcastMessage(
|
||||
plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
}
|
||||
|
||||
// Login is now finish , we can force all commands
|
||||
forceCommands();
|
||||
|
||||
@@ -26,7 +26,8 @@ public class AsyncronousRegister {
|
||||
private DataSource database;
|
||||
private Messages m = Messages.getInstance();
|
||||
|
||||
public AsyncronousRegister(Player player, String password, String email, AuthMe plugin, DataSource data) {
|
||||
public AsyncronousRegister(Player player, String password, String email,
|
||||
AuthMe plugin, DataSource data) {
|
||||
this.player = player;
|
||||
this.password = password;
|
||||
name = player.getName().toLowerCase();
|
||||
@@ -38,11 +39,11 @@ public class AsyncronousRegister {
|
||||
}
|
||||
|
||||
protected String getIp() {
|
||||
return plugin.getIP(player);
|
||||
return plugin.getIP(player);
|
||||
}
|
||||
|
||||
protected void preRegister() {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
m._(player, "logged_in");
|
||||
allowRegister = false;
|
||||
}
|
||||
@@ -54,8 +55,9 @@ public class AsyncronousRegister {
|
||||
|
||||
String lowpass = password.toLowerCase();
|
||||
if ((lowpass.contains("delete") || lowpass.contains("where")
|
||||
|| lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from")
|
||||
|| lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null"))
|
||||
|| lowpass.contains("insert") || lowpass.contains("modify")
|
||||
|| lowpass.contains("from") || lowpass.contains("select")
|
||||
|| lowpass.contains(";") || lowpass.contains("null"))
|
||||
|| !lowpass.matches(Settings.getPassRegex)) {
|
||||
m._(player, "password_error");
|
||||
allowRegister = false;
|
||||
@@ -63,102 +65,122 @@ public class AsyncronousRegister {
|
||||
|
||||
if (database.isAuthAvailable(player.getName().toLowerCase())) {
|
||||
m._(player, "user_regged");
|
||||
if (plugin.pllog.getStringList("players").contains(player.getName())) {
|
||||
plugin.pllog.getStringList("players").remove(player.getName());
|
||||
if (plugin.pllog.getStringList("players")
|
||||
.contains(player.getName())) {
|
||||
plugin.pllog.getStringList("players").remove(player.getName());
|
||||
}
|
||||
allowRegister = false;
|
||||
}
|
||||
|
||||
if(Settings.getmaxRegPerIp > 0 ){
|
||||
if(!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp && !getIp().equalsIgnoreCase("127.0.0.1") && !getIp().equalsIgnoreCase("localhost")) {
|
||||
m._(player, "max_reg");
|
||||
allowRegister = false;
|
||||
}
|
||||
if (Settings.getmaxRegPerIp > 0) {
|
||||
if (!plugin.authmePermissible(player, "authme.allow2accounts")
|
||||
&& database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp
|
||||
&& !getIp().equalsIgnoreCase("127.0.0.1")
|
||||
&& !getIp().equalsIgnoreCase("localhost")) {
|
||||
m._(player, "max_reg");
|
||||
allowRegister = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void process() {
|
||||
preRegister();
|
||||
if(!allowRegister) return;
|
||||
if(!email.isEmpty() && email != "") {
|
||||
if(Settings.getmaxRegPerEmail > 0) {
|
||||
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||
m._(player, "max_reg");
|
||||
return;
|
||||
}
|
||||
}
|
||||
emailRegister();
|
||||
return;
|
||||
}
|
||||
passwordRegister();
|
||||
preRegister();
|
||||
if (!allowRegister) return;
|
||||
if (!email.isEmpty() && email != "") {
|
||||
if (Settings.getmaxRegPerEmail > 0) {
|
||||
if (!plugin.authmePermissible(player, "authme.allow2accounts")
|
||||
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||
m._(player, "max_reg");
|
||||
return;
|
||||
}
|
||||
}
|
||||
emailRegister();
|
||||
return;
|
||||
}
|
||||
passwordRegister();
|
||||
}
|
||||
|
||||
protected void emailRegister() {
|
||||
if(Settings.getmaxRegPerEmail > 0) {
|
||||
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||
m._(player, "max_reg");
|
||||
return;
|
||||
}
|
||||
}
|
||||
PlayerAuth auth = null;
|
||||
try {
|
||||
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
|
||||
auth = new PlayerAuth(name, hashnew, getIp(), new Date().getTime(), (int) player.getLocation().getX() , (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email, realName);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
m._(player, "error");
|
||||
return;
|
||||
}
|
||||
if (PasswordSecurity.userSalt.containsKey(name)) {
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
}
|
||||
if (Settings.getmaxRegPerEmail > 0) {
|
||||
if (!plugin.authmePermissible(player, "authme.allow2accounts")
|
||||
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||
m._(player, "max_reg");
|
||||
return;
|
||||
}
|
||||
}
|
||||
PlayerAuth auth = null;
|
||||
try {
|
||||
final String hashnew = PasswordSecurity.getHash(
|
||||
Settings.getPasswordHash, password, name);
|
||||
auth = new PlayerAuth(name, hashnew, getIp(), new Date().getTime(),
|
||||
(int) player.getLocation().getX(), (int) player
|
||||
.getLocation().getY(), (int) player.getLocation()
|
||||
.getZ(), player.getLocation().getWorld().getName(),
|
||||
email, realName);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
m._(player, "error");
|
||||
return;
|
||||
}
|
||||
if (PasswordSecurity.userSalt.containsKey(name)) {
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
}
|
||||
database.saveAuth(auth);
|
||||
database.updateEmail(auth);
|
||||
database.updateSession(auth);
|
||||
plugin.mail.main(auth, password);
|
||||
ProcessSyncronousEmailRegister syncronous = new ProcessSyncronousEmailRegister(player, plugin);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
|
||||
return;
|
||||
database.updateEmail(auth);
|
||||
database.updateSession(auth);
|
||||
plugin.mail.main(auth, password);
|
||||
ProcessSyncronousEmailRegister syncronous = new ProcessSyncronousEmailRegister(
|
||||
player, plugin);
|
||||
plugin.getServer().getScheduler()
|
||||
.scheduleSyncDelayedTask(plugin, syncronous);
|
||||
return;
|
||||
}
|
||||
|
||||
protected void passwordRegister() {
|
||||
if(password.length() < Settings.getPasswordMinLen || password.length() > Settings.passwordMaxLength) {
|
||||
m._(player, "pass_len");
|
||||
if (password.length() < Settings.getPasswordMinLen
|
||||
|| password.length() > Settings.passwordMaxLength) {
|
||||
m._(player, "pass_len");
|
||||
return;
|
||||
}
|
||||
if(!Settings.unsafePasswords.isEmpty()) {
|
||||
if (Settings.unsafePasswords.contains(password.toLowerCase())) {
|
||||
m._(player, "password_error");
|
||||
return;
|
||||
}
|
||||
if (!Settings.unsafePasswords.isEmpty()) {
|
||||
if (Settings.unsafePasswords.contains(password.toLowerCase())) {
|
||||
m._(player, "password_error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
PlayerAuth auth = null;
|
||||
String hash = "";
|
||||
try {
|
||||
hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
m._(player, "error");
|
||||
return;
|
||||
}
|
||||
if (Settings.getMySQLColumnSalt.isEmpty() && !PasswordSecurity.userSalt.containsKey(name))
|
||||
{
|
||||
auth = new PlayerAuth(name, hash, getIp(), new Date().getTime(), "your@email.com", player.getName());
|
||||
try {
|
||||
hash = PasswordSecurity.getHash(Settings.getPasswordHash, password,
|
||||
name);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
m._(player, "error");
|
||||
return;
|
||||
}
|
||||
if (Settings.getMySQLColumnSalt.isEmpty()
|
||||
&& !PasswordSecurity.userSalt.containsKey(name)) {
|
||||
auth = new PlayerAuth(name, hash, getIp(), new Date().getTime(),
|
||||
"your@email.com", player.getName());
|
||||
} else {
|
||||
auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), getIp(), new Date().getTime(), player.getName());
|
||||
auth = new PlayerAuth(name, hash,
|
||||
PasswordSecurity.userSalt.get(name), getIp(),
|
||||
new Date().getTime(), player.getName());
|
||||
}
|
||||
if (!database.saveAuth(auth)) {
|
||||
m._(player, "error");
|
||||
m._(player, "error");
|
||||
return;
|
||||
}
|
||||
if (!Settings.forceRegLogin) {
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
database.setLogged(name);
|
||||
database.setLogged(name);
|
||||
}
|
||||
plugin.otherAccounts.addPlayer(player.getUniqueId());
|
||||
ProcessSyncronousPasswordRegister syncronous = new ProcessSyncronousPasswordRegister(player, plugin);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
|
||||
ProcessSyncronousPasswordRegister syncronous = new ProcessSyncronousPasswordRegister(
|
||||
player, plugin);
|
||||
plugin.getServer().getScheduler()
|
||||
.scheduleSyncDelayedTask(plugin, syncronous);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+46
-33
@@ -20,56 +20,69 @@ import fr.xephi.authme.task.TimeoutTask;
|
||||
|
||||
public class ProcessSyncronousEmailRegister implements Runnable {
|
||||
|
||||
protected Player player;
|
||||
protected String name;
|
||||
private AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
public ProcessSyncronousEmailRegister(Player player, AuthMe plugin) {
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if(!Settings.getRegisteredGroup.isEmpty()){
|
||||
protected Player player;
|
||||
protected String name;
|
||||
private AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
|
||||
public ProcessSyncronousEmailRegister(Player player, AuthMe plugin) {
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!Settings.getRegisteredGroup.isEmpty()) {
|
||||
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
|
||||
}
|
||||
m._(player, "vb_nonActiv");
|
||||
int time = Settings.getRegistrationTimeout * 20;
|
||||
int msgInterval = Settings.getWarnMessageInterval;
|
||||
int time = Settings.getRegistrationTimeout * 20;
|
||||
int msgInterval = Settings.getWarnMessageInterval;
|
||||
if (time != 0) {
|
||||
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getTimeoutTaskId());
|
||||
int id = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), time);
|
||||
Bukkit.getScheduler().cancelTask(
|
||||
LimboCache.getInstance().getLimboPlayer(name)
|
||||
.getTimeoutTaskId());
|
||||
int id = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new TimeoutTask(plugin, name), time);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId());
|
||||
int nwMsg = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), msgInterval));
|
||||
Bukkit.getScheduler().cancelTask(
|
||||
LimboCache.getInstance().getLimboPlayer(name)
|
||||
.getMessageTaskId());
|
||||
int nwMsg = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new MessageTask(plugin, name, m._("login_msg"), msgInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg);
|
||||
|
||||
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||
Location loca = plugin.getSpawnLocation(player);
|
||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
||||
Location loca = plugin.getSpawnLocation(player);
|
||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player,
|
||||
loca);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
if (!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
|
||||
.isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
|
||||
.load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE
|
||||
&& !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
}
|
||||
if (Settings.applyBlindEffect)
|
||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
if (Settings.applyBlindEffect) player
|
||||
.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
player.saveData();
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " registered "+plugin.getIP(player));
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered by email!"));
|
||||
if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName()
|
||||
+ " registered " + plugin.getIP(player));
|
||||
if (plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] "
|
||||
+ player.getName() + " has registered by email!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+113
-100
@@ -24,125 +24,138 @@ import fr.xephi.authme.task.TimeoutTask;
|
||||
|
||||
public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
|
||||
protected Player player;
|
||||
protected String name;
|
||||
private AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
public ProcessSyncronousPasswordRegister(Player player, AuthMe plugin) {
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
protected void forceCommands(Player player) {
|
||||
for (String command : Settings.forceCommands) {
|
||||
try {
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
protected Player player;
|
||||
protected String name;
|
||||
private AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
|
||||
public ProcessSyncronousPasswordRegister(Player player, AuthMe plugin) {
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
protected void forceLogin(Player player) {
|
||||
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||
Location spawnLoc = plugin.getSpawnLocation(player);
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
protected void forceCommands(Player player) {
|
||||
for (String command : Settings.forceCommands) {
|
||||
try {
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
|
||||
protected void forceLogin(Player player) {
|
||||
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||
Location spawnLoc = plugin.getSpawnLocation(player);
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player,
|
||||
spawnLoc);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
|
||||
.isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
|
||||
.load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) LimboCache
|
||||
.getInstance().deleteLimboPlayer(name);
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
int delay = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
if (delay != 0) {
|
||||
int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), delay);
|
||||
int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(
|
||||
plugin, name), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), interval));
|
||||
int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(
|
||||
plugin, name, m._("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
try {
|
||||
plugin.pllog.removePlayer(name);
|
||||
if (player.isInsideVehicle())
|
||||
player.getVehicle().eject();
|
||||
plugin.pllog.removePlayer(name);
|
||||
if (player.isInsideVehicle()) player.getVehicle().eject();
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
if (limbo != null) {
|
||||
player.setGameMode(limbo.getGameMode());
|
||||
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||
Location loca = plugin.getSpawnLocation(player);
|
||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||
plugin.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
}
|
||||
|
||||
if(!Settings.getRegisteredGroup.isEmpty()){
|
||||
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
|
||||
}
|
||||
m._(player, "registered");
|
||||
if (!Settings.getmailAccount.isEmpty())
|
||||
m._(player, "add_email");
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
}
|
||||
if (Settings.applyBlindEffect)
|
||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
// The Loginevent now fires (as intended) after everything is processed
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " registered "+plugin.getIP(player));
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!"));
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
if (limbo != null) {
|
||||
player.setGameMode(limbo.getGameMode());
|
||||
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||
Location loca = plugin.getSpawnLocation(player);
|
||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(
|
||||
player, loca);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
|
||||
.isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
|
||||
.load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
plugin.getServer().getScheduler()
|
||||
.cancelTask(limbo.getTimeoutTaskId());
|
||||
plugin.getServer().getScheduler()
|
||||
.cancelTask(limbo.getMessageTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
|
||||
// Kick Player after Registration is enabled, kick the player
|
||||
if (Settings.forceRegKick) {
|
||||
player.kickPlayer(m._("registered")[0]);
|
||||
return;
|
||||
}
|
||||
if (!Settings.getRegisteredGroup.isEmpty()) {
|
||||
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
|
||||
}
|
||||
m._(player, "registered");
|
||||
if (!Settings.getmailAccount.isEmpty()) m._(player, "add_email");
|
||||
if (player.getGameMode() != GameMode.CREATIVE
|
||||
&& !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
}
|
||||
if (Settings.applyBlindEffect) player
|
||||
.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
// The Loginevent now fires (as intended) after everything is processed
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
|
||||
// Request Login after Registation
|
||||
if (Settings.forceRegLogin) {
|
||||
forceLogin(player);
|
||||
return;
|
||||
}
|
||||
if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName()
|
||||
+ " registered " + plugin.getIP(player));
|
||||
if (plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] "
|
||||
+ player.getName() + " has registered!"));
|
||||
}
|
||||
|
||||
// Register is finish and player is logged, display welcome message
|
||||
if(Settings.useWelcomeMessage)
|
||||
if(Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
}
|
||||
// Kick Player after Registration is enabled, kick the player
|
||||
if (Settings.forceRegKick) {
|
||||
player.kickPlayer(m._("registered")[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Register is now finish , we can force all commands
|
||||
forceCommands(player);
|
||||
// Request Login after Registation
|
||||
if (Settings.forceRegLogin) {
|
||||
forceLogin(player);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
// Register is finish and player is logged, display welcome message
|
||||
if (Settings.useWelcomeMessage) if (Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
Bukkit.getServer().broadcastMessage(
|
||||
plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
}
|
||||
|
||||
// Register is now finish , we can force all commands
|
||||
forceCommands(player);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user