3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01: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) { public void add(Protocol protocol) {
if (protocolList != null) { if (protocolList != null) {
// Make BaseProtocol be in the last position, so the login packets can be modified by other protocols protocolList.add(protocol);
protocolList.add(protocolList.size() - 1, protocol);
protocol.init(userConnection); 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 { } else {
throw new NullPointerException("Tried to add protocol to early"); throw new NullPointerException("Tried to add protocol to early");
} }

Datei anzeigen

@ -230,4 +230,12 @@ public class ProtocolRegistry {
return rangeProtocol.getValue(); return rangeProtocol.getValue();
throw new IllegalStateException("No Base Protocol for " + serverVersion); 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()); Via.getManager().addPortedClient(wrapper.user());
if (info.getPipeline().pipes().size() == 2 if (info.getPipeline().pipes().size() == 2
&& info.getPipeline().pipes().get(0).getClass() == BaseProtocol1_13.class && info.getPipeline().pipes().get(1).getClass() == BaseProtocol1_13.class
&& info.getPipeline().pipes().get(1).getClass() == BaseProtocol.class) // Only base protocol && info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol
wrapper.user().setActive(false); wrapper.user().setActive(false);
if (Via.getManager().isDebug()) { if (Via.getManager().isDebug()) {

Datei anzeigen

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