mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-31 11:17:33 +02:00
Always forward premium status to spigot
This commit is contained in:
39
.gitignore
vendored
39
.gitignore
vendored
@ -7,31 +7,15 @@
|
||||
nbproject/
|
||||
nb-configuration.xml
|
||||
|
||||
# Maven
|
||||
target/
|
||||
|
||||
# Vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# virtual machine crash logs, see https://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# various other potential build files
|
||||
build/
|
||||
bin/
|
||||
dist/
|
||||
manifest.mf
|
||||
*.log
|
||||
|
||||
# Mac filesystem dust
|
||||
.DS_Store
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Maven
|
||||
target/
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
|
||||
@ -40,3 +24,20 @@ gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# various other potential build files
|
||||
build/
|
||||
bin/
|
||||
dist/
|
||||
manifest.mf
|
||||
*.log
|
||||
|
||||
# Vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# virtual machine crash logs, see https://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# Mac filesystem dust
|
||||
.DS_Store
|
||||
|
||||
|
@ -3,12 +3,13 @@ package com.github.games647.fastlogin.bukkit;
|
||||
import com.github.games647.fastlogin.bukkit.commands.CrackedCommand;
|
||||
import com.github.games647.fastlogin.bukkit.commands.PremiumCommand;
|
||||
import com.github.games647.fastlogin.bukkit.listener.BungeeListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.JoinListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.ConnectionListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.protocollib.ProtocolLibListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.protocollib.SkinApplyListener;
|
||||
import com.github.games647.fastlogin.bukkit.listener.protocolsupport.ProtocolSupportListener;
|
||||
import com.github.games647.fastlogin.bukkit.tasks.DelayedAuthHook;
|
||||
import com.github.games647.fastlogin.core.CommonUtil;
|
||||
import com.github.games647.fastlogin.core.PremiumStatus;
|
||||
import com.github.games647.fastlogin.core.messages.ChannelMessage;
|
||||
import com.github.games647.fastlogin.core.shared.FastLoginCore;
|
||||
import com.github.games647.fastlogin.core.shared.PlatformPlugin;
|
||||
@ -16,6 +17,9 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -30,14 +34,14 @@ import org.slf4j.Logger;
|
||||
*/
|
||||
public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<CommandSender> {
|
||||
|
||||
private final Logger logger = CommonUtil.createLoggerFromJDK(getLogger());
|
||||
|
||||
private boolean bungeeCord;
|
||||
private FastLoginCore<Player, CommandSender, FastLoginBukkit> core;
|
||||
private boolean serverStarted;
|
||||
|
||||
//1 minutes should be enough as a timeout for bad internet connection (Server, Client and Mojang)
|
||||
private final ConcurrentMap<String, BukkitLoginSession> loginSession = CommonUtil.buildCache(1, -1);
|
||||
private final Logger logger = CommonUtil.createLoggerFromJDK(getLogger());
|
||||
private final Map<UUID, PremiumStatus> premiumPlayers = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean serverStarted;
|
||||
private boolean bungeeCord;
|
||||
private FastLoginCore<Player, CommandSender, FastLoginBukkit> core;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -84,7 +88,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
||||
//delay dependency setup because we load the plugin very early where plugins are initialized yet
|
||||
getServer().getScheduler().runTaskLater(this, new DelayedAuthHook(this), 5L);
|
||||
|
||||
pluginManager.registerEvents(new JoinListener(this), this);
|
||||
pluginManager.registerEvents(new ConnectionListener(this), this);
|
||||
|
||||
//register commands using a unique name
|
||||
getCommand("premium").setExecutor(new PremiumCommand(this));
|
||||
@ -99,6 +103,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
||||
@Override
|
||||
public void onDisable() {
|
||||
loginSession.clear();
|
||||
premiumPlayers.clear();
|
||||
|
||||
if (core != null) {
|
||||
core.close();
|
||||
@ -122,6 +127,10 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
||||
return loginSession;
|
||||
}
|
||||
|
||||
public Map<UUID, PremiumStatus> getPremiumPlayers() {
|
||||
return premiumPlayers;
|
||||
}
|
||||
|
||||
public boolean isBungeeEnabled() {
|
||||
return bungeeCord;
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ package com.github.games647.fastlogin.bukkit.listener;
|
||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||
import com.github.games647.fastlogin.bukkit.tasks.ForceLoginTask;
|
||||
import com.github.games647.fastlogin.core.PremiumStatus;
|
||||
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
||||
import com.github.games647.fastlogin.core.messages.ForceActionMessage;
|
||||
import com.github.games647.fastlogin.core.messages.ForceActionMessage.Type;
|
||||
import com.github.games647.fastlogin.core.messages.LoginActionMessage;
|
||||
import com.github.games647.fastlogin.core.messages.LoginActionMessage.Type;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
@ -51,12 +52,12 @@ public class BungeeListener implements PluginMessageListener {
|
||||
|
||||
ByteArrayDataInput dataInput = ByteStreams.newDataInput(message);
|
||||
String subChannel = dataInput.readUTF();
|
||||
if (!"FORCE_ACTION".equals(subChannel)) {
|
||||
if (!"LoginAction".equals(subChannel)) {
|
||||
plugin.getLog().info("Unknown sub channel {}", subChannel);
|
||||
return;
|
||||
}
|
||||
|
||||
ForceActionMessage loginMessage = new ForceActionMessage();
|
||||
LoginActionMessage loginMessage = new LoginActionMessage();
|
||||
loginMessage.readFrom(dataInput);
|
||||
|
||||
plugin.getLog().debug("Received plugin message {}", loginMessage);
|
||||
@ -81,18 +82,23 @@ public class BungeeListener implements PluginMessageListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void readMessage(Player player, ForceActionMessage message) {
|
||||
private void readMessage(Player player, LoginActionMessage message) {
|
||||
String playerName = message.getPlayerName();
|
||||
Type type = message.getType();
|
||||
|
||||
InetSocketAddress address = player.getAddress();
|
||||
String id = '/' + address.getAddress().getHostAddress() + ':' + address.getPort();
|
||||
if (type == Type.LOGIN) {
|
||||
plugin.getPremiumPlayers().put(player.getUniqueId(), PremiumStatus.PREMIUM);
|
||||
|
||||
BukkitLoginSession playerSession = new BukkitLoginSession(playerName, true);
|
||||
playerSession.setVerified(true);
|
||||
plugin.getLoginSessions().put(id, playerSession);
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new ForceLoginTask(plugin.getCore(), player), 20L);
|
||||
} else if (type == Type.REGISTER) {
|
||||
plugin.getPremiumPlayers().put(player.getUniqueId(), PremiumStatus.PREMIUM);
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> {
|
||||
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
|
||||
try {
|
||||
@ -107,6 +113,8 @@ public class BungeeListener implements PluginMessageListener {
|
||||
plugin.getLog().error("Failed to query isRegistered for player: {}", player, ex);
|
||||
}
|
||||
}, 20L);
|
||||
} else if (type == Type.CRACKED) {
|
||||
plugin.getPremiumPlayers().put(player.getUniqueId(), PremiumStatus.CRACKED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,13 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
* This listener tells authentication plugins if the player has a premium account and we checked it successfully. So the
|
||||
* plugin can skip authentication.
|
||||
*/
|
||||
public class JoinListener implements Listener {
|
||||
public class ConnectionListener implements Listener {
|
||||
|
||||
private static final long DELAY_LOGIN = 20L / 2;
|
||||
|
||||
private final FastLoginBukkit plugin;
|
||||
|
||||
public JoinListener(FastLoginBukkit plugin) {
|
||||
public ConnectionListener(FastLoginBukkit plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@ -51,5 +51,6 @@ public class JoinListener implements Listener {
|
||||
player.removeMetadata(plugin.getName(), plugin);
|
||||
|
||||
plugin.getCore().getPendingConfirms().remove(player.getUniqueId());
|
||||
plugin.getPremiumPlayers().remove(player.getUniqueId());
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ public class BungeeAuthHook implements AuthPlugin<ProxiedPlayer> {
|
||||
public boolean forceLogin(ProxiedPlayer player) {
|
||||
String playerName = player.getName();
|
||||
return Main.plonline.contains(playerName) || requestHandler.forceLogin(playerName);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.games647.fastlogin.bungee.listener;
|
||||
|
||||
import com.github.games647.craftapi.UUIDAdapter;
|
||||
import com.github.games647.fastlogin.bungee.FastLoginBungee;
|
||||
import com.github.games647.fastlogin.bungee.tasks.AsyncPremiumCheck;
|
||||
import com.github.games647.fastlogin.bungee.tasks.ForceLoginTask;
|
||||
|
@ -56,9 +56,9 @@ public class MessageListener implements Listener {
|
||||
|
||||
ByteArrayDataInput dataInput = ByteStreams.newDataInput(data);
|
||||
String subChannel = dataInput.readUTF();
|
||||
if ("SUCCESS".equals(subChannel)) {
|
||||
if ("Success".equals(subChannel)) {
|
||||
onSuccessMessage(forPlayer);
|
||||
} else if ("CHANGE".equals(subChannel)) {
|
||||
} else if ("ChangeStatus".equals(subChannel)) {
|
||||
ChangePremiumMessage changeMessage = new ChangePremiumMessage();
|
||||
changeMessage.readFrom(dataInput);
|
||||
|
||||
|
@ -3,8 +3,8 @@ package com.github.games647.fastlogin.bungee.tasks;
|
||||
import com.github.games647.fastlogin.bungee.BungeeLoginSession;
|
||||
import com.github.games647.fastlogin.bungee.FastLoginBungee;
|
||||
import com.github.games647.fastlogin.core.messages.ChannelMessage;
|
||||
import com.github.games647.fastlogin.core.messages.ForceActionMessage;
|
||||
import com.github.games647.fastlogin.core.messages.ForceActionMessage.Type;
|
||||
import com.github.games647.fastlogin.core.messages.LoginActionMessage;
|
||||
import com.github.games647.fastlogin.core.messages.LoginActionMessage.Type;
|
||||
import com.github.games647.fastlogin.core.shared.FastLoginCore;
|
||||
import com.github.games647.fastlogin.core.shared.ForceLoginManagement;
|
||||
import com.github.games647.fastlogin.core.shared.LoginSession;
|
||||
@ -66,7 +66,7 @@ public class ForceLoginTask
|
||||
}
|
||||
|
||||
UUID proxyId = UUID.fromString(ProxyServer.getInstance().getConfig().getUuid());
|
||||
ChannelMessage loginMessage = new ForceActionMessage(type, player.getName(), proxyId);
|
||||
ChannelMessage loginMessage = new LoginActionMessage(type, player.getName(), proxyId);
|
||||
|
||||
core.getPlugin().sendPluginMessage(server, loginMessage);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.github.games647.fastlogin.core;
|
||||
|
||||
public enum PremiumStatus {
|
||||
|
||||
PREMIUM,
|
||||
|
||||
CRACKED,
|
||||
|
||||
UNKNOWN
|
||||
}
|
@ -33,7 +33,7 @@ public class ChangePremiumMessage implements ChannelMessage {
|
||||
|
||||
@Override
|
||||
public String getChannelName() {
|
||||
return "CHANGE";
|
||||
return "ChangeStatus";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,20 +5,20 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ForceActionMessage implements ChannelMessage {
|
||||
public class LoginActionMessage implements ChannelMessage {
|
||||
|
||||
private Type type;
|
||||
|
||||
private String playerName;
|
||||
private UUID proxyId;
|
||||
|
||||
public ForceActionMessage(Type type, String playerName, UUID proxyId) {
|
||||
public LoginActionMessage(Type type, String playerName, UUID proxyId) {
|
||||
this.type = type;
|
||||
this.playerName = playerName;
|
||||
this.proxyId = proxyId;
|
||||
}
|
||||
|
||||
public ForceActionMessage() {
|
||||
public LoginActionMessage() {
|
||||
//reading mode
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public class ForceActionMessage implements ChannelMessage {
|
||||
|
||||
@Override
|
||||
public String getChannelName() {
|
||||
return "FORCE_ACTION";
|
||||
return "LoginAction";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,6 +76,8 @@ public class ForceActionMessage implements ChannelMessage {
|
||||
|
||||
LOGIN,
|
||||
|
||||
REGISTER
|
||||
REGISTER,
|
||||
|
||||
CRACKED
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ public class SuccessMessage implements ChannelMessage {
|
||||
|
||||
@Override
|
||||
public String getChannelName() {
|
||||
return "SUCCESS";
|
||||
return "Success";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user