mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-23 17:08:15 +01:00
Fix PacketWrapper sending and implement Movement Transmitter for Bungee
This commit is contained in:
parent
31c9332e56
commit
10fc8f846d
@ -178,6 +178,11 @@ public class BukkitViaInjector implements ViaInjector {
|
|||||||
return "encoder";
|
return "encoder";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDecoderName() {
|
||||||
|
return "decoder";
|
||||||
|
}
|
||||||
|
|
||||||
public static Object getServerConnection() throws Exception {
|
public static Object getServerConnection() throws Exception {
|
||||||
Class<?> serverClazz = NMSUtil.nms("MinecraftServer");
|
Class<?> serverClazz = NMSUtil.nms("MinecraftServer");
|
||||||
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
|
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
|
||||||
|
@ -116,7 +116,7 @@ public class BungeeConfigAPI implements ViaVersionConfig, ConfigurationProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStimulatePlayerTick() {
|
public boolean isStimulatePlayerTick() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,4 +50,9 @@ public class BungeeViaInjector implements ViaInjector {
|
|||||||
public String getEncoderName() {
|
public String getEncoderName() {
|
||||||
return "via-encoder";
|
return "via-encoder";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDecoderName() {
|
||||||
|
return "via-decoder";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package us.myles.ViaVersion.bungee.platform;
|
package us.myles.ViaVersion.bungee.platform;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
|
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 {
|
public class BungeeViaLoader implements ViaPlatformLoader {
|
||||||
@Override
|
@Override
|
||||||
@ -8,6 +11,6 @@ public class BungeeViaLoader implements ViaPlatformLoader {
|
|||||||
// TODO: Movement Transmitter
|
// TODO: Movement Transmitter
|
||||||
// TODO: Config
|
// TODO: Config
|
||||||
// TODO: Platform specific commands
|
// TODO: Platform specific commands
|
||||||
// TODO: Get rid of bungeecord-proxy just use reflection
|
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -455,19 +455,16 @@ public class PacketWrapper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the current packet to the server.
|
* 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
|
* @throws Exception If it failed to write
|
||||||
*/
|
*/
|
||||||
public void sendToServer() throws Exception {
|
public void sendToServer() throws Exception {
|
||||||
// TODO: Fix for bungee
|
|
||||||
if (!isCancelled()) {
|
if (!isCancelled()) {
|
||||||
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
|
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
|
||||||
Type.VAR_INT.write(output, PacketWrapper.PASSTHROUGH_ID); // Pass through
|
|
||||||
|
|
||||||
writeToBuffer(output);
|
writeToBuffer(output);
|
||||||
|
|
||||||
PipelineUtil.getContextBefore("decompress", user().getChannel().pipeline()).fireChannelRead(output);
|
user().getChannel().pipeline().context(Via.getManager().getInjector().getDecoderName()).fireChannelRead(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,4 +29,11 @@ public interface ViaInjector {
|
|||||||
* @return The name
|
* @return The name
|
||||||
*/
|
*/
|
||||||
String getEncoderName();
|
String getEncoderName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the decoder for then netty pipeline for this platform.
|
||||||
|
*
|
||||||
|
* @return The name
|
||||||
|
*/
|
||||||
|
String getDecoderName();
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ public class PipelineUtil {
|
|||||||
boolean mark = false;
|
boolean mark = false;
|
||||||
for (String s : pipeline.names()) {
|
for (String s : pipeline.names()) {
|
||||||
if (mark) {
|
if (mark) {
|
||||||
|
System.out.println("Context before: " + s);
|
||||||
return pipeline.context(pipeline.get(s));
|
return pipeline.context(pipeline.get(s));
|
||||||
}
|
}
|
||||||
if (s.equalsIgnoreCase(name))
|
if (s.equalsIgnoreCase(name))
|
||||||
|
@ -137,6 +137,11 @@ public class SpongeViaInjector implements ViaInjector {
|
|||||||
return "encoder";
|
return "encoder";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDecoderName() {
|
||||||
|
return "decoder";
|
||||||
|
}
|
||||||
|
|
||||||
public static Object getServerConnection() throws Exception {
|
public static Object getServerConnection() throws Exception {
|
||||||
Class<?> serverClazz = Class.forName("net.minecraft.server.MinecraftServer");
|
Class<?> serverClazz = Class.forName("net.minecraft.server.MinecraftServer");
|
||||||
Object server = getServer();
|
Object server = getServer();
|
||||||
|
Loading…
Reference in New Issue
Block a user