From c96d64597af99beac7395b66dce040ef9e864bb9 Mon Sep 17 00:00:00 2001 From: games647 Date: Thu, 9 Jul 2020 18:29:17 +0200 Subject: [PATCH] Clear proxies file name --- README.md | 2 +- .../fastlogin/bukkit/BungeeManager.java | 25 +++++++++++++------ .../bukkit/command/PremiumCommand.java | 2 +- .../bukkit/listener/BungeeListener.java | 6 ++--- .../bukkit/listener/ConnectionListener.java | 6 ++--- .../fastlogin/bukkit/task/ForceLoginTask.java | 2 +- bukkit/src/main/resources/plugin.yml | 2 +- core/src/main/resources/config.yml | 3 ++- core/src/main/resources/messages.yml | 4 +-- 9 files changed, 31 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index cc1125b2..e312e603 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ This plugin performs network requests to: 1. Activate BungeeCord in the Spigot configuration 2. Restart your server -3. Now there is proxy-whitelist file in the FastLogin folder +3. Now there is `allowed-proxies.txt` file in the FastLogin folder Put your stats id from the BungeeCord config into this file 4. Activate ipForward in your BungeeCord config 5. Download and Install FastLogin (or FastLoginBungee in newer versions) on BungeeCord AND Spigot diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java index a42ef553..a9646e49 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java @@ -27,9 +27,10 @@ import static java.util.stream.Collectors.toSet; public class BungeeManager { - private static final String FILE_NAME = "proxy-whitelist.txt"; + private static final String LEGACY_FILE_NAME = "proxy-whitelist.txt"; + private static final String FILE_NAME = "allowed-proxies.txt"; - //null if whitelist is empty so bungeecord support is disabled + //null if proxies allowed list is empty so bungeecord support is disabled private Set proxyIds; private final FastLoginBukkit plugin; @@ -42,7 +43,7 @@ public class BungeeManager { } public void cleanup() { - //remove old blacklists + //remove old blocked status Bukkit.getOnlinePlayers().forEach(player -> player.removeMetadata(plugin.getName(), plugin)); } @@ -101,19 +102,27 @@ public class BungeeManager { } private Set loadBungeeCordIds() { - Path whitelistFile = plugin.getPluginFolder().resolve(FILE_NAME); + Path proxiesFile = plugin.getPluginFolder().resolve(FILE_NAME); + Path legacyFile = plugin.getPluginFolder().resolve(LEGACY_FILE_NAME); try { - if (Files.notExists(whitelistFile)) { - Files.createFile(whitelistFile); + Path readFile = proxiesFile; + if (Files.notExists(proxiesFile)) { + if (Files.exists(legacyFile)) { + readFile = legacyFile; + } + + if (Files.notExists(legacyFile)) { + Files.createFile(proxiesFile); + } } - try (Stream lines = Files.lines(whitelistFile)) { + try (Stream lines = Files.lines(readFile)) { return lines.map(String::trim) .map(UUID::fromString) .collect(toSet()); } } catch (IOException ex) { - plugin.getLog().error("Failed to read proxy whitelist", ex); + plugin.getLog().error("Failed to read proxies", ex); } catch (Exception ex) { plugin.getLog().error("Failed to retrieve proxy Id. Disabling BungeeCord support", ex); } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/PremiumCommand.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/PremiumCommand.java index f8d900fe..56f025a8 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/PremiumCommand.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/PremiumCommand.java @@ -15,7 +15,7 @@ import org.bukkit.entity.Player; /** * Let users activate fast login by command. This only be accessible if * the user has access to it's account. So we can make sure that not another - * person with a paid account and the same username can steal his account. + * person with a paid account and the same username can steal their account. */ public class PremiumCommand extends ToggleCommand { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java index 2af388cf..516b107c 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java @@ -50,15 +50,15 @@ public class BungeeListener implements PluginMessageListener { return; } - // fail if target player is blacklisted because already authenticated or wrong bungeecord id + // fail if target player is blocked because already authenticated or wrong bungeecord id if (targetPlayer.hasMetadata(plugin.getName())) { - plugin.getLog().warn("Received message {} from a blacklisted player {}", loginMessage, targetPlayer); + plugin.getLog().warn("Received message {} from a blocked player {}", loginMessage, targetPlayer); } else { UUID sourceId = loginMessage.getProxyId(); if (plugin.getBungeeManager().isProxyAllowed(sourceId)) { readMessage(targetPlayer, loginMessage); } else { - plugin.getLog().warn("Received proxy id: {} that doesn't exist in the proxy whitelist file", sourceId); + plugin.getLog().warn("Received proxy id: {} that doesn't exist in the proxy file", sourceId); } } } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java index e2b3d0ab..dc76a34a 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java @@ -30,7 +30,7 @@ public class ConnectionListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onPlayerLogin(PlayerLoginEvent loginEvent) { - removeBlacklistStatus(loginEvent.getPlayer()); + removeBlockedStatus(loginEvent.getPlayer()); if (loginEvent.getResult() == Result.ALLOWED && !plugin.isServerFullyStarted()) { loginEvent.disallow(Result.KICK_OTHER, plugin.getCore().getMessage("not-started")); } @@ -63,13 +63,13 @@ public class ConnectionListener implements Listener { public void onPlayerQuit(PlayerQuitEvent quitEvent) { Player player = quitEvent.getPlayer(); - removeBlacklistStatus(player); + removeBlockedStatus(player); plugin.getCore().getPendingConfirms().remove(player.getUniqueId()); plugin.getPremiumPlayers().remove(player.getUniqueId()); plugin.getBungeeManager().cleanup(player); } - private void removeBlacklistStatus(Player player) { + private void removeBlockedStatus(Player player) { player.removeMetadata(plugin.getName(), plugin); } } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/ForceLoginTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/ForceLoginTask.java index 9e54e21a..59d6ea18 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/ForceLoginTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/ForceLoginTask.java @@ -27,7 +27,7 @@ public class ForceLoginTask extends ForceLoginManagement [player] permission: ${project.artifactId}.command.cracked diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index 3e932e45..6253ff98 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -47,7 +47,8 @@ secondAttemptCracked: false # New cracked players will be kicked from server. Good if you want switch from offline-mode to online-mode without # losing players! # -# Existing cracked and premium players could still join your server. Moreover you could add playernames to a whitelist. +# Existing cracked and premium players could still join your server. Moreover you could add playernames to a +# allowlist. # So that these cracked players could join too although they are new players. switchMode: false diff --git a/core/src/main/resources/messages.yml b/core/src/main/resources/messages.yml index f9b8526d..99221b51 100644 --- a/core/src/main/resources/messages.yml +++ b/core/src/main/resources/messages.yml @@ -21,8 +21,8 @@ # ========= Shared (BungeeCord and Bukkit) ============ -# Switch mode is activated and a new (non-whitelist) cracked player tries to join -switch-kick-message: '&4Only paid Minecraft whitelisted accounts are allowed to join this server' +# Switch mode is activated and a new cracked player tries to join, who is not namely allowed +switch-kick-message: '&4Only paid Minecraft allowed accounts are allowed to join this server' # GameProfile activated premium login in order to skip offline authentication add-premium: '&2Added to the list of premium players'