Fix loading of settings
This commit is contained in:
1 parent
acab4766b1
commit
da266c7e91
15 files changed
+57
-48
No files matched your search
@@ -23,7 +23,8 @@ import net.md_5.bungee.config.YamlConfiguration;
|
||||
public class BungeeCore extends FastLoginCore<ProxiedPlayer> {
|
||||
|
||||
private static Map<String, Object> generateConfigMap(Configuration config) {
|
||||
return config.getKeys().stream().collect(Collectors.toMap(key -> key, config::get));
|
||||
return config.getKeys().stream().filter(key -> config.get(key) != null)
|
||||
.collect(Collectors.toMap(key -> key, config::get));
|
||||
}
|
||||
|
||||
private final FastLoginBungee plugin;
|
||||
|
||||
@@ -35,7 +35,9 @@ public class FastLoginBungee extends Plugin {
|
||||
|
||||
try {
|
||||
File configFile = new File(getDataFolder(), "config.yml");
|
||||
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
ConfigurationProvider provider = ConfigurationProvider.getProvider(YamlConfiguration.class);
|
||||
Configuration defaults = provider.load(getResourceAsStream("config.yml"));
|
||||
config = provider.load(configFile, defaults);
|
||||
|
||||
core = new BungeeCore(this, config);
|
||||
if (!core.setupDatabase()) {
|
||||
@@ -47,6 +49,7 @@ public class FastLoginBungee extends Plugin {
|
||||
}
|
||||
|
||||
core.loadConfig();
|
||||
core.setApiConnector();
|
||||
core.loadMessages();
|
||||
|
||||
//events
|
||||
@@ -64,7 +67,9 @@ public class FastLoginBungee extends Plugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
core.close();
|
||||
if (core != null) {
|
||||
core.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveDefaultFile(String fileName) {
|
||||
|
||||
@@ -24,11 +24,12 @@ public class MojangApiBungee extends MojangApiConnector {
|
||||
mojangPlayer = BungeeCord.getInstance().gson.fromJson(json, MojangPlayer.class);
|
||||
}
|
||||
|
||||
if (mojangPlayer.getId() == null || mojangPlayer.getId().equals("null")) {
|
||||
String id = mojangPlayer.getId();
|
||||
if ("null".equals(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mojangPlayer.getId();
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-10
@@ -29,26 +29,25 @@ public class BungeeAuthHook implements AuthPlugin<ProxiedPlayer> {
|
||||
|
||||
@Override
|
||||
public boolean forceLogin(ProxiedPlayer player) {
|
||||
String playerName = player.getName();
|
||||
//https://github.com/MatteCarra/BungeeAuth/blob/master/src/me/vik1395/BungeeAuth/Login.java#L92-95
|
||||
if (Main.plonline.contains(player.getName())) {
|
||||
Main.plugin.getLogger().log(Level.INFO, "Cannot force login player {0}, because he/she is already online"
|
||||
, player.getName());
|
||||
if (Main.plonline.contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Main.plonline.add(player.getName());
|
||||
Main.plonline.add(playerName);
|
||||
|
||||
//renamed from ct to databaseConnection
|
||||
// databaseConnection.setStatus(player.getName(), "online");
|
||||
Class<?>[] parameterTypes = new Class<?>[]{String.class, String.class};
|
||||
Object[] arguments = new Object[]{player.getName(), "online"};
|
||||
Object[] arguments = new Object[]{playerName, "online"};
|
||||
|
||||
try {
|
||||
callProtected("setStatus", parameterTypes, arguments);
|
||||
ListenerClass.movePlayer(player, false);
|
||||
|
||||
//proparly not thread-safe
|
||||
ListenerClass.prelogin.get(player.getName()).cancel();
|
||||
ListenerClass.prelogin.get(playerName).cancel();
|
||||
} catch (Exception ex) {
|
||||
Main.plugin.getLogger().log(Level.SEVERE, "Error force loging in player", ex);
|
||||
return false;
|
||||
@@ -82,15 +81,12 @@ public class BungeeAuthHook implements AuthPlugin<ProxiedPlayer> {
|
||||
String hash = ph.newHash(Pw, pType);
|
||||
|
||||
//creates a new SQL entry with the player's details.
|
||||
|
||||
//renamed t to databaseConnection
|
||||
// databaseConnection.newPlayerEntry(player.getName(), hash, pType, "", lastip, regdate, lastip, lastseen);
|
||||
|
||||
Class<?>[] parameterTypes = new Class<?>[] {String.class, String.class, String.class, String.class
|
||||
, String.class, String.class, String.class, String.class};
|
||||
Object[] arguments = new Object[] {player.getName(), hash, pType, "", lastip, regdate, lastip, lastseen};
|
||||
|
||||
try {
|
||||
|
||||
callProtected("newPlayerEntry", parameterTypes, arguments);
|
||||
//proparly not thread-safe
|
||||
forceLogin(player);
|
||||
@@ -108,6 +104,8 @@ public class BungeeAuthHook implements AuthPlugin<ProxiedPlayer> {
|
||||
|
||||
Method method = tableClass.getDeclaredMethod(methodName, parameterTypes);
|
||||
method.setAccessible(true);
|
||||
//renamed t to databaseConnection
|
||||
//databaseConnection.newPlayerEntry(player.getName(), hash, pType, "", lastip, regdate, lastip, lastseen);
|
||||
method.invoke(databaseConnection, arguments);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,8 +3,8 @@ package com.github.games647.fastlogin.bungee.listener;
|
||||
import com.github.games647.fastlogin.bungee.FastLoginBungee;
|
||||
import com.github.games647.fastlogin.bungee.tasks.AsyncPremiumCheck;
|
||||
import com.github.games647.fastlogin.bungee.tasks.ForceLoginTask;
|
||||
import com.github.games647.fastlogin.core.shared.LoginSession;
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user