Ejemplo n.º 1
0
  @Override
  public void onTick() {
    if (!bot.hasSpawned() || !bot.isConnected()) return;
    if (ticksToGo > 0) {
      ticksToGo--;
      return;
    }

    MainPlayerEntity player = bot.getPlayer();
    if (player == null) return;
    if (firstStart) {
      bot.say("/tpa DarkStorm_");
      ticksToGo = 15;
      firstStart = false;
      return;
    } else if (asdfasdfasdf) {
      bot.say("/warp arena");
      ticksToGo = 200;
      asdfasdfasdf = false;
      return;
    } else if (asdfasdf) {
      bot.say("/pay DarkStorm_ 1000");
      try {
        Thread.sleep(500);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      /*try {
      	PlayerInventory inventory = player.getInventory();
      	for(int i = 0; i < 44; i++) {
      		ItemStack item = inventory.getItemAt(i);
      		if(item != null) {
      			inventory.selectItemAt(i);
      			inventory.dropSelectedItem();
      		}
      	}
      } catch(Exception exception) {}*/
      bot.say("\247bai");
      asdfasdf = false;
      return;
    }
    // connectionHandler.disconnect("");
    // return;
    // } else if("".equals(""))
    // return;
    // if(player.getDistanceTo(spawn) < 7 && player.getZ() < 589.5) {
    // player.setZ(player.getZ() + 0.12);
    // bot.updateMovement();
    // } else
    // canSpam = true;

    // if(player.getDistanceTo(spawn) < 10 && player.getY() < 72) {
    // if(player.getZ() < -37.6)
    // player.setZ(player.getZ() + 0.1);
    // else if(player.getX() < 232.4)
    // player.setX(player.getX() + 0.1);
    // else
    // player.setY(player.getY() + 0.1);
    // bot.updateMovement();
    // } else if(player.getZ() > -38 && player.getZ() < -36.6
    // && player.getX() > 232 && player.getX() < 233) {
    // player.setZ(player.getZ() + 0.1);
    // bot.updateMovement();
    // } else

    // if(player.getDistanceToSquared(spawn) > 49)
    // mode = 3;
    // if(mode == 0)
    // mode = player.getZ() > 295 ? 2 : 1;
    // switch(mode) {
    // case -1:
    // canSpam = true;
    // break;
    // case 1:
    // canSpam = false;
    // if(player.getZ() < 296.3) {
    // player.setZ(player.getZ() + 0.1);
    // bot.updateMovement();
    // } else
    // mode = -1;
    // break;
    // case 2:
    // canSpam = false;
    // if(player.getZ() > 286.6) {
    // player.setZ(player.getZ() - 0.1);
    // bot.updateMovement();
    // } else
    // mode = -1;
    // break;
    // default:
    // connectionHandler.disconnect("Bad location!");
    // break;
    // }

    canSpam = true;
  }
Ejemplo n.º 2
0
  private DarkBotMCSpambot(
      DarkBot darkBot,
      String server,
      String username,
      String password,
      String sessionId,
      String loginProxy,
      String proxy,
      String owner) {
    synchronized (bots) {
      bots.add(this);
      // slotsTaken.incrementAndGet();
      synchronized (slotsTaken) {
        slotsTaken.notifyAll();
      }
    }
    MinecraftBotData.Builder builder = MinecraftBotData.builder();
    // botData.nickname = "";
    // for(int i = 0; i < 10; i++)
    // botData.nickname += alphas[random.nextInt(alphas.length)];
    if (proxy != null && !proxy.isEmpty()) {
      int port = 80;
      ProxyType type = ProxyType.SOCKS;
      if (proxy.contains(":")) {
        String[] parts = proxy.split(":");
        proxy = parts[0];
        port = Integer.parseInt(parts[1]);
        if (parts.length > 2) type = ProxyType.values()[Integer.parseInt(parts[2]) - 1];
      }
      builder.withSocksProxy(new ProxyData(proxy, port, type));
      this.proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(proxy, port));
    }
    if (loginProxy != null && !loginProxy.isEmpty()) {
      int port = 80;
      if (loginProxy.contains(":")) {
        String[] parts = loginProxy.split(":");
        loginProxy = parts[0];
        port = Integer.parseInt(parts[1]);
      }
      builder.withHttpProxy(new ProxyData(loginProxy, port, ProxyType.HTTP));
      this.loginProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(loginProxy, port));
    }
    builder.withUsername(username);
    if (sessionId != null) builder.withSessionId(sessionId);
    else builder.withPassword(password);
    if (server != null && !server.isEmpty()) {
      int port = 25565;
      if (server.contains(":")) {
        String[] parts = server.split(":");
        server = parts[0];
        port = Integer.parseInt(parts[1]);
      }
      builder.withServer(server).withPort(port);
    } else throw new IllegalArgumentException("Unknown server!");

    this.owner = owner;
    MinecraftBotData botData = builder.build();
    System.setProperty("socksProxyHost", "");
    System.setProperty("socksProxyPort", "");
    System.out.println("[" + username + "] Connecting...");
    bot = new MinecraftBot(darkBot, botData);
    bot.setMovementDisabled(true);
    connectionHandler = bot.getConnectionHandler();
    Session session = bot.getSession();
    // System.gc();
    System.out.println("[" + username + "] Done! (" + amountJoined.incrementAndGet() + ")");
    bot.getEventManager().registerListener(this);
    bot.getGameHandler().registerListener(this);

    long lastShoutTime = System.currentTimeMillis();
    while (bot.isConnected()) {
      if (die) {
        connectionHandler.sendPacket(new Packet255KickDisconnect("Goodbye"));
        return;
      }
      try {
        Thread.sleep(3000 + random.nextInt(1000));
      } catch (InterruptedException exception) {
        exception.printStackTrace();
      }
      if (!bot.hasSpawned()) continue;
      connectionHandler.sendPacket(new Packet0KeepAlive(random.nextInt()));
      if (spamMessage == null || !canSpam) continue;
      String message = spamMessage;
      if (message.contains("%skill")) message = message.replace("%skill", skills[nextSkill++]);
      if (nextSkill >= skills.length) nextSkill = 0;
      if (message.contains("%bot")) {
        synchronized (bots) {
          message =
              message.replace(
                  "%bot",
                  bots.get(nextBot > bots.size() ? (nextBot = 0) * 0 : nextBot++)
                      .bot
                      .getSession()
                      .getUsername());
        }
      }
      if (message.contains("%spamlist"))
        message = message.replace("%spamlist", spamList[nextSpamList++]);
      if (nextSpamList >= spamList.length) nextSpamList = 0;
      if (message.contains("%rnd")) {
        int length = 1;
        int index = message.indexOf("%rnd") + "%rnd".length();
        int lastIndex;
        for (lastIndex = index; lastIndex < message.length(); lastIndex++)
          if (Character.isDigit(message.charAt(lastIndex))) lastIndex++;
          else break;
        if (lastIndex > message.length()) lastIndex--;
        try {
          System.out.println(index + "," + lastIndex + "," + message.length());
          length = Integer.parseInt(message.substring(index, lastIndex));
        } catch (Exception exception) {
        }

        String randomChars = "";
        for (int i = 0; i < length; i++) randomChars += alphas[random.nextInt(alphas.length)];
        message = message.replace("%rnd", randomChars);
      }
      if (message.contains("%msg"))
        message = "/msg " + msgChars[nextMsgChar++] + " " + message.replace("%msg", "");
      if (message.contains("%ernd")) {
        message = message.replace("%ernd", "");
        int extraMessageLength = 15 + random.nextInt(6);
        message = message.substring(0, Math.min(100 - extraMessageLength, message.length())) + " [";
        extraMessageLength -= 3;
        for (int i = 0; i < extraMessageLength; i++)
          message += alphas[random.nextInt(alphas.length)];
        message += "]";
      } else message = message.substring(0, Math.min(100, message.length()));
      connectionHandler.sendPacket(new Packet3Chat(message));
    }
    synchronized (bots) {
      bots.remove(this);
    }
    amountJoined.decrementAndGet();
    slotsTaken.decrementAndGet();
    synchronized (slotsTaken) {
      slotsTaken.notifyAll();
    }
  }