made required changes to search
import java.io.IOException;
import java.net.UnknownHostException;
-import java.util.*;
+import java.util.List;
+import java.util.Set;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.Optional;
+import java.util.Arrays;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@@ -250,15 +255,14 @@ public String search(@CommandParam("searched") String searched) {
*/
private List<String> findBlockMatches(String searchLowercase) {
ResourceUrn curUrn;
- List<String> l=new ArrayList<String>();
+ List<String> outputList=new ArrayList<String>();
for (ResourceUrn urn : assetManager.getAvailableAssets(BlockFamilyDefinition.class)) {
// Current urn for logging purposes to find the broken urn
curUrn = urn;
try{
Optional<BlockFamilyDefinition> def = assetManager.getAsset(urn, BlockFamilyDefinition.class);
if (def.isPresent() && def.get().isLoadable() && matchesSearch(searchLowercase, def.get())) {
- String s = new BlockUri(def.get().getUrn()).toString();
- l.add(s);
+ outputList.add(new BlockUri(def.get().getUrn()).toString());
}
}
// If a prefab is broken , it will throw an exception
@@ -267,10 +271,11 @@ public String search(@CommandParam("searched") String searched) {
console.addMessage("Note : Search may not return results if invalid assets are present");
console.addMessage("Error parsing : "+curUrn.toString());
console.addMessage(e.toString());
- return(EmptyList);
+ // return(EmptyList);
+ continue;
}
}
- return l;
+ return outputList;
}
@@ -538,16 +543,17 @@ public String spawnPrefab(@Sender EntityRef sender, @CommandParam("prefabId") St
} else {
dir.set(Direction.FORWARD.getVector3f());
}
+ Quat4f rotation = Quat4f.shortestArcQuat(Direction.FORWARD.getVector3f(), dir);
- return Assets.getPrefab(prefabName).map(prefab -> {
- LocationComponent loc = prefab.getComponent(LocationComponent.class);
- if (loc != null) {
- entityManager.create(prefab, spawnPos);
+ Optional<Prefab> prefab = Assets.getPrefab(prefabName);
+ if (prefab.isPresent() && prefab.get().getComponent(LocationComponent.class) != null) {
+ entityManager.create(prefab.get(), spawnPos, rotation);
return "Done";
+ } else if (!prefab.isPresent()) {
+ return "Unknown prefab";
} else {
return "Prefab cannot be spawned (no location component)";
}
- }).orElse("Unknown prefab");
}
/**
