forked from TuxCoding/FastLogin
Depend saving of FastLogin data on the success of the force actions
not in reverse order
This commit is contained in:
@@ -48,14 +48,17 @@ public class ForceLoginTask implements Runnable {
|
|||||||
if (playerProfile != null) {
|
if (playerProfile != null) {
|
||||||
playerProfile.setUuid(session.getUuid());
|
playerProfile.setUuid(session.getUuid());
|
||||||
playerProfile.setPremium(true);
|
playerProfile.setPremium(true);
|
||||||
success = storage.save(playerProfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
if (session.needsRegistration()) {
|
if (session.needsRegistration()) {
|
||||||
forceRegister(authPlugin, player);
|
if (forceRegister(authPlugin, player)) {
|
||||||
|
storage.save(playerProfile);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
forceLogin(authPlugin, player);
|
if (forceLogin(authPlugin, player)) {
|
||||||
|
storage.save(playerProfile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (playerProfile != null) {
|
} else if (playerProfile != null) {
|
||||||
@@ -63,18 +66,20 @@ public class ForceLoginTask implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forceRegister(BukkitAuthPlugin authPlugin, Player player) {
|
private boolean forceRegister(BukkitAuthPlugin authPlugin, Player player) {
|
||||||
plugin.getLogger().log(Level.FINE, "Register player {0}", player.getName());
|
plugin.getLogger().log(Level.FINE, "Register player {0}", player.getName());
|
||||||
|
|
||||||
String generatedPassword = plugin.generateStringPassword();
|
String generatedPassword = plugin.generateStringPassword();
|
||||||
authPlugin.forceRegister(player, generatedPassword);
|
boolean success = authPlugin.forceRegister(player, generatedPassword);
|
||||||
player.sendMessage(ChatColor.DARK_GREEN + "Auto registered with password: " + generatedPassword);
|
player.sendMessage(ChatColor.DARK_GREEN + "Auto registered with password: " + generatedPassword);
|
||||||
player.sendMessage(ChatColor.DARK_GREEN + "You may want change it?");
|
player.sendMessage(ChatColor.DARK_GREEN + "You may want change it?");
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forceLogin(BukkitAuthPlugin authPlugin, Player player) {
|
private boolean forceLogin(BukkitAuthPlugin authPlugin, Player player) {
|
||||||
plugin.getLogger().log(Level.FINE, "Logging player {0} in", player.getName());
|
plugin.getLogger().log(Level.FINE, "Logging player {0} in", player.getName());
|
||||||
authPlugin.forceLogin(player);
|
boolean success = authPlugin.forceLogin(player);
|
||||||
player.sendMessage(ChatColor.DARK_GREEN + "Auto logged in");
|
player.sendMessage(ChatColor.DARK_GREEN + "Auto logged in");
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -128,9 +128,6 @@ public class Storage {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// public PlayerProfile getProfile(UUID uuid, boolean fetch) {
|
|
||||||
//todo
|
|
||||||
// }
|
|
||||||
|
|
||||||
public boolean save(PlayerProfile playerProfile) {
|
public boolean save(PlayerProfile playerProfile) {
|
||||||
Connection con = null;
|
Connection con = null;
|
||||||
|
@@ -23,18 +23,15 @@ public class ForceLoginTask implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
PlayerProfile playerProfile = plugin.getStorage().getProfile(player.getName(), false);
|
PlayerProfile playerProfile = plugin.getStorage().getProfile(player.getName(), false);
|
||||||
|
|
||||||
boolean success = true;
|
|
||||||
if (playerProfile.getUserId() == -1) {
|
if (playerProfile.getUserId() == -1) {
|
||||||
playerProfile.setPremium(player.getPendingConnection().isOnlineMode());
|
playerProfile.setPremium(player.getPendingConnection().isOnlineMode());
|
||||||
if (player.getPendingConnection().isOnlineMode()) {
|
if (player.getPendingConnection().isOnlineMode()) {
|
||||||
playerProfile.setUuid(player.getUniqueId());
|
playerProfile.setUuid(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
success = plugin.getStorage().save(playerProfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//force login only on success
|
//force login only on success
|
||||||
if (success && player.getPendingConnection().isOnlineMode()) {
|
if (player.getPendingConnection().isOnlineMode()) {
|
||||||
Server server = player.getServer();
|
Server server = player.getServer();
|
||||||
|
|
||||||
boolean autoRegister = plugin.getPendingAutoRegister().remove(player.getPendingConnection()) != null;
|
boolean autoRegister = plugin.getPendingAutoRegister().remove(player.getPendingConnection()) != null;
|
||||||
@@ -61,11 +58,15 @@ public class ForceLoginTask implements Runnable {
|
|||||||
if (authPlugin != null) {
|
if (authPlugin != null) {
|
||||||
if (autoRegister) {
|
if (autoRegister) {
|
||||||
String password = plugin.generateStringPassword();
|
String password = plugin.generateStringPassword();
|
||||||
authPlugin.forceRegister(player, password);
|
if (authPlugin.forceRegister(player, password)) {
|
||||||
|
plugin.getStorage().save(playerProfile);
|
||||||
|
}
|
||||||
|
} else if (authPlugin.forceLogin(player)) {
|
||||||
|
plugin.getStorage().save(playerProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
authPlugin.forceLogin(player);
|
plugin.getStorage().save(playerProfile);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -128,9 +128,6 @@ public class Storage {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// public PlayerProfile getProfile(UUID uuid, boolean fetch) {
|
|
||||||
//todo
|
|
||||||
// }
|
|
||||||
|
|
||||||
public boolean save(PlayerProfile playerProfile) {
|
public boolean save(PlayerProfile playerProfile) {
|
||||||
Connection con = null;
|
Connection con = null;
|
||||||
|
Reference in New Issue
Block a user