J3MLoader: enforce MaterialKey requirements based on extension

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

@ -569,10 +569,15 @@ public class J3MLoader implements AssetLoader {
public Object load(AssetInfo info) throws IOException {
this.assetManager = info.getManager();
InputStream in = info.openStream();
try {
key = info.getKey();
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