mirror of
https://github.com/ViaVersion/ViaLegacy.git
synced 2024-06-26 10:24:55 +02:00
Default disable fly on regular classic servers
This commit is contained in:
parent
f5a66731eb
commit
1cdeac431f
|
@ -36,6 +36,7 @@ public class ViaLegacyConfig extends Config implements net.raphimc.vialegacy.pla
|
|||
private boolean remapBasedOnColor;
|
||||
private int classicChunkRange;
|
||||
private int chunksPerTick;
|
||||
private boolean enableClassicFly;
|
||||
|
||||
public ViaLegacyConfig(final File configFile) {
|
||||
super(configFile);
|
||||
|
@ -57,6 +58,7 @@ public class ViaLegacyConfig extends Config implements net.raphimc.vialegacy.pla
|
|||
this.remapBasedOnColor = this.getBoolean("remap-based-on-color", true);
|
||||
this.classicChunkRange = this.getInt("classic-chunk-range", 10);
|
||||
this.chunksPerTick = this.getInt("chunks-per-tick", -1);
|
||||
this.enableClassicFly = this.getBoolean("enable-classic-fly", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,4 +120,9 @@ public class ViaLegacyConfig extends Config implements net.raphimc.vialegacy.pla
|
|||
return this.chunksPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableClassicFly() {
|
||||
return this.enableClassicFly;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,4 +37,6 @@ public interface ViaLegacyConfig {
|
|||
|
||||
int getChunksPerTick();
|
||||
|
||||
boolean enableClassicFly();
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.protocol.packet.State;
|
|||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.api.data.BlockList1_6;
|
||||
import net.raphimc.vialegacy.api.model.ChunkCoord;
|
||||
import net.raphimc.vialegacy.api.model.IdAndData;
|
||||
|
@ -563,7 +564,7 @@ public class Protocola1_0_15toc0_30 extends AbstractProtocol<ClientboundPacketsc
|
|||
userConnection.put(new PreNettySplitter(userConnection, Protocola1_0_15toc0_30.class, ClientboundPacketsc0_28::getPacket));
|
||||
|
||||
userConnection.put(new ClassicPositionTracker(userConnection));
|
||||
userConnection.put(new ClassicOpLevelStorage(userConnection));
|
||||
userConnection.put(new ClassicOpLevelStorage(userConnection, ViaLegacy.getConfig().enableClassicFly()));
|
||||
userConnection.put(new ClassicProgressStorage(userConnection));
|
||||
userConnection.put(new ClassicBlockRemapper(userConnection, i -> ClassicBlocks.MAPPING.get(i), o -> {
|
||||
int block = ClassicBlocks.REVERSE_MAPPING.getInt(o);
|
||||
|
|
|
@ -31,16 +31,27 @@ public class ClassicOpLevelStorage extends StoredObject {
|
|||
|
||||
private byte opLevel;
|
||||
|
||||
private boolean flying = true;
|
||||
private boolean noClip = true;
|
||||
private boolean speed = true;
|
||||
private boolean respawn = true;
|
||||
private final boolean haxEnabled;
|
||||
private boolean flying = false;
|
||||
private boolean noClip = false;
|
||||
private boolean speed = false;
|
||||
private boolean respawn = false;
|
||||
|
||||
public ClassicOpLevelStorage(final UserConnection user) {
|
||||
public ClassicOpLevelStorage(final UserConnection user, final boolean haxEnabled) {
|
||||
super(user);
|
||||
this.haxEnabled = haxEnabled;
|
||||
|
||||
if (haxEnabled) {
|
||||
this.flying = true;
|
||||
this.noClip = true;
|
||||
this.speed = true;
|
||||
this.respawn = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateHax(final boolean flying, final boolean noClip, final boolean speed, final boolean respawn) throws Exception {
|
||||
if (!this.haxEnabled) return;
|
||||
|
||||
boolean changed = this.flying != flying;
|
||||
changed |= this.noClip != noClip;
|
||||
changed |= this.speed != speed;
|
||||
|
@ -75,10 +86,12 @@ public class ClassicOpLevelStorage extends StoredObject {
|
|||
final boolean changed = this.opLevel != opLevel;
|
||||
this.opLevel = opLevel;
|
||||
|
||||
final ClassicServerTitleStorage serverTitleStorage = this.getUser().get(ClassicServerTitleStorage.class);
|
||||
this.updateHax(serverTitleStorage.isFlyEffectivelyEnabled(), serverTitleStorage.isNoclipEffectivelyEnabled(), serverTitleStorage.isSpeedEffectivelyEnabled(), serverTitleStorage.isRespawnEffectivelyEnabled());
|
||||
if (changed) {
|
||||
this.updateAbilities();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +106,7 @@ public class ClassicOpLevelStorage extends StoredObject {
|
|||
playerAbilities.write(Type.BOOLEAN, false); // flying
|
||||
playerAbilities.write(Type.BOOLEAN, this.flying); // allow flying
|
||||
playerAbilities.write(Type.BOOLEAN, true); // creative mode
|
||||
playerAbilities.send(Protocol1_2_4_5to1_2_1_3.class);
|
||||
playerAbilities.scheduleSend(Protocol1_2_4_5to1_2_1_3.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -348,6 +348,7 @@ public class Protocolc0_30toc0_30cpe extends AbstractProtocol<ClientboundPackets
|
|||
userConnection.put(new PreNettySplitter(userConnection, Protocolc0_30toc0_30cpe.class, ClientboundPacketsc0_30cpe::getPacket));
|
||||
|
||||
userConnection.put(new ExtensionProtocolMetadataStorage(userConnection));
|
||||
userConnection.put(new ClassicOpLevelStorage(userConnection, true));
|
||||
|
||||
final ClassicBlockRemapper previousRemapper = userConnection.get(ClassicBlockRemapper.class);
|
||||
userConnection.put(new ClassicBlockRemapper(userConnection, i -> {
|
||||
|
|
|
@ -26,3 +26,6 @@ classic-chunk-range: 10
|
|||
#
|
||||
# How many chunks should be sent to the client per movement tick (-1 for auto)
|
||||
chunks-per-tick: -1
|
||||
#
|
||||
# Enable fly on regular (non CPE) classic servers
|
||||
enable-classic-fly: false
|
||||
|
|
Loading…
Reference in New Issue
Block a user