Clear proxies file name
This commit is contained in:
9 files changed
+31
-21
No files matched your search
@@ -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<UUID> 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<UUID> 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<String> lines = Files.lines(whitelistFile)) {
|
||||
try (Stream<String> 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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class ForceLoginTask extends ForceLoginManagement<Player, CommandSender,
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//blacklist this target player for BungeeCord ID brute force attacks
|
||||
// block this target player for BungeeCord ID brute force attacks
|
||||
FastLoginBukkit plugin = core.getPlugin();
|
||||
player.setMetadata(core.getPlugin().getName(), new FixedMetadataValue(plugin, true));
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ commands:
|
||||
permission: ${project.artifactId}.command.premium
|
||||
|
||||
cracked:
|
||||
description: 'Label the invoker or the player specified as cracked if he was marked premium before'
|
||||
description: 'Label the invoker or the player specified as cracked if marked premium before'
|
||||
aliases: [unpremium]
|
||||
usage: /<command> [player]
|
||||
permission: ${project.artifactId}.command.cracked
|
||||
|
||||
Reference in new issue
Block a user