mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-13 14:58:35 +00:00
Update Upstream
0036e06 Alter the CUI lifecycle to be more consistent and reliable (1633)
This commit is contained in:
@ -107,12 +107,17 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class LocalSession implements TextureHolder {
|
||||
|
||||
private static final transient int CUI_VERSION_UNINITIALIZED = -1;
|
||||
public static transient int MAX_HISTORY_SIZE = 15;
|
||||
|
||||
// Non-session related fields
|
||||
private transient LocalConfiguration config;
|
||||
private final transient AtomicBoolean dirty = new AtomicBoolean();
|
||||
|
||||
// Single-connection lifetime fields
|
||||
private transient int failedCuiAttempts = 0;
|
||||
private transient boolean hasCUISupport = false;
|
||||
private transient int cuiVersion = CUI_VERSION_UNINITIALIZED;
|
||||
|
||||
// Session related
|
||||
private transient RegionSelector selector = new CuboidRegionSelector();
|
||||
@ -145,8 +150,6 @@ public class LocalSession implements TextureHolder {
|
||||
private transient boolean useInventory;
|
||||
private transient com.sk89q.worldedit.world.snapshot.Snapshot snapshot;
|
||||
private transient Snapshot snapshotExperimental;
|
||||
private transient boolean hasCUISupport = false;
|
||||
private transient int cuiVersion = -1;
|
||||
private transient SideEffectSet sideEffectSet = SideEffectSet.defaults();
|
||||
private transient Mask mask;
|
||||
private transient Mask sourceMask;
|
||||
@ -1398,7 +1401,12 @@ public class LocalSession implements TextureHolder {
|
||||
*/
|
||||
public void handleCUIInitializationMessage(String text, Actor actor) {
|
||||
checkNotNull(text);
|
||||
if (this.hasCUISupport || this.failedCuiAttempts > 3) {
|
||||
if (this.hasCUISupport) {
|
||||
// WECUI is a bit aggressive about re-initializing itself
|
||||
// the last attempt to touch handshakes didn't go well, so this will do... for now
|
||||
dispatchCUISelection(actor);
|
||||
return;
|
||||
} else if (this.failedCuiAttempts > 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1456,6 +1464,10 @@ public class LocalSession implements TextureHolder {
|
||||
* @param cuiVersion the CUI version
|
||||
*/
|
||||
public void setCUIVersion(int cuiVersion) {
|
||||
if (cuiVersion < 0) {
|
||||
throw new IllegalArgumentException("CUI protocol version must be non-negative, but '" + cuiVersion + "' was received.");
|
||||
}
|
||||
|
||||
this.cuiVersion = cuiVersion;
|
||||
}
|
||||
|
||||
@ -1687,4 +1699,15 @@ public class LocalSession implements TextureHolder {
|
||||
this.transform = transform;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call when this session has become inactive.
|
||||
*
|
||||
* <p>This is for internal use only.</p>
|
||||
*/
|
||||
public void onIdle() {
|
||||
this.cuiVersion = CUI_VERSION_UNINITIALIZED;
|
||||
this.hasCUISupport = false;
|
||||
this.failedCuiAttempts = 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user