Skip to content

Commit 785854f

Browse files
Remove ItemUtils#setSkullGameProfile
Because both Paper 1.14.4 and 1.15.0 are not up-to-date with the changes of Spigot 1.14.4 (CraftMetaSkull#setProfile exists on Spigot 1.14.4, but not Paper 1.14.4 and 1.15.0), it does not make sense to put this behind inventory-access revisions. Instead, the SkullBuilder will now just check every time whether CraftMetaSkull#setProfile exists.
1 parent be09c86 commit 785854f

File tree

20 files changed

+23
-179
lines changed

20 files changed

+23
-179
lines changed

inventoryaccess/inventory-access-r1/src/main/java/xyz/xenondevs/inventoryaccess/r1/ItemUtilsImpl.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package xyz.xenondevs.inventoryaccess.r1;
22

3-
import com.mojang.authlib.GameProfile;
43
import net.minecraft.server.v1_14_R1.ItemStack;
54
import net.minecraft.server.v1_14_R1.NBTCompressedStreamTools;
65
import net.minecraft.server.v1_14_R1.NBTTagCompound;
@@ -13,16 +12,11 @@
1312
import xyz.xenondevs.inventoryaccess.util.ReflectionUtils;
1413

1514
import java.io.*;
16-
import java.lang.reflect.Field;
1715
import java.util.List;
1816
import java.util.stream.Collectors;
1917

2018
class ItemUtilsImpl implements ItemUtils {
2119

22-
private static final Field CRAFT_META_SKULL_GAME_PROFILE_FIELD = ReflectionUtils.getField(
23-
ReflectionRegistry.CB_CRAFT_META_SKULL_CLASS, true, "profile"
24-
);
25-
2620
@Override
2721
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {
2822
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -94,9 +88,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9488
);
9589
}
9690

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.setFieldValue(CRAFT_META_SKULL_GAME_PROFILE_FIELD, itemMeta, gameProfile);
100-
}
101-
10291
}

inventoryaccess/inventory-access-r10/src/main/java/xyz/xenondevs/inventoryaccess/r10/ItemUtilsImpl.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
import java.util.stream.Collectors;
1919

2020
class ItemUtilsImpl implements ItemUtils {
21-
22-
private static final Method CRAFT_META_SKULL_SET_PROFILE_METHOD = ReflectionUtils.getMethod(
23-
ReflectionRegistry.CB_CRAFT_META_SKULL_CLASS, true, "setProfile", GameProfile.class
24-
);
25-
21+
2622
@Override
2723
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {
2824
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -94,9 +90,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9490
);
9591
}
9692

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.invokeMethod(CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, gameProfile);
100-
}
101-
10293
}

inventoryaccess/inventory-access-r11/src/main/java/xyz/xenondevs/inventoryaccess/r11/ItemUtilsImpl.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
import java.util.stream.Collectors;
1919

2020
class ItemUtilsImpl implements ItemUtils {
21-
22-
private static final Method CRAFT_META_SKULL_SET_PROFILE_METHOD = ReflectionUtils.getMethod(
23-
ReflectionRegistry.CB_CRAFT_META_SKULL_CLASS, true, "setProfile", GameProfile.class
24-
);
25-
21+
2622
@Override
2723
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {
2824
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -94,9 +90,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9490
);
9591
}
9692

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.invokeMethod(CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, gameProfile);
100-
}
101-
10293
}

inventoryaccess/inventory-access-r12/src/main/java/xyz/xenondevs/inventoryaccess/r12/ItemUtilsImpl.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package xyz.xenondevs.inventoryaccess.r12;
22

3-
import com.mojang.authlib.GameProfile;
43
import net.minecraft.nbt.CompoundTag;
54
import net.minecraft.nbt.NbtIo;
65
import net.minecraft.world.item.ItemStack;
@@ -13,16 +12,11 @@
1312
import xyz.xenondevs.inventoryaccess.util.ReflectionUtils;
1413

1514
import java.io.*;
16-
import java.lang.reflect.Method;
1715
import java.util.List;
1816
import java.util.stream.Collectors;
1917

2018
class ItemUtilsImpl implements ItemUtils {
21-
22-
private static final Method CRAFT_META_SKULL_SET_PROFILE_METHOD = ReflectionUtils.getMethod(
23-
ReflectionRegistry.CB_CRAFT_META_SKULL_CLASS, true, "setProfile", GameProfile.class
24-
);
25-
19+
2620
@Override
2721
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {
2822
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -94,9 +88,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9488
);
9589
}
9690

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.invokeMethod(CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, gameProfile);
100-
}
101-
10291
}

inventoryaccess/inventory-access-r13/src/main/java/xyz/xenondevs/inventoryaccess/r13/ItemUtilsImpl.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package xyz.xenondevs.inventoryaccess.r13;
22

3-
import com.mojang.authlib.GameProfile;
43
import net.minecraft.nbt.CompoundTag;
54
import net.minecraft.nbt.NbtIo;
65
import net.minecraft.world.item.ItemStack;
@@ -13,16 +12,11 @@
1312
import xyz.xenondevs.inventoryaccess.util.ReflectionUtils;
1413

1514
import java.io.*;
16-
import java.lang.reflect.Method;
1715
import java.util.List;
1816
import java.util.stream.Collectors;
1917

