mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-08-01 19:54:44 +02:00
Log invalid proxy id messages
This commit is contained in:
@@ -2,19 +2,11 @@ package com.github.games647.fastlogin.bukkit.hooks;
|
|||||||
|
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
import fr.xephi.authme.api.v3.AuthMeApi;
|
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||||
import fr.xephi.authme.events.RestoreSessionEvent;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Github: https://github.com/Xephi/AuthMeReloaded/
|
* Github: https://github.com/Xephi/AuthMeReloaded/
|
||||||
@@ -27,29 +19,16 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
*/
|
*/
|
||||||
public class AuthMeHook implements AuthPlugin<Player>, Listener {
|
public class AuthMeHook implements AuthPlugin<Player>, Listener {
|
||||||
|
|
||||||
private final Set<UUID> sessionLogins = Sets.newConcurrentHashSet();
|
|
||||||
private final FastLoginBukkit plugin;
|
private final FastLoginBukkit plugin;
|
||||||
|
|
||||||
public AuthMeHook(FastLoginBukkit plugin) {
|
public AuthMeHook(FastLoginBukkit plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
|
||||||
public void onRestoreSession(RestoreSessionEvent restoreSessionEvent) {
|
|
||||||
UUID uniqueId = restoreSessionEvent.getPlayer().getUniqueId();
|
|
||||||
sessionLogins.add(uniqueId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent quitEvent) {
|
|
||||||
UUID uniqueId = quitEvent.getPlayer().getUniqueId();
|
|
||||||
sessionLogins.remove(uniqueId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean forceLogin(Player player) {
|
public boolean forceLogin(Player player) {
|
||||||
//skips registration and login
|
//skips registration and login
|
||||||
if (AuthMeApi.getInstance().isAuthenticated(player) || sessionLogins.contains(player.getUniqueId())) {
|
if (AuthMeApi.getInstance().isAuthenticated(player)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
AuthMeApi.getInstance().forceLogin(player);
|
AuthMeApi.getInstance().forceLogin(player);
|
||||||
|
@@ -65,6 +65,8 @@ public class BungeeListener implements PluginMessageListener {
|
|||||||
//fail if BungeeCord support is disabled (id = null)
|
//fail if BungeeCord support is disabled (id = null)
|
||||||
if (proxyIds.contains(sourceId)) {
|
if (proxyIds.contains(sourceId)) {
|
||||||
readMessage(checkedPlayer, subChannel, playerName, player);
|
readMessage(checkedPlayer, subChannel, playerName, player);
|
||||||
|
} else {
|
||||||
|
plugin.getLog().warn("Received proxy id: {} that doesn't exist in the proxy whitelist file", sourceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,9 +78,9 @@ public class BungeeListener implements PluginMessageListener {
|
|||||||
BukkitLoginSession playerSession = new BukkitLoginSession(playerName, true);
|
BukkitLoginSession playerSession = new BukkitLoginSession(playerName, true);
|
||||||
playerSession.setVerified(true);
|
playerSession.setVerified(true);
|
||||||
plugin.getLoginSessions().put(id, playerSession);
|
plugin.getLoginSessions().put(id, playerSession);
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new ForceLoginTask(plugin.getCore(), player));
|
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new ForceLoginTask(plugin.getCore(), player), 20L);
|
||||||
} else if ("AUTO_REGISTER".equalsIgnoreCase(subChannel)) {
|
} else if ("AUTO_REGISTER".equalsIgnoreCase(subChannel)) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> {
|
||||||
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
|
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
|
||||||
try {
|
try {
|
||||||
//we need to check if the player is registered on Bukkit too
|
//we need to check if the player is registered on Bukkit too
|
||||||
@@ -91,7 +93,7 @@ public class BungeeListener implements PluginMessageListener {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.getLog().error("Failed to query isRegistered", ex);
|
plugin.getLog().error("Failed to query isRegistered", ex);
|
||||||
}
|
}
|
||||||
});
|
}, 20L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,8 +26,7 @@ import net.md_5.bungee.event.EventHandler;
|
|||||||
import net.md_5.bungee.event.EventPriority;
|
import net.md_5.bungee.event.EventPriority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables online mode logins for specified users and sends
|
* Enables online mode logins for specified users and sends plugin message to the Bukkit version of this plugin in
|
||||||
* plugin message to the Bukkit version of this plugin in
|
|
||||||
* order to clear that the connection is online mode.
|
* order to clear that the connection is online mode.
|
||||||
*/
|
*/
|
||||||
public class ConnectListener implements Listener {
|
public class ConnectListener implements Listener {
|
||||||
|
Reference in New Issue
Block a user