Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Hopefully finish preparation, minor optimizations
Dieser Commit ist enthalten in:
Ursprung
6371b77b94
Commit
107892fb24
@ -1,11 +1,11 @@
|
|||||||
package us.myles.ViaVersion;
|
package us.myles.ViaVersion;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||||
import us.myles.ViaVersion.util.Config;
|
import us.myles.ViaVersion.util.Config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public abstract class AbstractViaConfig extends Config implements ViaVersionConfig {
|
public abstract class AbstractViaConfig extends Config implements ViaVersionConfig {
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
|||||||
private boolean autoTeam;
|
private boolean autoTeam;
|
||||||
private boolean forceJsonTransform;
|
private boolean forceJsonTransform;
|
||||||
private boolean nbtArrayFix;
|
private boolean nbtArrayFix;
|
||||||
private Set<Integer> blockedProtocols;
|
private IntSet blockedProtocols;
|
||||||
private String blockedDisconnectMessage;
|
private String blockedDisconnectMessage;
|
||||||
private String reloadDisconnectMessage;
|
private String reloadDisconnectMessage;
|
||||||
private boolean suppressConversionWarnings;
|
private boolean suppressConversionWarnings;
|
||||||
@ -93,7 +93,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
|||||||
autoTeam = getBoolean("auto-team", true);
|
autoTeam = getBoolean("auto-team", true);
|
||||||
forceJsonTransform = getBoolean("force-json-transform", false);
|
forceJsonTransform = getBoolean("force-json-transform", false);
|
||||||
nbtArrayFix = getBoolean("chat-nbt-fix", true);
|
nbtArrayFix = getBoolean("chat-nbt-fix", true);
|
||||||
blockedProtocols = new HashSet<>(getIntegerList("block-protocols"));
|
blockedProtocols = new IntOpenHashSet(getIntegerList("block-protocols"));
|
||||||
blockedDisconnectMessage = getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
|
blockedDisconnectMessage = getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
|
||||||
reloadDisconnectMessage = getString("reload-disconnect-msg", "Server reload, please rejoin!");
|
reloadDisconnectMessage = getString("reload-disconnect-msg", "Server reload, please rejoin!");
|
||||||
minimizeCooldown = getBoolean("minimize-cooldown", true);
|
minimizeCooldown = getBoolean("minimize-cooldown", true);
|
||||||
@ -257,7 +257,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Integer> getBlockedProtocols() {
|
public IntSet getBlockedProtocols() {
|
||||||
return blockedProtocols;
|
return blockedProtocols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package us.myles.ViaVersion.api;
|
package us.myles.ViaVersion.api;
|
||||||
|
|
||||||
import java.util.Set;
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
|
|
||||||
public interface ViaVersionConfig {
|
public interface ViaVersionConfig {
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ public interface ViaVersionConfig {
|
|||||||
*
|
*
|
||||||
* @return An Integer list
|
* @return An Integer list
|
||||||
*/
|
*/
|
||||||
Set<Integer> getBlockedProtocols();
|
IntSet getBlockedProtocols();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the custom disconnect message
|
* Get the custom disconnect message
|
||||||
|
@ -161,6 +161,10 @@ public class ProtocolVersion {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOriginalId() {
|
||||||
|
return snapshotId == -1 ? id : ((1 << 30) | snapshotId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return snapshot protocol version without the snapshot indicator bit, -1 if not a snapshot
|
* @return snapshot protocol version without the snapshot indicator bit, -1 if not a snapshot
|
||||||
*/
|
*/
|
||||||
|
@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.platform.providers.ViaProviders;
|
|||||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||||
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
|
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
@ -57,7 +58,10 @@ public class BaseProtocol extends SimpleProtocol {
|
|||||||
// Ensure mapping data has already been loaded
|
// Ensure mapping data has already been loaded
|
||||||
ProtocolRegistry.completeMappingDataLoading(prot.getValue().getClass());
|
ProtocolRegistry.completeMappingDataLoading(prot.getValue().getClass());
|
||||||
}
|
}
|
||||||
wrapper.set(Type.VAR_INT, 0, serverProtocol);
|
|
||||||
|
// Set the original snapshot version if present
|
||||||
|
ProtocolVersion protocol = ProtocolVersion.getProtocol(serverProtocol);
|
||||||
|
wrapper.set(Type.VAR_INT, 0, protocol.getOriginalId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Base Protocol
|
// Add Base Protocol
|
||||||
|
@ -52,14 +52,12 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
|||||||
protocolVersion = ((Long) version.get("protocol").getAsLong()).intValue();
|
protocolVersion = ((Long) version.get("protocol").getAsLong()).intValue();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
version = new JsonObject();
|
json.getAsJsonObject().add("version", version = new JsonObject());
|
||||||
json.getAsJsonObject().add("version", version);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Format properly
|
// Format properly
|
||||||
json = new JsonObject();
|
json = new JsonObject();
|
||||||
version = new JsonObject();
|
json.getAsJsonObject().add("version", version = new JsonObject());
|
||||||
json.getAsJsonObject().add("version", version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Via.getConfig().isSendSupportedVersions()) { // Send supported versions
|
if (Via.getConfig().isSendSupportedVersions()) { // Send supported versions
|
||||||
@ -71,12 +69,13 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the server has a version provider
|
// Ensure the server has a version provider
|
||||||
if (Via.getManager().getProviders().get(VersionProvider.class) == null) {
|
VersionProvider versionProvider = Via.getManager().getProviders().get(VersionProvider.class);
|
||||||
|
if (versionProvider == null) {
|
||||||
wrapper.user().setActive(false);
|
wrapper.user().setActive(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
|
int protocol = versionProvider.getServerProtocol(wrapper.user());
|
||||||
List<Pair<Integer, Protocol>> protocols = null;
|
List<Pair<Integer, Protocol>> protocols = null;
|
||||||
|
|
||||||
// Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
|
// Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
|
||||||
@ -85,9 +84,9 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (protocols != null) {
|
if (protocols != null) {
|
||||||
if (protocolVersion == protocol || protocolVersion == 0) {
|
if (protocolVersion == protocol || protocolVersion == 0) { // Fix ServerListPlus
|
||||||
//Fix ServerListPlus
|
ProtocolVersion prot = ProtocolVersion.getProtocol(info.getProtocolVersion());
|
||||||
version.addProperty("protocol", info.getProtocolVersion());
|
version.addProperty("protocol", prot.getOriginalId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not compatible :(, *plays very sad violin*
|
// not compatible :(, *plays very sad violin*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren