Skip to content

Commit 762c7df

Browse files
committed
Update spawn location handling for Bedrock players and bump Paper version
1 parent b8bd929 commit 762c7df

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencyResolutionManagement {
1111
versionCatalogs {
1212
create("libs") {
1313

14-
version("paper", "1.21.1-R0.1-SNAPSHOT")
14+
version("paper", "1.21.10-R0.1-SNAPSHOT")
1515
version("apacheCommons", "3.17.0")
1616
version("geyser", "2.4.2-SNAPSHOT")
1717

src/main/java/de/theshadowsdust/ultimatespawn/listener/BedrockSpawnLocationListener.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import de.theshadowsdust.ultimatespawn.UltimateSpawnPlugin;
44
import de.theshadowsdust.ultimatespawn.position.SpawnPosition;
55
import de.theshadowsdust.ultimatespawn.position.WrappedLocation;
6+
import io.papermc.paper.event.player.AsyncPlayerSpawnLocationEvent;
67
import org.bukkit.Location;
78
import org.bukkit.entity.Player;
89
import org.bukkit.event.EventHandler;
@@ -25,24 +26,23 @@ public BedrockSpawnLocationListener(UltimateSpawnPlugin plugin) {
2526
}
2627

2728
@EventHandler
28-
public void onPlayerJoin(PlayerSpawnLocationEvent event) {
29-
Player player = event.getPlayer();
30-
if (GeyserApi.api().isBedrockPlayer(event.getPlayer().getUniqueId())) {
29+
public void onPlayerJoin(AsyncPlayerSpawnLocationEvent event) {
30+
if (GeyserApi.api().isBedrockPlayer(event.getConnection().getProfile().getUniqueId())) {
3131
try {
32-
if(!player.hasPlayedBefore() && plugin.getConfigurationService().getConfig().isFirstJoinSpawn()) {
32+
if(event.isNewPlayer() && plugin.getConfigurationService().getConfig().isFirstJoinSpawn()) {
3333
if(getLocation() == null) return;
3434
event.setSpawnLocation(getLocation());
3535
}
3636
else {
3737
if (this.plugin.getConfigurationService().getConfig().isJoinAtSpawn()) {
38-
getLocation();
38+
if(getLocation() == null) return;
39+
event.setSpawnLocation(getLocation());
3940
}
4041
}
4142
} catch (ExecutionException | InterruptedException e) {
4243
this.plugin.getLogger().log(Level.SEVERE, "Cannot set spawn location for Bedrock player", e);
4344
Thread.currentThread().interrupt();
4445
}
45-
player.teleport(event.getSpawnLocation());
4646
}
4747

4848
}

src/main/java/de/theshadowsdust/ultimatespawn/listener/SpawnLocationListener.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import de.theshadowsdust.ultimatespawn.position.SpawnPosition;
55
import de.theshadowsdust.ultimatespawn.position.WrappedLocation;
66
import de.theshadowsdust.ultimatespawn.UltimateSpawnPlugin;
7+
import io.papermc.paper.event.player.AsyncPlayerSpawnLocationEvent;
78
import org.bukkit.Location;
89
import org.bukkit.entity.Player;
910
import org.bukkit.event.EventHandler;
@@ -27,10 +28,9 @@ public SpawnLocationListener(@NotNull UltimateSpawnPlugin plugin) {
2728
}
2829

2930
@EventHandler(priority = EventPriority.HIGHEST)
30-
public void handlePlayerSpawnLocation(PlayerSpawnLocationEvent event) {
31-
Player player = event.getPlayer();
31+
public void handlePlayerSpawnLocation(AsyncPlayerSpawnLocationEvent event) {
3232
try {
33-
if(!player.hasPlayedBefore() && plugin.getConfigurationService().getConfig().isFirstJoinSpawn()) {
33+
if(event.isNewPlayer() && plugin.getConfigurationService().getConfig().isFirstJoinSpawn()) {
3434
if(getLocation() == null) return;
3535
event.setSpawnLocation(getLocation());
3636
}

0 commit comments

Comments
 (0)