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 FastLoginCore<ProxiedPlayer, CommandSender, FastLoginBungee> core;
private Configuration config;
@Override
public void onEnable() {
try {
File configFile = new File(getDataFolder(), "config.yml");
ConfigurationProvider provider = ConfigurationProvider.getProvider(YamlConfiguration.class);
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);
core = new FastLoginCore<>(this);
core.load();
if (!core.setupDatabase()) {
return;
}
@ -106,10 +95,6 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
return core;
}
public Configuration getConfig() {
return config;
}
public ConcurrentMap<PendingConnection, BungeeLoginSession> getSession() {
return session;
}

View File

@ -71,7 +71,7 @@ public class PlayerConnectionListener implements Listener {
//bungeecord will do this automatically so override it on disabled option
InitialHandler initialHandler = (InitialHandler) connection;
if (!plugin.getConfig().getBoolean("premiumUuid")) {
if (!plugin.getCore().getConfig().get("premiumUuid", true)) {
try {
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
LoginResult loginProfile = initialHandler.getLoginProfile();
if (loginProfile != null) {

View File

@ -59,7 +59,7 @@ public class PluginMessageListener implements Listener {
String playerName = dataInput.readUTF();
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())) {
String message = core.getMessage("premium-warning");
forPlayer.sendMessage(TextComponent.fromLegacyText(message));