3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-09-08 22:02:50 +02:00

More BaseProtocol changes

Dieser Commit ist enthalten in:
creeper123123321 2018-07-03 11:19:32 -03:00
Ursprung f81892ea74
Commit 697e883649
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
4 geänderte Dateien mit 20 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -54,9 +54,15 @@ public class ProtocolPipeline extends Protocol {
*/
public void add(Protocol protocol) {
if (protocolList != null) {
// Make BaseProtocol be in the last position, so the login packets can be modified by other protocols
protocolList.add(protocolList.size() - 1, protocol);
protocolList.add(protocol);
protocol.init(userConnection);
// Move base Protocols to the end, so the login packets can be modified by other protocols
List<Protocol> toMove = new ArrayList<>();
for (Protocol p : protocolList)
if (ProtocolRegistry.isBaseProtocol(p))
toMove.add(p);
protocolList.removeAll(toMove);
protocolList.addAll(toMove);
} else {
throw new NullPointerException("Tried to add protocol to early");
}

Datei anzeigen

@ -230,4 +230,12 @@ public class ProtocolRegistry {
return rangeProtocol.getValue();
throw new IllegalStateException("No Base Protocol for " + serverVersion);
}
public static boolean isBaseProtocol(Protocol protocol) {
for (Pair<Range<Integer>, Protocol> p : baseProtocols)
if (p.getValue() == protocol)
return true;
return false;
}
}

Datei anzeigen

@ -131,8 +131,8 @@ public class BaseProtocol1_13 extends Protocol {
Via.getManager().addPortedClient(wrapper.user());
if (info.getPipeline().pipes().size() == 2
&& info.getPipeline().pipes().get(0).getClass() == BaseProtocol1_13.class
&& info.getPipeline().pipes().get(1).getClass() == BaseProtocol.class) // Only base protocol
&& info.getPipeline().pipes().get(1).getClass() == BaseProtocol1_13.class
&& info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol
wrapper.user().setActive(false);
if (Via.getManager().isDebug()) {

Datei anzeigen

@ -131,8 +131,8 @@ public class BaseProtocol1_7 extends Protocol {
Via.getManager().addPortedClient(wrapper.user());
if (info.getPipeline().pipes().size() == 2
&& info.getPipeline().pipes().get(0).getClass() == BaseProtocol1_7.class
&& info.getPipeline().pipes().get(1).getClass() == BaseProtocol.class) // Only base protocol
&& info.getPipeline().pipes().get(1).getClass() == BaseProtocol1_7.class
&& info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol
wrapper.user().setActive(false);
if (Via.getManager().isDebug()) {