If enabled, force first spawn location on tick after join.
Fixes
@@ -6,7 +6,7 @@ package io.github.nucleuspowered.nucleus.modules.spawn.listeners;
import com.google.inject.Inject;
import io.github.nucleuspowered.nucleus.Nucleus;
-import io.github.nucleuspowered.nucleus.Util;
+import io.github.nucleuspowered.nucleus.api.events.NucleusFirstJoinEvent;
import io.github.nucleuspowered.nucleus.dataservices.GeneralService;
import io.github.nucleuspowered.nucleus.internal.ListenerBase;
import io.github.nucleuspowered.nucleus.internal.annotations.ConditionalListener;
@@ -16,7 +16,7 @@ import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.Order;
import org.spongepowered.api.event.filter.Getter;
-import org.spongepowered.api.event.network.ClientConnectionEvent;
+import org.spongepowered.api.scheduler.Task;
import java.util.function.Predicate;
@@ -26,11 +26,9 @@ public class FirstSpawnConditionalListener extends ListenerBase {
@Inject private GeneralService store;
@Listener(order = Order.LATE)
- public void onJoin(ClientConnectionEvent.Join event, @Getter("getTargetEntity") Player player) {
- if (Util.isFirstPlay(player)) {
- // Try to force a subject location.
- store.getFirstSpawn().ifPresent(player::setTransform);
- }
+ public void onJoin(NucleusFirstJoinEvent event, @Getter("getTargetEntity") Player player) {
+ // Try to force a subject location in a tick.
+ Task.builder().execute(() -> store.getFirstSpawn().ifPresent(player::setTransform)).delayTicks(1).submit(plugin);
}
public static class Condition implements Predicate<Nucleus> {
