Correctly wait for BungeeAuth loading by using the correct depend tag (Fixes #119)

This commit is contained in:
games647
2017-02-10 19:06:57 +01:00
parent b8d029d6da
commit 70a81bfcdf
4 changed files with 12 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ import com.github.games647.fastlogin.bukkit.tasks.ForceLoginTask;
import com.github.games647.fastlogin.core.hooks.AuthPlugin; import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener; import org.bukkit.plugin.messaging.PluginMessageListener;
@@ -98,12 +99,14 @@ public class BungeeCordListener implements PluginMessageListener {
public Set<UUID> loadBungeeCordIds() { public Set<UUID> loadBungeeCordIds() {
Path whitelistFile = plugin.getDataFolder().toPath().resolve(FILE_NAME); Path whitelistFile = plugin.getDataFolder().toPath().resolve(FILE_NAME);
try { try {
if (!Files.exists(whitelistFile)) { if (Files.notExists(whitelistFile)) {
Files.createFile(whitelistFile); Files.createFile(whitelistFile);
} }
List<String> lines = Files.readAllLines(whitelistFile); return Files.readAllLines(whitelistFile).stream()
return lines.stream().map(String::trim).map(UUID::fromString).collect(Collectors.toSet()); .map(String::trim)
.map(UUID::fromString)
.collect(Collectors.toSet());
} catch (IOException ex) { } catch (IOException ex) {
plugin.getLogger().log(Level.SEVERE, "Failed to create file for Proxy whitelist", ex); plugin.getLogger().log(Level.SEVERE, "Failed to create file for Proxy whitelist", ex);
} catch (Exception ex) { } catch (Exception ex) {

View File

@@ -43,6 +43,8 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
@Override @Override
public void onEnable() { public void onEnable() {
System.out.println(this.getDescription());
core = new FastLoginCore<>(this); core = new FastLoginCore<>(this);
core.load(); core.load();
if (!core.setupDatabase()) { if (!core.setupDatabase()) {

View File

@@ -8,7 +8,7 @@ main: ${project.groupId}.${project.artifactId}.${project.name}
version: ${project.version} version: ${project.version}
author: games647, http://github.com/games647/FastLogin/graphs/contributors author: games647, http://github.com/games647/FastLogin/graphs/contributors
softdepend: softDepends:
# BungeeCord auth plugins # BungeeCord auth plugins
- BungeeAuth - BungeeAuth

View File

@@ -13,9 +13,11 @@ import com.google.common.cache.CacheLoader;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.file.CopyOption;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
@@ -244,7 +246,7 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
} }
Path configFile = plugin.getDataFolder().toPath().resolve(fileName); Path configFile = plugin.getDataFolder().toPath().resolve(fileName);
if (!Files.exists(configFile)) { if (Files.notExists(configFile)) {
InputStream in = getClass().getClassLoader().getResourceAsStream(fileName); InputStream in = getClass().getClassLoader().getResourceAsStream(fileName);
try { try {
Files.copy(in, configFile); Files.copy(in, configFile);