forked from TuxCoding/FastLogin
Switch to mcapi.ca and add configurable number of requests
This commit is contained in:
@@ -5,15 +5,18 @@ import com.github.games647.fastlogin.bungee.hooks.BungeeAuthPlugin;
|
||||
import com.github.games647.fastlogin.bungee.listener.PlayerConnectionListener;
|
||||
import com.github.games647.fastlogin.bungee.listener.PluginMessageListener;
|
||||
import com.github.games647.fastlogin.core.FastLoginCore;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
@@ -48,9 +51,12 @@ public class FastLoginBungee extends Plugin {
|
||||
File configFile = new File(getDataFolder(), "config.yml");
|
||||
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
|
||||
loginCore.setMojangApiConnector(new MojangApiBungee(loginCore
|
||||
, config.getStringList("ip-addresses")
|
||||
, config.getBoolean("lookup-third-party")));
|
||||
List<String> ipAddresses = getConfig().getStringList("ip-addresses");
|
||||
int requestLimit = getConfig().getInt("mojang-request-limit");
|
||||
ConcurrentMap<Object, Object> requestCache = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(10, TimeUnit.MINUTES).build().asMap();
|
||||
MojangApiBungee mojangApi = new MojangApiBungee(requestCache, getLogger(), ipAddresses, requestLimit);
|
||||
loginCore.setMojangApiConnector(mojangApi);
|
||||
|
||||
String driver = config.getString("driver");
|
||||
String host = config.getString("host", "");
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.github.games647.fastlogin.bungee;
|
||||
|
||||
public class McAPIProfile {
|
||||
|
||||
private String uuid;
|
||||
private String name;
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,16 @@ import com.github.games647.fastlogin.core.MojangApiConnector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
|
||||
public class MojangApiBungee extends MojangApiConnector {
|
||||
|
||||
public MojangApiBungee(FastLoginCore plugin, List<String> localAddresses, boolean apiLookup) {
|
||||
super(plugin, localAddresses, apiLookup);
|
||||
public MojangApiBungee(ConcurrentMap<Object, Object> requests, Logger logger, List<String> localAddresses
|
||||
, int rateLimit) {
|
||||
super(requests, logger, localAddresses, rateLimit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,10 +28,4 @@ public class MojangApiBungee extends MojangApiConnector {
|
||||
//this is not needed in Bungee
|
||||
throw new UnsupportedOperationException("Not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UUID getUUIDFromJsonAPI(String json) {
|
||||
McAPIProfile apiPlayer = BungeeCord.getInstance().gson.fromJson(json, McAPIProfile.class);
|
||||
return FastLoginCore.parseId(apiPlayer.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -55,7 +55,6 @@ public class PlayerConnectionListener implements Listener {
|
||||
|
||||
//use the loginevent instead of the postlogin event in order to send the loginsuccess packet to the client
|
||||
//with the offline uuid this makes it possible to set the skin then
|
||||
|
||||
PendingConnection connection = loginEvent.getConnection();
|
||||
String username = connection.getName();
|
||||
if (connection.isOnlineMode()) {
|
||||
|
||||
Reference in New Issue
Block a user