Fixes #11
This commit is contained in:
parent
37ac1846d5
commit
e20fc16a81
|
@ -6,11 +6,12 @@
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="EnergeticStorage" />
|
<module name="energeticstorage" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel>
|
<bytecodeTargetLevel>
|
||||||
<module name="EnergeticStorage" target="1.8" />
|
<module name="EnergeticStorage" target="1.8" />
|
||||||
|
<module name="energeticstorage" target="1.8" />
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="codemc-repo" />
|
||||||
|
<option name="name" value="codemc-repo" />
|
||||||
|
<option name="url" value="https://repo.codemc.org/repository/maven-public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jitpack.io" />
|
||||||
|
<option name="name" value="jitpack.io" />
|
||||||
|
<option name="url" value="https://jitpack.io" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="sonatype" />
|
||||||
|
<option name="name" value="sonatype" />
|
||||||
|
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="spigotmc-repo" />
|
||||||
|
<option name="name" value="spigotmc-repo" />
|
||||||
|
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
22
pom.xml
22
pom.xml
|
@ -53,7 +53,8 @@
|
||||||
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.2_\plugins\EnergeticStorage-MC-v${project.version}.jar</outputFile>-->
|
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.2_\plugins\EnergeticStorage-MC-v${project.version}.jar</outputFile>-->
|
||||||
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.16.1_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>-->
|
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.16.1_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>-->
|
||||||
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.16.2_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>-->
|
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.16.2_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>-->
|
||||||
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.4_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>
|
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.4_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>-->
|
||||||
|
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.16.4_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
@ -90,19 +91,34 @@
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.14-R0.1-SNAPSHOT</version>
|
<version>1.14-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.tr7zw</groupId>
|
<groupId>de.tr7zw</groupId>
|
||||||
<artifactId>item-nbt-api</artifactId>
|
<artifactId>item-nbt-api</artifactId>
|
||||||
<version>2.6.0</version>
|
<version>2.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.WesJD.AnvilGUI</groupId>
|
<groupId>com.github.WesJD.AnvilGUI</groupId>
|
||||||
<artifactId>anvilgui</artifactId>
|
<artifactId>anvilgui</artifactId>
|
||||||
<version>master-5d0f592c63-1</version>
|
<version>master-5d0f592c63-1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.googlecode.json-simple</groupId>
|
||||||
|
<artifactId>json-simple</artifactId>
|
||||||
|
<version>1.1.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-text</artifactId>
|
||||||
|
<version>1.9</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>13.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
package net.seanomik.energeticstorage;
|
package net.seanomik.energeticstorage;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||||
import com.mojang.authlib.properties.Property;
|
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||||
import net.seanomik.energeticstorage.utils.Utils;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public enum Skulls {
|
public enum Skulls {
|
||||||
|
|
||||||
|
@ -19,30 +15,33 @@ public enum Skulls {
|
||||||
private ItemStack item;
|
private ItemStack item;
|
||||||
private String name;
|
private String name;
|
||||||
private String texture;
|
private String texture;
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
Skulls(String name, int id, String texture, String uuid) {
|
Skulls(String name, int id, String texture, String uuid) {
|
||||||
item = createSkull(texture, name);
|
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.uuid = uuid;
|
||||||
|
item = createSkull(uuid, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack createSkull (String url, String name) {
|
private ItemStack createSkull (String url, String name) {
|
||||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
|
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
|
||||||
if (url.isEmpty()) return head;
|
if (url.isEmpty()) return head;
|
||||||
|
|
||||||
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
|
NBTItem headNBT = new NBTItem(head);
|
||||||
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null);
|
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||||
|
|
||||||
gameProfile.getProperties().put("textures", new Property("textures", url));
|
NBTCompound ownerNBT;
|
||||||
|
if (version.startsWith("v1_16")) {
|
||||||
try {
|
ownerNBT = headNBT.addCompound("SkullOwner");
|
||||||
Field profileField = headMeta.getClass().getDeclaredField("profile");
|
} else {
|
||||||
profileField.setAccessible(true);
|
ownerNBT = headNBT.addCompound("Owner");
|
||||||
profileField.set(headMeta, gameProfile);
|
|
||||||
} catch (IllegalArgumentException | NoSuchFieldException | SecurityException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
head.setItemMeta(headMeta);
|
|
||||||
|
ownerNBT.addCompound("Properties").getCompoundList("textures").addCompound().setString("Value", texture);
|
||||||
|
ownerNBT.setString("Id", uuid);
|
||||||
|
head = headNBT.getItem();
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,11 @@ public class ESGiveCommand implements TabExecutor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
sender.sendMessage(generateCommandUsage(args));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (args[0]) { // Switch on item type
|
switch (args[0]) { // Switch on item type
|
||||||
case "save":
|
case "save":
|
||||||
PlayersFile.savePlayerSystems(Reference.ES_SYSTEMS.get(((Player) sender).getUniqueId()));
|
PlayersFile.savePlayerSystems(Reference.ES_SYSTEMS.get(((Player) sender).getUniqueId()));
|
||||||
|
|
|
@ -240,6 +240,7 @@ public class PlayersFile extends YamlConfiguration {
|
||||||
getConfig().set(systemPath + "drives", null);
|
getConfig().set(systemPath + "drives", null);
|
||||||
|
|
||||||
for (ESDrive drive : esSystem.getESDrives()) {
|
for (ESDrive drive : esSystem.getESDrives()) {
|
||||||
|
if (drive == null) continue;
|
||||||
getConfig().set(systemPath + "drives." + drive.getUUID() + ".size", drive.getSize());
|
getConfig().set(systemPath + "drives." + drive.getUUID() + ".size", drive.getSize());
|
||||||
|
|
||||||
JSONArray itemsJson = new JSONArray();
|
JSONArray itemsJson = new JSONArray();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.seanomik.energeticstorage.gui;
|
package net.seanomik.energeticstorage.gui;
|
||||||
|
|
||||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||||
|
import net.seanomik.energeticstorage.EnergeticStorage;
|
||||||
import net.seanomik.energeticstorage.files.PlayersFile;
|
import net.seanomik.energeticstorage.files.PlayersFile;
|
||||||
import net.seanomik.energeticstorage.objects.ESDrive;
|
import net.seanomik.energeticstorage.objects.ESDrive;
|
||||||
import net.seanomik.energeticstorage.objects.ESSystem;
|
import net.seanomik.energeticstorage.objects.ESSystem;
|
||||||
|
@ -58,7 +59,9 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
||||||
for (int i = 2; i < esSystem.getESDrives().size() + 2; i++) {
|
for (int i = 2; i < esSystem.getESDrives().size() + 2; i++) {
|
||||||
ESDrive drive = esSystem.getESDrives().get(i - 2);
|
ESDrive drive = esSystem.getESDrives().get(i - 2);
|
||||||
|
|
||||||
inv.setItem(i , drive.getDriveItem());
|
if (drive != null) {
|
||||||
|
inv.setItem(i, drive.getDriveItem());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +152,11 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Player player = (Player) event.getPlayer();
|
Player player = (Player) event.getPlayer();
|
||||||
PlayersFile.savePlayerSystem(openSystems.get(player.getUniqueId()));
|
ESSystem openSystem = openSystems.get(player.getUniqueId());
|
||||||
|
// Serialize null drives
|
||||||
|
openSystem.getESDrives().removeIf(Objects::isNull);
|
||||||
|
|
||||||
|
PlayersFile.savePlayerSystem(openSystem);
|
||||||
|
|
||||||
openSystems.remove(player);
|
openSystems.remove(player);
|
||||||
}
|
}
|
||||||
|
@ -219,12 +226,12 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
||||||
|
|
||||||
Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
|
Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
|
||||||
} else if (slot != 1 && slot != 7 && slot != 8) {
|
} else if (slot != 1 && slot != 7 && slot != 8) {
|
||||||
if (Utils.isItemADrive(cursor)) {
|
if (Utils.isItemADrive(clickedItem)) {
|
||||||
event.setCancelled(false);
|
|
||||||
|
|
||||||
List<ESDrive> drives = esSystem.getESDrives();
|
List<ESDrive> drives = esSystem.getESDrives();
|
||||||
drives.remove(slot - 2);
|
drives.set(slot - 2, null);
|
||||||
esSystem.setESDrives(drives);
|
esSystem.setESDrives(drives);
|
||||||
|
|
||||||
|
event.setCancelled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.seanomik.energeticstorage.listeners;
|
package net.seanomik.energeticstorage.listeners;
|
||||||
|
|
||||||
|
import net.seanomik.energeticstorage.EnergeticStorage;
|
||||||
import net.seanomik.energeticstorage.files.PlayersFile;
|
import net.seanomik.energeticstorage.files.PlayersFile;
|
||||||
import net.seanomik.energeticstorage.objects.ESDrive;
|
import net.seanomik.energeticstorage.objects.ESDrive;
|
||||||
import net.seanomik.energeticstorage.objects.ESSystem;
|
import net.seanomik.energeticstorage.objects.ESSystem;
|
||||||
|
@ -7,7 +8,9 @@ import net.seanomik.energeticstorage.utils.ItemConstructor;
|
||||||
import net.seanomik.energeticstorage.utils.PermissionChecks;
|
import net.seanomik.energeticstorage.utils.PermissionChecks;
|
||||||
import net.seanomik.energeticstorage.utils.Reference;
|
import net.seanomik.energeticstorage.utils.Reference;
|
||||||
import net.seanomik.energeticstorage.utils.Utils;
|
import net.seanomik.energeticstorage.utils.Utils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -36,15 +39,19 @@ public class BlockBreakListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the system from cache and storage
|
// Remove the system from cache and storage
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(EnergeticStorage.getPlugin(), () -> {
|
||||||
PlayersFile.removePlayerSystem(player.getUniqueId(), esSystem.getUUID());
|
PlayersFile.removePlayerSystem(player.getUniqueId(), esSystem.getUUID());
|
||||||
|
|
||||||
List<ESSystem> systems = new LinkedList<>(Reference.ES_SYSTEMS.get(player.getUniqueId()));
|
List<ESSystem> systems = new LinkedList<>(Reference.ES_SYSTEMS.get(player.getUniqueId()));
|
||||||
systems.removeIf(esSystem::equals);
|
systems.removeIf(esSystem::equals);
|
||||||
Reference.ES_SYSTEMS.replace(player.getUniqueId(), systems);
|
Reference.ES_SYSTEMS.replace(player.getUniqueId(), systems);
|
||||||
|
});
|
||||||
|
|
||||||
// Drop an ES System
|
// Only drop the system if they're not in creative.
|
||||||
event.setDropItems(false);
|
event.setDropItems(false);
|
||||||
|
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), ItemConstructor.createSystemBlock());
|
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), ItemConstructor.createSystemBlock());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(Reference.PREFIX + ChatColor.RED + "You are not trusted to this system!");
|
player.sendMessage(Reference.PREFIX + ChatColor.RED + "You are not trusted to this system!");
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package net.seanomik.energeticstorage.listeners;
|
package net.seanomik.energeticstorage.listeners;
|
||||||
|
|
||||||
import de.tr7zw.changeme.nbtapi.NBTTileEntity;
|
import de.tr7zw.changeme.nbtapi.NBTTileEntity;
|
||||||
|
import net.seanomik.energeticstorage.EnergeticStorage;
|
||||||
import net.seanomik.energeticstorage.Skulls;
|
import net.seanomik.energeticstorage.Skulls;
|
||||||
import net.seanomik.energeticstorage.files.PlayersFile;
|
import net.seanomik.energeticstorage.files.PlayersFile;
|
||||||
import net.seanomik.energeticstorage.objects.ESSystem;
|
import net.seanomik.energeticstorage.objects.ESSystem;
|
||||||
import net.seanomik.energeticstorage.utils.PermissionChecks;
|
import net.seanomik.energeticstorage.utils.PermissionChecks;
|
||||||
import net.seanomik.energeticstorage.utils.Reference;
|
import net.seanomik.energeticstorage.utils.Reference;
|
||||||
import net.seanomik.energeticstorage.utils.Utils;
|
import net.seanomik.energeticstorage.utils.Utils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -26,6 +28,8 @@ public class BlockPlaceListener implements Listener {
|
||||||
|
|
||||||
if (Utils.isBlockASystem(block)) {
|
if (Utils.isBlockASystem(block)) {
|
||||||
if (PermissionChecks.canCreateSystem(player)) {
|
if (PermissionChecks.canCreateSystem(player)) {
|
||||||
|
// Cache and store the new system on another thread
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(EnergeticStorage.getPlugin(), () -> {
|
||||||
ESSystem newSystem = new ESSystem(player.getUniqueId(), UUID.randomUUID(), block.getLocation());
|
ESSystem newSystem = new ESSystem(player.getUniqueId(), UUID.randomUUID(), block.getLocation());
|
||||||
PlayersFile.savePlayerSystem(newSystem);
|
PlayersFile.savePlayerSystem(newSystem);
|
||||||
|
|
||||||
|
@ -38,6 +42,7 @@ public class BlockPlaceListener implements Listener {
|
||||||
} else {
|
} else {
|
||||||
Reference.ES_SYSTEMS.put(player.getUniqueId(), Collections.singletonList(newSystem));
|
Reference.ES_SYSTEMS.put(player.getUniqueId(), Collections.singletonList(newSystem));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import net.seanomik.energeticstorage.utils.ItemConstructor;
|
||||||
import net.seanomik.energeticstorage.utils.ItemSerialization;
|
import net.seanomik.energeticstorage.utils.ItemSerialization;
|
||||||
import net.seanomik.energeticstorage.utils.Reference;
|
import net.seanomik.energeticstorage.utils.Reference;
|
||||||
import net.seanomik.energeticstorage.utils.Utils;
|
import net.seanomik.energeticstorage.utils.Utils;
|
||||||
|
import org.apache.commons.text.StringEscapeUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.StringEscapeUtils;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package net.seanomik.energeticstorage.utils;
|
package net.seanomik.energeticstorage.utils;
|
||||||
|
|
||||||
|
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||||
import de.tr7zw.changeme.nbtapi.NBTTileEntity;
|
import de.tr7zw.changeme.nbtapi.NBTTileEntity;
|
||||||
import net.seanomik.energeticstorage.Skulls;
|
import net.seanomik.energeticstorage.Skulls;
|
||||||
|
@ -12,7 +14,6 @@ import org.bukkit.block.Block;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
@ -132,13 +133,15 @@ public class Utils {
|
||||||
public static boolean isBlockASystem(Block block) {
|
public static boolean isBlockASystem(Block block) {
|
||||||
NBTTileEntity blockNBT = new NBTTileEntity(block.getState());
|
NBTTileEntity blockNBT = new NBTTileEntity(block.getState());
|
||||||
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||||
if (version.substring(0, 5).equals("v1_15") || version.substring(0, 5).equals("v1_14")) {
|
|
||||||
return blockNBT.getCompound("Owner").getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture());
|
NBTCompound ownerNBT;
|
||||||
} else if (version.substring(0, 5).equals("v1_16")) {
|
if (version.startsWith("v1_16")) {
|
||||||
return blockNBT.getCompound("SkullOwner").getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture());
|
ownerNBT = blockNBT.getCompound("SkullOwner");
|
||||||
|
} else {
|
||||||
|
ownerNBT = blockNBT.getCompound("Owner");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return ownerNBT.getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isItemADrive(ItemStack item) {
|
public static boolean isItemADrive(ItemStack item) {
|
||||||
|
|
Loading…
Reference in New Issue