mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 02:37:34 +02:00
Drop support for old authme API
This commit is contained in:
@ -107,7 +107,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.xephi</groupId>
|
<groupId>fr.xephi</groupId>
|
||||||
<artifactId>authme</artifactId>
|
<artifactId>authme</artifactId>
|
||||||
<version>5.2-SNAPSHOT</version>
|
<version>5.3.1</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -2,10 +2,7 @@ package com.github.games647.fastlogin.bukkit.hooks;
|
|||||||
|
|
||||||
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
||||||
|
|
||||||
import fr.xephi.authme.api.API;
|
|
||||||
import fr.xephi.authme.api.NewAPI;
|
import fr.xephi.authme.api.NewAPI;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -20,58 +17,27 @@ import org.bukkit.entity.Player;
|
|||||||
*/
|
*/
|
||||||
public class AuthMeHook implements AuthPlugin<Player> {
|
public class AuthMeHook implements AuthPlugin<Player> {
|
||||||
|
|
||||||
private final boolean isNewAPIAvailable;
|
|
||||||
|
|
||||||
public AuthMeHook() {
|
|
||||||
boolean apiAvailable = false;
|
|
||||||
try {
|
|
||||||
Class.forName("fr.xephi.authme.api.NewAPI");
|
|
||||||
apiAvailable = true;
|
|
||||||
} catch (ClassNotFoundException ex) {
|
|
||||||
Logger.getLogger(AuthMeHook.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isNewAPIAvailable = apiAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public boolean forceLogin(Player player) {
|
public boolean forceLogin(Player player) {
|
||||||
//skips registration and login
|
//skips registration and login
|
||||||
if (isNewAPIAvailable) {
|
if (NewAPI.getInstance().isAuthenticated(player)) {
|
||||||
if (NewAPI.getInstance().isAuthenticated(player)) {
|
return false;
|
||||||
return false;
|
} else {
|
||||||
} else {
|
NewAPI.getInstance().forceLogin(player);
|
||||||
NewAPI.getInstance().forceLogin(player);
|
|
||||||
}
|
|
||||||
} else if (!API.isAuthenticated(player)) {
|
|
||||||
API.forceLogin(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public boolean isRegistered(String playerName) throws Exception {
|
public boolean isRegistered(String playerName) throws Exception {
|
||||||
if (isNewAPIAvailable) {
|
return NewAPI.getInstance().isRegistered(playerName);
|
||||||
return NewAPI.getInstance().isRegistered(playerName);
|
|
||||||
} else {
|
|
||||||
return API.isRegistered(playerName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public boolean forceRegister(Player player, String password) {
|
public boolean forceRegister(Player player, String password) {
|
||||||
if (isNewAPIAvailable) {
|
//this automatically registers the player too
|
||||||
//this automatically registers the player too
|
NewAPI.getInstance().forceRegister(player, password);
|
||||||
NewAPI.getInstance().forceRegister(player, password);
|
|
||||||
} else {
|
|
||||||
API.registerPlayer(player.getName(), password);
|
|
||||||
forceLogin(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user