Update API methods to reflect errors

This commit is contained in:
games647 committed 2016-05-03 18:05:26 +02:00
1 parent a7b164b513
commit 5174a84a17
19 files changed
+300 -188

No files matched your search

@@ -65,6 +65,8 @@ public class PlayerConnectionListener implements Listener {
}
}
}
} catch (Exception ex) {
plugin.getLogger().log(Level.SEVERE, "Failed to check premium state", ex);
} finally {
preLoginEvent.completeIntent(plugin);
}
@@ -25,7 +25,7 @@ public class BungeeAuthHook implements BungeeAuthPlugin {
private final Tables databaseConnection = new Tables();
@Override
public void forceLogin(final ProxiedPlayer player) {
public boolean forceLogin(final ProxiedPlayer player) {
//https://github.com/MatteCarra/BungeeAuth/blob/master/src/me/vik1395/BungeeAuth/Login.java#L92-95
Main.plonline.add(player.getName());
@@ -42,18 +42,21 @@ public class BungeeAuthHook implements BungeeAuthPlugin {
ListenerClass.prelogin.get(player.getName()).cancel();
} catch (Exception ex) {
Main.plugin.getLogger().severe("[BungeeAuth] Error force loging in player");
return false;
}
return true;
}
@Override
public boolean isRegistered(String playerName) {
public boolean isRegistered(String playerName) throws Exception {
//https://github.com/MatteCarra/BungeeAuth/blob/master/src/me/vik1395/BungeeAuth/Register.java#L46
//renamed t to databaseConnection
return databaseConnection.checkPlayerEntry(playerName);
}
@Override
public void forceRegister(final ProxiedPlayer player, String password) {
public boolean forceRegister(final ProxiedPlayer player, String password) {
//https://github.com/MatteCarra/BungeeAuth/blob/master/src/me/vik1395/BungeeAuth/Register.java#L102
PasswordHandler ph = new PasswordHandler();
Random rand = new Random();
@@ -84,7 +87,10 @@ public class BungeeAuthHook implements BungeeAuthPlugin {
forceLogin(player);
} catch (Exception ex) {
Main.plugin.getLogger().severe("[BungeeAuth] Error when creating a new player in the Database");
return false;
}
return true;
}
//pail ;(
@@ -2,6 +2,9 @@ package com.github.games647.fastlogin.bungee.hooks;
import net.md_5.bungee.api.connection.ProxiedPlayer;
/**
* Represents a supporting authentication plugin in BungeeCord/Waterfall/... servers
*/
public interface BungeeAuthPlugin {
/**
@@ -9,8 +12,9 @@ public interface BungeeAuthPlugin {
* the player joined successfully a server.
*
* @param player the player that needs to be logged in
* @return if the operation was successful
*/
void forceLogin(ProxiedPlayer player);
boolean forceLogin(ProxiedPlayer player);
/**
* Checks whether an account exists for this player name.
@@ -24,8 +28,9 @@ public interface BungeeAuthPlugin {
*
* @param playerName player name
* @return if the player has an account
* @throws Exception if an error occurred
*/
boolean isRegistered(String playerName);
boolean isRegistered(String playerName) throws Exception;
/**
* Forces a register in order to protect the paid account.
@@ -44,6 +49,7 @@ public interface BungeeAuthPlugin {
*
* @param player the premium account
* @param password a strong random generated password
* @return if the operation was successful
*/
void forceRegister(ProxiedPlayer player, String password);
boolean forceRegister(ProxiedPlayer player, String password);
}