Search in sources :

Example 1 with IllegalParticleDeclarationException

use of io.xol.chunkstories.api.exceptions.content.IllegalParticleDeclarationException in project chunkstories by Hugobros3.

the class ParticlesTypesStore method loadParticlesFile.

private void loadParticlesFile(Asset f) {
    if (f == null)
        return;
    try (BufferedReader reader = new BufferedReader(f.reader())) {
        String line = "";
        while ((line = reader.readLine()) != null) {
            if (line.startsWith("#")) {
            // It's a comment, ignore.
            } else {
                if (line.startsWith("end")) {
                    logger().warn("Syntax error in file : " + f + " : ");
                    continue;
                }
                String[] splitted = line.split(" ");
                if (splitted.length == 2 && splitted[0].startsWith("particle")) {
                    // int id = Integer.parseInt(splitted[2]);
                    String particleName = splitted[1];
                    try {
                        ParticleTypeDefinitionImplementation type = new ParticleTypeDefinitionImplementation(this, particleName, reader);
                        ParticleTypeHandler handler = type.handler();
                        particleTypesByName.put(particleName, handler);
                    // particleTypesById.put(id, handler);
                    } catch (IllegalParticleDeclarationException e) {
                        this.store.getContext().logger().error("Could not load particle type " + particleName + " : \n" + e.getMessage());
                        e.printStackTrace();
                    }
                }
            }
        }
    } catch (IOException e) {
        logger().warn(e.getMessage());
    }
}
Also used : ParticleTypeHandler(io.xol.chunkstories.api.particles.ParticleTypeHandler) BufferedReader(java.io.BufferedReader) IllegalParticleDeclarationException(io.xol.chunkstories.api.exceptions.content.IllegalParticleDeclarationException) IOException(java.io.IOException)

Aggregations

IllegalParticleDeclarationException (io.xol.chunkstories.api.exceptions.content.IllegalParticleDeclarationException)1 ParticleTypeHandler (io.xol.chunkstories.api.particles.ParticleTypeHandler)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1