forked from TuxCoding/FastLogin
Fixed premium logins if the server is not fully started (Fixes #12)
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
######1.3
|
######1.3
|
||||||
|
|
||||||
* Add support for AuthMe 3.X
|
* Add support for AuthMe 3.X
|
||||||
|
* Fixed premium logins if the server is not fully started
|
||||||
|
|
||||||
######1.2.1
|
######1.2.1
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ public class FastLoginBukkit extends JavaPlugin {
|
|||||||
|
|
||||||
private boolean bungeeCord;
|
private boolean bungeeCord;
|
||||||
private Storage storage;
|
private Storage storage;
|
||||||
|
private boolean serverStarted;
|
||||||
|
|
||||||
//this map is thread-safe for async access (Packet Listener)
|
//this map is thread-safe for async access (Packet Listener)
|
||||||
//SafeCacheBuilder is used in order to be version independent
|
//SafeCacheBuilder is used in order to be version independent
|
||||||
@ -255,4 +256,20 @@ public class FastLoginBukkit extends JavaPlugin {
|
|||||||
public boolean isBungeeCord() {
|
public boolean isBungeeCord() {
|
||||||
return bungeeCord;
|
return bungeeCord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait before the server is fully started. This is workaround, because connections right on startup are not
|
||||||
|
* injected by ProtocolLib
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isServerFullyStarted() {
|
||||||
|
return serverStarted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerStarted() {
|
||||||
|
if (!this.serverStarted) {
|
||||||
|
this.serverStarted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,11 @@ import com.github.games647.fastlogin.bukkit.PlayerSession;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
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.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,12 +30,19 @@ public class BukkitJoinListener implements Listener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent loginEvent) {
|
||||||
|
if (loginEvent.getResult() == Result.ALLOWED && !plugin.isServerFullyStarted()) {
|
||||||
|
loginEvent.disallow(Result.KICK_OTHER, "§cServer is not fully started yet. Please retry");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerJoin(PlayerJoinEvent joinEvent) {
|
public void onPlayerJoin(PlayerJoinEvent joinEvent) {
|
||||||
final Player player = joinEvent.getPlayer();
|
Player player = joinEvent.getPlayer();
|
||||||
|
|
||||||
//removing the session because we now use it
|
//removing the session because we now use it
|
||||||
final PlayerSession session = plugin.getSessions().get(player.getAddress().toString());
|
PlayerSession session = plugin.getSessions().get(player.getAddress().toString());
|
||||||
if (session != null && plugin.getConfig().getBoolean("forwardSkin")) {
|
if (session != null && plugin.getConfig().getBoolean("forwardSkin")) {
|
||||||
WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player);
|
WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player);
|
||||||
WrappedSignedProperty skin = session.getSkin();
|
WrappedSignedProperty skin = session.getSkin();
|
||||||
@ -49,7 +59,7 @@ public class BukkitJoinListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent quitEvent) {
|
public void onPlayerQuit(PlayerQuitEvent quitEvent) {
|
||||||
final Player player = quitEvent.getPlayer();
|
Player player = quitEvent.getPlayer();
|
||||||
|
|
||||||
//prevent memory leaks
|
//prevent memory leaks
|
||||||
player.removeMetadata(plugin.getName(), plugin);
|
player.removeMetadata(plugin.getName(), plugin);
|
||||||
|
@ -61,7 +61,9 @@ public class StartPacketListener extends PacketAdapter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||||
final Player player = packetEvent.getPlayer();
|
plugin.setServerStarted();
|
||||||
|
|
||||||
|
Player player = packetEvent.getPlayer();
|
||||||
|
|
||||||
//this includes ip:port. Should be unique for an incoming login request with a timeout of 2 minutes
|
//this includes ip:port. Should be unique for an incoming login request with a timeout of 2 minutes
|
||||||
String sessionKey = player.getAddress().toString();
|
String sessionKey = player.getAddress().toString();
|
||||||
|
Reference in New Issue
Block a user