Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Hopefully finish preparation, minor optimizations
Dieser Commit ist enthalten in:
Ursprung
6371b77b94
Commit
107892fb24
@ -1,11 +1,11 @@
|
||||
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.util.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
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 forceJsonTransform;
|
||||
private boolean nbtArrayFix;
|
||||
private Set<Integer> blockedProtocols;
|
||||
private IntSet blockedProtocols;
|
||||
private String blockedDisconnectMessage;
|
||||
private String reloadDisconnectMessage;
|
||||
private boolean suppressConversionWarnings;
|
||||
@ -93,7 +93,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
||||
autoTeam = getBoolean("auto-team", true);
|
||||
forceJsonTransform = getBoolean("force-json-transform", false);
|
||||
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!");
|
||||
reloadDisconnectMessage = getString("reload-disconnect-msg", "Server reload, please rejoin!");
|
||||
minimizeCooldown = getBoolean("minimize-cooldown", true);
|
||||
@ -257,7 +257,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Integer> getBlockedProtocols() {
|
||||
public IntSet getBlockedProtocols() {
|
||||
return blockedProtocols;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package us.myles.ViaVersion.api;
|
||||
|
||||
import java.util.Set;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
||||
public interface ViaVersionConfig {
|
||||
|
||||
@ -213,7 +213,7 @@ public interface ViaVersionConfig {
|
||||
*
|
||||
* @return An Integer list
|
||||
*/
|
||||
Set<Integer> getBlockedProtocols();
|
||||
IntSet getBlockedProtocols();
|
||||
|
||||
/**
|
||||
* Get the custom disconnect message
|
||||
|
@ -161,6 +161,10 @@ public class ProtocolVersion {
|
||||
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
|
||||
*/
|
||||
|
@ -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.ProtocolPipeline;
|
||||
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.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
@ -57,7 +58,10 @@ public class BaseProtocol extends SimpleProtocol {
|
||||
// Ensure mapping data has already been loaded
|
||||
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
|
||||
|
@ -52,14 +52,12 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
||||
protocolVersion = ((Long) version.get("protocol").getAsLong()).intValue();
|
||||
}
|
||||
} else {
|
||||
version = new JsonObject();
|
||||
json.getAsJsonObject().add("version", version);
|
||||
json.getAsJsonObject().add("version", version = new JsonObject());
|
||||
}
|
||||
} else {
|
||||
// Format properly
|
||||
json = new JsonObject();
|
||||
version = new JsonObject();
|
||||
json.getAsJsonObject().add("version", version);
|
||||
json.getAsJsonObject().add("version", version = new JsonObject());
|
||||
}
|
||||
|
||||
if (Via.getConfig().isSendSupportedVersions()) { // Send supported versions
|
||||
@ -71,12 +69,13 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
||||
}
|
||||
|
||||
// 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);
|
||||
return;
|
||||
}
|
||||
|
||||
int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
|
||||
int protocol = versionProvider.getServerProtocol(wrapper.user());
|
||||
List<Pair<Integer, Protocol>> protocols = null;
|
||||
|
||||
// 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 (protocolVersion == protocol || protocolVersion == 0) {
|
||||
//Fix ServerListPlus
|
||||
version.addProperty("protocol", info.getProtocolVersion());
|
||||
if (protocolVersion == protocol || protocolVersion == 0) { // Fix ServerListPlus
|
||||
ProtocolVersion prot = ProtocolVersion.getProtocol(info.getProtocolVersion());
|
||||
version.addProperty("protocol", prot.getOriginalId());
|
||||
}
|
||||
} else {
|
||||
// not compatible :(, *plays very sad violin*
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren