Replace all '/' in path to File.separator - Code Refactor

This commit is contained in:
Xephi
2014-08-25 03:12:28 +02:00
parent 12795436a0
commit d7cb60c1fe
104 changed files with 2470 additions and 3690 deletions
@@ -17,6 +17,7 @@ import fr.xephi.authme.settings.Settings;
*
*/
public class Management extends Thread {
public DataSource database;
public AuthMe plugin;
public static RandomString rdm = new RandomString(Settings.captchaLength);
@@ -33,13 +34,11 @@ public class Management extends Thread {
public void performLogin(final Player player, final String password,
final boolean forceLogin) {
new AsyncronousLogin(player, password, forceLogin, plugin, database)
.process();
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();
new AsyncronousRegister(player, password, email, plugin, database).process();
}
}
@@ -22,6 +22,7 @@ import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.MessageTask;
public class AsyncronousLogin {
protected Player player;
protected String name;
protected String password;
@@ -56,17 +57,13 @@ 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);
@@ -89,28 +86,19 @@ public class AsyncronousLogin {
if (!database.isAuthAvailable(name)) {
m._(player, "user_unknown");
if (LimboCache.getInstance().hasLimboPlayer(name)) {
Bukkit.getScheduler().cancelTask(
LimboCache.getInstance().getLimboPlayer(name)
.getMessageTaskId());
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId());
String[] msg;
if (Settings.emailRegistration) {
msg = m._("reg_email_msg");
} else {
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 (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;
@@ -121,8 +109,7 @@ public class AsyncronousLogin {
m._(player, "user_unknown");
return null;
}
if (!Settings.getMySQLColumnGroup.isEmpty()
&& pAuth.getGroupId() == Settings.getNonActivatedGroup) {
if (!Settings.getMySQLColumnGroup.isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
m._(player, "vb_nonActiv");
return null;
}
@@ -131,22 +118,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) {
@@ -163,12 +150,11 @@ 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
@@ -180,46 +166,32 @@ public class AsyncronousLogin {
// 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);
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");
return;
}
} else {
ConsoleLogger.showError("Player " + name
+ " wasn't online during login process, aborted... ");
ConsoleLogger.showError("Player " + name + " wasn't online during login process, aborted... ");
}
}
@@ -260,8 +232,7 @@ public class AsyncronousLogin {
*/
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()));
@@ -24,6 +24,7 @@ import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Settings;
public class ProcessSyncronousPlayerLogin implements Runnable {
private LimboPlayer limbo;
private Player player;
private String name;
@@ -51,21 +52,18 @@ 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();
@@ -78,8 +76,7 @@ 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();
@@ -91,12 +88,10 @@ 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());
}
}
@@ -108,9 +103,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
}
}
for (String command : Settings.forceCommandsAsConsole) {
Bukkit.getServer().dispatchCommand(
Bukkit.getServer().getConsoleSender(),
command.replace("%p", player.getName()));
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.replace("%p", player.getName()));
}
}
@@ -132,16 +125,14 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
// 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()) {
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
restoreInventory();
}
player.setGameMode(GameMode.SURVIVAL);
@@ -149,22 +140,15 @@ 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();
@@ -173,7 +157,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
// Re-Force Survival GameMode if we need due to world change
// specification
if (Settings.isForceSurvivalModeEnabled) Utils.forceGM(player);
if (Settings.isForceSurvivalModeEnabled)
Utils.forceGM(player);
// Restore Permission Group
Utils.getInstance().setGroup(player, groupType.LOGGEDIN);
@@ -186,35 +171,32 @@ 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()) {
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));
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));
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));
}
}
} else {
for (String s : Settings.welcomeMsg) {
player.sendMessage(plugin.replaceAllInfos(s, player));
}
}
// Login is now finish , we can force all commands
forceCommands();
@@ -54,29 +54,21 @@ 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.matches(Settings.getPassRegex)) {
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.matches(Settings.getPassRegex)) {
m._(player, "password_error");
allowRegister = false;
}
if (database.isAuthAvailable(player.getName().toLowerCase())) {
m._(player, "user_regged");
if (plugin.pllog.getStringList("players")
.contains(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")) {
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;
}
@@ -86,11 +78,11 @@ public class AsyncronousRegister {
public void process() {
preRegister();
if (!allowRegister) return;
if (!allowRegister)
return;
if (!email.isEmpty() && email != "") {
if (Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(player, "authme.allow2accounts")
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
m._(player, "max_reg");
return;
}
@@ -103,21 +95,15 @@ public class AsyncronousRegister {
protected void emailRegister() {
if (Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(player, "authme.allow2accounts")
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
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(), 0,
(int) player.getLocation().getX(), (int) player
.getLocation().getY(), (int) player.getLocation()
.getZ(), player.getLocation().getWorld().getName(),
email, realName);
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
auth = new PlayerAuth(name, hashnew, getIp(), 0, (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");
@@ -130,16 +116,13 @@ public class AsyncronousRegister {
database.updateEmail(auth);
database.updateSession(auth);
plugin.mail.main(auth, password);
ProcessSyncronousEmailRegister syncronous = new ProcessSyncronousEmailRegister(
player, plugin);
plugin.getServer().getScheduler()
.scheduleSyncDelayedTask(plugin, syncronous);
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) {
if (password.length() < Settings.getPasswordMinLen || password.length() > Settings.passwordMaxLength) {
m._(player, "pass_len");
return;
}
@@ -152,21 +135,16 @@ public class AsyncronousRegister {
PlayerAuth auth = null;
String hash = "";
try {
hash = PasswordSecurity.getHash(Settings.getPasswordHash, password,
name);
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());
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");
@@ -177,10 +155,8 @@ public class AsyncronousRegister {
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;
}
}
@@ -40,48 +40,37 @@ public class ProcessSyncronousEmailRegister implements Runnable {
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);
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();
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 (!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!"));
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered by email!"));
}
}
@@ -47,35 +47,31 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
protected void forceLogin(Player player) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawnLoc = plugin.getSpawnLocation(player);
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player,
spawnLoc);
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();
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);
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();
if (player.isInsideVehicle())
player.getVehicle().eject();
} catch (NullPointerException npe) {
}
}
@@ -87,22 +83,17 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.setGameMode(limbo.getGameMode());
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location loca = plugin.getSpawnLocation(player);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(
player, loca);
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();
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());
plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
plugin.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
}
@@ -110,24 +101,22 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
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) {
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);
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();
if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName()
+ " registered " + plugin.getIP(player));
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!"));
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!"));
}
// Kick Player after Registration is enabled, kick the player
@@ -143,16 +132,16 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
}
// 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));
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));
}
}
} else {
for (String s : Settings.welcomeMsg) {
player.sendMessage(plugin.replaceAllInfos(s, player));
}
}
// Register is now finish , we can force all commands
forceCommands(player);