Now actually update for 1.16.5

This commit is contained in:
SeanOMik 2021-04-04 14:51:04 -05:00
parent e2f530a4dd
commit f6c1426744
No known key found for this signature in database
GPG Key ID: CA09E5BE1F32728A
4 changed files with 35 additions and 16 deletions

View File

@ -95,7 +95,7 @@
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<artifactId>spigot</artifactId>
<version>1.14-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View File

@ -1,11 +1,19 @@
package net.seanomik.energeticstorage;
import de.tr7zw.changeme.nbtapi.NBTCompound;
import de.tr7zw.changeme.nbtapi.NBTGameProfile;
import de.tr7zw.changeme.nbtapi.NBTItem;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
import java.util.UUID;
public enum Skulls {
LeftGreenArrow("LeftGreenArrow", 0, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTRjNDE3NDZhZjU1N2EyNGJlOGEwOTAzNjlhNTkxYWU2M2Q1Y2U5YzRiZjQwNWQzNTQyNDdkODEwYzdjNyJ9fX0=", "5da5509d-136d-4716-bc2d-d04f82058e91"),
@ -21,26 +29,25 @@ public enum Skulls {
this.texture = texture;
this.name = name;
this.uuid = uuid;
item = createSkull(uuid, name);
item = createSkull();
}
private ItemStack createSkull (String url, String name) {
private ItemStack createSkull() {
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
if (url.isEmpty()) return head;
SkullMeta meta = (SkullMeta) head.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
NBTItem headNBT = new NBTItem(head);
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
profile.getProperties().put("textures", new Property("textures", texture));
NBTCompound ownerNBT;
if (version.startsWith("v1_16")) {
ownerNBT = headNBT.addCompound("SkullOwner");
} else {
ownerNBT = headNBT.addCompound("Owner");
try {
Field profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(meta, profile);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
ownerNBT.addCompound("Properties").getCompoundList("textures").addCompound().setString("Value", texture);
ownerNBT.setString("Id", uuid);
head = headNBT.getItem();
head.setItemMeta(meta);
return head;
}

View File

@ -15,7 +15,7 @@ import java.util.List;
import java.util.UUID;
public class ItemConstructor {
private static Material DRIVE_MATERIAL = Material.BLUE_DYE;
private static final Material DRIVE_MATERIAL = Material.BLUE_DYE;
public static ItemStack createSystemBlock() {
ItemStack systemBlock = Skulls.Computer.getItemStack();

View File

@ -1,6 +1,7 @@
package net.seanomik.energeticstorage.utils;
import de.tr7zw.changeme.nbtapi.NBTCompound;
import de.tr7zw.changeme.nbtapi.NBTListCompound;
import org.jetbrains.annotations.Nullable;
import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBTTileEntity;
@ -141,7 +142,18 @@ public class Utils {
ownerNBT = blockNBT.getCompound("Owner");
}
return ownerNBT.getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture());
if (ownerNBT != null && ownerNBT.getCompound("Properties") != null) {
//return ownerNBT.getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture());
for (NBTListCompound list : ownerNBT.getCompound("Properties").getCompoundList("textures")) {
if (list.getString("Value").equals(Skulls.Computer.getTexture())) {
return true;
}
}
return false;
}
return false;
}
public static boolean isItemADrive(ItemStack item) {