Don’t support older versions if protocol support is installed, fixes #615

This commit is contained in:
Myles 2017-01-30 17:15:47 +00:00
parent 5e437d26d9
commit 0388f340cc
5 changed files with 36 additions and 2 deletions

View File

@ -253,4 +253,9 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
return platformSpecific;
}
@Override
public boolean isOldClientsAllowed() {
return !protocolSupport; // Use protocolsupport for older clients
}
}

View File

@ -155,6 +155,11 @@ public class BungeePlugin extends Plugin implements ViaPlatform, Listener {
return platformSpecific;
}
@Override
public boolean isOldClientsAllowed() {
return true;
}
@EventHandler
public void onQuit(PlayerDisconnectEvent e) {
Via.getManager().removePortedClient(e.getPlayer().getUniqueId());

View File

@ -140,4 +140,12 @@ public interface ViaPlatform<T> {
* @return The json data
*/
JsonObject getDump();
/**
* Get if older clients are allowed to be used using ViaVersion.
* (Only 1.9 on 1.9.2 server is supported by ViaVersion alone)
*
* @return True if allowed
*/
boolean isOldClientsAllowed();
}

View File

@ -72,7 +72,12 @@ public class BaseProtocol extends Protocol {
ProtocolRegistry.SERVER_PROTOCOL = protocolVersion;
int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
List<Pair<Integer, Protocol>> protocols = null;
// Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
if (info.getProtocolVersion() >= protocol || Via.getPlatform().isOldClientsAllowed()) {
protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
}
if (protocols != null) {
if (protocolVersion != 9999) {
@ -163,7 +168,13 @@ public class BaseProtocol extends Protocol {
info.setProtocolVersion(protVer);
// Choose the pipe
int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
List<Pair<Integer, Protocol>> protocols = null;
// Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
if (info.getProtocolVersion() >= protocol || Via.getPlatform().isOldClientsAllowed()) {
protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
}
ProtocolPipeline pipeline = wrapper.user().get(ProtocolInfo.class).getPipeline();
if (protocols != null) {
for (Pair<Integer, Protocol> prot : protocols) {

View File

@ -199,4 +199,9 @@ public class SpongePlugin implements ViaPlatform {
return platformSpecific;
}
@Override
public boolean isOldClientsAllowed() {
return true;
}
}