Guest User

Untitled

a guest
Aug 30th, 2021
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.47 KB | None | 0 0
  1. public void respawnEntity() {
  2.         if (!Questing.runnables.contains(Integer.valueOf(respawnTask.getTaskId()))) {
  3.             respawnTask.runTaskTimer(Bukkit.getPluginManager().getPlugin("questing"), 0, respawnTime * 20);
  4.             Questing.runnables.add(Integer.valueOf(respawnTask.getTaskId()));
  5.         }
  6.     }
  7.  
  8.  
  9.     private void init() {
  10.         Questing.mobZones.put(area, this);
  11.         respawnTask = new BukkitRunnable(){
  12.  
  13.             @Override
  14.             public void run() {
  15.                 int amount = world.getNearbyEntities(area.clone().expand(3, 10, 3), (mob) -> mob.getType() == mobType).size();
  16.                 System.out.println(amount);
  17.                 Random random = new Random();
  18.                 double x = random.nextInt((int) (area.getMaxX() - area.getMinX())) + area.getMinX();
  19.                 double z = random.nextInt((int) (area.getMaxZ() - area.getMinZ())) + area.getMinZ();
  20.                 int y = world.getHighestBlockYAt((int) x, (int) z) + 1;
  21.  
  22.                 Location spawnLocation = new Location(world, x, (double) y, z);
  23.  
  24.                 Entity spawnedEntity = world.spawnEntity(spawnLocation, mobType);
  25.                 spawnedEntity.getPersistentDataContainer().set(new NamespacedKey(Bukkit.getPluginManager().getPlugin("questing"), quest.getCustomQuestId()), PersistentDataType.INTEGER, 1);
  26.  
  27.                 if (amount + 1 >= amountToKeep) {
  28.                     Questing.runnables.remove(Integer.valueOf(this.getTaskId()));
  29.                     this.cancel();
  30.                 }
  31.             }
  32.         };
  33.  
  34.         respawnTask.runTaskTimer(Bukkit.getPluginManager().getPlugin("questing"), 0, respawnTime * 20);
  35.         Questing.runnables.add(Integer.valueOf(respawnTask.getTaskId()));
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment