Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Merge pull request #1120 from creeper123123321/master
ProtocolVersion#SUPPORTED_VERSIONS, relocate javassist
Dieser Commit ist enthalten in:
Commit
1fd0211725
@ -54,7 +54,7 @@
|
|||||||
<shadedPattern>us.myles.viaversion.libs.gson</shadedPattern>
|
<shadedPattern>us.myles.viaversion.libs.gson</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.javassist</pattern>
|
<pattern>javassist</pattern>
|
||||||
<shadedPattern>us.myles.viaversion.libs.javassist</shadedPattern>
|
<shadedPattern>us.myles.viaversion.libs.javassist</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
|
@ -8,28 +8,24 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
|||||||
import us.myles.ViaVersion.protocols.base.VersionProvider;
|
import us.myles.ViaVersion.protocols.base.VersionProvider;
|
||||||
import us.myles.ViaVersion.velocity.platform.VelocityViaInjector;
|
import us.myles.ViaVersion.velocity.platform.VelocityViaInjector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
import java.util.stream.Collectors;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class VelocityVersionProvider extends VersionProvider {
|
public class VelocityVersionProvider extends VersionProvider {
|
||||||
|
private static final List<Integer> VELOCITY_PROTOCOLS = com.velocitypowered.api.network.ProtocolVersion.SUPPORTED_VERSIONS.stream()
|
||||||
|
.map(com.velocitypowered.api.network.ProtocolVersion::getProtocol)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getServerProtocol(UserConnection user) throws Exception {
|
public int getServerProtocol(UserConnection user) throws Exception {
|
||||||
// TODO Have one constant list forever until restart? (Might limit plugins if they change this)
|
|
||||||
List<Integer> sorted = new ArrayList<>(com.velocitypowered.api.network.ProtocolVersion.ID_TO_PROTOCOL_CONSTANT.keySet());
|
|
||||||
sorted.remove(Integer.valueOf(-1)); // Unknown
|
|
||||||
sorted.remove(Integer.valueOf(-2)); // Legacy
|
|
||||||
Collections.sort(sorted);
|
|
||||||
|
|
||||||
int playerVersion = user.get(ProtocolInfo.class).getProtocolVersion();
|
int playerVersion = user.get(ProtocolInfo.class).getProtocolVersion();
|
||||||
|
|
||||||
// Bungee supports it
|
// Bungee supports it
|
||||||
if (sorted.contains(playerVersion))
|
if (Collections.binarySearch(VELOCITY_PROTOCOLS, playerVersion) >= 0)
|
||||||
return playerVersion;
|
return playerVersion;
|
||||||
|
|
||||||
// Older than bungee supports, get the lowest version
|
// Older than bungee supports, get the lowest version
|
||||||
if (playerVersion < sorted.get(0)) {
|
if (playerVersion < VELOCITY_PROTOCOLS.get(0)) {
|
||||||
return VelocityViaInjector.getLowestSupportedProtocolVersion();
|
return VelocityViaInjector.getLowestSupportedProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +33,7 @@ public class VelocityVersionProvider extends VersionProvider {
|
|||||||
|
|
||||||
// TODO: This needs a better fix, i.e checking ProtocolRegistry to see if it would work.
|
// TODO: This needs a better fix, i.e checking ProtocolRegistry to see if it would work.
|
||||||
// This is more of a workaround for snapshot support by bungee.
|
// This is more of a workaround for snapshot support by bungee.
|
||||||
for (Integer protocol : Lists.reverse(sorted)) {
|
for (Integer protocol : Lists.reverse(VELOCITY_PROTOCOLS)) {
|
||||||
if (playerVersion > protocol && ProtocolVersion.isRegistered(protocol))
|
if (playerVersion > protocol && ProtocolVersion.isRegistered(protocol))
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren