diff --git a/spigot/src/main/java/org/geysermc/floodgate/listener/PaperProfileListener.java b/spigot/src/main/java/org/geysermc/floodgate/listener/PaperProfileListener.java index 5672ead8..29ade2ec 100644 --- a/spigot/src/main/java/org/geysermc/floodgate/listener/PaperProfileListener.java +++ b/spigot/src/main/java/org/geysermc/floodgate/listener/PaperProfileListener.java @@ -26,13 +26,16 @@ package org.geysermc.floodgate.listener; import com.destroystokyo.paper.event.profile.PreFillProfileEvent; +import com.destroystokyo.paper.profile.PlayerProfile; import com.destroystokyo.paper.profile.ProfileProperty; import com.google.inject.Inject; import java.util.HashSet; import java.util.Set; import java.util.UUID; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; import org.geysermc.floodgate.api.SimpleFloodgateApi; import org.geysermc.floodgate.api.player.FloodgatePlayer; @@ -62,4 +65,23 @@ public void onFill(PreFillProfileEvent event) { properties.add(new ProfileProperty("textures", "", "")); event.setProperties(properties); } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + Player bukkitPlayer = event.getPlayer(); + FloodgatePlayer player = api.getPlayer(bukkitPlayer.getUniqueId()); + if (player == null || player.isLinked()) { + return; + } + + PlayerProfile profile = bukkitPlayer.getPlayerProfile(); + if (profile.getProperties().stream().noneMatch( + prop -> "textures".equals(prop.getName()) && prop.getValue().isEmpty() + && prop.getSignature() != null && prop.getSignature().isEmpty())) { + return; + } + + profile.removeProperty("textures"); + bukkitPlayer.setPlayerProfile(profile); + } }