mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add SessionDisconnectEvent (#4052)
* Add SessionDisconnectEvent * Move disconnect event calling to UpstreamSession, debug double calling issues * Prevent duplicate disconnect calling * Tidy up disconnection logic, ensure SessionDisconnectEvent is always fired - but only once. Fix /geyser reload command
This commit is contained in:
parent
9dad1acfe5
commit
0ebb7232f9
4 changed files with 89 additions and 7 deletions
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.api.event.bedrock;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.connection.GeyserConnection;
|
||||
import org.geysermc.geyser.api.event.connection.ConnectionEvent;
|
||||
|
||||
/**
|
||||
* Called when a Geyser session disconnects.
|
||||
*/
|
||||
public class SessionDisconnectEvent extends ConnectionEvent {
|
||||
private String disconnectReason;
|
||||
|
||||
public SessionDisconnectEvent(@NonNull GeyserConnection connection, @NonNull String reason) {
|
||||
super(connection);
|
||||
this.disconnectReason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the disconnect reason.
|
||||
*
|
||||
* @return the reason for the disconnect
|
||||
*/
|
||||
public @NonNull String disconnectReason() {
|
||||
return disconnectReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the disconnect reason, thereby overriding th original reason.
|
||||
*
|
||||
* @param disconnectReason the reason for the disconnect
|
||||
*/
|
||||
public void disconnectReason(@NonNull String disconnectReason) {
|
||||
this.disconnectReason = disconnectReason;
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue