Update for 1.16 while still supporting 1.15
This commit is contained in:
parent
aab53b8909
commit
995886672b
14
pom.xml
14
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>net.seanomik</groupId>
|
||||
<artifactId>energeticstorage</artifactId>
|
||||
<version>0.2.2-SNAPSHOT</version>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EnergeticStorage</name>
|
||||
|
@ -40,7 +40,9 @@
|
|||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\EnergeticStorage-MC-v1.15.X-v${project.version}.jar</outputFile>
|
||||
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.14.4_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>-->
|
||||
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>-->
|
||||
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.1_\plugins\EnergeticStorage-MC-v${project.version}.jar</outputFile>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -63,7 +65,7 @@
|
|||
<relocations>
|
||||
<relocation>
|
||||
<pattern>de.tr7zw.changeme.nbtapi</pattern>
|
||||
<shadedPattern>de.tr7zw.nbtapi</shadedPattern>
|
||||
<shadedPattern>de.tr7zw.nbtapi.energeticstorage</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
|
@ -101,19 +103,19 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.tr7zw</groupId>
|
||||
<artifactId>item-nbt-api</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<scope>compile</scope>
|
||||
<!--<scope>compile</scope>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.WesJD.AnvilGUI</groupId>
|
||||
<artifactId>anvilgui</artifactId>
|
||||
<version>ef71db62ecd6e14405eb7891d7d1c58341b9e61e</version>
|
||||
<version>ef71db62ec</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package net.seanomik.energeticstorage.listeners;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTTileEntity;
|
||||
import net.seanomik.energeticstorage.Skulls;
|
||||
import net.seanomik.energeticstorage.files.PlayersFile;
|
||||
import net.seanomik.energeticstorage.objects.ESDrive;
|
||||
import net.seanomik.energeticstorage.objects.ESSystem;
|
||||
|
@ -28,8 +26,7 @@ public class BlockBreakListener implements Listener {
|
|||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
NBTTileEntity blockNBT = new NBTTileEntity(block.getState());
|
||||
if (blockNBT.getCompound("SkullOwner").getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture())) {
|
||||
if (Utils.isBlockASystem(block)) {
|
||||
ESSystem esSystem = Utils.findSystemAtLocation(block.getLocation());
|
||||
|
||||
if (esSystem != null) {
|
||||
|
|
|
@ -14,10 +14,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class BlockPlaceListener implements Listener {
|
||||
|
||||
|
@ -27,9 +24,7 @@ public class BlockPlaceListener implements Listener {
|
|||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
NBTTileEntity blockNBT = new NBTTileEntity(block.getState());
|
||||
|
||||
if (blockNBT.getCompound("SkullOwner").getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture())) {
|
||||
if (Utils.isBlockASystem(block)) {
|
||||
if (PermissionChecks.canCreateSystem(player)) {
|
||||
ESSystem newSystem = new ESSystem(player.getUniqueId(), UUID.randomUUID(), block.getLocation());
|
||||
PlayersFile.savePlayerSystem(newSystem);
|
||||
|
@ -41,7 +36,7 @@ public class BlockPlaceListener implements Listener {
|
|||
|
||||
Reference.ES_SYSTEMS.replace(player.getUniqueId(), playerESSystems);
|
||||
} else {
|
||||
Reference.ES_SYSTEMS.put(player.getUniqueId(), Arrays.asList(newSystem));
|
||||
Reference.ES_SYSTEMS.put(player.getUniqueId(), Collections.singletonList(newSystem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package net.seanomik.energeticstorage.listeners;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTTileEntity;
|
||||
import net.seanomik.energeticstorage.Skulls;
|
||||
import net.seanomik.energeticstorage.objects.ESSystem;
|
||||
import net.seanomik.energeticstorage.utils.PermissionChecks;
|
||||
import net.seanomik.energeticstorage.utils.Reference;
|
||||
|
@ -24,9 +22,7 @@ public class PlayerInteractListener implements Listener {
|
|||
Block block = event.getClickedBlock();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
NBTTileEntity blockNBT = new NBTTileEntity(block.getState());
|
||||
|
||||
if (blockNBT.getCompound("SkullOwner").getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture())) {
|
||||
if (Utils.isBlockASystem(block)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
ESSystem esSystem = Utils.findSystemAtLocation(block.getLocation());
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package net.seanomik.energeticstorage.utils;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTTileEntity;
|
||||
import net.seanomik.energeticstorage.Skulls;
|
||||
import net.seanomik.energeticstorage.objects.ESSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
|
@ -124,4 +127,16 @@ public class Utils {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isBlockASystem(Block block) {
|
||||
NBTTileEntity blockNBT = new NBTTileEntity(block.getState());
|
||||
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
if (version.equals("v1_15_R1")) {
|
||||
return blockNBT.getCompound("Owner").getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture());
|
||||
} else if (version.equals("v1_16_R1")) {
|
||||
return blockNBT.getCompound("SkullOwner").getCompound("Properties").getCompoundList("textures").get(0).getString("Value").equals(Skulls.Computer.getTexture());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue