FuskedLLCC

Untitled

Apr 21st, 2021
885
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ==============================================================IRCClient=============================================================
  2. import io.netty.bootstrap.Bootstrap;
  3. import io.netty.channel.Channel;
  4. import io.netty.channel.ChannelOption;
  5. import io.netty.channel.EventLoopGroup;
  6. import io.netty.channel.nio.NioEventLoopGroup;
  7. import io.netty.channel.socket.nio.NioSocketChannel;
  8. import me.soros.multiping.MultiPing;
  9. import me.soros.multiping.MultiPingMod;
  10. import net.minecraft.client.Minecraft;
  11. import net.minecraftforge.common.MinecraftForge;
  12. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  13. import net.minecraftforge.fml.common.gameevent.TickEvent;
  14.  
  15. import java.io.*;
  16. import java.net.InetAddress;
  17. import java.net.Socket;
  18. import java.util.Scanner;
  19. import java.util.concurrent.LinkedBlockingQueue;
  20.  
  21. public class IRCClient {
  22.     private final String host;
  23.     private final  int port;
  24.     Channel channel = null;
  25.  
  26.     public IRCClient(String host, int port){
  27.         this.host = host;
  28.         this.port = port;
  29.     }
  30.  
  31.     public void run() {
  32.         EventLoopGroup group = new NioEventLoopGroup();
  33.         try {
  34.             Bootstrap bootstrap  = new Bootstrap()
  35.                     .group(group)
  36.                     .channel(NioSocketChannel.class)
  37.                     .handler(new NettyInit());
  38.               channel = bootstrap.connect(host, port).sync().channel();
  39.               BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  40.             while(true){
  41.           //    channel.write(in.readLine() + "\r\n");
  42.             }
  43.         } catch (Exception e) {
  44.             e.printStackTrace();
  45.         } finally {
  46.             group.shutdownGracefully();
  47.         }
  48.  
  49.     }
  50.     public void send(String string) {
  51.         if (channel != null) {
  52.             channel.write(string + "\r\n");
  53.         }
  54.     }
  55. ==============================================================NettyClientHandler=======================================================
  56. import io.netty.channel.ChannelHandlerContext;
  57. import io.netty.channel.SimpleChannelInboundHandler;
  58. import me.soros.multiping.MultiPing;
  59. import me.soros.multiping.MultiPingMod;
  60. import net.minecraft.client.Minecraft;
  61.  
  62. public class NettyClientHandler extends SimpleChannelInboundHandler<String> {
  63.  
  64.  
  65.     public boolean entity;
  66.     public int lTicks = 0;
  67.     String key;
  68.     private int z;
  69.     private String name;
  70.     private String world;
  71.     private String serverName;
  72.     private int x;
  73.     private int y;
  74.  
  75.     @Override
  76.     protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
  77.         System.out.println("Received server message:" + msg);
  78.         parse(msg);
  79.     }
  80.  
  81.     private void parse(String message) {
  82.         String msg = String.valueOf(message);
  83.         if (msg.contains("-")) {
  84.             if (msg.contains("key")) {
  85.                 key = msg.split("-")[1];
  86.             } else if (msg.contains("name")) {
  87.                 name = msg.split("-")[1];
  88.             } else if (msg.contains("world")) {
  89.                 world = msg.split("-")[1];
  90.             } else if (msg.contains("server")) {
  91.                 serverName = msg.split("-")[1];
  92.             } else if (msg.contains("x")) {
  93.                 x = Integer.parseInt(msg.split("-")[1]);
  94.             } else if (msg.contains("y")) {
  95.                 y = Integer.parseInt(msg.split("-")[1]);
  96.             } else if (msg.contains("z")) {
  97.                 z = Integer.parseInt(msg.split("-")[1]);
  98.             } else if (msg.contains("isEntity")) {
  99.                 entity = msg.split("-")[1].equalsIgnoreCase("true");
  100.             } else if (msg.contains("ticks")) {
  101.                 lTicks = Integer.parseInt(msg.split("-")[1]);
  102.             } else if (msg.contains("end")) {
  103.                 if (key.equalsIgnoreCase(MultiPingMod.getKey()) && !name.equalsIgnoreCase(Minecraft.getMinecraft().thePlayer.getName())) {
  104.                     MultiPing m = new MultiPing(name, world, serverName, x, y, z, entity);
  105.                     MultiPingMod.setTime(lTicks);
  106.                     m.render = true;
  107.                     if (MultiPingMod.render.getToRender().containsKey(name)) {
  108.                         MultiPingMod.render.getToRender().get(name).render = false;
  109.                         MultiPingMod.render.getToRender().remove(name);
  110.                     }
  111.                     MultiPingMod.render.addToRender(m);
  112.                 }
  113.             }
  114.         }
  115.     }
  116. }
  117. ==============================================================NettyInit================================================================
  118.  
  119. import io.netty.channel.ChannelInitializer;
  120. import io.netty.channel.ChannelPipeline;
  121. import io.netty.channel.socket.SocketChannel;
  122. import io.netty.handler.codec.DelimiterBasedFrameDecoder;
  123. import io.netty.handler.codec.Delimiters;
  124. import io.netty.handler.codec.string.StringDecoder;
  125. import io.netty.handler.codec.string.StringEncoder;
  126. import io.netty.util.CharsetUtil;
  127.  
  128.     public class NettyInit extends ChannelInitializer<SocketChannel> {
  129.  
  130.             @Override
  131.             protected void initChannel(SocketChannel socketChannel) throws Exception {
  132.                 ChannelPipeline pipeline = socketChannel.pipeline();
  133.                 pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
  134.                 pipeline.addLast("decoder", new StringDecoder());
  135.                 pipeline.addLast("encoder", new StringEncoder());
  136.                 pipeline.addLast("handler", new NettyClientHandler());
  137.  
  138.             }
  139.     }
  140.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×