Fix FileNotFoundEx if the bungee config doesn't exist

This commit is contained in:
games647
2017-01-28 16:38:48 +01:00
parent 4d5b1787b1
commit c47dd1df80
3 changed files with 6 additions and 21 deletions

View File

@ -40,23 +40,12 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
private final ConcurrentMap<PendingConnection, BungeeLoginSession> session = Maps.newConcurrentMap(); private final ConcurrentMap<PendingConnection, BungeeLoginSession> session = Maps.newConcurrentMap();
private FastLoginCore<ProxiedPlayer, CommandSender, FastLoginBungee> core; private FastLoginCore<ProxiedPlayer, CommandSender, FastLoginBungee> core;
private Configuration config;
@Override @Override
public void onEnable() { public void onEnable() {
try { core = new FastLoginCore<>(this);
File configFile = new File(getDataFolder(), "config.yml"); core.load();
ConfigurationProvider provider = ConfigurationProvider.getProvider(YamlConfiguration.class); if (!core.setupDatabase()) {
Configuration defaults = provider.load(getResourceAsStream("config.yml"));
config = provider.load(configFile, defaults);
core = new FastLoginCore<>(this);
core.load();
if (!core.setupDatabase()) {
return;
}
} catch (IOException ioExc) {
getLogger().log(Level.SEVERE, "Error loading config. Disabling plugin...", ioExc);
return; return;
} }
@ -106,10 +95,6 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
return core; return core;
} }
public Configuration getConfig() {
return config;
}
public ConcurrentMap<PendingConnection, BungeeLoginSession> getSession() { public ConcurrentMap<PendingConnection, BungeeLoginSession> getSession() {
return session; return session;
} }

View File

@ -71,7 +71,7 @@ public class PlayerConnectionListener implements Listener {
//bungeecord will do this automatically so override it on disabled option //bungeecord will do this automatically so override it on disabled option
InitialHandler initialHandler = (InitialHandler) connection; InitialHandler initialHandler = (InitialHandler) connection;
if (!plugin.getConfig().getBoolean("premiumUuid")) { if (!plugin.getCore().getConfig().get("premiumUuid", true)) {
try { try {
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8)); UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8));
@ -85,7 +85,7 @@ public class PlayerConnectionListener implements Listener {
} }
} }
if (!plugin.getConfig().getBoolean("forwardSkin")) { if (!plugin.getCore().getConfig().get("forwardSkin", true)) {
//this is null on offline mode //this is null on offline mode
LoginResult loginProfile = initialHandler.getLoginProfile(); LoginResult loginProfile = initialHandler.getLoginProfile();
if (loginProfile != null) { if (loginProfile != null) {

View File

@ -59,7 +59,7 @@ public class PluginMessageListener implements Listener {
String playerName = dataInput.readUTF(); String playerName = dataInput.readUTF();
boolean isPlayerSender = dataInput.readBoolean(); boolean isPlayerSender = dataInput.readBoolean();
if (playerName.equals(forPlayer.getName()) && plugin.getConfig().getBoolean("premium-warning") if (playerName.equals(forPlayer.getName()) && plugin.getCore().getConfig().get("premium-warning", true)
&& !core.getPendingConfirms().contains(forPlayer.getUniqueId())) { && !core.getPendingConfirms().contains(forPlayer.getUniqueId())) {
String message = core.getMessage("premium-warning"); String message = core.getMessage("premium-warning");
forPlayer.sendMessage(TextComponent.fromLegacyText(message)); forPlayer.sendMessage(TextComponent.fromLegacyText(message));