Advertisement
Mrolcraft

Classe Principal

Mar 10th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1.     private Map<String, SpawnWither> withers = new HashMap<>();
  2.  
  3.     public SpawnWither getWither(String witherName){
  4.         return withers.get(witherName);
  5.     }
  6.  
  7.     public void addWither(SpawnWither spawnWither){
  8.         withers.put(spawnWither.getName(), spawnWither);
  9.     }
  10.  
  11.     public void removeWither(SpawnWither spawnWither){
  12.         withers.remove(spawnWither);
  13.         for (Chunk chunk : spawnWither.getLocation().getWorld().getLoadedChunks()) {
  14.             for(Entity entity : chunk.getEntities()){
  15.                 if(entity instanceof Wither){
  16.                     if(entity.getName().equals(spawnWither.getName())){
  17.                         entity.remove();
  18.                     }
  19.                 }
  20.             }
  21.         }
  22.     }
  23.  
  24.     public void deleteAllWithers(){
  25.         withers.clear();
  26.         for(World world : Bukkit.getWorlds()){
  27.             for (Chunk chunk : world.getLoadedChunks()) {
  28.                 for(Entity entity : chunk.getEntities()){
  29.                     if(entity instanceof Wither){
  30.                         if(withers.containsKey(entity.getCustomName())){
  31.                             entity.remove();
  32.                         }
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.     }
  38.    
  39.     //exemple d'utilisation
  40.     private void exemple(){
  41.         addWither(new SpawnWither(new Location(Bukkit.getWorld("world"), 0, 0, 0), "ยง4Team Rouge"));
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement