Brord icon

Destroy() of an instance

Brord | PRO | 02/13/13 10:14:00 PM UTC | 0 ⭐ | 390 👁️ | Never ⏰ | []
Java 5 |

0 B

|

None

|

0 👍

/

0 👎

/**
     * Destroys the instance, and removes it from the config "instances.yml"
     */
    public void destroy(){
        instanceFinishEvent event = new instanceFinishEvent(getHomeLocation().getWorld().getChunkAt(chunkX, chunkZ));
        Bukkit.getServer().getPluginManager().callEvent(event);
        
        IDinstance.remove(getID());
        instanceLocation.remove(world + chunkX + chunkZ);
        
        YamlConfiguration instances = YamlConfiguration.loadConfiguration(new File(InstancesBase.plugin.getDataFolder(),"instances.yml"));
        List<String> list = instances.getStringList(type.toString());
        if (list != null){
            if (list.contains(world + ":" + chunkX + ":" + chunkZ)){
                list.remove(world + ":" + chunkX + ":" + chunkZ);
                
                instances.set(type.toString(), list);
                
                 try {
                     instances.save(new File(InstancesBase.plugin.getDataFolder(),"instances.yml"));
                 } catch (IOException e) {
                     System.out.print("Unable to save the 'instances.yml'. Is the disk full?");
                 }
            }
        }
    }

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