Remove session in ProtocolSupport directly without expiring

This commit is contained in:
games647
2018-03-18 16:22:03 +01:00
parent 3651c4873c
commit 71c1f4f12e
5 changed files with 15 additions and 4 deletions

View File

@ -51,12 +51,16 @@ public class BukkitLoginSession extends LoginSession {
return ArrayUtils.clone(verifyToken);
}
/**
* @return premium skin if available
*/
public synchronized Optional<SkinProperty> getSkin() {
return Optional.ofNullable(skinProperty);
}
/**
* Sets the premium skin property which was retrieved by the session server
* @param skinProperty premium skin
*/
public synchronized void setSkinProperty(SkinProperty skinProperty) {
this.skinProperty = skinProperty;

View File

@ -152,7 +152,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
* Wait before the server is fully started. This is workaround, because connections right on startup are not
* injected by ProtocolLib
*
* @return
* @return true if ProtocolLib can now intercept packets
*/
public boolean isServerFullyStarted() {
return serverStarted;

View File

@ -12,6 +12,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import protocolsupport.api.events.ConnectionCloseEvent;
import protocolsupport.api.events.PlayerLoginStartEvent;
import protocolsupport.api.events.PlayerPropertiesResolveEvent;
@ -41,6 +42,12 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
super.onLogin(username, new ProtocolLoginSource(loginStartEvent));
}
@EventHandler
public void onConnectionClosed(ConnectionCloseEvent closeEvent) {
InetSocketAddress address = closeEvent.getConnection().getAddress();
plugin.getLoginSessions().remove(address.toString());
}
@EventHandler
public void onPropertiesResolve(PlayerPropertiesResolveEvent propertiesResolveEvent) {
InetSocketAddress address = propertiesResolveEvent.getAddress();

View File

@ -64,7 +64,7 @@ public class MessageListener implements Listener {
String playerName = changeMessage.getPlayerName();
boolean isSourceInvoker = changeMessage.isSourceInvoker();
if (changeMessage.isWillEnable()) {
if (changeMessage.shouldEnable()) {
if (playerName.equals(forPlayer.getName()) && plugin.getCore().getConfig().get("premium-warning", true)
&& !core.getPendingConfirms().contains(forPlayer.getUniqueId())) {
String message = core.getMessage("premium-warning");

View File

@ -23,7 +23,7 @@ public class ChangePremiumMessage implements ChannelMessage {
return playerName;
}
public boolean isWillEnable() {
public boolean shouldEnable() {
return willEnable;
}
@ -54,7 +54,7 @@ public class ChangePremiumMessage implements ChannelMessage {
public String toString() {
return this.getClass().getSimpleName() + '{' +
"playerName='" + playerName + '\'' +
", willEnable=" + willEnable +
", shouldEnable=" + willEnable +
", isSourceInvoker=" + isSourceInvoker +
'}';
}