SHARE
TWEET

Untitled

a guest May 24th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import org.bukkit.Bukkit;
  3. import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.event.EventHandler;
  6. import org.bukkit.event.Listener;
  7. import org.bukkit.event.player.PlayerJoinEvent;
  8. import org.bukkit.event.player.PlayerQuitEvent;
  9. import org.bukkit.plugin.java.JavaPlugin;
  10.  
  11. import io.netty.channel.Channel;
  12. import io.netty.channel.ChannelDuplexHandler;
  13. import io.netty.channel.ChannelHandlerContext;
  14. import io.netty.channel.ChannelPipeline;
  15. import io.netty.channel.ChannelPromise;
  16. import net.minecraft.server.v1_8_R3.PacketPlayOutTabComplete;
  17.  
  18. public class Main extends JavaPlugin implements Listener {
  19.  
  20.     @Override
  21.     public void onEnable() {
  22.  
  23.         Bukkit.getServer().getPluginManager().registerEvents(this, this);
  24.  
  25.     }
  26.  
  27.     @EventHandler
  28.     public void onJoin(PlayerJoinEvent e) {
  29.  
  30.         injectPlayer(e.getPlayer());
  31.  
  32.     }
  33.  
  34.     @EventHandler
  35.     public void onQuit(PlayerQuitEvent e) {
  36.         removePlayer(e.getPlayer());
  37.     }
  38.  
  39.     private void removePlayer(Player player) {
  40.         Channel channel = ((CraftPlayer) player).getHandle().playerConnection.networkManager.channel;
  41.         channel.eventLoop().submit(() -> {
  42.  
  43.             channel.pipeline().remove(player.getName());
  44.  
  45.         });
  46.     }
  47.  
  48.     private void injectPlayer(Player player) {
  49.  
  50.         ChannelDuplexHandler handler = new ChannelDuplexHandler() {
  51.  
  52.             @Override
  53.             public void channelRead(ChannelHandlerContext context, Object packet) throws Exception {
  54.  
  55.                 super.channelRead(context, packet);
  56.  
  57.                 if (packet instanceof PacketPlayOutTabComplete) {
  58.  
  59.                     return;
  60.  
  61.                 }
  62.  
  63.             }
  64.  
  65.             @Override
  66.             public void write(ChannelHandlerContext context, Object packet, ChannelPromise promise) throws Exception {
  67.  
  68.                 super.write(context, packet, promise);
  69.             }
  70.  
  71.         };
  72.  
  73.         ChannelPipeline pipeline = ((CraftPlayer) player).getHandle().playerConnection.networkManager.channel
  74.                 .pipeline();
  75.         pipeline.addBefore("packet_handler", player.getName(), handler);
  76.     }
  77.  
  78. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top