We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a715bf commit 3529573Copy full SHA for 3529573
engine/modules/entities/src/main/java/com/codingame/gameengine/module/entities/ContainerBasedEntity.java
@@ -47,8 +47,15 @@ public void remove(Entity<?> entity) {
47
*/
48
public void add(Entity<?>... entities) {
49
Stream.of(entities).forEach(entity -> {
50
- if (entity.parent != null) {
51
- throw new IllegalArgumentException();
+ if (entity.getParent().isPresent()) {
+ throw new IllegalArgumentException(
52
+ String.format(
53
+ "Cannot add entity %d to container %d: it is already in container %d",
54
+ entity.getId(),
55
+ getId(),
56
+ entity.getParent().get().getId()
57
+ )
58
+ );
59
}
60
this.entities.add(entity);
61
entity.parent = this;
0 commit comments