Advertisement
Brord

Destroy() of an instance

Feb 13th, 2013
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.98 KB | None | 0 0
  1. /**
  2.      * Destroys the instance, and removes it from the config "instances.yml"
  3.      */
  4.     public void destroy(){
  5.         instanceFinishEvent event = new instanceFinishEvent(getHomeLocation().getWorld().getChunkAt(chunkX, chunkZ));
  6.         Bukkit.getServer().getPluginManager().callEvent(event);
  7.        
  8.         IDinstance.remove(getID());
  9.         instanceLocation.remove(world + chunkX + chunkZ);
  10.        
  11.         YamlConfiguration instances = YamlConfiguration.loadConfiguration(new File(InstancesBase.plugin.getDataFolder(),"instances.yml"));
  12.         List<String> list = instances.getStringList(type.toString());
  13.         if (list != null){
  14.             if (list.contains(world + ":" + chunkX + ":" + chunkZ)){
  15.                 list.remove(world + ":" + chunkX + ":" + chunkZ);
  16.                
  17.                 instances.set(type.toString(), list);
  18.                
  19.                  try {
  20.                      instances.save(new File(InstancesBase.plugin.getDataFolder(),"instances.yml"));
  21.                  } catch (IOException e) {
  22.                      System.out.print("Unable to save the 'instances.yml'. Is the disk full?");
  23.                  }
  24.             }
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement