Skip to content

Commit

Permalink
Maybe fix empty profile issue (GeyserMC#458)
Browse files Browse the repository at this point in the history
Co-authored-by: Camotoy <[email protected]>
  • Loading branch information
Kas-tle and Camotoy authored Oct 10, 2023
1 parent 7b88918 commit f9b427f
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}

0 comments on commit f9b427f

Please sign in to comment.