mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 18:57:31 +02:00
Fixed bungeecord detection for older Spigot builds
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
######1.1
|
||||
|
||||
* Make the configuration options also work under BungeeCord (premiumUUID, forwardSkin)
|
||||
* Catch configuration loading exception if it's not spigot build
|
||||
* Fix config loading for older PaperSpigot builds
|
||||
|
||||
######1.0
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.github.games647.fastlogin.bukkit;
|
||||
import com.comphenix.protocol.AsynchronousManager;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||
import com.comphenix.protocol.utility.SafeCacheBuilder;
|
||||
import com.github.games647.fastlogin.bukkit.commands.CrackedCommand;
|
||||
import com.github.games647.fastlogin.bukkit.commands.PremiumCommand;
|
||||
@ -16,6 +17,7 @@ import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.KeyPair;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
@ -25,6 +27,7 @@ import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -32,7 +35,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
* This plugin checks if a player has a paid account and if so tries to skip offline mode authentication.
|
||||
*/
|
||||
public class FastLoginBukkit extends JavaPlugin {
|
||||
|
||||
|
||||
private static final int WORKER_THREADS = 5;
|
||||
|
||||
public static UUID parseId(String withoutDashes) {
|
||||
@ -46,7 +49,6 @@ public class FastLoginBukkit extends JavaPlugin {
|
||||
//provide a immutable key pair to be thread safe | used for encrypting and decrypting traffic
|
||||
private final KeyPair keyPair = EncryptionUtil.generateKeyPair();
|
||||
|
||||
|
||||
private boolean bungeeCord;
|
||||
private Storage storage;
|
||||
|
||||
@ -79,7 +81,20 @@ public class FastLoginBukkit extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
bungeeCord = Bukkit.spigot().getConfig().getBoolean("settings.bungeecord");
|
||||
try {
|
||||
if (Bukkit.spigot().getConfig().isBoolean("settings.bungeecord")) {
|
||||
bungeeCord = Bukkit.spigot().getConfig().getBoolean("settings.bungeecord");
|
||||
} else {
|
||||
Method getConfigMethod = FuzzyReflection.fromObject(getServer().spigot(), true)
|
||||
.getMethodByName("getSpigotConfig");
|
||||
getConfigMethod.setAccessible(true);
|
||||
YamlConfiguration spigotConfig = (YamlConfiguration) getConfigMethod.invoke(getServer().spigot());
|
||||
bungeeCord = spigotConfig.getBoolean("settings.bungeecord");
|
||||
}
|
||||
} catch (Exception | NoSuchMethodError ex) {
|
||||
getLogger().warning("Cannot check bungeecord support. You use a non-spigot build");
|
||||
}
|
||||
|
||||
boolean hookFound = registerHooks();
|
||||
if (bungeeCord) {
|
||||
getLogger().info("BungeeCord setting detected. No auth plugin is required");
|
||||
|
@ -30,15 +30,14 @@ public class ForceLoginTask implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
//remove the bungeecord identifier
|
||||
//remove the bungeecord identifier if there is ones
|
||||
String id = '/' + player.getAddress().getAddress().getHostAddress() + ':' + player.getAddress().getPort();
|
||||
PlayerSession session = plugin.getSessions().get(id);
|
||||
|
||||
//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
|
||||
|
||||
final BukkitAuthPlugin authPlugin = plugin.getAuthPlugin();
|
||||
BukkitAuthPlugin authPlugin = plugin.getAuthPlugin();
|
||||
|
||||
Storage storage = plugin.getStorage();
|
||||
PlayerProfile playerProfile = null;
|
||||
@ -53,6 +52,7 @@ public class ForceLoginTask implements Runnable {
|
||||
playerProfile.setPremium(false);
|
||||
storage.save(playerProfile);
|
||||
}
|
||||
//check if it's the same player as we checked before
|
||||
} else if (player.getName().equals(session.getUsername())) {
|
||||
//premium player
|
||||
if (authPlugin == null) {
|
||||
|
@ -68,7 +68,7 @@ public class PlayerProfile {
|
||||
this.lastIp = lastIp;
|
||||
}
|
||||
|
||||
public long getLastLogin() {
|
||||
public synchronized long getLastLogin() {
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
*/
|
||||
public class BukkitJoinListener implements Listener {
|
||||
|
||||
private static final long DELAY_LOGIN = 1 * 20L / 2;
|
||||
private static final long DELAY_LOGIN = 20L / 2;
|
||||
|
||||
protected final FastLoginBukkit plugin;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.games647.fastlogin.bungee;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@ -9,6 +10,7 @@ import java.net.URL;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
|
||||
public class MojangApiConnector {
|
||||
|
@ -68,7 +68,7 @@ public class PlayerProfile {
|
||||
this.lastIp = lastIp;
|
||||
}
|
||||
|
||||
public long getLastLogin() {
|
||||
public synchronized long getLastLogin() {
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user