Small refactor in AbstractClient
The private method findClientEntityRef is only called from createEntity, where we already have a handy reference to the EntityManager, so there is no need to take it from the CoreRegistry.
import org.terasology.network.ClientComponent;
import org.terasology.network.ClientInfoComponent;
import org.terasology.network.ColorComponent;
-import org.terasology.registry.CoreRegistry;
import org.terasology.rendering.nui.Color;
import java.util.HashSet;
@@ -51,8 +50,8 @@ public void disconnect() {
clientEntity.destroy();
}
- private EntityRef findClientEntityRef() {
- for (EntityRef entityRef: CoreRegistry.get(EntityManager.class).getEntitiesWith(ClientInfoComponent.class)) {
+ private EntityRef findClientEntityRef(EntityManager entityManager) {
+ for (EntityRef entityRef: entityManager.getEntitiesWith(ClientInfoComponent.class)) {
ClientInfoComponent clientInfoComponent = entityRef.getComponent(ClientInfoComponent.class);
if (clientInfoComponent.playerId.equals(getId())) {
return entityRef;
@@ -67,7 +66,7 @@ protected void createEntity(String preferredName, Color color, EntityManager ent
// TODO: Send event for clientInfo creation, don't create here.
- EntityRef clientInfo = findClientEntityRef();
+ EntityRef clientInfo = findClientEntityRef(entityManager);
if (!clientInfo.exists()) {
clientInfo = createClientInfoEntity(entityManager);
}
