3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-24 23:30:15 +01:00

Fix PacketWrapper sending and implement Movement Transmitter for Bungee

Dieser Commit ist enthalten in:
Myles 2016-09-29 21:29:58 +01:00
Ursprung 31c9332e56
Commit 10fc8f846d
9 geänderte Dateien mit 64 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -178,6 +178,11 @@ public class BukkitViaInjector implements ViaInjector {
return "encoder";
}
@Override
public String getDecoderName() {
return "decoder";
}
public static Object getServerConnection() throws Exception {
Class<?> serverClazz = NMSUtil.nms("MinecraftServer");
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");

Datei anzeigen

@ -116,7 +116,7 @@ public class BungeeConfigAPI implements ViaVersionConfig, ConfigurationProvider
@Override
public boolean isStimulatePlayerTick() {
return false;
return true;
}
@Override

Datei anzeigen

@ -50,4 +50,9 @@ public class BungeeViaInjector implements ViaInjector {
public String getEncoderName() {
return "via-encoder";
}
@Override
public String getDecoderName() {
return "via-decoder";
}
}

Datei anzeigen

@ -1,6 +1,9 @@
package us.myles.ViaVersion.bungee.platform;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
public class BungeeViaLoader implements ViaPlatformLoader {
@Override
@ -8,6 +11,6 @@ public class BungeeViaLoader implements ViaPlatformLoader {
// TODO: Movement Transmitter
// TODO: Config
// TODO: Platform specific commands
// TODO: Get rid of bungeecord-proxy just use reflection
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
}
}

Datei anzeigen

@ -0,0 +1,34 @@
package us.myles.ViaVersion.bungee.providers;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
public class BungeeMovementTransmitter extends MovementTransmitterProvider {
@Override
public Object getFlyingPacket() {
return null;
}
@Override
public Object getGroundPacket() {
return null;
}
public void sendPlayer(UserConnection userConnection) {
if (userConnection.get(ProtocolInfo.class).getState() == State.PLAY) {
PacketWrapper wrapper = new PacketWrapper(0x03, null, userConnection);
wrapper.write(Type.BOOLEAN, userConnection.get(MovementTracker.class).isGround());
try {
wrapper.sendToServer();
} catch (Exception e) {
e.printStackTrace();
}
// PlayerPackets will increment idle
}
}
}

Datei anzeigen

@ -455,19 +455,16 @@ public class PacketWrapper {
/**
* Send the current packet to the server.
* (Ensure the ID is suitable for the server version)
* (Ensure the ID is suitable for viaversion)
*
* @throws Exception If it failed to write
*/
public void sendToServer() throws Exception {
// TODO: Fix for bungee
if (!isCancelled()) {
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
Type.VAR_INT.write(output, PacketWrapper.PASSTHROUGH_ID); // Pass through
writeToBuffer(output);
PipelineUtil.getContextBefore("decompress", user().getChannel().pipeline()).fireChannelRead(output);
user().getChannel().pipeline().context(Via.getManager().getInjector().getDecoderName()).fireChannelRead(output);
}
}

Datei anzeigen

@ -29,4 +29,11 @@ public interface ViaInjector {
* @return The name
*/
String getEncoderName();
/**
* Get the name of the decoder for then netty pipeline for this platform.
*
* @return The name
*/
String getDecoderName();
}

Datei anzeigen

@ -95,6 +95,7 @@ public class PipelineUtil {
boolean mark = false;
for (String s : pipeline.names()) {
if (mark) {
System.out.println("Context before: " + s);
return pipeline.context(pipeline.get(s));
}
if (s.equalsIgnoreCase(name))

Datei anzeigen

@ -137,6 +137,11 @@ public class SpongeViaInjector implements ViaInjector {
return "encoder";
}
@Override
public String getDecoderName() {
return "decoder";
}
public static Object getServerConnection() throws Exception {
Class<?> serverClazz = Class.forName("net.minecraft.server.MinecraftServer");
Object server = getServer();