3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

Fix 1.8R0.1 not working, ensure flying packets are sent from right place in pipeline, should fix #273

Dieser Commit ist enthalten in:
Myles 2016-03-30 16:43:01 +01:00
Ursprung 1872845d2b
Commit 639c9ea8c1
5 geänderte Dateien mit 30 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -1,10 +1,13 @@
package us.myles.ViaVersion; package us.myles.ViaVersion;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
import us.myles.ViaVersion.util.PipelineUtil;
import us.myles.ViaVersion.util.ReflectionUtil; import us.myles.ViaVersion.util.ReflectionUtil;
import java.util.Map; import java.util.Map;
@ -30,7 +33,9 @@ public class ViaIdleThread extends BukkitRunnable {
if (info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) { if (info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket(); long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
if (nextIdleUpdate <= System.currentTimeMillis()) { if (nextIdleUpdate <= System.currentTimeMillis()) {
info.getChannel().pipeline().fireChannelRead(idlePacket); ChannelHandlerContext context = PipelineUtil.getContextBefore("decoder", info.getChannel().pipeline());
context.fireChannelRead(idlePacket);
info.get(MovementTracker.class).incrementIdlePacket(); info.get(MovementTracker.class).incrementIdlePacket();
} }
} }

Datei anzeigen

@ -70,8 +70,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
getLogger().info("ViaVersion " + getDescription().getVersion() + " is now enabled, injecting."); getLogger().info("ViaVersion " + getDescription().getVersion() + " is now enabled, injecting.");
injectPacketHandler(); injectPacketHandler();
if (getConfig().getBoolean("simulate-pt", true))
new ViaIdleThread(portedPlayers).runTaskTimerAsynchronously(this, 1L, 1L); // Updates player's idle status
if (isCheckForUpdates()) if (isCheckForUpdates())
UpdateUtil.sendUpdateMessage(this); UpdateUtil.sendUpdateMessage(this);
@ -359,4 +358,8 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
e.printStackTrace(); e.printStackTrace();
} }
} }
public Map<UUID, UserConnection> getPortedPlayers() {
return portedPlayers;
}
} }

Datei anzeigen

@ -11,6 +11,7 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
import us.myles.ViaVersion.exception.InformativeException; import us.myles.ViaVersion.exception.InformativeException;
import us.myles.ViaVersion.handlers.ViaDecodeHandler; import us.myles.ViaVersion.handlers.ViaDecodeHandler;
import us.myles.ViaVersion.util.PipelineUtil;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -278,15 +279,7 @@ public class PacketWrapper {
writeToBuffer(output); writeToBuffer(output);
boolean mark = false; PipelineUtil.getContextBefore("decompress", user().getChannel().pipeline()).fireChannelRead(output);
for (String s : user().getChannel().pipeline().names()) {
if (mark) {
user().getChannel().pipeline().context(user().getChannel().pipeline().get(s)).fireChannelRead(output);
return;
}
if (s.equalsIgnoreCase("decompress"))
mark = true;
}
} }
} }
} }

Datei anzeigen

@ -5,6 +5,7 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import us.myles.ViaVersion.ViaIdleThread;
import us.myles.ViaVersion.ViaVersionPlugin; 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.ViaVersion;
@ -103,6 +104,8 @@ public class Protocol1_9TO1_8 extends Protocol {
plugin.getLogger().info("Enabling PaperSpigot patch: Fixes block placement."); plugin.getLogger().info("Enabling PaperSpigot patch: Fixes block placement.");
Bukkit.getPluginManager().registerEvents(new PaperPatch(), plugin); Bukkit.getPluginManager().registerEvents(new PaperPatch(), plugin);
} }
if (plugin.getConfig().getBoolean("simulate-pt", true))
new ViaIdleThread(plugin.getPortedPlayers()).runTaskTimerAsynchronously(plugin, 1L, 1L); // Updates player's idle status
} }
@Override @Override

Datei anzeigen

@ -1,7 +1,9 @@
package us.myles.ViaVersion.util; package us.myles.ViaVersion.util;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
@ -57,4 +59,16 @@ public class PipelineUtil {
} }
return false; return false;
} }
public static ChannelHandlerContext getContextBefore(String name, ChannelPipeline pipeline) {
boolean mark = false;
for (String s : pipeline.names()) {
if (mark) {
return pipeline.context(pipeline.get(s));
}
if (s.equalsIgnoreCase(name))
mark = true;
}
return null;
}
} }