J3MLoader: enforce MaterialKey requirements based on extension

experimental
Kirill Vainer 10 years ago
parent ed4b70bcad
commit aba48495e1
  1. 8
      jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java

@ -573,6 +573,11 @@ public class J3MLoader implements AssetLoader {
InputStream in = info.openStream();
try {
key = info.getKey();
if (key.getExtension().equals("j3m") && !(key instanceof MaterialKey)) {
throw new IOException("Material instances must be loaded via MaterialKey");
} else if (key.getExtension().equals("j3md") && key instanceof MaterialKey) {
throw new IOException("Material definitions must be loaded via AssetKey");
}
loadFromRoot(BlockLanguageParser.parse(in));
} finally {
if (in != null){
@ -581,9 +586,6 @@ public class J3MLoader implements AssetLoader {
}
if (material != null){
if (!(info.getKey() instanceof MaterialKey)){
throw new IOException("Material instances must be loaded via MaterialKey");
}
// material implementation
return material;
}else{

Loading…
Cancel
Save