From 70a81bfcdfc82a8c9ba760c53d5c92cc24d3e73f Mon Sep 17 00:00:00 2001 From: games647 Date: Fri, 10 Feb 2017 19:06:57 +0100 Subject: [PATCH] Correctly wait for BungeeAuth loading by using the correct depend tag (Fixes #119) --- .../fastlogin/bukkit/listener/BungeeCordListener.java | 9 ++++++--- .../games647/fastlogin/bungee/FastLoginBungee.java | 2 ++ bungee/src/main/resources/bungee.yml | 2 +- .../games647/fastlogin/core/shared/FastLoginCore.java | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeCordListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeCordListener.java index a22d0b61..5c860516 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeCordListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeCordListener.java @@ -6,6 +6,7 @@ import com.github.games647.fastlogin.bukkit.tasks.ForceLoginTask; import com.github.games647.fastlogin.core.hooks.AuthPlugin; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; @@ -98,12 +99,14 @@ public class BungeeCordListener implements PluginMessageListener { public Set loadBungeeCordIds() { Path whitelistFile = plugin.getDataFolder().toPath().resolve(FILE_NAME); try { - if (!Files.exists(whitelistFile)) { + if (Files.notExists(whitelistFile)) { Files.createFile(whitelistFile); } - List lines = Files.readAllLines(whitelistFile); - return lines.stream().map(String::trim).map(UUID::fromString).collect(Collectors.toSet()); + return Files.readAllLines(whitelistFile).stream() + .map(String::trim) + .map(UUID::fromString) + .collect(Collectors.toSet()); } catch (IOException ex) { plugin.getLogger().log(Level.SEVERE, "Failed to create file for Proxy whitelist", ex); } catch (Exception ex) { diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java index a01f2143..fd5c6905 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java @@ -43,6 +43,8 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin(this); core.load(); if (!core.setupDatabase()) { diff --git a/bungee/src/main/resources/bungee.yml b/bungee/src/main/resources/bungee.yml index b11a720e..6d18251d 100644 --- a/bungee/src/main/resources/bungee.yml +++ b/bungee/src/main/resources/bungee.yml @@ -8,7 +8,7 @@ main: ${project.groupId}.${project.artifactId}.${project.name} version: ${project.version} author: games647, http://github.com/games647/FastLogin/graphs/contributors -softdepend: +softDepends: # BungeeCord auth plugins - BungeeAuth diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java index 830fa909..ea84ac14 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java @@ -13,9 +13,11 @@ import com.google.common.cache.CacheLoader; import com.google.common.collect.Sets; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.file.CopyOption; import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; @@ -244,7 +246,7 @@ public class FastLoginCore

> { } Path configFile = plugin.getDataFolder().toPath().resolve(fileName); - if (!Files.exists(configFile)) { + if (Files.notExists(configFile)) { InputStream in = getClass().getClassLoader().getResourceAsStream(fileName); try { Files.copy(in, configFile);