forked from TuxCoding/FastLogin
Try to upgrade to Java 8. I hope enough people are using it.
This commit is contained in:
@@ -18,13 +18,13 @@ public class AuthStorage {
|
||||
|
||||
private static final String PREMIUM_TABLE = "premium";
|
||||
|
||||
private final FastLoginCore core;
|
||||
private final FastLoginCore<?> core;
|
||||
private final HikariDataSource dataSource;
|
||||
|
||||
//a try to fix https://www.spigotmc.org/threads/fastlogin.101192/page-26#post-1874647
|
||||
private final Calendar calendar = Calendar.getInstance(Locale.US);
|
||||
|
||||
public AuthStorage(FastLoginCore core, String driver, String host, int port, String databasePath
|
||||
public AuthStorage(FastLoginCore<?> core, String driver, String host, int port, String databasePath
|
||||
, String user, String pass) {
|
||||
this.core = core;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
@@ -17,9 +18,7 @@ public class BalancedSSLFactory extends SSLSocketFactory {
|
||||
//in order to be thread-safe
|
||||
private final List<InetAddress> localAddresses;
|
||||
|
||||
private final Object lock = new Object();
|
||||
|
||||
private int id;
|
||||
private AtomicInteger id;
|
||||
|
||||
public BalancedSSLFactory(SSLSocketFactory oldFactory, Set<InetAddress> localAddresses) {
|
||||
this.oldFactory = oldFactory;
|
||||
@@ -65,16 +64,7 @@ public class BalancedSSLFactory extends SSLSocketFactory {
|
||||
}
|
||||
|
||||
private InetAddress getNextLocalAddress() {
|
||||
int next;
|
||||
synchronized (lock) {
|
||||
next = id;
|
||||
id++;
|
||||
if (next == Integer.MAX_VALUE) {
|
||||
id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int index = next % localAddresses.size();
|
||||
int index = id.incrementAndGet() % localAddresses.size();
|
||||
return localAddresses.get(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ public class CompatibleCacheBuilder<K, V> {
|
||||
* @return A new cache builder.
|
||||
*/
|
||||
public static <K, V> CompatibleCacheBuilder<K, V> newBuilder() {
|
||||
return new CompatibleCacheBuilder<K, V>();
|
||||
return new CompatibleCacheBuilder<>();
|
||||
}
|
||||
|
||||
private CacheBuilder<K, V> builder;
|
||||
private final CacheBuilder<K, V> builder;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private CompatibleCacheBuilder() {
|
||||
|
||||
+1
-1
@@ -4,9 +4,9 @@ import java.util.Random;
|
||||
|
||||
public class DefaultPasswordGenerator<T> implements PasswordGenerator<T> {
|
||||
|
||||
private final Random random = new Random();
|
||||
private static final char[] PASSWORD_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
.toCharArray();
|
||||
private final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public String getRandomPassword(T player) {
|
||||
|
||||
@@ -8,10 +8,10 @@ import java.util.logging.Level;
|
||||
|
||||
public abstract class JoinManagement<T, S extends LoginSource> {
|
||||
|
||||
protected final FastLoginCore core;
|
||||
protected final FastLoginCore<T> core;
|
||||
protected final AuthPlugin<T> authHook;
|
||||
|
||||
public JoinManagement(FastLoginCore core, AuthPlugin<T> authHook) {
|
||||
public JoinManagement(FastLoginCore<T> core, AuthPlugin<T> authHook) {
|
||||
this.core = core;
|
||||
this.authHook = authHook;
|
||||
}
|
||||
@@ -62,8 +62,7 @@ public abstract class JoinManagement<T, S extends LoginSource> {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkPremiumName(String username, S source, PlayerProfile profile)
|
||||
throws Exception {
|
||||
private boolean checkPremiumName(String username, S source, PlayerProfile profile) throws Exception {
|
||||
if (core.getSharedConfig().get("autoRegister", false)
|
||||
&& (authHook == null || !authHook.isRegistered(username))) {
|
||||
core.getLogger().log(Level.FINER, "Player {0} uses a premium username", username);
|
||||
|
||||
+3
-2
@@ -1,6 +1,8 @@
|
||||
package com.github.games647.fastlogin.core.shared;
|
||||
|
||||
import com.github.games647.fastlogin.core.BalancedSSLFactory;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -8,7 +10,6 @@ import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -56,7 +57,7 @@ public abstract class MojangApiConnector {
|
||||
if (localAddresses.isEmpty()) {
|
||||
this.sslFactory = null;
|
||||
} else {
|
||||
Set<InetAddress> addresses = new HashSet<>();
|
||||
Set<InetAddress> addresses = Sets.newHashSet();
|
||||
for (String localAddress : localAddresses) {
|
||||
try {
|
||||
InetAddress address = InetAddress.getByName(localAddress);
|
||||
|
||||
Reference in New Issue
Block a user