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)); } }
@MCCommand( cmds = {"as", "addspawn"}, selection = true, admin = true, min = 2, usage = "/aa addspawn <mob/item/block/spawnGroup> [buffs or effects] [number] [fs=first spawn time] [rt=respawn time] [trigger=<trigger type>]") public boolean arenaAddSpawn(Player sender, String[] args) { Long number = -1L; try { number = Long.parseLong(args[args.length - 1].toString()); } catch (Exception e) { return MessageUtil.sendMessage( sender, "&cYou need to specify an index as the final value. &61-10000"); } if (number == -1) { number = 1L; } if (number <= 0 || number > 10000) { return MessageUtil.sendMessage( sender, "&cYou need to specify an index within the range &61-10000"); } Arena a = aac.getArena(sender); TimedSpawn spawn = parseSpawn(Arrays.copyOfRange(args, 0, args.length - 1)); if (spawn == null) { return MessageUtil.sendMessage(sender, "Couldnt recognize spawn " + args[1]); } Location l = sender.getLocation(); spawn.getSpawn().setLocation(l); a.addTimedSpawn(number, spawn); ac.updateArena(a); BattleArena.saveArenas(); return MessageUtil.sendMessage( sender, "&6" + a.getName() + "&e now has spawn &6" + spawn + "&2 index=&4" + number); }