Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void respawnEntity() {
- if (!Questing.runnables.contains(Integer.valueOf(respawnTask.getTaskId()))) {
- respawnTask.runTaskTimer(Bukkit.getPluginManager().getPlugin("questing"), 0, respawnTime * 20);
- Questing.runnables.add(Integer.valueOf(respawnTask.getTaskId()));
- }
- }
- private void init() {
- Questing.mobZones.put(area, this);
- respawnTask = new BukkitRunnable(){
- @Override
- public void run() {
- int amount = world.getNearbyEntities(area.clone().expand(3, 10, 3), (mob) -> mob.getType() == mobType).size();
- System.out.println(amount);
- Random random = new Random();
- double x = random.nextInt((int) (area.getMaxX() - area.getMinX())) + area.getMinX();
- double z = random.nextInt((int) (area.getMaxZ() - area.getMinZ())) + area.getMinZ();
- int y = world.getHighestBlockYAt((int) x, (int) z) + 1;
- Location spawnLocation = new Location(world, x, (double) y, z);
- Entity spawnedEntity = world.spawnEntity(spawnLocation, mobType);
- spawnedEntity.getPersistentDataContainer().set(new NamespacedKey(Bukkit.getPluginManager().getPlugin("questing"), quest.getCustomQuestId()), PersistentDataType.INTEGER, 1);
- if (amount + 1 >= amountToKeep) {
- Questing.runnables.remove(Integer.valueOf(this.getTaskId()));
- this.cancel();
- }
- }
- };
- respawnTask.runTaskTimer(Bukkit.getPluginManager().getPlugin("questing"), 0, respawnTime * 20);
- Questing.runnables.add(Integer.valueOf(respawnTask.getTaskId()));
- }
Advertisement
Add Comment
Please, Sign In to add comment