mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-29 18:27:36 +02:00
Removes the need to use a bukkit auth plugin if you have a bungee one
(Fixes #4)
This commit is contained in:
@ -153,7 +153,8 @@ public class FastLoginBukkit extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the auth plugin hook in order to interact with the plugins
|
||||
* Gets the auth plugin hook in order to interact with the plugins.
|
||||
* This can be null if no supporting auth plugin was found
|
||||
*
|
||||
* @return interface to any supported auth plugin
|
||||
*/
|
||||
|
@ -4,6 +4,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||
import com.github.games647.fastlogin.bukkit.PlayerSession;
|
||||
import com.github.games647.fastlogin.bukkit.hooks.BukkitAuthPlugin;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -56,20 +57,23 @@ public class BukkitJoinListener implements Listener {
|
||||
//blacklist this target player for BungeeCord Id brute force attacks
|
||||
player.setMetadata(plugin.getName(), new FixedMetadataValue(plugin, true));
|
||||
//check if it's the same player as we checked before
|
||||
if (session != null && player.getName().equals(session.getUsername()) && session.isVerified()) {
|
||||
|
||||
BukkitAuthPlugin authPlugin = plugin.getAuthPlugin();
|
||||
if (session != null && player.getName().equals(session.getUsername()) && session.isVerified()
|
||||
&& authPlugin != null) {
|
||||
if (session.needsRegistration()) {
|
||||
plugin.getLogger().log(Level.FINE, "Register player {0}", player.getName());
|
||||
|
||||
plugin.getEnabledPremium().add(session.getUsername());
|
||||
|
||||
String generatedPassword = plugin.generateStringPassword();
|
||||
plugin.getAuthPlugin().forceRegister(player, generatedPassword);
|
||||
authPlugin.forceRegister(player, generatedPassword);
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Auto registered with password: "
|
||||
+ generatedPassword);
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "You may want change it?");
|
||||
} else {
|
||||
plugin.getLogger().log(Level.FINE, "Logging player {0} in", player.getName());
|
||||
plugin.getAuthPlugin().forceLogin(player);
|
||||
authPlugin.forceLogin(player);
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Auto logged in");
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.github.games647.fastlogin.bukkit.listener;
|
||||
|
||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||
import com.github.games647.fastlogin.bukkit.PlayerSession;
|
||||
import com.github.games647.fastlogin.bukkit.hooks.BukkitAuthPlugin;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@ -29,10 +30,13 @@ public class ProtcolSupportListener implements Listener {
|
||||
|
||||
//remove old data every time on a new login in order to keep the session only for one person
|
||||
plugin.getSessions().remove(playerName);
|
||||
|
||||
BukkitAuthPlugin authPlugin = plugin.getAuthPlugin();
|
||||
if (plugin.getEnabledPremium().contains(playerName)) {
|
||||
//the player have to be registered in order to invoke the command
|
||||
startPremiumSession(playerName, loginStartEvent, true);
|
||||
} else if (plugin.getConfig().getBoolean("autoRegister") && !plugin.getAuthPlugin().isRegistered(playerName)) {
|
||||
} else if (plugin.getConfig().getBoolean("autoRegister")
|
||||
&& authPlugin != null && !plugin.getAuthPlugin().isRegistered(playerName)) {
|
||||
startPremiumSession(playerName, loginStartEvent, false);
|
||||
plugin.getEnabledPremium().add(playerName);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||
import com.github.games647.fastlogin.bukkit.PlayerSession;
|
||||
import com.github.games647.fastlogin.bukkit.hooks.BukkitAuthPlugin;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.PublicKey;
|
||||
@ -72,9 +73,11 @@ public class StartPacketListener extends PacketAdapter {
|
||||
plugin.getLogger().log(Level.FINER, "Player {0} with {1} connecting to the server"
|
||||
, new Object[]{sessionKey, username});
|
||||
if (!plugin.getBungeeCordUsers().containsKey(player)) {
|
||||
BukkitAuthPlugin authPlugin = plugin.getAuthPlugin();
|
||||
if (plugin.getEnabledPremium().contains(username)) {
|
||||
enablePremiumLogin(username, sessionKey, player, packetEvent, true);
|
||||
} else if (plugin.getConfig().getBoolean("autologin") && !plugin.getAuthPlugin().isRegistered(username)) {
|
||||
} else if (plugin.getConfig().getBoolean("autologin")
|
||||
&& authPlugin != null && !plugin.getAuthPlugin().isRegistered(username)) {
|
||||
enablePremiumLogin(username, sessionKey, player, packetEvent, false);
|
||||
plugin.getEnabledPremium().add(username);
|
||||
}
|
||||
|
Reference in New Issue
Block a user