Move long plugin channel name check to a config option

This commit is contained in:
KennyTV 2020-07-19 17:30:03 +02:00
parent 5047aaff0c
commit 647230a996
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
4 changed files with 20 additions and 12 deletions

View File

@ -54,6 +54,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
private boolean fullBlockLightFix;
private boolean healthNaNFix;
private boolean instantRespawn;
private boolean ignoreLongChannelNames;
protected AbstractViaConfig(File configFile) {
super(configFile);
@ -111,6 +112,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
fullBlockLightFix = getBoolean("fix-non-full-blocklight", false);
healthNaNFix = getBoolean("fix-1_14-health-nan", true);
instantRespawn = getBoolean("use-1_15-instant-respawn", false);
ignoreLongChannelNames = getBoolean("ignore-long-1_16-channel-names", true);
}
@Override
@ -363,4 +365,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
public boolean is1_15InstantRespawn() {
return instantRespawn;
}
@Override
public boolean isIgnoreLong1_16ChannelMessages() {
return ignoreLongChannelNames;
}
}

View File

@ -346,9 +346,16 @@ public interface ViaVersionConfig {
boolean is1_14HealthNaNFix();
/**
* Should 1.15 clients respawn instantly / without showing the death screen
* Should 1.15 clients respawn instantly / without showing the death screen.
*
* @return True if enabled
*/
boolean is1_15InstantRespawn();
/**
* Ignores incoming plugin channel messages of 1.16 clients with channel names longer than 32 charatcers.
*
* @return True if enabled
*/
boolean isIgnoreLong1_16ChannelMessages();
}

View File

@ -143,8 +143,7 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
}
});
// Spigot has the arbitrary limit of 32 in 1.15, upped to 64 in 1.16
if (isSpigot()) {
if (Via.getConfig().isIgnoreLong1_16ChannelMessages()) {
registerIncoming(ServerboundPackets1_16.PLUGIN_MESSAGE, new PacketRemapper() {
@Override
public void registerMap() {
@ -250,13 +249,4 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
userConnection.put(new ClientWorld(userConnection));
}
}
private boolean isSpigot() {
try {
Class.forName("org.spigotmc.SpigotConfig");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
}

View File

@ -147,6 +147,10 @@ flowerstem-when-block-above: false
# Vines that are not connected to blocks will be mapped to air, else 1.13+ would still be able to climb up on them.
vine-climb-fix: false
#
# Ignores incoming plugin channel messages of 1.16 clients with channel names longer than 32 charatcers.
# CraftBukkit had this limit hardcoded until 1.16, so we have to assume any server/proxy might have this arbitrary check present.
ignore-long-1_16-channel-names: true
#
#----------------------------------------------------------#
# 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #
#----------------------------------------------------------#