Fixed edge case in update op level handling

Fixes #76
This commit is contained in:
RaphiMC 2024-07-26 18:41:48 +02:00
parent a7984797d9
commit c87ec975bd
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94

View File

@ -83,14 +83,12 @@ public class ClassicOpLevelStorage extends StoredObject {
}
public void setOpLevel(final byte opLevel) {
final boolean changed = this.opLevel != opLevel;
this.opLevel = opLevel;
if (this.haxEnabled) {
final ClassicServerTitleStorage serverTitleStorage = this.getUser().get(ClassicServerTitleStorage.class);
this.updateHax(serverTitleStorage.isFlyEffectivelyEnabled(), serverTitleStorage.isNoclipEffectivelyEnabled(), serverTitleStorage.isSpeedEffectivelyEnabled(), serverTitleStorage.isRespawnEffectivelyEnabled());
if (changed) {
this.updateAbilities();
if (serverTitleStorage != null) { // Some servers update the op level before sending the login packet. Just ignore that because the op level is resent in the login packet.
this.updateHax(serverTitleStorage.isFlyEffectivelyEnabled(), serverTitleStorage.isNoclipEffectivelyEnabled(), serverTitleStorage.isSpeedEffectivelyEnabled(), serverTitleStorage.isRespawnEffectivelyEnabled());
}
}
}