Skip to content

Commit

Permalink
Maybe fix empty profile issue (#458)
Browse files Browse the repository at this point in the history
Co-authored-by: Camotoy <[email protected]>

(cherry picked from commit f9b427f)
  • Loading branch information
Kas-tle authored and Tim203 committed Oct 13, 2023
1 parent 112eeac commit ec5faf2
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
package org.geysermc.floodgate.spigot.listener;

import com.destroystokyo.paper.event.profile.PreFillProfileEvent;
import com.destroystokyo.paper.profile.PlayerProfile;
import com.destroystokyo.paper.profile.ProfileProperty;
import io.micronaut.context.annotation.Requires;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
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.api.connection.Connection;
import org.geysermc.floodgate.core.api.SimpleFloodgateApi;
import org.geysermc.floodgate.core.listener.McListener;
Expand Down Expand Up @@ -67,4 +70,23 @@ public void onFill(PreFillProfileEvent event) {
properties.add(new ProfileProperty("textures", "", ""));
event.setProperties(properties);
}

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
Connection connection = api.connectionByPlatformIdentifier(player);
if (connection == null || connection.isLinked()) {
return;
}

PlayerProfile profile = player.getPlayerProfile();
if (profile.getProperties().stream().noneMatch(
prop -> "textures".equals(prop.getName()) && prop.getValue().isEmpty()
&& prop.getSignature() != null && prop.getSignature().isEmpty())) {
return;
}

profile.removeProperty("textures");
player.setPlayerProfile(profile);
}
}

0 comments on commit ec5faf2

Please sign in to comment.