mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
Fixed skins not working with player heads
This commit is contained in:
parent
c8b75bc43b
commit
575de786b2
@ -17,6 +17,7 @@ public class ItemStats {
|
||||
public static final ItemStat
|
||||
REVISION_ID = new RevisionID(),
|
||||
MATERIAL = new MaterialStat(),
|
||||
SKULL_TEXTURE = new SkullTextureStat(),
|
||||
ITEM_DAMAGE = new ItemDamage(),
|
||||
CUSTOM_MODEL_DATA = new CustomModelData(),
|
||||
MAX_DURABILITY = new MaximumDurability(),
|
||||
@ -187,7 +188,6 @@ public class ItemStats {
|
||||
DOWNGRADE_ON_DEATH_CHANCE = new DoubleStat("DEATH_DOWNGRADE_CHANCE", Material.SKELETON_SKULL, "Death Downgrade Chance", new String[]{"Probability that an item with &cDowngrade ", "&con Death&7 will be downgraded when the", "player dies. ", "", "Exceeding 100% will for sure downgrade", "one item, and roll again to downgrade", "another (with the excess probability).", "&6The same item wont be downgraded twice."}, new String[]{"!miscellaneous", "!block", "all"}, false),
|
||||
|
||||
// Unique Item Stats
|
||||
SKULL_TEXTURE = new SkullTextureStat(),
|
||||
DYE_COLOR = new DyeColor(),
|
||||
HIDE_DYE = new HideDye(),
|
||||
TRIM_MATERIAL = new TrimMaterialStat(),
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.api.interaction;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
@ -19,9 +20,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSkin extends UseItem {
|
||||
@ -171,14 +172,8 @@ public class ItemSkin extends UseItem {
|
||||
if (volSkin.hasData(ItemStats.SKULL_TEXTURE)
|
||||
&& item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()
|
||||
&& nbtSkin.getItem().getType() == VersionMaterial.PLAYER_HEAD.toMaterial())
|
||||
try {
|
||||
final Field profileField = meta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(meta,
|
||||
((SkullTextureData) volSkin.getData(ItemStats.SKULL_TEXTURE)).getGameProfile());
|
||||
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
|
||||
MMOItems.plugin.getLogger().warning("Could not read skull texture");
|
||||
}
|
||||
MythicLib.plugin.getVersion().getWrapper().setProfile((SkullMeta) meta,
|
||||
((SkullTextureData) volSkin.getData(ItemStats.SKULL_TEXTURE)).getGameProfile());
|
||||
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.api.util.SmartGive;
|
||||
import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
@ -29,9 +29,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -82,15 +82,9 @@ public class CanDeskin extends BooleanStat implements ConsumableItemInteraction
|
||||
((LeatherArmorMeta) targetItemMeta).setColor(((LeatherArmorMeta) originalItemMeta).getColor());
|
||||
|
||||
if (target.hasTag("SkullOwner") && (targetItem.getType() == VersionMaterial.PLAYER_HEAD.toMaterial())
|
||||
&& (originalItem.getType() == VersionMaterial.PLAYER_HEAD.toMaterial())) {
|
||||
try {
|
||||
Field profileField = targetItemMeta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(targetItemMeta, ((SkullTextureData) originalMmoitem.getData(ItemStats.SKULL_TEXTURE)).getGameProfile());
|
||||
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
|
||||
MMOItems.plugin.getLogger().warning("Could not read skull texture");
|
||||
}
|
||||
}
|
||||
&& (originalItem.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()))
|
||||
MythicLib.plugin.getVersion().getWrapper().setProfile((SkullMeta) targetItemMeta,
|
||||
((SkullTextureData) originalMmoitem.getData(ItemStats.SKULL_TEXTURE)).getGameProfile());
|
||||
|
||||
// Update deskined item
|
||||
final ItemStack updated = target.getItem();
|
||||
|
@ -29,8 +29,11 @@ import java.util.UUID;
|
||||
|
||||
public class SkullTextureStat extends ItemStat<SkullTextureData, SkullTextureData> {
|
||||
public SkullTextureStat() {
|
||||
super("SKULL_TEXTURE", VersionMaterial.PLAYER_HEAD.toMaterial(), "Skull Texture", new String[]{"The skull texture &nvalue&7 which can be found on head databases.",
|
||||
"1.20+ users are advised to use the texture&n URL&7 instead."}, new String[]{"all"}, VersionMaterial.PLAYER_HEAD.toMaterial());
|
||||
super("SKULL_TEXTURE", VersionMaterial.PLAYER_HEAD.toMaterial(), "Skull Texture", new String[]{
|
||||
"The skull texture &nvalue&7 which can be found on",
|
||||
"head databases. 1.20+ users can also provide the",
|
||||
"texture URL directly (starting with https://...)."
|
||||
}, new String[]{"all"}, VersionMaterial.PLAYER_HEAD.toMaterial());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user