forked from TuxCoding/FastLogin
Update BungeeAuth dependency and use the new API
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
######1.10
|
######1.10
|
||||||
|
|
||||||
|
* Automatically register accounts if they are not in the auth plugin database but in the FastLogin database
|
||||||
|
* Update BungeeAuth dependency and use the new API. Please update your plugin if you still use the old one.
|
||||||
* Remove deprecated API methods from the last version
|
* Remove deprecated API methods from the last version
|
||||||
* Finally set a value to the API column
|
* Finally set a value to the API column
|
||||||
* No duplicate session login
|
* No duplicate session login
|
||||||
|
@@ -47,7 +47,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.vik1395</groupId>
|
<groupId>me.vik1395</groupId>
|
||||||
<artifactId>BungeeAuth</artifactId>
|
<artifactId>BungeeAuth</artifactId>
|
||||||
<version>1.3.1</version>
|
<version>1.4</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>*</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -2,16 +2,8 @@ package com.github.games647.fastlogin.bungee.hooks;
|
|||||||
|
|
||||||
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import me.vik1395.BungeeAuth.ListenerClass;
|
|
||||||
import me.vik1395.BungeeAuth.Main;
|
import me.vik1395.BungeeAuth.Main;
|
||||||
import me.vik1395.BungeeAuth.Password.PasswordHandler;
|
import me.vik1395.BungeeAuthAPI.RequestHandler;
|
||||||
import me.vik1395.BungeeAuth.Tables;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@@ -24,87 +16,25 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
*/
|
*/
|
||||||
public class BungeeAuthHook implements AuthPlugin<ProxiedPlayer> {
|
public class BungeeAuthHook implements AuthPlugin<ProxiedPlayer> {
|
||||||
|
|
||||||
//https://github.com/vik1395/BungeeAuth-Minecraft/blob/master/src/me/vik1395/BungeeAuth/Login.java#L32
|
private final RequestHandler requestHandler = new RequestHandler();
|
||||||
private final Tables databaseConnection = new Tables();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean forceLogin(ProxiedPlayer player) {
|
public boolean forceLogin(ProxiedPlayer player) {
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
//https://github.com/vik1395/BungeeAuth-Minecraft/blob/master/src/me/vik1395/BungeeAuth/Login.java#L92-95
|
|
||||||
if (Main.plonline.contains(playerName)) {
|
if (Main.plonline.contains(playerName)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Main.plonline.add(playerName);
|
return requestHandler.forceLogin(playerName);
|
||||||
|
|
||||||
//renamed from ct to databaseConnection
|
|
||||||
// databaseConnection.setStatus(player.getName(), "online");
|
|
||||||
Class<?>[] parameterTypes = new Class<?>[]{String.class, String.class};
|
|
||||||
Object[] arguments = new Object[]{playerName, "online"};
|
|
||||||
|
|
||||||
try {
|
|
||||||
callProtected("setStatus", parameterTypes, arguments);
|
|
||||||
ListenerClass.movePlayer(player, false);
|
|
||||||
|
|
||||||
//proparly not thread-safe
|
|
||||||
ListenerClass.prelogin.get(playerName).cancel();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Main.plugin.getLogger().log(Level.SEVERE, "Error force loging in player", ex);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegistered(String playerName) throws Exception {
|
public boolean isRegistered(String playerName) throws Exception {
|
||||||
//https://github.com/vik1395/BungeeAuth-Minecraft/blob/master/src/me/vik1395/BungeeAuth/Register.java#L46
|
return requestHandler.isRegistered(playerName);
|
||||||
//renamed t to databaseConnection
|
|
||||||
return databaseConnection.checkPlayerEntry(playerName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean forceRegister(ProxiedPlayer player, String password) {
|
public boolean forceRegister(ProxiedPlayer player, String password) {
|
||||||
//https://github.com/vik1395/BungeeAuth-Minecraft/blob/master/src/me/vik1395/BungeeAuth/Register.java#L102
|
return requestHandler.forceRegister(player, password);
|
||||||
PasswordHandler ph = new PasswordHandler();
|
|
||||||
Random rand = new Random();
|
|
||||||
int maxp = 7; //Total Password Hashing methods.
|
|
||||||
Date dNow = new Date();
|
|
||||||
SimpleDateFormat ft = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
|
|
||||||
|
|
||||||
String Pw = password;
|
|
||||||
String pType = "" + rand.nextInt(maxp + 1);
|
|
||||||
String regdate = ft.format(dNow);
|
|
||||||
//https://github.com/vik1395/BungeeAuth-Minecraft/blob/master/src/me/vik1395/BungeeAuth/Register.java#L60
|
|
||||||
String lastip = player.getAddress().getAddress().getHostAddress();
|
|
||||||
String lastseen = regdate;
|
|
||||||
String hash = ph.newHash(Pw, pType);
|
|
||||||
|
|
||||||
//creates a new SQL entry with the player's details.
|
|
||||||
Class<?>[] parameterTypes = new Class<?>[] {String.class, String.class, String.class, String.class
|
|
||||||
, String.class, String.class, String.class, String.class};
|
|
||||||
Object[] arguments = new Object[] {player.getName(), hash, pType, "", lastip, regdate, lastip, lastseen};
|
|
||||||
|
|
||||||
try {
|
|
||||||
callProtected("newPlayerEntry", parameterTypes, arguments);
|
|
||||||
//proparly not thread-safe
|
|
||||||
forceLogin(player);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Main.plugin.getLogger().log(Level.SEVERE, "[BungeeAuth] Error when creating a new player in the Database", ex);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//pail ;(
|
|
||||||
private void callProtected(String methodName, Class<?>[] parameterTypes, Object[] arguments) throws Exception {
|
|
||||||
Class<Tables> tableClass = Tables.class;
|
|
||||||
|
|
||||||
Method method = tableClass.getDeclaredMethod(methodName, parameterTypes);
|
|
||||||
method.setAccessible(true);
|
|
||||||
//renamed t to databaseConnection
|
|
||||||
//databaseConnection.newPlayerEntry(player.getName(), hash, pType, "", lastip, regdate, lastip, lastseen);
|
|
||||||
method.invoke(databaseConnection, arguments);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.zaxxer</groupId>
|
<groupId>com.zaxxer</groupId>
|
||||||
<artifactId>HikariCP</artifactId>
|
<artifactId>HikariCP</artifactId>
|
||||||
<version>2.5.0</version>
|
<version>2.5.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--Logging framework implements slf4j which is required by hikari-->
|
<!--Logging framework implements slf4j which is required by hikari-->
|
||||||
|
Reference in New Issue
Block a user