Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Update DEBUG to work in APIv2, also fix a few usages to the config API (may need more)
Dieser Commit ist enthalten in:
Ursprung
88ab4e53a7
Commit
bae3599388
@ -1,8 +1,11 @@
|
|||||||
package us.myles.ViaVersion.api.protocol;
|
package us.myles.ViaVersion.api.protocol;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.ViaVersion;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.packets.Direction;
|
import us.myles.ViaVersion.packets.Direction;
|
||||||
|
import us.myles.ViaVersion.packets.PacketType;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.base.BaseProtocol;
|
import us.myles.ViaVersion.protocols.base.BaseProtocol;
|
||||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||||
@ -11,6 +14,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ProtocolPipeline extends Protocol {
|
public class ProtocolPipeline extends Protocol {
|
||||||
LinkedList<Protocol> protocolList;
|
LinkedList<Protocol> protocolList;
|
||||||
@ -45,7 +49,6 @@ public class ProtocolPipeline extends Protocol {
|
|||||||
|
|
||||||
public void add(Protocol protocol) {
|
public void add(Protocol protocol) {
|
||||||
if (protocolList != null) {
|
if (protocolList != null) {
|
||||||
System.out.println("Adding protocol to list!!");
|
|
||||||
protocolList.addLast(protocol);
|
protocolList.addLast(protocol);
|
||||||
protocol.init(userConnection);
|
protocol.init(userConnection);
|
||||||
} else {
|
} else {
|
||||||
@ -55,21 +58,67 @@ public class ProtocolPipeline extends Protocol {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception {
|
public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception {
|
||||||
// System.out.println("--> Packet ID incoming: " + packetWrapper.getId() + " - " + state);
|
int originalID = packetWrapper.getId();
|
||||||
List<Protocol> protocols = new ArrayList<>(protocolList);
|
List<Protocol> protocols = new ArrayList<>(protocolList);
|
||||||
// Other way if outgoing
|
// Other way if outgoing
|
||||||
if (direction == Direction.OUTGOING)
|
if (direction == Direction.OUTGOING)
|
||||||
Collections.reverse(protocols);
|
Collections.reverse(protocols);
|
||||||
|
|
||||||
for (Protocol protocol : protocols) { // Copy to prevent from removal.
|
for (Protocol protocol : protocols) { // Copy to prevent from removal.
|
||||||
System.out.println("Calling " + protocol.getClass().getSimpleName() + " " + direction);
|
|
||||||
protocol.transform(direction, state, packetWrapper);
|
protocol.transform(direction, state, packetWrapper);
|
||||||
// Reset the reader for the packetWrapper (So it can be recycled across packets)
|
// Reset the reader for the packetWrapper (So it can be recycled across packets)
|
||||||
packetWrapper.resetReader();
|
packetWrapper.resetReader();
|
||||||
}
|
}
|
||||||
super.transform(direction, state, packetWrapper);
|
super.transform(direction, state, packetWrapper);
|
||||||
if (packetWrapper.getId() != 37 && packetWrapper.getId() != 32 && packetWrapper.getId() != 52 && packetWrapper.getId() != 21 && packetWrapper.getId() != 59)
|
|
||||||
System.out.println("--> Sending Packet ID: " + packetWrapper.getId() + " " + state + " " + direction);
|
if (ViaVersion.getInstance().isDebug()) {
|
||||||
|
// Debug packet
|
||||||
|
String packet = "UNKNOWN";
|
||||||
|
|
||||||
|
// For 1.8/1.9 server version, eventually we'll probably get an API for this...
|
||||||
|
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.V1_8 &&
|
||||||
|
ProtocolRegistry.SERVER_PROTOCOL <= ProtocolVersion.V1_9_1_PRE2) {
|
||||||
|
|
||||||
|
PacketType type;
|
||||||
|
if (ProtocolRegistry.SERVER_PROTOCOL == ProtocolVersion.V1_8) {
|
||||||
|
if (direction == Direction.INCOMING) {
|
||||||
|
type = PacketType.findNewPacket(state, direction, originalID);
|
||||||
|
} else {
|
||||||
|
type = PacketType.findOldPacket(state, direction, originalID);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (direction == Direction.INCOMING) {
|
||||||
|
type = PacketType.findOldPacket(state, direction, originalID);
|
||||||
|
} else {
|
||||||
|
type = PacketType.findNewPacket(state, direction, originalID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter :) This would be not hard coded too, sorry :(
|
||||||
|
if(type == PacketType.PLAY_CHUNK_DATA) return;
|
||||||
|
if(type == PacketType.PLAY_TIME_UPDATE) return;
|
||||||
|
if(type == PacketType.PLAY_KEEP_ALIVE) return;
|
||||||
|
if(type == PacketType.PLAY_KEEP_ALIVE_REQUEST) return;
|
||||||
|
if(type == PacketType.PLAY_ENTITY_LOOK_MOVE) return;
|
||||||
|
if(type == PacketType.PLAY_ENTITY_LOOK) return;
|
||||||
|
if(type == PacketType.PLAY_ENTITY_RELATIVE_MOVE) return;
|
||||||
|
if(type == PacketType.PLAY_PLAYER_POSITION_LOOK_REQUEST) return;
|
||||||
|
if(type == PacketType.PLAY_PLAYER_LOOK_REQUEST) return;
|
||||||
|
if(type == PacketType.PLAY_PLAYER_POSITION_REQUEST) return;
|
||||||
|
|
||||||
|
packet = type.name();
|
||||||
|
}
|
||||||
|
String name = packet + "[" + userConnection.get(ProtocolInfo.class).getProtocolVersion() + "]";
|
||||||
|
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||||
|
plugin.getLogger().log(Level.INFO, "{0}: {1} {2} -> {3} [{4}]",
|
||||||
|
new Object[]{
|
||||||
|
direction,
|
||||||
|
state,
|
||||||
|
originalID,
|
||||||
|
packetWrapper.getId(),
|
||||||
|
name
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Class<? extends Protocol> pipeClass) {
|
public boolean contains(Class<? extends Protocol> pipeClass) {
|
||||||
|
@ -84,11 +84,11 @@ public class EntityPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||||
if (((ViaVersionPlugin) ViaVersion.getInstance()).isHologramPatch()) {
|
if (ViaVersion.getConfig().isHologramPatch()) {
|
||||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||||
if (tracker.getKnownHolograms().contains(entityID)) {
|
if (tracker.getKnownHolograms().contains(entityID)) {
|
||||||
Double newValue = wrapper.get(Type.DOUBLE, 1);
|
Double newValue = wrapper.get(Type.DOUBLE, 1);
|
||||||
newValue += (32D * ((ViaVersionPlugin) ViaVersion.getInstance()).getHologramYOffset());
|
newValue += (32D * ViaVersion.getConfig().getHologramYOffset());
|
||||||
wrapper.set(Type.DOUBLE, 1, newValue);
|
wrapper.set(Type.DOUBLE, 1, newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class PlayerPackets {
|
|||||||
|
|
||||||
wrapper.passthrough(Type.STRING);
|
wrapper.passthrough(Type.STRING);
|
||||||
|
|
||||||
wrapper.write(Type.STRING, ((ViaVersionPlugin) ViaVersion.getInstance()).isPreventCollision() ? "never" : "");
|
wrapper.write(Type.STRING, ViaVersion.getConfig().isPreventCollision() ? "never" : "");
|
||||||
|
|
||||||
wrapper.passthrough(Type.BYTE);
|
wrapper.passthrough(Type.BYTE);
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ public class WorldPackets {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
if (((ViaVersionPlugin) ViaVersion.getInstance()).isAutoTeam()) {
|
if (ViaVersion.getConfig().isAutoTeam()) {
|
||||||
EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
||||||
entityTracker.setAutoTeam(true);
|
entityTracker.setAutoTeam(true);
|
||||||
entityTracker.sendTeamPacket(true);
|
entityTracker.sendTeamPacket(true);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren