Skip to content

Commit

Permalink
2.0.1: Do not close entities on non-primary threads (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
KCodeYT authored Jul 31, 2022
1 parent 320d478 commit 2fdc4b7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.kcodeyt</groupId>
<artifactId>Heads</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public int getSkullType() {

@Override
public void close() {
if(!this.server.isPrimaryThread()) {
this.server.getScheduler().scheduleTask(null, this::close);
return;
}

if(this.entitySkull != null) this.entitySkull.close();
super.close();
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/de/kcodeyt/heads/entity/EntitySkull.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ public void despawnFrom(Player player) {
SpawnProvider.despawnFrom(player, this);
}

@Override
public void close() {
if(!this.server.isPrimaryThread()) {
this.server.getScheduler().scheduleTask(null, this::close);
return;
}

super.close();
}

@Override
public void saveNBT() {
this.namedTag = EMPTY_COMPOUND;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/kcodeyt/heads/provider/SpawnProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static void tick(Server server) {
if(allSkulls.isEmpty()) continue;

final List<EntitySkull> sortedSkulls = new ArrayList<>(allSkulls);
sortedSkulls.removeIf(Objects::isNull);
sortedSkulls.sort(Comparator.comparingDouble(e -> e.distanceSquared(player)));

final int maxSkulls = Math.min(50, sortedSkulls.size());
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Heads
version: "2.0.0"
version: "2.0.1"
api: [ "1.0.0" ]
main: de.kcodeyt.heads.Heads

0 comments on commit 2fdc4b7

Please sign in to comment.