mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
Add placeholder variables
This commit is contained in:
@ -51,6 +51,12 @@
|
|||||||
<id>jitpack.io</id>
|
<id>jitpack.io</id>
|
||||||
<url>https://jitpack.io</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<!--PlaceholerAPI -->
|
||||||
|
<repository>
|
||||||
|
<id>placeholderapi</id>
|
||||||
|
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -76,12 +82,26 @@
|
|||||||
<version>3.6.5</version>
|
<version>3.6.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.ProtocolSupport</groupId>
|
<groupId>com.github.ProtocolSupport</groupId>
|
||||||
<artifactId>ProtocolSupport</artifactId>
|
<artifactId>ProtocolSupport</artifactId>
|
||||||
<!--4.25.dev-->
|
<!--4.25.dev-->
|
||||||
<version>a4f060dc46</version>
|
<version>a4f060dc46</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.6.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>*</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--Login Plugins-->
|
<!--Login Plugins-->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -110,10 +130,10 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.games647</groupId>
|
<groupId>com.github.games647</groupId>
|
||||||
<artifactId>LogIt</artifactId>
|
<artifactId>LogIt</artifactId>
|
||||||
<version>9e3581db27</version>
|
<version>9e3581db27</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
@ -122,7 +142,7 @@
|
|||||||
<artifactId>*</artifactId>
|
<artifactId>*</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.RoyalDev</groupId>
|
<groupId>com.github.RoyalDev</groupId>
|
||||||
|
@ -27,6 +27,8 @@ import java.util.concurrent.ThreadFactory;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -49,7 +51,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
private boolean serverStarted;
|
private boolean serverStarted;
|
||||||
|
|
||||||
//1 minutes should be enough as a timeout for bad internet connection (Server, Client and Mojang)
|
//1 minutes should be enough as a timeout for bad internet connection (Server, Client and Mojang)
|
||||||
private final ConcurrentMap<String, BukkitLoginSession> session = FastLoginCore.buildCache(1, -1);
|
private final ConcurrentMap<String, BukkitLoginSession> loginSession = FastLoginCore.buildCache(1, -1);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -64,7 +66,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getServer().getOnlineMode()) {
|
if (getServer().getOnlineMode()) {
|
||||||
//we need to require offline to prevent a session request for a offline player
|
//we need to require offline to prevent a loginSession request for a offline player
|
||||||
getLogger().severe("Server have to be in offline mode");
|
getLogger().severe("Server have to be in offline mode");
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
return;
|
return;
|
||||||
@ -110,11 +112,15 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
getCommand("premium").setExecutor(new PremiumCommand(this));
|
getCommand("premium").setExecutor(new PremiumCommand(this));
|
||||||
getCommand("cracked").setExecutor(new CrackedCommand(this));
|
getCommand("cracked").setExecutor(new CrackedCommand(this));
|
||||||
getCommand("import-auth").setExecutor(new ImportCommand(core));
|
getCommand("import-auth").setExecutor(new ImportCommand(core));
|
||||||
|
|
||||||
|
if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||||
|
PlaceholderAPI.registerPlaceholderHook(this, new PremiumPlaceholder(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
session.clear();
|
loginSession.clear();
|
||||||
|
|
||||||
if (core != null) {
|
if (core != null) {
|
||||||
core.close();
|
core.close();
|
||||||
@ -146,10 +152,10 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
* Gets a thread-safe map about players which are connecting to the server are being checked to be premium (paid
|
* Gets a thread-safe map about players which are connecting to the server are being checked to be premium (paid
|
||||||
* account)
|
* account)
|
||||||
*
|
*
|
||||||
* @return a thread-safe session map
|
* @return a thread-safe loginSession map
|
||||||
*/
|
*/
|
||||||
public ConcurrentMap<String, BukkitLoginSession> getSessions() {
|
public ConcurrentMap<String, BukkitLoginSession> getLoginSessions() {
|
||||||
return session;
|
return loginSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.github.games647.fastlogin.bukkit;
|
||||||
|
|
||||||
|
import me.clip.placeholderapi.PlaceholderHook;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PremiumPlaceholder extends PlaceholderHook {
|
||||||
|
|
||||||
|
private final FastLoginBukkit plugin;
|
||||||
|
|
||||||
|
public PremiumPlaceholder(FastLoginBukkit plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onPlaceholderRequest(Player player, String variable) {
|
||||||
|
if (player != null && "fastlogin_status".contains(variable)) {
|
||||||
|
List<MetadataValue> metadata = player.getMetadata(plugin.getName());
|
||||||
|
if (metadata == null) {
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metadata.size() > 0) {
|
||||||
|
return "premium";
|
||||||
|
} else {
|
||||||
|
return "cracked";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -58,9 +58,6 @@ public class BungeeCordListener implements PluginMessageListener {
|
|||||||
Player checkedPlayer = plugin.getServer().getPlayerExact(playerName);
|
Player checkedPlayer = plugin.getServer().getPlayerExact(playerName);
|
||||||
//fail if target player is blacklisted because already authed or wrong bungeecord id
|
//fail if target player is blacklisted because already authed or wrong bungeecord id
|
||||||
if (checkedPlayer != null && !checkedPlayer.hasMetadata(plugin.getName())) {
|
if (checkedPlayer != null && !checkedPlayer.hasMetadata(plugin.getName())) {
|
||||||
//blacklist this target player for BungeeCord Id brute force attacks
|
|
||||||
player.setMetadata(plugin.getName(), new FixedMetadataValue(plugin, true));
|
|
||||||
|
|
||||||
//bungeecord UUID
|
//bungeecord UUID
|
||||||
long mostSignificantBits = dataInput.readLong();
|
long mostSignificantBits = dataInput.readLong();
|
||||||
long leastSignificantBits = dataInput.readLong();
|
long leastSignificantBits = dataInput.readLong();
|
||||||
@ -80,7 +77,7 @@ public class BungeeCordListener implements PluginMessageListener {
|
|||||||
if ("AUTO_LOGIN".equalsIgnoreCase(subchannel)) {
|
if ("AUTO_LOGIN".equalsIgnoreCase(subchannel)) {
|
||||||
BukkitLoginSession playerSession = new BukkitLoginSession(playerName, true);
|
BukkitLoginSession playerSession = new BukkitLoginSession(playerName, true);
|
||||||
playerSession.setVerified(true);
|
playerSession.setVerified(true);
|
||||||
plugin.getSessions().put(id, playerSession);
|
plugin.getLoginSessions().put(id, playerSession);
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new ForceLoginTask(plugin.getCore(), player));
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new ForceLoginTask(plugin.getCore(), player));
|
||||||
} else if ("AUTO_REGISTER".equalsIgnoreCase(subchannel)) {
|
} else if ("AUTO_REGISTER".equalsIgnoreCase(subchannel)) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
@ -90,7 +87,7 @@ public class BungeeCordListener implements PluginMessageListener {
|
|||||||
if (authPlugin == null || !authPlugin.isRegistered(playerName)) {
|
if (authPlugin == null || !authPlugin.isRegistered(playerName)) {
|
||||||
BukkitLoginSession playerSession = new BukkitLoginSession(playerName, false);
|
BukkitLoginSession playerSession = new BukkitLoginSession(playerName, false);
|
||||||
playerSession.setVerified(true);
|
playerSession.setVerified(true);
|
||||||
plugin.getSessions().put(id, playerSession);
|
plugin.getLoginSessions().put(id, playerSession);
|
||||||
new ForceLoginTask(plugin.getCore(), player).run();
|
new ForceLoginTask(plugin.getCore(), player).run();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -43,7 +43,7 @@ public class LoginSkinApplyListener implements Listener {
|
|||||||
if (plugin.getConfig().getBoolean("forwardSkin")) {
|
if (plugin.getConfig().getBoolean("forwardSkin")) {
|
||||||
//go through every session, because player.getAddress is null
|
//go through every session, because player.getAddress is null
|
||||||
//loginEvent.getAddress is just a InetAddress not InetSocketAddres, so not unique enough
|
//loginEvent.getAddress is just a InetAddress not InetSocketAddres, so not unique enough
|
||||||
for (BukkitLoginSession session : plugin.getSessions().values()) {
|
for (BukkitLoginSession session : plugin.getLoginSessions().values()) {
|
||||||
if (session.getUsername().equals(player.getName())) {
|
if (session.getUsername().equals(player.getName())) {
|
||||||
String signature = session.getSkinSignature();
|
String signature = session.getSkinSignature();
|
||||||
String skinData = session.getEncodedSkinData();
|
String skinData = session.getEncodedSkinData();
|
||||||
|
@ -61,7 +61,7 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
|
|||||||
byte[] verify = source.getVerifyToken();
|
byte[] verify = source.getVerifyToken();
|
||||||
|
|
||||||
BukkitLoginSession playerSession = new BukkitLoginSession(username, serverId, verify, registered, profile);
|
BukkitLoginSession playerSession = new BukkitLoginSession(username, serverId, verify, registered, profile);
|
||||||
plugin.getSessions().put(player.getAddress().toString(), playerSession);
|
plugin.getLoginSessions().put(player.getAddress().toString(), playerSession);
|
||||||
//cancel only if the player has a paid account otherwise login as normal offline player
|
//cancel only if the player has a paid account otherwise login as normal offline player
|
||||||
synchronized (packetEvent.getAsyncMarker().getProcessingLock()) {
|
synchronized (packetEvent.getAsyncMarker().getProcessingLock()) {
|
||||||
packetEvent.setCancelled(true);
|
packetEvent.setCancelled(true);
|
||||||
@ -71,6 +71,6 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
|
|||||||
@Override
|
@Override
|
||||||
public void startCrackedSession(ProtocolLibLoginSource source, PlayerProfile profile, String username) {
|
public void startCrackedSession(ProtocolLibLoginSource source, PlayerProfile profile, String username) {
|
||||||
BukkitLoginSession loginSession = new BukkitLoginSession(username, profile);
|
BukkitLoginSession loginSession = new BukkitLoginSession(username, profile);
|
||||||
plugin.getSessions().put(player.getAddress().toString(), loginSession);
|
plugin.getLoginSessions().put(player.getAddress().toString(), loginSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public class StartPacketListener extends PacketAdapter {
|
|||||||
String sessionKey = player.getAddress().toString();
|
String sessionKey = player.getAddress().toString();
|
||||||
|
|
||||||
//remove old data every time on a new login in order to keep the session only for one person
|
//remove old data every time on a new login in order to keep the session only for one person
|
||||||
plugin.getSessions().remove(sessionKey);
|
plugin.getLoginSessions().remove(sessionKey);
|
||||||
|
|
||||||
//player.getName() won't work at this state
|
//player.getName() won't work at this state
|
||||||
PacketContainer packet = packetEvent.getPacket();
|
PacketContainer packet = packetEvent.getPacket();
|
||||||
|
@ -45,7 +45,7 @@ public class VerifyResponseTask implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
BukkitLoginSession session = plugin.getSessions().get(fromPlayer.getAddress().toString());
|
BukkitLoginSession session = plugin.getLoginSessions().get(fromPlayer.getAddress().toString());
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
disconnect(plugin.getCore().getMessage("invalid-requst"), true
|
disconnect(plugin.getCore().getMessage("invalid-requst"), true
|
||||||
, "Player {0} tried to send encryption response at invalid state", fromPlayer.getAddress());
|
, "Player {0} tried to send encryption response at invalid state", fromPlayer.getAddress());
|
||||||
|
@ -36,7 +36,7 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
|
|||||||
InetSocketAddress address = loginStartEvent.getAddress();
|
InetSocketAddress address = loginStartEvent.getAddress();
|
||||||
|
|
||||||
//remove old data every time on a new login in order to keep the session only for one person
|
//remove old data every time on a new login in order to keep the session only for one person
|
||||||
plugin.getSessions().remove(address.toString());
|
plugin.getLoginSessions().remove(address.toString());
|
||||||
|
|
||||||
super.onLogin(username, new ProtocolLoginSource(loginStartEvent));
|
super.onLogin(username, new ProtocolLoginSource(loginStartEvent));
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPropertiesResolve(PlayerPropertiesResolveEvent propertiesResolveEvent) {
|
public void onPropertiesResolve(PlayerPropertiesResolveEvent propertiesResolveEvent) {
|
||||||
InetSocketAddress address = propertiesResolveEvent.getAddress();
|
InetSocketAddress address = propertiesResolveEvent.getAddress();
|
||||||
BukkitLoginSession session = plugin.getSessions().get(address.toString());
|
BukkitLoginSession session = plugin.getLoginSessions().get(address.toString());
|
||||||
|
|
||||||
//skin was resolved -> premium player
|
//skin was resolved -> premium player
|
||||||
if (propertiesResolveEvent.hasProperty("textures") && session != null) {
|
if (propertiesResolveEvent.hasProperty("textures") && session != null) {
|
||||||
@ -60,7 +60,7 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
|
|||||||
plugin.getCore().getPendingLogins().put(ip + username, new Object());
|
plugin.getCore().getPendingLogins().put(ip + username, new Object());
|
||||||
|
|
||||||
BukkitLoginSession playerSession = new BukkitLoginSession(username, null, null, registered, profile);
|
BukkitLoginSession playerSession = new BukkitLoginSession(username, null, null, registered, profile);
|
||||||
plugin.getSessions().put(source.getAddress().toString(), playerSession);
|
plugin.getLoginSessions().put(source.getAddress().toString(), playerSession);
|
||||||
if (plugin.getConfig().getBoolean("premiumUuid")) {
|
if (plugin.getConfig().getBoolean("premiumUuid")) {
|
||||||
source.getLoginStartEvent().setUseOnlineModeUUID(true);
|
source.getLoginStartEvent().setUseOnlineModeUUID(true);
|
||||||
}
|
}
|
||||||
@ -69,6 +69,6 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
|
|||||||
@Override
|
@Override
|
||||||
public void startCrackedSession(ProtocolLoginSource source, PlayerProfile profile, String username) {
|
public void startCrackedSession(ProtocolLoginSource source, PlayerProfile profile, String username) {
|
||||||
BukkitLoginSession loginSession = new BukkitLoginSession(username, profile);
|
BukkitLoginSession loginSession = new BukkitLoginSession(username, profile);
|
||||||
plugin.getSessions().put(source.getAddress().toString(), loginSession);
|
plugin.getLoginSessions().put(source.getAddress().toString(), loginSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import java.util.logging.Level;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
public class ForceLoginTask extends ForceLoginMangement<Player, CommandSender, BukkitLoginSession, FastLoginBukkit> {
|
public class ForceLoginTask extends ForceLoginMangement<Player, CommandSender, BukkitLoginSession, FastLoginBukkit> {
|
||||||
|
|
||||||
@ -25,7 +26,11 @@ public class ForceLoginTask extends ForceLoginMangement<Player, CommandSender, B
|
|||||||
public void run() {
|
public void run() {
|
||||||
//remove the bungeecord identifier if there is ones
|
//remove the bungeecord identifier if there is ones
|
||||||
String id = '/' + player.getAddress().getAddress().getHostAddress() + ':' + player.getAddress().getPort();
|
String id = '/' + player.getAddress().getAddress().getHostAddress() + ':' + player.getAddress().getPort();
|
||||||
session = core.getPlugin().getSessions().remove(id);
|
session = core.getPlugin().getLoginSessions().remove(id);
|
||||||
|
|
||||||
|
//blacklist this target player for BungeeCord Id brute force attacks
|
||||||
|
FastLoginBukkit plugin = core.getPlugin();
|
||||||
|
player.setMetadata(core.getPlugin().getName(), new FixedMetadataValue(plugin, true));
|
||||||
|
|
||||||
super.run();
|
super.run();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ softdepend:
|
|||||||
# We depend either ProtocolLib or ProtocolSupport
|
# We depend either ProtocolLib or ProtocolSupport
|
||||||
- ProtocolSupport
|
- ProtocolSupport
|
||||||
- ProtocolLib
|
- ProtocolLib
|
||||||
|
- PlaceholderAPI
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
${project.parent.name}:
|
${project.parent.name}:
|
||||||
|
Reference in New Issue
Block a user