예제 #1
0
  public void start() {
    System.out.println("Arena::onStart " + timedSpawns);
    if (timedSpawns != null && !timedSpawns.isEmpty()) {
      Plugin plugin = BattleArena.getSelf();
      /// Create our Q, with a descending Comparator
      spawnQ =
          new PriorityQueue<NextSpawn>(
              timedSpawns.size(),
              new Comparator<NextSpawn>() {
                public int compare(NextSpawn o1, NextSpawn o2) {
                  return (o1.timeToNext.compareTo(o2.timeToNext));
                }
              });
      /// TeamJoinResult our items into the Q
      ArrayList<NextSpawn> nextspawns = new ArrayList<NextSpawn>();
      for (TimedSpawn is : timedSpawns.values()) {
        //				System.out.println("itemSpawns = " + timedSpawns.size() + " " +
        // is.getFirstSpawnTime()+ "  ts=" + is);
        long tts = is.getFirstSpawnTime();
        if (tts == 0) is.spawn();
        NextSpawn ns = new NextSpawn(is, tts);
        spawnQ.add(ns);
        nextspawns.add(ns);
      }

      timerId =
          plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SpawnNextEvent(0L));
    }
  }