mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 18:57:31 +02:00
Clean up
This commit is contained in:
@ -99,18 +99,19 @@ public class BungeeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isProxySupported(String className, String fieldName) throws Exception {
|
private boolean isProxySupported(String className, String fieldName) {
|
||||||
try {
|
try {
|
||||||
return Class.forName(className).getDeclaredField(fieldName).getBoolean(null);
|
return Class.forName(className).getDeclaredField(fieldName).getBoolean(null);
|
||||||
} catch (ClassNotFoundException notFoundEx) {
|
} catch (ClassNotFoundException notFoundEx) {
|
||||||
//ignore server has no proxy support
|
//ignore server has no proxy support
|
||||||
return false;
|
} catch (NoSuchFieldException | IllegalAccessException noSuchFieldException) {
|
||||||
} catch (Exception ex) {
|
plugin.getLog().warn("Cannot access proxy field", noSuchFieldException);
|
||||||
throw ex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean detectProxy() throws Exception {
|
private boolean detectProxy() {
|
||||||
return isProxySupported("org.spigotmc.SpigotConfig", "bungee")
|
return isProxySupported("org.spigotmc.SpigotConfig", "bungee")
|
||||||
|| isProxySupported("com.destroystokyo.paper.PaperConfig", "velocitySupport");
|
|| isProxySupported("com.destroystokyo.paper.PaperConfig", "velocitySupport");
|
||||||
}
|
}
|
||||||
@ -166,7 +167,7 @@ public class BungeeManager {
|
|||||||
/**
|
/**
|
||||||
* Mark the event to be fired including the task delay.
|
* Mark the event to be fired including the task delay.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player joining player
|
||||||
*/
|
*/
|
||||||
public synchronized void markJoinEventFired(Player player) {
|
public synchronized void markJoinEventFired(Player player) {
|
||||||
firedJoinEvents.add(player.getUniqueId());
|
firedJoinEvents.add(player.getUniqueId());
|
||||||
@ -180,7 +181,7 @@ public class BungeeManager {
|
|||||||
* session. If not fired, we can start a new force login task. This will still match the requirement that we wait
|
* session. If not fired, we can start a new force login task. This will still match the requirement that we wait
|
||||||
* a certain time after the player join event fired.
|
* a certain time after the player join event fired.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player joining player
|
||||||
* @return event fired including delay
|
* @return event fired including delay
|
||||||
*/
|
*/
|
||||||
public synchronized boolean didJoinEventFired(Player player) {
|
public synchronized boolean didJoinEventFired(Player player) {
|
||||||
@ -190,7 +191,7 @@ public class BungeeManager {
|
|||||||
/**
|
/**
|
||||||
* Player quit clean up
|
* Player quit clean up
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player joining player
|
||||||
*/
|
*/
|
||||||
public synchronized void cleanup(Player player) {
|
public synchronized void cleanup(Player player) {
|
||||||
firedJoinEvents.remove(player.getUniqueId());
|
firedJoinEvents.remove(player.getUniqueId());
|
||||||
|
@ -40,6 +40,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.metadata.Metadatable;
|
||||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +112,7 @@ public class ConnectionListener implements Listener {
|
|||||||
plugin.getBungeeManager().cleanup(player);
|
plugin.getBungeeManager().cleanup(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeBlockedStatus(Player player) {
|
private void removeBlockedStatus(Metadatable player) {
|
||||||
player.removeMetadata(plugin.getName(), plugin);
|
player.removeMetadata(plugin.getName(), plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ public class PaperCacheListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
//if paper is used - player skin must be set at pre login, otherwise usercache is used
|
//if paper is used - player skin must be set at pre login, otherwise user cache is used
|
||||||
//using usercache makes premium name change basically impossible
|
// user cache makes premium name change basically impossible
|
||||||
public void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
public void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||||
if (event.getLoginResult() != Result.ALLOWED) {
|
if (event.getLoginResult() != Result.ALLOWED) {
|
||||||
return;
|
return;
|
||||||
|
@ -35,6 +35,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
@ -60,7 +60,7 @@ class ProtocolLibLoginSource implements LoginSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enableOnlinemode() throws Exception {
|
public void enableOnlinemode() throws InvocationTargetException {
|
||||||
verifyToken = EncryptionUtil.generateVerifyToken(random);
|
verifyToken = EncryptionUtil.generateVerifyToken(random);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -36,31 +36,11 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
|||||||
public class EncryptionUtilTest {
|
public class EncryptionUtilTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVerifyToken() throws Exception {
|
public void testVerifyToken() {
|
||||||
SecureRandom random = new SecureRandom();
|
SecureRandom random = new SecureRandom();
|
||||||
byte[] token = EncryptionUtil.generateVerifyToken(random);
|
byte[] token = EncryptionUtil.generateVerifyToken(random);
|
||||||
|
|
||||||
assertThat(token, notNullValue());
|
assertThat(token, notNullValue());
|
||||||
assertThat(token.length, is(4));
|
assertThat(token.length, is(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
|
||||||
// public void testDecryptSharedSecret() throws Exception {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testDecryptData() throws Exception {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static SecretKey createNewSharedKey() {
|
|
||||||
// try {
|
|
||||||
// KeyGenerator keygenerator = KeyGenerator.getInstance("AES");
|
|
||||||
// keygenerator.init(128);
|
|
||||||
// return keygenerator.generateKey();
|
|
||||||
// } catch (NoSuchAlgorithmException nosuchalgorithmexception) {
|
|
||||||
// throw new Error(nosuchalgorithmexception);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -25,22 +25,23 @@
|
|||||||
*/
|
*/
|
||||||
package com.github.games647.fastlogin.bungee.hook;
|
package com.github.games647.fastlogin.bungee.hook;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import com.github.games647.fastlogin.bungee.FastLoginBungee;
|
import com.github.games647.fastlogin.bungee.FastLoginBungee;
|
||||||
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
||||||
|
|
||||||
import de.xxschrandxx.bca.bungee.BungeeCordAuthenticatorBungee;
|
import de.xxschrandxx.bca.bungee.BungeeCordAuthenticatorBungee;
|
||||||
import de.xxschrandxx.bca.bungee.api.BungeeCordAuthenticatorBungeeAPI;
|
import de.xxschrandxx.bca.bungee.api.BungeeCordAuthenticatorBungeeAPI;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GitHub:
|
* GitHub:
|
||||||
* https://github.com/xXSchrandXx/SpigotPlugins/tree/master/BungeeCordAuthenticator
|
* https://github.com/xXSchrandXx/SpigotPlugins/tree/master/BungeeCordAuthenticator
|
||||||
*
|
* <p>
|
||||||
* Project page:
|
* Project page:
|
||||||
*
|
* <p>
|
||||||
* Spigot: https://www.spigotmc.org/resources/bungeecordauthenticator.87669/
|
* Spigot: https://www.spigotmc.org/resources/bungeecordauthenticator.87669/
|
||||||
*/
|
*/
|
||||||
public class BungeeCordAuthenticatorBungeeHook implements AuthPlugin<ProxiedPlayer> {
|
public class BungeeCordAuthenticatorBungeeHook implements AuthPlugin<ProxiedPlayer> {
|
||||||
@ -49,7 +50,7 @@ public class BungeeCordAuthenticatorBungeeHook implements AuthPlugin<ProxiedPlay
|
|||||||
|
|
||||||
public BungeeCordAuthenticatorBungeeHook(FastLoginBungee plugin) {
|
public BungeeCordAuthenticatorBungeeHook(FastLoginBungee plugin) {
|
||||||
api = ((BungeeCordAuthenticatorBungee) plugin.getProxy().getPluginManager()
|
api = ((BungeeCordAuthenticatorBungee) plugin.getProxy().getPluginManager()
|
||||||
.getPlugin("BungeeCordAuthenticatorBungee")).getAPI();
|
.getPlugin("BungeeCordAuthenticatorBungee")).getAPI();
|
||||||
plugin.getLog().info("BungeeCordAuthenticatorHook | Hooked successful!");
|
plugin.getLog().info("BungeeCordAuthenticatorHook | Hooked successful!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,25 +58,24 @@ public class BungeeCordAuthenticatorBungeeHook implements AuthPlugin<ProxiedPlay
|
|||||||
public boolean forceLogin(ProxiedPlayer player) {
|
public boolean forceLogin(ProxiedPlayer player) {
|
||||||
if (api.isAuthenticated(player)) {
|
if (api.isAuthenticated(player)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
api.setAuthenticated(player);
|
|
||||||
}
|
|
||||||
catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
api.setAuthenticated(player);
|
||||||
|
} catch (SQLException sqlEx) {
|
||||||
|
api.getLogger().log(Level.WARNING, "Failed to force login", sqlEx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegistered(String playerName) {
|
public boolean isRegistered(String playerName) {
|
||||||
try {
|
try {
|
||||||
return api.getSQL().checkPlayerEntry(playerName);
|
return api.getSQL().checkPlayerEntry(playerName);
|
||||||
}
|
} catch (SQLException sqlEx) {
|
||||||
catch (SQLException e) {
|
api.getLogger().log(Level.WARNING, "Failed to check registration", sqlEx);
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,9 +84,8 @@ public class BungeeCordAuthenticatorBungeeHook implements AuthPlugin<ProxiedPlay
|
|||||||
public boolean forceRegister(ProxiedPlayer player, String password) {
|
public boolean forceRegister(ProxiedPlayer player, String password) {
|
||||||
try {
|
try {
|
||||||
return api.createPlayerEntry(player, password);
|
return api.createPlayerEntry(player, password);
|
||||||
}
|
} catch (SQLException sqlEx) {
|
||||||
catch (SQLException e) {
|
api.getLogger().log(Level.WARNING, "Failed to force register", sqlEx);
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,14 +80,12 @@ public class ConnectListener implements Listener {
|
|||||||
Field uuidField = InitialHandler.class.getDeclaredField(UUID_FIELD_NAME);
|
Field uuidField = InitialHandler.class.getDeclaredField(UUID_FIELD_NAME);
|
||||||
uuidField.setAccessible(true);
|
uuidField.setAccessible(true);
|
||||||
setHandle = lookup.unreflectSetter(uuidField);
|
setHandle = lookup.unreflectSetter(uuidField);
|
||||||
} catch (ClassNotFoundException classNotFoundException) {
|
} catch (ReflectiveOperationException reflectiveOperationException) {
|
||||||
Logger logger = LoggerFactory.getLogger(ConnectListener.class);
|
Logger logger = LoggerFactory.getLogger(ConnectListener.class);
|
||||||
logger.error(
|
logger.error(
|
||||||
"Cannot find Bungee initial handler; Disabling premium UUID and skin won't work.",
|
"Cannot find Bungee initial handler; Disabling premium UUID and skin won't work.",
|
||||||
classNotFoundException
|
reflectiveOperationException
|
||||||
);
|
);
|
||||||
} catch (ReflectiveOperationException reflectiveOperationException) {
|
|
||||||
reflectiveOperationException.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uniqueIdSetter = setHandle;
|
uniqueIdSetter = setHandle;
|
||||||
|
@ -45,8 +45,8 @@ public class AsyncPremiumCheck extends JoinManagement<Player, CommandSource, Vel
|
|||||||
|
|
||||||
private final FastLoginVelocity plugin;
|
private final FastLoginVelocity plugin;
|
||||||
private final String username;
|
private final String username;
|
||||||
private Continuation continuation;
|
private final Continuation continuation;
|
||||||
private PreLoginEvent preLoginEvent;
|
private final PreLoginEvent preLoginEvent;
|
||||||
private final InboundConnection connection;
|
private final InboundConnection connection;
|
||||||
|
|
||||||
public AsyncPremiumCheck(FastLoginVelocity plugin, InboundConnection connection, String username, Continuation continuation, PreLoginEvent preLoginEvent) {
|
public AsyncPremiumCheck(FastLoginVelocity plugin, InboundConnection connection, String username, Continuation continuation, PreLoginEvent preLoginEvent) {
|
||||||
|
Reference in New Issue
Block a user