mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-27 10:59:13 +00:00
2.2.9
This commit is contained in:
@@ -22,14 +22,13 @@ import com.saicone.rtag.tag.TagBase;
|
||||
import com.saicone.rtag.tag.TagCompound;
|
||||
import com.saicone.rtag.tag.TagList;
|
||||
import net.momirealms.customfishing.bukkit.item.BukkitItemFactory;
|
||||
import net.momirealms.customfishing.bukkit.util.SkullUtils;
|
||||
import net.momirealms.customfishing.common.plugin.CustomFishingPlugin;
|
||||
import net.momirealms.customfishing.common.util.Key;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public class UniversalItemFactory extends BukkitItemFactory {
|
||||
|
||||
@@ -72,7 +71,11 @@ public class UniversalItemFactory extends BukkitItemFactory {
|
||||
if (skullData == null) {
|
||||
item.remove("SkullOwner");
|
||||
} else {
|
||||
item.set(List.of(Map.of("Value", skullData)), "SkullOwner", "Properties", "textures");
|
||||
item.set(UUID.nameUUIDFromBytes(SkullUtils.identifierFromBase64(skullData).getBytes(StandardCharsets.UTF_8)), "SkullOwner", "Id");
|
||||
item.set(
|
||||
List.of(Map.of("Value", skullData)),
|
||||
"SkullOwner", "Properties", "textures"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.bukkit.util;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
public class SkullUtils {
|
||||
|
||||
public static String identifierFromBase64(String base64) {
|
||||
byte[] decodedBytes = Base64.getDecoder().decode(base64);
|
||||
String decodedString = new String(decodedBytes);
|
||||
int urlStartIndex = decodedString.indexOf("\"url\":\"") + 7;
|
||||
int urlEndIndex = decodedString.indexOf("\"", urlStartIndex);
|
||||
String textureUrl = decodedString.substring(urlStartIndex, urlEndIndex);
|
||||
return textureUrl.substring(textureUrl.lastIndexOf('/') + 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user