From 834d12d14b6caae121a11b83f92c96c737cf7c9f Mon Sep 17 00:00:00 2001 From: Niklas Ehlen Date: Mon, 22 Jul 2024 00:46:38 +0200 Subject: [PATCH] Moved initial nametag refresh to join event because register event is called to early --- .../src/main/java/de/spookly/manager/NametagManager.java | 8 ++++++-- build.gradle | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SpooklyCorePlugin/src/main/java/de/spookly/manager/NametagManager.java b/SpooklyCorePlugin/src/main/java/de/spookly/manager/NametagManager.java index a6a38dc..f058120 100644 --- a/SpooklyCorePlugin/src/main/java/de/spookly/manager/NametagManager.java +++ b/SpooklyCorePlugin/src/main/java/de/spookly/manager/NametagManager.java @@ -13,14 +13,18 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.scoreboard.ScoreboardManager; import org.bukkit.scoreboard.Team; public class NametagManager { public NametagManager() { - Spookly.getServer().getEventExecuter().register(PlayerRegisterEvent.class, event -> { - refreshNameTag(event.getSpooklyPlayer()); + Spookly.getServer().getEventExecuter().register(PlayerJoinEvent.class, event -> { + SpooklyPlayer spPlayer = Spookly.getPlayer(event.getPlayer().getUniqueId()); + if (spPlayer != null) { + refreshNameTag(spPlayer); + } }); } diff --git a/build.gradle b/build.gradle index 52672ce..2b05c1a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ plugins { id 'java' id 'java-library' - id("io.freefair.lombok") version "8.6" + id "io.freefair.lombok" version "8.6" // Check for new versions at https://plugins.gradle.org/plugin/io.papermc.paperweight.userdev id "com.diffplug.spotless" version "6.20.0" - id("io.papermc.paperweight.userdev") version "1.7.1" + id "io.papermc.paperweight.userdev" version "1.7.1" id 'com.github.johnrengelman.shadow' version '8.1.1' id 'maven-publish' }