forked from TuxCoding/FastLogin
Generalize references from Bungee to proxies
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package com.github.games647.fastlogin.bukkit;
|
package com.github.games647.fastlogin.bukkit;
|
||||||
|
|
||||||
|
import com.github.games647.fastlogin.bukkit.auth.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.core.SessionManager;
|
import com.github.games647.fastlogin.core.SessionManager;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.games647.fastlogin.bukkit;
|
package com.github.games647.fastlogin.bukkit;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.bukkit.auth.bungee.BungeeManager;
|
import com.github.games647.fastlogin.bukkit.auth.proxy.ProxyManager;
|
||||||
import com.github.games647.fastlogin.bukkit.auth.protocollib.ProtocolLibListener;
|
import com.github.games647.fastlogin.bukkit.auth.protocollib.ProtocolLibListener;
|
||||||
import com.github.games647.fastlogin.bukkit.auth.protocolsupport.ProtocolSupportListener;
|
import com.github.games647.fastlogin.bukkit.auth.protocolsupport.ProtocolSupportListener;
|
||||||
import com.github.games647.fastlogin.bukkit.command.CrackedCommand;
|
import com.github.games647.fastlogin.bukkit.command.CrackedCommand;
|
||||||
@ -40,7 +40,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final BukkitScheduler scheduler;
|
private final BukkitScheduler scheduler;
|
||||||
|
|
||||||
private BungeeManager bungeeManager;
|
private ProxyManager proxyManager;
|
||||||
|
|
||||||
private PremiumPlaceholder premiumPlaceholder;
|
private PremiumPlaceholder premiumPlaceholder;
|
||||||
|
|
||||||
@ -60,11 +60,11 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bungeeManager = new BungeeManager(this);
|
proxyManager = new ProxyManager(this);
|
||||||
bungeeManager.initialize();
|
proxyManager.initialize();
|
||||||
|
|
||||||
PluginManager pluginManager = getServer().getPluginManager();
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
if (!bungeeManager.isEnabled()) {
|
if (!proxyManager.isEnabled()) {
|
||||||
if (!core.setupDatabase()) {
|
if (!core.setupDatabase()) {
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
return;
|
return;
|
||||||
@ -75,7 +75,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
} else if (pluginManager.isPluginEnabled("ProtocolLib")) {
|
} else if (pluginManager.isPluginEnabled("ProtocolLib")) {
|
||||||
ProtocolLibListener.register(this, core.getRateLimiter());
|
ProtocolLibListener.register(this, core.getRateLimiter());
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Either ProtocolLib or ProtocolSupport have to be installed if you don't use BungeeCord");
|
logger.warn("Either ProtocolLib or ProtocolSupport have to be installed if you don't use proxies");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
premiumPlayers.clear();
|
premiumPlayers.clear();
|
||||||
core.close();
|
core.close();
|
||||||
|
|
||||||
bungeeManager.cleanup();
|
proxyManager.cleanup();
|
||||||
if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI") && premiumPlaceholder != null) {
|
if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI") && premiumPlaceholder != null) {
|
||||||
premiumPlaceholder.unregister();
|
premiumPlaceholder.unregister();
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
* Fetches the premium status of an online player.
|
* Fetches the premium status of an online player.
|
||||||
*
|
*
|
||||||
* @param onlinePlayer
|
* @param onlinePlayer
|
||||||
* @return the online status or unknown if an error happened, the player isn't online or BungeeCord doesn't send
|
* @return the online status or unknown if an error happened, the player isn't online or a proxy doesn't send
|
||||||
* us the status message yet (This means you cannot check the login status on the PlayerJoinEvent).
|
* us the status message yet (This means you cannot check the login status on the PlayerJoinEvent).
|
||||||
* @deprecated this method could be removed in future versions and exists only as a temporarily solution
|
* @deprecated this method could be removed in future versions and exists only as a temporarily solution
|
||||||
*/
|
*/
|
||||||
@ -146,8 +146,8 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
return premiumPlayers;
|
return premiumPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BungeeManager getBungeeManager() {
|
public ProxyManager getProxyManager() {
|
||||||
return bungeeManager;
|
return proxyManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.games647.fastlogin.bukkit;
|
package com.github.games647.fastlogin.bukkit;
|
||||||
|
|
||||||
|
import com.github.games647.fastlogin.bukkit.auth.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginAutoLoginEvent;
|
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginAutoLoginEvent;
|
||||||
import com.github.games647.fastlogin.core.PremiumStatus;
|
import com.github.games647.fastlogin.core.PremiumStatus;
|
||||||
import com.github.games647.fastlogin.core.storage.StoredProfile;
|
import com.github.games647.fastlogin.core.storage.StoredProfile;
|
||||||
@ -25,7 +26,7 @@ public class ForceLoginTask extends ForceLoginManagement<Player, CommandSender,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// block this target player for BungeeCord ID brute force attacks
|
// block this target player for proxy ID brute force attacks
|
||||||
FastLoginBukkit plugin = core.getPlugin();
|
FastLoginBukkit plugin = core.getPlugin();
|
||||||
player.setMetadata(core.getPlugin().getName(), new FixedMetadataValue(plugin, true));
|
player.setMetadata(core.getPlugin().getName(), new FixedMetadataValue(plugin, true));
|
||||||
|
|
||||||
@ -54,8 +55,8 @@ public class ForceLoginTask extends ForceLoginManagement<Player, CommandSender,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onForceActionSuccess(LoginSession session) {
|
public void onForceActionSuccess(LoginSession session) {
|
||||||
if (core.getPlugin().getBungeeManager().isEnabled()) {
|
if (core.getPlugin().getProxyManager().isEnabled()) {
|
||||||
core.getPlugin().getBungeeManager().sendPluginMessage(player, new SuccessMessage());
|
core.getPlugin().getProxyManager().sendPluginMessage(player, new SuccessMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.github.games647.fastlogin.bukkit;
|
package com.github.games647.fastlogin.bukkit.auth;
|
||||||
|
|
||||||
import com.github.games647.craftapi.model.skin.SkinProperty;
|
import com.github.games647.craftapi.model.skin.SkinProperty;
|
||||||
import com.github.games647.fastlogin.core.storage.StoredProfile;
|
import com.github.games647.fastlogin.core.storage.StoredProfile;
|
||||||
@ -30,7 +30,7 @@ public class BukkitLoginSession extends LoginSession {
|
|||||||
this.verifyToken = verifyToken.clone();
|
this.verifyToken = verifyToken.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
//available for BungeeCord
|
// available for proxies
|
||||||
public BukkitLoginSession(String username, boolean registered) {
|
public BukkitLoginSession(String username, boolean registered) {
|
||||||
this(username, "", EMPTY_ARRAY, registered, null);
|
this(username, "", EMPTY_ARRAY, registered, null);
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ public class BukkitLoginSession extends LoginSession {
|
|||||||
/**
|
/**
|
||||||
* Gets the verify token the server sent to the client.
|
* Gets the verify token the server sent to the client.
|
||||||
*
|
*
|
||||||
* Empty if it's a BungeeCord connection
|
* Empty if it's a proxy connection
|
||||||
*
|
*
|
||||||
* @return the verify token from the server
|
* @return the verify token from the server
|
||||||
*/
|
*/
|
@ -2,7 +2,7 @@ package com.github.games647.fastlogin.bukkit.auth.protocollib;
|
|||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
import com.github.games647.fastlogin.bukkit.auth.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPreLoginEvent;
|
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPreLoginEvent;
|
||||||
import com.github.games647.fastlogin.core.storage.StoredProfile;
|
import com.github.games647.fastlogin.core.storage.StoredProfile;
|
||||||
|
@ -6,7 +6,7 @@ import com.comphenix.protocol.utility.MinecraftReflection;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
||||||
import com.github.games647.craftapi.model.skin.Textures;
|
import com.github.games647.craftapi.model.skin.Textures;
|
||||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
import com.github.games647.fastlogin.bukkit.auth.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -12,7 +12,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|||||||
import com.github.games647.craftapi.model.auth.Verification;
|
import com.github.games647.craftapi.model.auth.Verification;
|
||||||
import com.github.games647.craftapi.model.skin.SkinProperty;
|
import com.github.games647.craftapi.model.skin.SkinProperty;
|
||||||
import com.github.games647.craftapi.resolver.MojangResolver;
|
import com.github.games647.craftapi.resolver.MojangResolver;
|
||||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
import com.github.games647.fastlogin.bukkit.auth.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.games647.fastlogin.bukkit.auth.protocolsupport;
|
package com.github.games647.fastlogin.bukkit.auth.protocolsupport;
|
||||||
|
|
||||||
import com.github.games647.craftapi.UUIDAdapter;
|
import com.github.games647.craftapi.UUIDAdapter;
|
||||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
import com.github.games647.fastlogin.bukkit.auth.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPreLoginEvent;
|
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPreLoginEvent;
|
||||||
import com.github.games647.fastlogin.core.auth.RateLimiter;
|
import com.github.games647.fastlogin.core.auth.RateLimiter;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.github.games647.fastlogin.bukkit.auth.bungee;
|
package com.github.games647.fastlogin.bukkit.auth.proxy;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
import com.github.games647.fastlogin.core.message.ChannelMessage;
|
import com.github.games647.fastlogin.core.message.ChannelMessage;
|
||||||
@ -25,12 +25,12 @@ import static com.github.games647.fastlogin.core.message.ChangePremiumMessage.CH
|
|||||||
import static com.github.games647.fastlogin.core.message.SuccessMessage.SUCCESS_CHANNEL;
|
import static com.github.games647.fastlogin.core.message.SuccessMessage.SUCCESS_CHANNEL;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
public class BungeeManager {
|
public class ProxyManager {
|
||||||
|
|
||||||
private static final String LEGACY_FILE_NAME = "proxy-whitelist.txt";
|
private static final String LEGACY_FILE_NAME = "proxy-whitelist.txt";
|
||||||
private static final String FILE_NAME = "allowed-proxies.txt";
|
private static final String FILE_NAME = "allowed-proxies.txt";
|
||||||
|
|
||||||
//null if proxies allowed list is empty so bungeecord support is disabled
|
//null if proxies allowed list is empty so proxy support is disabled
|
||||||
private Set<UUID> proxyIds;
|
private Set<UUID> proxyIds;
|
||||||
|
|
||||||
private final FastLoginBukkit plugin;
|
private final FastLoginBukkit plugin;
|
||||||
@ -38,7 +38,7 @@ public class BungeeManager {
|
|||||||
|
|
||||||
private final Set<UUID> firedJoinEvents = new HashSet<>();
|
private final Set<UUID> firedJoinEvents = new HashSet<>();
|
||||||
|
|
||||||
public BungeeManager(FastLoginBukkit plugin) {
|
public ProxyManager(FastLoginBukkit plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,23 +63,23 @@ public class BungeeManager {
|
|||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
try {
|
try {
|
||||||
enabled = detectBungeeCord();
|
enabled = detectProxy();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.getLog().warn("Cannot check bungeecord support. Fallback to non-bungee mode", ex);
|
plugin.getLog().warn("Cannot check proxy support. Fallback to non-proxy mode", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
proxyIds = loadBungeeCordIds();
|
proxyIds = loadProxyIds();
|
||||||
registerPluginChannels();
|
registerPluginChannels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean detectBungeeCord() throws Exception {
|
private boolean detectProxy() throws Exception {
|
||||||
try {
|
try {
|
||||||
enabled = Class.forName("org.spigotmc.SpigotConfig").getDeclaredField("bungee").getBoolean(null);
|
enabled = Class.forName("org.spigotmc.SpigotConfig").getDeclaredField("bungee").getBoolean(null);
|
||||||
return enabled;
|
return enabled;
|
||||||
} catch (ClassNotFoundException notFoundEx) {
|
} catch (ClassNotFoundException notFoundEx) {
|
||||||
//ignore server has no bungee support
|
//ignore server has no proxy support
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
@ -89,10 +89,10 @@ public class BungeeManager {
|
|||||||
private void registerPluginChannels() {
|
private void registerPluginChannels() {
|
||||||
Server server = Bukkit.getServer();
|
Server server = Bukkit.getServer();
|
||||||
|
|
||||||
// check for incoming messages from the bungeecord version of this plugin
|
// check for incoming messages from the proxy version of this plugin
|
||||||
String groupId = plugin.getName();
|
String groupId = plugin.getName();
|
||||||
String forceChannel = NamespaceKey.getCombined(groupId, LoginActionMessage.FORCE_CHANNEL);
|
String forceChannel = NamespaceKey.getCombined(groupId, LoginActionMessage.FORCE_CHANNEL);
|
||||||
server.getMessenger().registerIncomingPluginChannel(plugin, forceChannel, new BungeeMessagingListener(plugin));
|
server.getMessenger().registerIncomingPluginChannel(plugin, forceChannel, new ProxyMessagingListener(plugin));
|
||||||
|
|
||||||
// outgoing
|
// outgoing
|
||||||
String successChannel = new NamespaceKey(groupId, SUCCESS_CHANNEL).getCombinedName();
|
String successChannel = new NamespaceKey(groupId, SUCCESS_CHANNEL).getCombinedName();
|
||||||
@ -101,7 +101,7 @@ public class BungeeManager {
|
|||||||
server.getMessenger().registerOutgoingPluginChannel(plugin, changeChannel);
|
server.getMessenger().registerOutgoingPluginChannel(plugin, changeChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<UUID> loadBungeeCordIds() {
|
private Set<UUID> loadProxyIds() {
|
||||||
Path proxiesFile = plugin.getPluginFolder().resolve(FILE_NAME);
|
Path proxiesFile = plugin.getPluginFolder().resolve(FILE_NAME);
|
||||||
Path legacyFile = plugin.getPluginFolder().resolve(LEGACY_FILE_NAME);
|
Path legacyFile = plugin.getPluginFolder().resolve(LEGACY_FILE_NAME);
|
||||||
try {
|
try {
|
||||||
@ -124,7 +124,7 @@ public class BungeeManager {
|
|||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
plugin.getLog().error("Failed to read proxies", ex);
|
plugin.getLog().error("Failed to read proxies", ex);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.getLog().error("Failed to retrieve proxy Id. Disabling BungeeCord support", ex);
|
plugin.getLog().error("Failed to retrieve proxy Id. Disabling proxy support", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
@ -145,7 +145,7 @@ public class BungeeManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the event fired including with the task delay. This necessary to restore the order of processing the
|
* Check if the event fired including with the task delay. This necessary to restore the order of processing the
|
||||||
* BungeeCord messages after the PlayerJoinEvent fires including the delay.
|
* proxy messages after the PlayerJoinEvent fires including the delay.
|
||||||
*
|
*
|
||||||
* If the join event fired, the delay exceeded, but it ran earlier and couldn't find the recently started login
|
* If the join event fired, the delay exceeded, but it ran earlier and couldn't find the recently started login
|
||||||
* session. If not fired, we can start a new force login task. This will still match the requirement that we wait
|
* session. If not fired, we can start a new force login task. This will still match the requirement that we wait
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.games647.fastlogin.bukkit.auth.bungee;
|
package com.github.games647.fastlogin.bukkit.auth.proxy;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
import com.github.games647.fastlogin.bukkit.auth.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
import com.github.games647.fastlogin.bukkit.ForceLoginTask;
|
import com.github.games647.fastlogin.bukkit.ForceLoginTask;
|
||||||
import com.github.games647.fastlogin.core.PremiumStatus;
|
import com.github.games647.fastlogin.core.PremiumStatus;
|
||||||
@ -18,16 +18,16 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for receiving messages from a BungeeCord instance.
|
* Responsible for receiving messages from a proxy instance.
|
||||||
*
|
*
|
||||||
* This class also receives the plugin message from the bungeecord version of this plugin in order to get notified if
|
* This class also receives the plugin message from the proxy version of this plugin in order to get notified if
|
||||||
* the connection is in online mode.
|
* the connection is in online mode.
|
||||||
*/
|
*/
|
||||||
public class BungeeMessagingListener implements PluginMessageListener {
|
public class ProxyMessagingListener implements PluginMessageListener {
|
||||||
|
|
||||||
private final FastLoginBukkit plugin;
|
private final FastLoginBukkit plugin;
|
||||||
|
|
||||||
protected BungeeMessagingListener(FastLoginBukkit plugin) {
|
protected ProxyMessagingListener(FastLoginBukkit plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,12 +50,12 @@ public class BungeeMessagingListener implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fail if target player is blocked because already authenticated or wrong bungeecord id
|
// fail if target player is blocked because already authenticated or wrong proxy id
|
||||||
if (targetPlayer.hasMetadata(plugin.getName())) {
|
if (targetPlayer.hasMetadata(plugin.getName())) {
|
||||||
plugin.getLog().warn("Received message {} from a blocked player {}", loginMessage, targetPlayer);
|
plugin.getLog().warn("Received message {} from a blocked player {}", loginMessage, targetPlayer);
|
||||||
} else {
|
} else {
|
||||||
UUID sourceId = loginMessage.getProxyId();
|
UUID sourceId = loginMessage.getProxyId();
|
||||||
if (plugin.getBungeeManager().isProxyAllowed(sourceId)) {
|
if (plugin.getProxyManager().isProxyAllowed(sourceId)) {
|
||||||
readMessage(targetPlayer, loginMessage);
|
readMessage(targetPlayer, loginMessage);
|
||||||
} else {
|
} else {
|
||||||
plugin.getLog().warn("Received proxy id: {} that doesn't exist in the proxy file", sourceId);
|
plugin.getLog().warn("Received proxy id: {} that doesn't exist in the proxy file", sourceId);
|
||||||
@ -104,7 +104,7 @@ public class BungeeMessagingListener implements PluginMessageListener {
|
|||||||
plugin.getSessionManager().startLoginSession(player.getAddress(), session);
|
plugin.getSessionManager().startLoginSession(player.getAddress(), session);
|
||||||
|
|
||||||
// only start a new login task if the join event fired earlier. This event then didn
|
// only start a new login task if the join event fired earlier. This event then didn
|
||||||
boolean result = plugin.getBungeeManager().didJoinEventFired(player);
|
boolean result = plugin.getProxyManager().didJoinEventFired(player);
|
||||||
plugin.getLog().info("Delaying force login until join event fired?: {}", result);
|
plugin.getLog().info("Delaying force login until join event fired?: {}", result);
|
||||||
if (result) {
|
if (result) {
|
||||||
Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session);
|
Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session);
|
@ -35,8 +35,8 @@ public class CrackedCommand extends ToggleCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getBungeeManager().isEnabled()) {
|
if (plugin.getProxyManager().isEnabled()) {
|
||||||
sendBungeeActivateMessage(sender, sender.getName(), false);
|
sendProxyActivateMessage(sender, sender.getName(), false);
|
||||||
plugin.getCore().sendLocaleMessage("wait-on-proxy", sender);
|
plugin.getCore().sendLocaleMessage("wait-on-proxy", sender);
|
||||||
} else {
|
} else {
|
||||||
//todo: load async if
|
//todo: load async if
|
||||||
@ -89,6 +89,6 @@ public class CrackedCommand extends ToggleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean forwardCrackedCommand(CommandSender sender, String target) {
|
private boolean forwardCrackedCommand(CommandSender sender, String target) {
|
||||||
return forwardBungeeCommand(sender, target, false);
|
return forwardProxyCommand(sender, target, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ package com.github.games647.fastlogin.bukkit.command;
|
|||||||
|
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPremiumToggleEvent;
|
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPremiumToggleEvent;
|
||||||
|
import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason;
|
||||||
import com.github.games647.fastlogin.core.storage.StoredProfile;
|
import com.github.games647.fastlogin.core.storage.StoredProfile;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -99,6 +99,6 @@ public class PremiumCommand extends ToggleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean forwardPremiumCommand(CommandSender sender, String target) {
|
private boolean forwardPremiumCommand(CommandSender sender, String target) {
|
||||||
return forwardBungeeCommand(sender, target, true);
|
return forwardProxyCommand(sender, target, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ public abstract class ToggleCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean forwardBungeeCommand(CommandSender sender, String target, boolean activate) {
|
protected boolean forwardProxyCommand(CommandSender sender, String target, boolean activate) {
|
||||||
if (plugin.getBungeeManager().isEnabled()) {
|
if (plugin.getProxyManager().isEnabled()) {
|
||||||
sendBungeeActivateMessage(sender, target, activate);
|
sendProxyActivateMessage(sender, target, activate);
|
||||||
plugin.getCore().sendLocaleMessage("wait-on-proxy", sender);
|
plugin.getCore().sendLocaleMessage("wait-on-proxy", sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -50,10 +50,10 @@ public abstract class ToggleCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendBungeeActivateMessage(CommandSender invoker, String target, boolean activate) {
|
protected void sendProxyActivateMessage(CommandSender invoker, String target, boolean activate) {
|
||||||
if (invoker instanceof PluginMessageRecipient) {
|
if (invoker instanceof PluginMessageRecipient) {
|
||||||
ChannelMessage message = new ChangePremiumMessage(target, activate, true);
|
ChannelMessage message = new ChangePremiumMessage(target, activate, true);
|
||||||
plugin.getBungeeManager().sendPluginMessage((PluginMessageRecipient) invoker, message);
|
plugin.getProxyManager().sendPluginMessage((PluginMessageRecipient) invoker, message);
|
||||||
} else {
|
} else {
|
||||||
Optional<? extends Player> optPlayer = Bukkit.getServer().getOnlinePlayers().stream().findFirst();
|
Optional<? extends Player> optPlayer = Bukkit.getServer().getOnlinePlayers().stream().findFirst();
|
||||||
if (!optPlayer.isPresent()) {
|
if (!optPlayer.isPresent()) {
|
||||||
@ -63,7 +63,7 @@ public abstract class ToggleCommand implements CommandExecutor {
|
|||||||
|
|
||||||
Player sender = optPlayer.get();
|
Player sender = optPlayer.get();
|
||||||
ChannelMessage message = new ChangePremiumMessage(target, activate, false);
|
ChannelMessage message = new ChangePremiumMessage(target, activate, false);
|
||||||
plugin.getBungeeManager().sendPluginMessage(sender, message);
|
plugin.getProxyManager().sendPluginMessage(sender, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,12 @@ public class DelayedAuthHook implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
boolean hookFound = isHookFound();
|
boolean hookFound = isHookFound();
|
||||||
if (plugin.getBungeeManager().isEnabled()) {
|
if (plugin.getProxyManager().isEnabled()) {
|
||||||
plugin.getLog().info("BungeeCord setting detected. No auth plugin is required");
|
plugin.getLog().info("Proxy setting detected. No auth plugin is required");
|
||||||
} else if (!hookFound) {
|
} else if (!hookFound) {
|
||||||
plugin.getLog().warn("No auth plugin were found by this plugin "
|
plugin.getLog().warn("No auth plugin were found by this plugin "
|
||||||
+ "(other plugins could hook into this after the initialization of this plugin)"
|
+ "(other plugins could hook into this after the initialization of this plugin)"
|
||||||
+ "and BungeeCord is deactivated. "
|
+ "and BungeeCord (or similar proxies) is deactivated. "
|
||||||
+ "Either one or both of the checks have to pass in order to use this plugin");
|
+ "Either one or both of the checks have to pass in order to use this plugin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.games647.fastlogin.bukkit.listener;
|
package com.github.games647.fastlogin.bukkit.listener;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
import com.github.games647.fastlogin.bukkit.auth.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
import com.github.games647.fastlogin.bukkit.ForceLoginTask;
|
import com.github.games647.fastlogin.bukkit.ForceLoginTask;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public class ConnectionListener implements Listener {
|
|||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
// session exists so the player is ready for force login
|
// session exists so the player is ready for force login
|
||||||
// cases: Paper (firing BungeeCord message before PlayerJoinEvent) or not running BungeeCord and already
|
// cases: Paper (firing proxy message before PlayerJoinEvent) or not running proxy and already
|
||||||
// having the login session from the login process
|
// having the login session from the login process
|
||||||
BukkitLoginSession session = plugin.getSessionManager().getLoginSession(player.getAddress());
|
BukkitLoginSession session = plugin.getSessionManager().getLoginSession(player.getAddress());
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
@ -46,7 +46,7 @@ public class ConnectionListener implements Listener {
|
|||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, forceLoginTask);
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, forceLoginTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getBungeeManager().markJoinEventFired(player);
|
plugin.getProxyManager().markJoinEventFired(player);
|
||||||
// delay the login process to let auth plugins initialize the player
|
// delay the login process to let auth plugins initialize the player
|
||||||
// Magic number however as there is no direct event from those plugins
|
// Magic number however as there is no direct event from those plugins
|
||||||
}, DELAY_LOGIN);
|
}, DELAY_LOGIN);
|
||||||
@ -59,7 +59,7 @@ public class ConnectionListener implements Listener {
|
|||||||
removeBlockedStatus(player);
|
removeBlockedStatus(player);
|
||||||
plugin.getCore().getPendingConfirms().remove(player.getUniqueId());
|
plugin.getCore().getPendingConfirms().remove(player.getUniqueId());
|
||||||
plugin.getPremiumPlayers().remove(player.getUniqueId());
|
plugin.getPremiumPlayers().remove(player.getUniqueId());
|
||||||
plugin.getBungeeManager().cleanup(player);
|
plugin.getProxyManager().cleanup(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeBlockedStatus(Player player) {
|
private void removeBlockedStatus(Player player) {
|
||||||
|
@ -2,7 +2,7 @@ package com.github.games647.fastlogin.bukkit.listener;
|
|||||||
|
|
||||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||||
import com.github.games647.craftapi.model.skin.Textures;
|
import com.github.games647.craftapi.model.skin.Textures;
|
||||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
import com.github.games647.fastlogin.bukkit.auth.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
Reference in New Issue
Block a user