Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-09-08 22:02:50 +02: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:
Ursprung
1872845d2b
Commit
639c9ea8c1
@ -1,10 +1,13 @@
|
||||
package us.myles.ViaVersion;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
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.storage.MovementTracker;
|
||||
import us.myles.ViaVersion.util.PipelineUtil;
|
||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||
|
||||
import java.util.Map;
|
||||
@ -30,7 +33,9 @@ public class ViaIdleThread extends BukkitRunnable {
|
||||
if (info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
|
||||
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -70,8 +70,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
|
||||
getLogger().info("ViaVersion " + getDescription().getVersion() + " is now enabled, injecting.");
|
||||
injectPacketHandler();
|
||||
if (getConfig().getBoolean("simulate-pt", true))
|
||||
new ViaIdleThread(portedPlayers).runTaskTimerAsynchronously(this, 1L, 1L); // Updates player's idle status
|
||||
|
||||
|
||||
if (isCheckForUpdates())
|
||||
UpdateUtil.sendUpdateMessage(this);
|
||||
@ -359,4 +358,8 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<UUID, UserConnection> getPortedPlayers() {
|
||||
return portedPlayers;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.TypeConverter;
|
||||
import us.myles.ViaVersion.exception.InformativeException;
|
||||
import us.myles.ViaVersion.handlers.ViaDecodeHandler;
|
||||
import us.myles.ViaVersion.util.PipelineUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -278,15 +279,7 @@ public class PacketWrapper {
|
||||
|
||||
writeToBuffer(output);
|
||||
|
||||
boolean mark = false;
|
||||
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;
|
||||
}
|
||||
PipelineUtil.getContextBefore("decompress", user().getChannel().pipeline()).fireChannelRead(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import us.myles.ViaVersion.ViaIdleThread;
|
||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
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.");
|
||||
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
|
||||
|
@ -1,7 +1,9 @@
|
||||
package us.myles.ViaVersion.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
@ -57,4 +59,16 @@ public class PipelineUtil {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren