Skip to content

Commit

Permalink
Properly set as modified in setSkinBlob (#2375)
Browse files Browse the repository at this point in the history
  • Loading branch information
tal5 committed Sep 14, 2022
1 parent 1894f81 commit f23a20f
Showing 1 changed file with 26 additions and 24 deletions.
Expand Up @@ -13,23 +13,15 @@
import io.papermc.paper.potion.PotionMix;
import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Nameable;
import org.bukkit.NamespacedKey;
import org.bukkit.*;
import org.bukkit.block.Sign;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.*;
import org.bukkit.potion.PotionBrewer;

import java.util.*;
Expand Down Expand Up @@ -224,19 +216,14 @@ public void setSkin(Player player, String name) {
return;
}
DenizenCore.runOnMainThread(() -> {
for (ProfileProperty property : skinProfile.getProperties()) {
if (property.getName().equals("textures")) {
PlayerProfile playerProfile = player.getPlayerProfile();
playerProfile.setProperty(property);
player.setPlayerProfile(playerProfile);
if (isOwnName) {
modifiedTextures.remove(player.getUniqueId());
}
else {
modifiedTextures.add(player.getUniqueId());
}
return;
}
PlayerProfile playerProfile = player.getPlayerProfile();
playerProfile.setProperty(getProfileProperty(skinProfile, "textures"));
player.setPlayerProfile(playerProfile);
if (isOwnName) {
modifiedTextures.remove(player.getUniqueId());
}
else {
modifiedTextures.add(player.getUniqueId());
}
});
});
Expand All @@ -251,7 +238,22 @@ public void setSkinBlob(Player player, String blob) {
// Note: this API is present on all supported versions, but currently used for 1.19+ only
List<String> split = CoreUtilities.split(blob, ';');
PlayerProfile playerProfile = player.getPlayerProfile();
playerProfile.setProperty(new ProfileProperty("textures", split.get(0), split.size() > 1 ? split.get(1) : null));
ProfileProperty currentTextures = getProfileProperty(playerProfile, "textures");
String value = split.get(0);
String signature = split.size() > 1 ? split.get(1) : null;
if (!value.equals(currentTextures.getValue()) && (signature == null || !signature.equals(currentTextures.getSignature()))) {
modifiedTextures.add(player.getUniqueId());
}
playerProfile.setProperty(new ProfileProperty("textures", value, signature));
player.setPlayerProfile(playerProfile);
}

public ProfileProperty getProfileProperty(PlayerProfile profile, String name) {
for (ProfileProperty property : profile.getProperties()) {
if (property.getName().equals(name)) {
return property;
}
}
return null;
}
}

0 comments on commit f23a20f

Please sign in to comment.