forked from TuxCoding/FastLogin
Fix FileAlreadyExistsException for sym linked folders
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
package com.github.games647.fastlogin.bukkit;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.Key;
|
||||
import java.security.KeyPair;
|
||||
@ -28,6 +27,10 @@ public class EncryptionUtil {
|
||||
public static final int VERIFY_TOKEN_LENGTH = 4;
|
||||
public static final String KEY_PAIR_ALGORITHM = "RSA";
|
||||
|
||||
private EncryptionUtil() {
|
||||
//utility
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a RSA key pair
|
||||
*
|
||||
@ -61,9 +64,9 @@ public class EncryptionUtil {
|
||||
/**
|
||||
* Generate the server id based on client and server data.
|
||||
*
|
||||
* @param sessionId session for the current login attempt
|
||||
* @param sessionId session for the current login attempt
|
||||
* @param sharedSecret shared secret between the client and the server
|
||||
* @param publicKey public key of the server
|
||||
* @param publicKey public key of the server
|
||||
* @return the server id formatted as a hexadecimal string.
|
||||
*/
|
||||
public static String getServerIdHashString(String sessionId, Key sharedSecret, PublicKey publicKey) {
|
||||
@ -80,9 +83,9 @@ public class EncryptionUtil {
|
||||
/**
|
||||
* Decrypts the content and extracts the key spec.
|
||||
*
|
||||
* @param cipher decryption cipher
|
||||
* @param cipher decryption cipher
|
||||
* @param privateKey private key of the server
|
||||
* @param sharedKey the encrypted shared key
|
||||
* @param sharedKey the encrypted shared key
|
||||
* @return shared secret key
|
||||
* @throws GeneralSecurityException
|
||||
*/
|
||||
@ -95,8 +98,8 @@ public class EncryptionUtil {
|
||||
* Decrypted the given data using the cipher.
|
||||
*
|
||||
* @param cipher decryption cypher
|
||||
* @param key server private key
|
||||
* @param data the encrypted data
|
||||
* @param key server private key
|
||||
* @param data the encrypted data
|
||||
* @return clear text data
|
||||
* @throws GeneralSecurityException if it fails to initialize and decrypt the data
|
||||
*/
|
||||
@ -109,14 +112,10 @@ public class EncryptionUtil {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-1");
|
||||
|
||||
digest.update(sessionId.getBytes(Charsets.ISO_8859_1));
|
||||
digest.update(sessionId.getBytes(StandardCharsets.ISO_8859_1));
|
||||
digest.update(sharedSecret.getEncoded());
|
||||
digest.update(publicKey.getEncoded());
|
||||
|
||||
return digest.digest();
|
||||
}
|
||||
|
||||
private EncryptionUtil() {
|
||||
//utility
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,14 @@ import com.github.games647.fastlogin.bukkit.commands.CrackedCommand;
|
||||
import com.github.games647.fastlogin.bukkit.commands.PremiumCommand;
|
||||
import com.github.games647.fastlogin.bukkit.listener.BungeeListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.JoinListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.protocollib.SkinApplyListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.protocollib.ProtocolLibListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.protocollib.SkinApplyListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.protocolsupport.ProtocolSupportListener;
|
||||
import com.github.games647.fastlogin.bukkit.tasks.DelayedAuthHook;
|
||||
import com.github.games647.fastlogin.core.CommonUtil;
|
||||
import com.github.games647.fastlogin.core.mojang.MojangApiConnector;
|
||||
import com.github.games647.fastlogin.core.shared.FastLoginCore;
|
||||
import com.github.games647.fastlogin.core.shared.PlatformPlugin;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.net.HostAndPort;
|
||||
@ -20,6 +19,7 @@ import com.google.common.net.HostAndPort;
|
||||
import java.nio.file.Path;
|
||||
import java.security.KeyPair;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
@ -124,13 +124,14 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
||||
if (sender instanceof PluginMessageRecipient) {
|
||||
notifyBungeeCord((PluginMessageRecipient) sender, target, activate, true);
|
||||
} else {
|
||||
Player firstPlayer = Iterables.getFirst(getServer().getOnlinePlayers(), null);
|
||||
if (firstPlayer == null) {
|
||||
|
||||
Optional<? extends Player> optPlayer = getServer().getOnlinePlayers().stream().findFirst();
|
||||
if (!optPlayer.isPresent()) {
|
||||
logger.info("No player online to send a plugin message to the proxy");
|
||||
return;
|
||||
}
|
||||
|
||||
notifyBungeeCord(firstPlayer, target, activate, false);
|
||||
notifyBungeeCord(optPlayer.get(), target, activate, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,12 +7,12 @@ import com.github.games647.fastlogin.core.CommonUtil;
|
||||
import com.github.games647.fastlogin.core.mojang.MojangApiConnector;
|
||||
import com.github.games647.fastlogin.core.shared.FastLoginCore;
|
||||
import com.github.games647.fastlogin.core.shared.PlatformPlugin;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
@ -30,7 +30,7 @@ import org.slf4j.Logger;
|
||||
*/
|
||||
public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSender> {
|
||||
|
||||
private final ConcurrentMap<PendingConnection, BungeeLoginSession> session = Maps.newConcurrentMap();
|
||||
private final ConcurrentMap<PendingConnection, BungeeLoginSession> session = new ConcurrentHashMap<>();
|
||||
|
||||
private FastLoginCore<ProxiedPlayer, CommandSender, FastLoginBungee> core;
|
||||
private Logger logger;
|
||||
|
@ -5,9 +5,9 @@ import com.github.games647.fastlogin.bungee.tasks.AsyncPremiumCheck;
|
||||
import com.github.games647.fastlogin.bungee.tasks.ForceLoginTask;
|
||||
import com.github.games647.fastlogin.core.PlayerProfile;
|
||||
import com.github.games647.fastlogin.core.shared.LoginSession;
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -46,7 +46,7 @@ public class ConnectListener implements Listener {
|
||||
}
|
||||
|
||||
preLoginEvent.registerIntent(plugin);
|
||||
|
||||
|
||||
PendingConnection connection = preLoginEvent.getConnection();
|
||||
Runnable asyncPremiumCheck = new AsyncPremiumCheck(plugin, preLoginEvent, connection);
|
||||
ProxyServer.getInstance().getScheduler().runAsync(plugin, asyncPremiumCheck);
|
||||
@ -74,7 +74,7 @@ public class ConnectListener implements Listener {
|
||||
//bungeecord will do this automatically so override it on disabled option
|
||||
if (!plugin.getCore().getConfig().get("premiumUuid", true)) {
|
||||
try {
|
||||
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
|
||||
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
//bungeecord doesn't support overriding the premium uuid
|
||||
//so we have to do it with reflection
|
||||
|
@ -3,7 +3,6 @@ package com.github.games647.fastlogin.core.mojang;
|
||||
import com.github.games647.fastlogin.core.CommonUtil;
|
||||
import com.github.games647.fastlogin.core.shared.LoginSession;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@ -19,6 +18,7 @@ import java.net.URL;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -60,7 +60,7 @@ public class MojangApiConnector {
|
||||
this.logger = logger;
|
||||
this.rateLimit = Math.max(rateLimit, 600);
|
||||
|
||||
List<Proxy> proxyBuilder = Lists.newArrayList();
|
||||
List<Proxy> proxyBuilder = new ArrayList<>();
|
||||
for (HostAndPort proxy : proxies) {
|
||||
proxyBuilder.add(new Proxy(Type.HTTP, new InetSocketAddress(proxy.getHostText(), proxy.getPort())));
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
||||
import com.github.games647.fastlogin.core.hooks.DefaultPasswordGenerator;
|
||||
import com.github.games647.fastlogin.core.hooks.PasswordGenerator;
|
||||
import com.github.games647.fastlogin.core.mojang.MojangApiConnector;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.net.HostAndPort;
|
||||
|
||||
import java.io.File;
|
||||
@ -15,7 +13,9 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -39,7 +39,7 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
|
||||
protected final Map<String, String> localeMessages = new ConcurrentHashMap<>();
|
||||
|
||||
private final ConcurrentMap<String, Object> pendingLogin = CommonUtil.buildCache(5, -1);
|
||||
private final Set<UUID> pendingConfirms = Sets.newHashSet();
|
||||
private final Set<UUID> pendingConfirms = new HashSet<>();
|
||||
private final T plugin;
|
||||
|
||||
private Configuration config;
|
||||
@ -76,7 +76,7 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
|
||||
|
||||
List<String> ipAddresses = config.getStringList("ip-addresses");
|
||||
int requestLimit = config.getInt("mojang-request-limit");
|
||||
List<String> proxyList = config.get("proxies", Lists.newArrayList());
|
||||
List<String> proxyList = config.get("proxies", new ArrayList<>());
|
||||
List<HostAndPort> proxies = proxyList.stream().map(HostAndPort::fromString).collect(Collectors.toList());
|
||||
|
||||
this.apiConnector = plugin.makeApiConnector(ipAddresses, requestLimit, proxies);
|
||||
@ -170,7 +170,9 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
|
||||
Path dataFolder = plugin.getPluginFolder();
|
||||
|
||||
try {
|
||||
Files.createDirectories(dataFolder);
|
||||
if (Files.notExists(dataFolder)) {
|
||||
Files.createDirectories(dataFolder);
|
||||
}
|
||||
|
||||
Path configFile = dataFolder.resolve(fileName);
|
||||
if (Files.notExists(configFile)) {
|
||||
|
Reference in New Issue
Block a user