Skip to content

Commit

Permalink
Fix SkinGUI (#710)
Browse files Browse the repository at this point in the history
* Better removal of sponge texture properties

* Fix SkinGUI
  • Loading branch information
AlexProgrammerDE committed Oct 29, 2021
1 parent bcb164c commit 9813086
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions bukkit/src/main/java/net/skinsrestorer/bukkit/SkinsGUI.java
Expand Up @@ -24,6 +24,7 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.skinsrestorer.api.bukkit.BukkitHeadAPI;
import net.skinsrestorer.api.property.IProperty;
import net.skinsrestorer.shared.storage.Locale;
import net.skinsrestorer.shared.utils.C;
import net.skinsrestorer.shared.utils.log.SRLogger;
Expand Down Expand Up @@ -51,7 +52,7 @@ public class SkinsGUI extends ItemStack implements Listener {
private final SkinsRestorer plugin;
private final SRLogger log;

public Inventory getGUI(Player player, int page, Map<String, Object> skinsList) {
public Inventory getGUI(Player player, int page, Map<String, IProperty> skinsList) {
Inventory inventory = Bukkit.createInventory(player, 54, C.c(Locale.SKINSMENU_TITLE_NEW).replace("%page", String.valueOf(page)));

ItemStack none = new GuiGlass(GlassType.NONE).getItemStack();
Expand Down Expand Up @@ -118,12 +119,12 @@ public Inventory getGUI(Player player, int page) {
page = 999;
int skinNumber = 36 * page;

Map<String, Object> skinsList = plugin.getSkinStorage().getSkins(skinNumber);
Map<String, IProperty> skinsList = plugin.getSkinStorage().getSkins(skinNumber);
++page; // start counting from 1
return getGUI(player, page, skinsList);
}

private ItemStack createSkull(String name, Object property) {
private ItemStack createSkull(String name, IProperty property) {
ItemStack is = XMaterial.PLAYER_HEAD.parseItem();
SkullMeta sm = (SkullMeta) Objects.requireNonNull(is).getItemMeta();

Expand Down
Expand Up @@ -227,7 +227,7 @@ public void onEnable() {
Map<String, GenericProperty> skinList = convertToObject(msgBytes);

//convert
Map<String, Object> newSkinList = new TreeMap<>();
Map<String, IProperty> newSkinList = new TreeMap<>();

skinList.forEach((name, property) -> newSkinList.put(name, mojangAPI.createProperty(property.getName(), property.getValue(), property.getSignature())));

Expand Down
Expand Up @@ -400,9 +400,9 @@ public void setSkinData(String skinName, IProperty textures) {

// TODO: CUSTOM_GUI
// seems to be that crs order is ignored...
public Map<String, Object> getSkins(int number) {
public Map<String, IProperty> getSkins(int number) {
//Using mysql
Map<String, Object> list = new TreeMap<>();
Map<String, IProperty> list = new TreeMap<>();

if (Config.MYSQL_ENABLED) {
String filterBy = "";
Expand Down Expand Up @@ -453,10 +453,10 @@ public Map<String, Object> getSkins(int number) {
if (Config.CUSTOM_GUI_ONLY) { //Show only Config.CUSTOM_GUI_SKINS in the gui
for (String GuiSkins : Config.CUSTOM_GUI_SKINS) {
if (skinName.toLowerCase().contains(GuiSkins.toLowerCase()))
list.put(skinName.toLowerCase(), getSkinData(skinName, false));
getSkinData(skinName, false).ifPresent(property -> list.put(skinName.toLowerCase(), property));
}
} else {
list.put(skinName.toLowerCase(), getSkinData(skinName, false));
getSkinData(skinName, false).ifPresent(property -> list.put(skinName.toLowerCase(), property));
}
}
i++;
Expand Down
Expand Up @@ -51,7 +51,7 @@ public void updateProfileSkin(GameProfile profile, String skin) throws SkinReque

private void setTexture(IProperty property, Collection<ProfileProperty> oldProperties) {
ProfileProperty newTextures = Sponge.getServer().getGameProfileManager().createProfileProperty("textures", property.getValue(), property.getSignature());
oldProperties.clear();
oldProperties.removeIf(property2 -> property2.getName().equals("textures"));
oldProperties.add(newTextures);
}

Expand Down

0 comments on commit 9813086

Please sign in to comment.