Skip to content

Commit

Permalink
Ignore fallback Floodgate skin
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Jul 16, 2024
1 parent 55422d1 commit 46cc7fa
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bungeecord/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>GeyserSkinManager</artifactId>
<groupId>com.github.camotoy.geyserskinmanager</groupId>
<version>1.7</version>
<version>1.8</version>
</parent>
<artifactId>bungeecord</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>GeyserSkinManager</artifactId>
<groupId>com.github.camotoy.geyserskinmanager</groupId>
<version>1.7</version>
<version>1.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public final class Constants {
* Used for future-proofing, in case the contents of a plugin message changes.
*/
public static final int SKIN_PLUGIN_MESSAGE_VERSION = 1;

/**
* The Steve skin applied to Floodgate players with no skin.
*/
public static final String FLOODGATE_STEVE_SKIN = "ewogICJ0aW1lc3RhbXAiIDogMTcxNTcxNzM1NTI2MywKICAicHJvZmlsZUlkIiA6ICIyMWUzNjdkNzI1Y2Y0ZTNiYjI2OTJjNGEzMDBhNGRlYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJHZXlzZXJNQyIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zMWY0NzdlYjFhN2JlZWU2MzFjMmNhNjRkMDZmOGY2OGZhOTNhMzM4NmQwNDQ1MmFiMjdmNDNhY2RmMWI2MGNiIgogICAgfQogIH0KfQ";
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.github.camotoy.geyserskinmanager</groupId>
<artifactId>GeyserSkinManager</artifactId>
<packaging>pom</packaging>
<version>1.7</version>
<version>1.8</version>
<modules>
<module>bungeecord</module>
<module>common</module>
Expand Down
2 changes: 1 addition & 1 deletion spigot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>GeyserSkinManager</artifactId>
<groupId>com.github.camotoy.geyserskinmanager</groupId>
<version>1.7</version>
<version>1.8</version>
</parent>

<name>GeyserSkinManager-Spigot</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.github.camotoy.geyserskinmanager.spigot.listener;

import com.destroystokyo.paper.profile.PlayerProfile;
import com.destroystokyo.paper.profile.ProfileProperty;
import com.github.camotoy.geyserskinmanager.common.Constants;
import com.github.camotoy.geyserskinmanager.common.RawSkin;
import com.github.camotoy.geyserskinmanager.spigot.GeyserSkinManager;
import com.github.camotoy.geyserskinmanager.spigot.profile.MinecraftProfileWrapper;
import com.github.camotoy.geyserskinmanager.spigot.profile.PaperProfileWrapper;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;

import java.util.Optional;

public class PaperEventListener extends SpigotPlatformEventListener {
public PaperEventListener(GeyserSkinManager plugin, boolean showSkins) {
super(plugin, showSkins);
Expand All @@ -19,7 +23,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
RawSkin skin = null;
if (this.skinApplier != null) {
PlayerProfile playerProfile = event.getPlayer().getPlayerProfile();
if (!playerProfile.hasTextures()) { // Don't add new textures if the player already has some. This behavior may change in the future.
if (hasNoTextures(playerProfile)) { // Don't add new textures if the player already has some. This behavior may change in the future.
skin = skinRetriever.getBedrockSkin(event.getPlayer().getUniqueId());
if (skin != null) {
MinecraftProfileWrapper profile = new PaperProfileWrapper(playerProfile);
Expand All @@ -35,4 +39,12 @@ public void onPlayerJoin(PlayerJoinEvent event) {
modListener.onBedrockPlayerJoin(event.getPlayer(), skin);
}
}

private boolean hasNoTextures(final PlayerProfile playerProfile) {
final Optional<ProfileProperty> property = playerProfile.getProperties()
.stream()
.filter(aProperty -> aProperty.getName().equals("textures"))
.findFirst();
return property.map(profileProperty -> Constants.FLOODGATE_STEVE_SKIN.equals(profileProperty.getValue())).orElse(true);
}
}
2 changes: 1 addition & 1 deletion velocity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>GeyserSkinManager</artifactId>
<groupId>com.github.camotoy.geyserskinmanager</groupId>
<version>1.7</version>
<version>1.8</version>
</parent>
<artifactId>velocity</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.camotoy.geyserskinmanager.velocity;

import com.github.camotoy.geyserskinmanager.common.Constants;
import com.github.camotoy.geyserskinmanager.common.RawSkin;
import com.github.camotoy.geyserskinmanager.common.SkinEntry;
import com.github.camotoy.geyserskinmanager.common.platform.ProxyPluginMessageSend;
Expand Down Expand Up @@ -37,7 +38,7 @@ public void onServerConnected(ServerPostConnectEvent event) {
boolean shouldApply = true;
if (showSkins) {
for (GameProfile.Property property : event.getPlayer().getGameProfileProperties()) {
if (property.getName().equals("textures") && !property.getValue().isEmpty()) {
if (property.getName().equals("textures") && (!property.getValue().isEmpty() && !property.getValue().equals(Constants.FLOODGATE_STEVE_SKIN))) {
// Don't overwrite existing textures
shouldApply = false;
break;
Expand Down

0 comments on commit 46cc7fa

Please sign in to comment.