daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest May 16th, 2018 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package pl.koxlifeg.proxy.commands;
  2.  
  3. import java.net.InetSocketAddress;
  4. import java.net.Proxy;
  5.  
  6. import org.spacehq.mc.protocol.MinecraftProtocol;
  7. import org.spacehq.mc.protocol.data.SubProtocol;
  8. import org.spacehq.mc.protocol.data.status.ServerStatusInfo;
  9. import org.spacehq.mc.protocol.data.status.handler.ServerInfoHandler;
  10. import org.spacehq.mc.protocol.data.status.handler.ServerPingTimeHandler;
  11. import org.spacehq.packetlib.Client;
  12. import org.spacehq.packetlib.Session;
  13. import org.spacehq.packetlib.tcp.TcpSessionFactory;
  14.  
  15. import pl.koxlifeg.proxy.handlers.ConnectHandler;
  16. import pl.koxlifeg.proxy.utils.ChatUtil;
  17.  
  18. public class Connect
  19. {
  20.     public static void execute(final String[] vargs, final Session s) {
  21.         if (vargs.length == 5 && vargs[4].equalsIgnoreCase("none")) {
  22.             ConnectHandler.users.remove(s);
  23.             final int port = Integer.parseInt(vargs[2]);
  24.             status(s, vargs[1], port);
  25.             ConnectHandler.connect(s, Proxy.NO_PROXY, vargs[3], vargs[1], port);
  26.         }
  27.         if (vargs.length == 7 && vargs[4].equalsIgnoreCase("socks")) {
  28.             ConnectHandler.users.remove(s);
  29.             final int port = Integer.parseInt(vargs[2]);
  30.             final int portsocks = Integer.parseInt(vargs[6]);
  31.             final Proxy psocks = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(vargs[5], portsocks));
  32.             status(s, vargs[1], port);
  33.             ConnectHandler.connect(s, psocks, vargs[3], vargs[1], port);
  34.         }
  35.         if (vargs.length == 7 && vargs[4].equalsIgnoreCase("http")) {
  36.             ConnectHandler.users.remove(s);
  37.             final int port = Integer.parseInt(vargs[2]);
  38.             final int porthttp = Integer.parseInt(vargs[6]);
  39.             final Proxy phttp = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(vargs[5], porthttp));
  40.             status(s, vargs[1], port);
  41.             ConnectHandler.connect(s, phttp, vargs[3], vargs[1], port);
  42.         }
  43.     }
  44.    
  45.     public static void status(final Session s, final String HOST, final int PORT) {
  46.         ChatUtil.sendMsg(s, "&7Pingowanie: &8(&a" + HOST + "&8:&a" + PORT + "&8)");
  47.         final MinecraftProtocol protocol = new MinecraftProtocol(SubProtocol.STATUS);
  48.         final Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(Proxy.NO_PROXY));
  49.         client.getSession().setFlag("auth-proxy", Proxy.NO_PROXY);
  50.         client.getSession().setFlag("server-info-handler", new ServerInfoHandler() {
  51.             @Override
  52.             public void handle(final Session session, final ServerStatusInfo info) {
  53.             }
  54.         });
  55.         client.getSession().setFlag("server-ping-time-handler", new ServerPingTimeHandler() {
  56.             @Override
  57.             public void handle(final Session session, final long pingTime) {
  58.             }
  59.         });
  60.         client.getSession().connect();
  61.         while (client.getSession().isConnected()) {
  62.             try {
  63.                 Thread.sleep(5L);
  64.             }
  65.             catch (InterruptedException e) {
  66.                 e.printStackTrace();
  67.             }
  68.         }
  69.     }
  70. }
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