2018
class ItemUtilsImpl implements ItemUtils {
21-
22-
private static final Method CRAFT_META_SKULL_SET_PROFILE_METHOD = ReflectionUtils.getMethod(
23-
ReflectionRegistry.CB_CRAFT_META_SKULL_CLASS, true, "setProfile", GameProfile.class
24-
);
25-
19+
2620
@Override
2721
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {
2822
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -94,9 +88,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9488
);
9589
}
9690

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.invokeMethod(CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, gameProfile);
100-
}
101-
10291
}

inventoryaccess/inventory-access-r14/src/main/java/xyz/xenondevs/inventoryaccess/r14/ItemUtilsImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9494
);
9595
}
9696

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.invokeMethod(CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, gameProfile);
100-
}
101-
10297
}

inventoryaccess/inventory-access-r15/src/main/java/xyz/xenondevs/inventoryaccess/r15/ItemUtilsImpl.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package xyz.xenondevs.inventoryaccess.r15;
22

3-
import com.mojang.authlib.GameProfile;
43
import net.minecraft.nbt.CompoundTag;
54
import net.minecraft.nbt.NbtIo;
65
import net.minecraft.world.item.ItemStack;
@@ -13,16 +12,11 @@
1312
import xyz.xenondevs.inventoryaccess.util.ReflectionUtils;
1413

1514
import java.io.*;
16-
import java.lang.reflect.Method;
1715
import java.util.List;
1816
import java.util.stream.Collectors;
1917

2018
class ItemUtilsImpl implements ItemUtils {
21-
22-
private static final Method CRAFT_META_SKULL_SET_PROFILE_METHOD = ReflectionUtils.getMethod(
23-
ReflectionRegistry.CB_CRAFT_META_SKULL_CLASS, true, "setProfile", GameProfile.class
24-
);
25-
19+
2620
@Override
2721
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {
2822
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -94,9 +88,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9488
);
9589
}
9690

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.invokeMethod(CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, gameProfile);
100-
}
101-
10291
}

inventoryaccess/inventory-access-r16/src/main/java/xyz/xenondevs/inventoryaccess/r16/ItemUtilsImpl.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package xyz.xenondevs.inventoryaccess.r16;
22

3-
import com.mojang.authlib.GameProfile;
43
import net.minecraft.nbt.CompoundTag;
54
import net.minecraft.nbt.NbtIo;
65
import net.minecraft.world.item.ItemStack;
@@ -13,16 +12,11 @@
1312
import xyz.xenondevs.inventoryaccess.util.ReflectionUtils;
1413

1514
import java.io.*;
16-
import java.lang.reflect.Method;
1715
import java.util.List;
1816
import java.util.stream.Collectors;
1917

2018
class ItemUtilsImpl implements ItemUtils {
21-
22-
private static final Method CRAFT_META_SKULL_SET_PROFILE_METHOD = ReflectionUtils.getMethod(
23-
ReflectionRegistry.CB_CRAFT_META_SKULL_CLASS, true, "setProfile", GameProfile.class
24-
);
25-
19+
2620
@Override
2721
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {
2822
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -94,9 +88,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9488
);
9589
}
9690

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.invokeMethod(CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, gameProfile);
100-
}
101-
10291
}

inventoryaccess/inventory-access-r17/src/main/java/xyz/xenondevs/inventoryaccess/r17/ItemUtilsImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9494
);
9595
}
9696

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.invokeMethod(CRAFT_META_SKULL_SET_PROFILE_METHOD, itemMeta, gameProfile);
100-
}
101-
10297
}

inventoryaccess/inventory-access-r2/src/main/java/xyz/xenondevs/inventoryaccess/r2/ItemUtilsImpl.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package xyz.xenondevs.inventoryaccess.r2;
22

3-
import com.mojang.authlib.GameProfile;
43
import net.minecraft.server.v1_14_R1.ItemStack;
54
import net.minecraft.server.v1_14_R1.NBTCompressedStreamTools;
65
import net.minecraft.server.v1_14_R1.NBTTagCompound;
@@ -13,16 +12,11 @@
1312
import xyz.xenondevs.inventoryaccess.util.ReflectionUtils;
1413

1514
import java.io.*;
16-
import java.lang.reflect.Field;
1715
import java.util.List;
1816
import java.util.stream.Collectors;
1917

2018
class ItemUtilsImpl implements ItemUtils {
2119

22-
private static final Field CRAFT_META_SKULL_GAME_PROFILE_FIELD = ReflectionUtils.getField(
23-
ReflectionRegistry.CB_CRAFT_META_SKULL_CLASS, true, "profile"
24-
);
25-
2620
@Override
2721
public byte[] serializeItemStack(org.bukkit.inventory.@NotNull ItemStack itemStack, boolean compressed) {
2822
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -94,9 +88,4 @@ public void setLore(@NotNull ItemMeta itemMeta, @NotNull List<@NotNull Component
9488
);
9589
}
9690

97-
@Override
98-
public void setSkullGameProfile(@NotNull ItemMeta itemMeta, @NotNull GameProfile gameProfile) {
99-
ReflectionUtils.setFieldValue(CRAFT_META_SKULL_GAME_PROFILE_FIELD, itemMeta, gameProfile);
100-
}
101-
10291
}

0 commit comments

Comments
 (0)