mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-31 19:24:47 +02:00
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) {
|
||||
playerProfile.setUuid(session.getUuid());
|
||||
playerProfile.setPremium(true);
|
||||
success = storage.save(playerProfile);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
if (session.needsRegistration()) {
|
||||
forceRegister(authPlugin, player);
|
||||
if (forceRegister(authPlugin, player)) {
|
||||
storage.save(playerProfile);
|
||||
}
|
||||
} else {
|
||||
forceLogin(authPlugin, player);
|
||||
if (forceLogin(authPlugin, player)) {
|
||||
storage.save(playerProfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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());
|
||||
|
||||
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 + "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());
|
||||
authPlugin.forceLogin(player);
|
||||
boolean success = authPlugin.forceLogin(player);
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Auto logged in");
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
@@ -128,9 +128,6 @@ public class Storage {
|
||||
|
||||
return null;
|
||||
}
|
||||
// public PlayerProfile getProfile(UUID uuid, boolean fetch) {
|
||||
//todo
|
||||
// }
|
||||
|
||||
public boolean save(PlayerProfile playerProfile) {
|
||||
Connection con = null;
|
||||
|
@@ -23,18 +23,15 @@ public class ForceLoginTask implements Runnable {
|
||||
public void run() {
|
||||
PlayerProfile playerProfile = plugin.getStorage().getProfile(player.getName(), false);
|
||||
|
||||
boolean success = true;
|
||||
if (playerProfile.getUserId() == -1) {
|
||||
playerProfile.setPremium(player.getPendingConnection().isOnlineMode());
|
||||
if (player.getPendingConnection().isOnlineMode()) {
|
||||
playerProfile.setUuid(player.getUniqueId());
|
||||
}
|
||||
|
||||
success = plugin.getStorage().save(playerProfile);
|
||||
}
|
||||
|
||||
//force login only on success
|
||||
if (success && player.getPendingConnection().isOnlineMode()) {
|
||||
if (player.getPendingConnection().isOnlineMode()) {
|
||||
Server server = player.getServer();
|
||||
|
||||
boolean autoRegister = plugin.getPendingAutoRegister().remove(player.getPendingConnection()) != null;
|
||||
@@ -61,11 +58,15 @@ public class ForceLoginTask implements Runnable {
|
||||
if (authPlugin != null) {
|
||||
if (autoRegister) {
|
||||
String password = plugin.generateStringPassword();
|
||||
authPlugin.forceRegister(player, password);
|
||||
} else {
|
||||
authPlugin.forceLogin(player);
|
||||
if (authPlugin.forceRegister(player, password)) {
|
||||
plugin.getStorage().save(playerProfile);
|
||||
}
|
||||
} else if (authPlugin.forceLogin(player)) {
|
||||
plugin.getStorage().save(playerProfile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.getStorage().save(playerProfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -128,9 +128,6 @@ public class Storage {
|
||||
|
||||
return null;
|
||||
}
|
||||
// public PlayerProfile getProfile(UUID uuid, boolean fetch) {
|
||||
//todo
|
||||
// }
|
||||
|
||||
public boolean save(PlayerProfile playerProfile) {
|
||||
Connection con = null;
|
||||
|
Reference in New Issue
Block a user