mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 18:57:31 +02:00
Load the plugin before worlds loading and auth plugins (Related to #12)
to display the message not fully started more less
This commit is contained in:
@ -30,6 +30,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -54,7 +55,7 @@ public class FastLoginBukkit extends JavaPlugin {
|
|||||||
//provide a immutable key pair to be thread safe | used for encrypting and decrypting traffic
|
//provide a immutable key pair to be thread safe | used for encrypting and decrypting traffic
|
||||||
private final KeyPair keyPair = EncryptionUtil.generateKeyPair();
|
private final KeyPair keyPair = EncryptionUtil.generateKeyPair();
|
||||||
|
|
||||||
private boolean bungeeCord;
|
protected boolean bungeeCord;
|
||||||
private Storage storage;
|
private Storage storage;
|
||||||
private boolean serverStarted;
|
private boolean serverStarted;
|
||||||
|
|
||||||
@ -76,18 +77,9 @@ public class FastLoginBukkit extends JavaPlugin {
|
|||||||
private BukkitAuthPlugin authPlugin;
|
private BukkitAuthPlugin authPlugin;
|
||||||
private final MojangApiConnector mojangApiConnector = new MojangApiConnector(this);
|
private final MojangApiConnector mojangApiConnector = new MojangApiConnector(this);
|
||||||
private PasswordGenerator passwordGenerator = new DefaultPasswordGenerator();
|
private PasswordGenerator passwordGenerator = new DefaultPasswordGenerator();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
saveDefaultConfig();
|
|
||||||
|
|
||||||
if (getServer().getOnlineMode()) {
|
|
||||||
//we need to require offline to prevent a session request for a offline player
|
|
||||||
getLogger().severe("Server have to be in offline mode");
|
|
||||||
setEnabled(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Bukkit.spigot().getConfig().isBoolean("settings.bungeecord")) {
|
if (Bukkit.spigot().getConfig().isBoolean("settings.bungeecord")) {
|
||||||
bungeeCord = Bukkit.spigot().getConfig().getBoolean("settings.bungeecord");
|
bungeeCord = Bukkit.spigot().getConfig().getBoolean("settings.bungeecord");
|
||||||
@ -102,18 +94,18 @@ public class FastLoginBukkit extends JavaPlugin {
|
|||||||
getLogger().warning("Cannot check bungeecord support. You use a non-spigot build");
|
getLogger().warning("Cannot check bungeecord support. You use a non-spigot build");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hookFound = registerHooks();
|
saveDefaultConfig();
|
||||||
if (bungeeCord) {
|
|
||||||
setServerStarted();
|
if (getServer().getOnlineMode()) {
|
||||||
getLogger().info("BungeeCord setting detected. No auth plugin is required");
|
//we need to require offline to prevent a session request for a offline player
|
||||||
} else if (!hookFound) {
|
getLogger().severe("Server have to be in offline mode");
|
||||||
getLogger().warning("No auth plugin were found by this plugin "
|
setEnabled(false);
|
||||||
+ "(other plugins could hook into this after the intialization of this plugin)"
|
return;
|
||||||
+ "and bungeecord is deactivated. "
|
|
||||||
+ "Either one or both of the checks have to pass in order to use this plugin");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bungeeCord) {
|
if (bungeeCord) {
|
||||||
|
setServerStarted();
|
||||||
|
|
||||||
//check for incoming messages from the bungeecord version of this plugin
|
//check for incoming messages from the bungeecord version of this plugin
|
||||||
getServer().getMessenger().registerIncomingPluginChannel(this, getName(), new BungeeCordListener(this));
|
getServer().getMessenger().registerIncomingPluginChannel(this, getName(), new BungeeCordListener(this));
|
||||||
getServer().getMessenger().registerOutgoingPluginChannel(this, getName());
|
getServer().getMessenger().registerOutgoingPluginChannel(this, getName());
|
||||||
@ -152,6 +144,22 @@ public class FastLoginBukkit extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//delay dependency setup because we load the plugin very early where plugins are initialized yet
|
||||||
|
getServer().getScheduler().runTask(this, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
boolean hookFound = registerHooks();
|
||||||
|
if (bungeeCord) {
|
||||||
|
getLogger().info("BungeeCord setting detected. No auth plugin is required");
|
||||||
|
} else if (!hookFound) {
|
||||||
|
getLogger().warning("No auth plugin were found by this plugin "
|
||||||
|
+ "(other plugins could hook into this after the intialization of this plugin)"
|
||||||
|
+ "and bungeecord is deactivated. "
|
||||||
|
+ "Either one or both of the checks have to pass in order to use this plugin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new BukkitJoinListener(this), this);
|
getServer().getPluginManager().registerEvents(new BukkitJoinListener(this), this);
|
||||||
|
|
||||||
//register commands using a unique name
|
//register commands using a unique name
|
||||||
@ -212,6 +220,14 @@ public class FastLoginBukkit extends JavaPlugin {
|
|||||||
* @return interface to any supported auth plugin
|
* @return interface to any supported auth plugin
|
||||||
*/
|
*/
|
||||||
public BukkitAuthPlugin getAuthPlugin() {
|
public BukkitAuthPlugin getAuthPlugin() {
|
||||||
|
if (authPlugin == null) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
Logger.getLogger(FastLoginBukkit.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return authPlugin;
|
return authPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +253,7 @@ public class FastLoginBukkit extends JavaPlugin {
|
|||||||
for (Class<? extends BukkitAuthPlugin> clazz : supportedHooks) {
|
for (Class<? extends BukkitAuthPlugin> clazz : supportedHooks) {
|
||||||
String pluginName = clazz.getSimpleName().replace("Hook", "");
|
String pluginName = clazz.getSimpleName().replace("Hook", "");
|
||||||
//uses only member classes which uses AuthPlugin interface (skip interfaces)
|
//uses only member classes which uses AuthPlugin interface (skip interfaces)
|
||||||
if (getServer().getPluginManager().isPluginEnabled(pluginName)) {
|
if (getServer().getPluginManager().getPlugin(pluginName) != null) {
|
||||||
//check only for enabled plugins. A single plugin could be disabled by plugin managers
|
//check only for enabled plugins. A single plugin could be disabled by plugin managers
|
||||||
authPluginHook = clazz.newInstance();
|
authPluginHook = clazz.newInstance();
|
||||||
getLogger().log(Level.INFO, "Hooking into auth plugin: {0}", pluginName);
|
getLogger().log(Level.INFO, "Hooking into auth plugin: {0}", pluginName);
|
||||||
|
@ -61,6 +61,7 @@ public class StartPacketListener extends PacketAdapter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||||
|
System.out.println("ON LOGIN");
|
||||||
plugin.setServerStarted();
|
plugin.setServerStarted();
|
||||||
|
|
||||||
Player player = packetEvent.getPlayer();
|
Player player = packetEvent.getPlayer();
|
||||||
@ -79,6 +80,7 @@ public class StartPacketListener extends PacketAdapter {
|
|||||||
|
|
||||||
BukkitAuthPlugin authPlugin = plugin.getAuthPlugin();
|
BukkitAuthPlugin authPlugin = plugin.getAuthPlugin();
|
||||||
if (authPlugin == null) {
|
if (authPlugin == null) {
|
||||||
|
System.out.println("NO AUTH PLUGIN");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,19 +11,22 @@ description: |
|
|||||||
website: ${project.url}
|
website: ${project.url}
|
||||||
dev-url: ${project.url}
|
dev-url: ${project.url}
|
||||||
|
|
||||||
|
# Load the plugin as early as possible to inject it for all players
|
||||||
|
load: STARTUP
|
||||||
|
|
||||||
# Without Protocollib the plugin does not work at all
|
# Without Protocollib the plugin does not work at all
|
||||||
depend: [ProtocolLib]
|
depend: [ProtocolLib]
|
||||||
|
|
||||||
softdepend:
|
softdepend:
|
||||||
- ProtocolSupport
|
- ProtocolSupport
|
||||||
# Auth plugins
|
# Auth plugins
|
||||||
- xAuth
|
# - xAuth
|
||||||
- AuthMe
|
# - AuthMe
|
||||||
- LogIt
|
# - LogIt
|
||||||
- CrazyLogin
|
# - CrazyLogin
|
||||||
- LoginSecurity
|
# - LoginSecurity
|
||||||
- RoyalAuth
|
# - RoyalAuth
|
||||||
- UltraAuth
|
# - UltraAuth
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
${project.parent.name}:
|
${project.parent.name}:
|
||||||
|
Reference in New Issue
Block a user