Fix race condition when waiting for bukkit message while

bungee redirects player
This commit is contained in:
games647
2016-08-19 21:07:29 +02:00
parent 596caa0573
commit 36d7564c3a
7 changed files with 22 additions and 7 deletions

View File

@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin</artifactId>
<version>1.7.1</version>
<version>1.8</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin</artifactId>
<version>1.7.1</version>
<version>1.8</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -6,6 +6,7 @@ import com.github.games647.fastlogin.core.PlayerProfile;
public class BungeeLoginSession extends LoginSession {
private boolean alreadySaved;
private boolean alreadyLogged;
public BungeeLoginSession(String username, boolean registered, PlayerProfile profile) {
super(username, registered, profile);
@ -22,4 +23,12 @@ public class BungeeLoginSession extends LoginSession {
public void setAlreadySaved(boolean alreadySaved) {
this.alreadySaved = alreadySaved;
}
public boolean isAlreadyLogged() {
return alreadyLogged;
}
public void setAlreadyLogged(boolean alreadyLogged) {
this.alreadyLogged = alreadyLogged;
}
}

View File

@ -48,8 +48,10 @@ public class ForceLoginTask implements Runnable {
//save will happen on success message from bukkit
sendBukkitLoginNotification(autoRegister);
} else if (session.needsRegistration()) {
session.setAlreadyLogged(true);
forceRegister(session, authPlugin);
} else if (authPlugin.forceLogin(player)) {
session.setAlreadyLogged(true);
forceLogin(session, authPlugin);
}
} else {
@ -66,8 +68,10 @@ public class ForceLoginTask implements Runnable {
}
private void forceRegister(BungeeLoginSession session, BungeeAuthPlugin authPlugin) {
session.setAlreadyLogged(true);
String password = plugin.generateStringPassword();
if (session.isAlreadySaved() || authPlugin.forceRegister(player, password)) {
if (session.isAlreadyLogged()|| authPlugin.forceRegister(player, password)) {
//save will happen on success message from bukkit
sendBukkitLoginNotification(true);
String message = plugin.getCore().getMessage("auto-register");
@ -79,7 +83,9 @@ public class ForceLoginTask implements Runnable {
}
private void forceLogin(BungeeLoginSession session, BungeeAuthPlugin authPlugin) {
if (session.isAlreadySaved() || authPlugin.forceLogin(player)) {
session.setAlreadyLogged(true);
if (session.isAlreadyLogged() || authPlugin.forceLogin(player)) {
//save will happen on success message from bukkit
sendBukkitLoginNotification(false);
String message = plugin.getCore().getMessage("auto-login");

View File

@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin</artifactId>
<version>1.7.1</version>
<version>1.8</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -8,7 +8,7 @@
<packaging>pom</packaging>
<name>FastLogin</name>
<version>1.7.1</version>
<version>1.8</version>
<inceptionYear>2015</inceptionYear>
<url>https://www.spigotmc.org/resources/fastlogin.14153/</url>
<description>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin</artifactId>
<version>1.7.1</version>
<version>1.8</version>
<relativePath>../pom.xml</relativePath>
</parent>