Beispiel #1
0
 @Override
 public void spawnEntity(Entity entity) {
   if (entity == null) throw new NullPointerException();
   synchronized (entities) {
     if (!entities.contains(entity)) entities.add(entity);
   }
 }
Beispiel #2
0
 @EventHandler
 public void onPacketProcess(PacketProcessEvent event) {
   if (event.getPacket().getId() != 201) return;
   Packet201PlayerInfo infoPacket = (Packet201PlayerInfo) event.getPacket();
   if (infoPacket.isConnected && !users.contains(infoPacket.playerName)) {
     users.add(infoPacket.playerName);
     if (infoPacket.ping == 1000) {
       if (infoPacket.playerName.equalsIgnoreCase(bot.getSession().getUsername())) return;
     }
   } else if (!infoPacket.isConnected && users.contains(infoPacket.playerName))
     users.remove(infoPacket.playerName);
 }
Beispiel #3
0
 @Override
 public void despawnEntity(Entity entity) {
   if (entity == null) throw new NullPointerException();
   synchronized (entities) {
     entities.remove(entity);
   }
 }
Beispiel #4
0
 public RegularBot(RegularBotControlsUI ui, RegularBotData data) {
   this.ui = ui;
   data.lock();
   this.data = data;
   commands = new ArrayList<Command>();
   commands.addAll(Arrays.asList((Command[]) DefaultCommands.values()));
   status("Waiting.");
   progress(0, false);
   connect();
 }
Beispiel #5
0
  @Override
  public void execute(String[] args) {
    String players = users.toString();
    players = players.substring(1, players.length() - 1);
    List<String> lines = new ArrayList<String>();
    String[] parts = players.split(", ");
    String current = "";
    for (int i = 0; i < parts.length; i++) {
      if (current.length() + parts[i].length() + 2 >= 100) {
        lines.add(current);
        current = parts[i] + ", ";
      } else current += parts[i] + ", ";
    }
    if (!current.isEmpty()) {
      current = current.substring(0, current.length() - 2);
      lines.add(current);
    }

    bot.say("Players:");
    for (String line : lines) bot.say(line);
  }
Beispiel #6
0
 @Override
 public Entity[] getEntities() {
   synchronized (entities) {
     return entities.toArray(new Entity[entities.size()]);
   }
 }