diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index 1c65975..6021957 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -4,7 +4,7 @@
net.seanomik
energeticstorage
EnergeticStorage
- 0.1-SNAPSHOT
+ 0.4-SNAPSHOT
clean package
@@ -25,22 +25,6 @@
maven-shade-plugin
3.1.0
-
-
- package
-
- shade
-
-
- D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\EnergeticStorage-MC-v1.15.X-v${project.version}.jar
- false
-
-
-
-
-
- maven-shade-plugin
- 3.2.1
shade
@@ -48,16 +32,16 @@
shade
+
+
+
+ de.tr7zw.changeme.nbtapi
+ de.tr7zw.nbtapi.energeticstorage
+
+
+
-
-
-
- de.tr7zw.changeme.nbtapi
- de.tr7zw.nbtapi
-
-
-
@@ -75,38 +59,16 @@
https://repo.codemc.org/repository/maven-public/
- maven-repository
- file:///${project.basedir}/maven-repository
+ jitpack.io
+ https://jitpack.io
org.spigotmc
- spigot-api
- 1.15.2-R0.1-SNAPSHOT
+ spigot
+ 1.14-R0.1-SNAPSHOT
provided
-
-
- commons-lang
- commons-lang
-
-
- guava
- com.google.guava
-
-
- gson
- com.google.code.gson
-
-
- bungeecord-chat
- net.md-5
-
-
- snakeyaml
- org.yaml
-
-
@@ -114,3 +76,4 @@
UTF-8
+
diff --git a/pom.xml b/pom.xml
index cd0bbf9..9a4b238 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
net.seanomik
energeticstorage
- 0.4-SNAPSHOT
+ 0.4.1-SNAPSHOT
jar
EnergeticStorage
@@ -47,10 +47,12 @@
- D:\Code\java\spigotPlugins\_TEST_SERVER_1.14.4_\plugins\EnergeticStorage-v${project.version}.jar
+
+
+ D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.16.2_\plugins\EnergeticStorage-v${project.version}.jar
@@ -99,7 +101,7 @@
com.github.WesJD.AnvilGUI
anvilgui
- ef71db62ec
+ master-cee0befbaf-1
diff --git a/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java b/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java
index 73576af..c1cbd44 100644
--- a/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java
+++ b/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java
@@ -39,7 +39,6 @@ public final class EnergeticStorage extends JavaPlugin implements Listener {
private void registerListener() {
getServer().getPluginManager().registerEvents(Reference.ES_TERMINAL_GUI, this);
- getServer().getPluginManager().registerEvents(Reference.ES_SYSTEM_GUI, this);
getServer().getPluginManager().registerEvents(Reference.ES_DRIVE_GUI, this);
getServer().getPluginManager().registerEvents(Reference.ES_SYSTEM_SECURITY_GUI, this);
getServer().getPluginManager().registerEvents(new PlayerInteractListener(), this);
diff --git a/src/main/java/net/seanomik/energeticstorage/gui/ESDriveGUI.java b/src/main/java/net/seanomik/energeticstorage/gui/ESDriveGUI.java
index 4e4d1f8..05408ed 100644
--- a/src/main/java/net/seanomik/energeticstorage/gui/ESDriveGUI.java
+++ b/src/main/java/net/seanomik/energeticstorage/gui/ESDriveGUI.java
@@ -180,7 +180,7 @@ public class ESDriveGUI implements InventoryHolder, Listener {
case SWAP:
break;
case SHIFT_IN:
- if (Utils.isItemValid(clickedItem)) {
+ if (Utils.isItemValid(clickedItem) && Utils.isItemADrive(clickedItem)) {
event.setCancelled(true);
// Add the item into the player's inventory
@@ -199,7 +199,7 @@ public class ESDriveGUI implements InventoryHolder, Listener {
break;
case INTO_HALF:
case INTO:
- if (Utils.isItemValid(cursor)) {
+ if (Utils.isItemValid(cursor) && Utils.isItemADrive(cursor)) {
NBTItem clickedNBT = new NBTItem(cursor);
if (clickedNBT.hasKey("ES_Drive") && clickedNBT.getBoolean("ES_Drive")) {
@@ -214,17 +214,18 @@ public class ESDriveGUI implements InventoryHolder, Listener {
case SHIFT_OUT:
case OUT_HALF:
case OUT:
- if (slot == 0) {
+ if (slot == 0) { // Back button.
player.closeInventory();
- Reference.ES_SYSTEM_GUI.initializeItems(player, esSystem);
- Reference.ES_SYSTEM_GUI.openInventory(player, esSystem);
+ Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
} else if (slot != 1 && slot != 7 && slot != 8) {
- event.setCancelled(false);
+ if (Utils.isItemADrive(cursor)) {
+ event.setCancelled(false);
- List drives = esSystem.getESDrives();
- drives.remove(slot - 2);
- esSystem.setESDrives(drives);
+ List drives = esSystem.getESDrives();
+ drives.remove(slot - 2);
+ esSystem.setESDrives(drives);
+ }
}
break;
case INVENTORY_CLICK:
diff --git a/src/main/java/net/seanomik/energeticstorage/gui/ESSystemGUI.java b/src/main/java/net/seanomik/energeticstorage/gui/ESSystemGUI.java
deleted file mode 100644
index 979fa55..0000000
--- a/src/main/java/net/seanomik/energeticstorage/gui/ESSystemGUI.java
+++ /dev/null
@@ -1,218 +0,0 @@
-package net.seanomik.energeticstorage.gui;
-
-import net.seanomik.energeticstorage.files.PlayersFile;
-import net.seanomik.energeticstorage.objects.ESDrive;
-import net.seanomik.energeticstorage.objects.ESSystem;
-import net.seanomik.energeticstorage.utils.Reference;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.InventoryClickEvent;
-import org.bukkit.event.inventory.InventoryCloseEvent;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-
-import java.util.*;
-
-public class ESSystemGUI implements InventoryHolder, Listener {
- private final Inventory inv;
- private final String title = "ES System";
-
- private Map openSystems = new HashMap<>();
-
- public ESSystemGUI() {
- inv = Bukkit.createInventory(this, 9, title);
- }
-
- @Override
- public Inventory getInventory() {
- return inv;
- }
-
- // You can call this whenever you want to put the items in
- public void initializeItems(Player player, ESSystem openSystem) {
- for (int i = 0; i < inv.getSize(); i++) {
- inv.setItem(i, createGuiItem(Material.BLACK_STAINED_GLASS_PANE, ""));
- }
-
- // Store the players open system
- if (openSystems.containsKey(player)) {
- openSystems.replace(player, openSystem);
- } else {
- openSystems.put(player, openSystem);
- }
-
- int maxSpace = 0;
- int filledSpace = 0;
- int filledTypes = 0;
- for (ESDrive drive : openSystem.getESDrives()) {
- maxSpace += drive.getSize();
- filledSpace += drive.getFilledSpace();
- filledTypes += drive.getFilledTypes();
- }
-
- // Get color of items text
- ChatColor spaceColor = ChatColor.GREEN;
- if (filledSpace >= maxSpace * 0.8) {
- spaceColor = ChatColor.RED;
- } else if (filledSpace >= maxSpace * 0.5) {
- spaceColor = ChatColor.YELLOW;
- }
-
- // Get color of types text
- ChatColor itemsColor = ChatColor.GREEN;
- if (filledTypes >= Reference.MAX_DRIVE_TYPES * 0.8) {
- itemsColor = ChatColor.RED;
- } else if (filledTypes >= Reference.MAX_DRIVE_TYPES * 0.5) {
- itemsColor = ChatColor.YELLOW;
- }
-
- List lore = new ArrayList<>();
- lore.add(ChatColor.BLUE + "Filled Items: " + spaceColor + filledSpace + ChatColor.BLUE + "/" + ChatColor.GREEN + maxSpace);
- lore.add(ChatColor.BLUE + "Filled Types: " + itemsColor + filledTypes + ChatColor.BLUE + "/" + ChatColor.GREEN + Reference.MAX_DRIVE_TYPES);
- inv.setItem(5, createGuiItem(Material.GLASS_PANE, "Drives", lore));
- inv.setItem(4, createGuiItem(Material.IRON_BARS, "Security"));
- inv.setItem(3, createGuiItem(Material.CHEST, "Terminal"));
- }
-
- private ItemStack createGuiItem(Material material, String name, List description) {
- ItemStack item = new ItemStack(material, 1);
- ItemMeta meta = item.getItemMeta();
- meta.setDisplayName(name);
- meta.setLore(description);
- item.setItemMeta(meta);
-
- return item;
- }
-
- private ItemStack createGuiItem(Material material, List description) {
- ItemStack item = new ItemStack(material, 1);
- ItemMeta meta = item.getItemMeta();
- meta.setLore(description);
- item.setItemMeta(meta);
-
- return item;
- }
-
- private ItemStack createGuiItem(Material material, String name) {
- ItemStack item = new ItemStack(material, 1);
- ItemMeta meta = item.getItemMeta();
- meta.setDisplayName(name);
- item.setItemMeta(meta);
-
- return item;
- }
-
- // You can open the inventory with this
- public void openInventory(Player p, ESSystem esSystem) {
- if (openSystems.containsKey(p)) {
- openSystems.replace(p, esSystem);
- } else {
- openSystems.put(p, esSystem);
- }
-
- p.openInventory(inv);
- }
-
- private enum ClickType {
- NONE,
- SWAP,
- SWAP_RIGHT_CLICK,
- INTO,
- INTO_HALF,
- OUT,
- OUT_HALF,
- SHIFT_OUT,
- SHIFT_IN,
- INVENTORY_CLICK
- }
-
- private ClickType findClickType(InventoryClickEvent event) {
- Inventory inventory = event.getClickedInventory();
-
- if (inventory == null || inventory.getHolder() == null || inventory.getHolder() != this) {
- // Check for a shift click or bottom inventory click.
- if (event.getView().getTitle().equals(title)) {
- return (event.isShiftClick()) ? ClickType.SHIFT_IN : ClickType.INVENTORY_CLICK;
- }
-
- return ClickType.NONE;
- }
-
- ItemStack clickedItem = event.getCurrentItem();
- ItemStack cursor = event.getCursor();
-
- if ((clickedItem == null || clickedItem.getType() == Material.AIR) && (cursor == null || cursor.getType() == Material.AIR)) {
- return ClickType.NONE;
- } else if ( (clickedItem == null || clickedItem.getType() == Material.AIR) && (cursor != null || cursor.getType() != Material.AIR) ) {
- return (event.isLeftClick()) ? ClickType.INTO : ClickType.INTO_HALF;
- } else if (cursor == null || cursor.getType() == Material.AIR) {
- return (event.isShiftClick()) ? ClickType.SHIFT_OUT : (event.isLeftClick()) ? ClickType.OUT : ClickType.OUT_HALF;
- }
-
- return (event.isLeftClick()) ? ClickType.SWAP : ClickType.SWAP_RIGHT_CLICK;
- }
-
- // Remove cached player data
- @EventHandler
- public void onInventoryClose(InventoryCloseEvent event) {
- Inventory inventory = event.getInventory();
-
- if (inventory == null || inventory.getHolder() == null || inventory.getHolder() != this) {
- return;
- } else {
- Player player = (Player) event.getPlayer();
- openSystems.remove(player);
- }
- }
-
- // Check for clicks on items
- @EventHandler
- public void onInventoryClick(InventoryClickEvent event) {
- ClickType clickType = findClickType(event);
-
- if (clickType != ClickType.NONE) {
- event.setCancelled(true);
-
- Player player = (Player) event.getWhoClicked();
- ItemStack clickedItem = event.getCurrentItem(); // Will be valid if clicks an item (i.e. taking an item from the inventory)
- ItemStack cursor = event.getCursor(); // Will be valid if an item is put into the inventory
- int slot = event.getSlot();
- ESSystem esSystem = openSystems.get(player);
-
- switch (clickType) {
- case SHIFT_IN:
- break;
- case SWAP_RIGHT_CLICK:
- break;
- case SWAP:
- break;
- case INTO_HALF:
- break;
- case INTO:
- break;
- case OUT_HALF:
- break;
- case OUT:
- if (slot == 3) {
- Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
- } else if (slot == 4) {
- Reference.ES_SYSTEM_SECURITY_GUI.openInventory(player, esSystem);
- } else if (slot == 5) {
- Reference.ES_DRIVE_GUI.openInventory(player, esSystem);
- }
- break;
- case SHIFT_OUT:
- break;
- case INVENTORY_CLICK:
- event.setCancelled(false);
- break;
- }
- }
- }
-}
diff --git a/src/main/java/net/seanomik/energeticstorage/gui/ESSystemSecurityGUI.java b/src/main/java/net/seanomik/energeticstorage/gui/ESSystemSecurityGUI.java
index e4ec304..c17b4a2 100644
--- a/src/main/java/net/seanomik/energeticstorage/gui/ESSystemSecurityGUI.java
+++ b/src/main/java/net/seanomik/energeticstorage/gui/ESSystemSecurityGUI.java
@@ -48,6 +48,7 @@ public class ESSystemSecurityGUI implements InventoryHolder, Listener {
inv.setItem(i, createGuiItem(Material.BLACK_STAINED_GLASS_PANE, ""));
}
+ inv.setItem(0, createGuiItem(Material.PAPER, "Back"));
inv.setItem(3, createGuiItem(Material.LIME_CONCRETE, "Trust player"));
inv.setItem(4, createGuiItem(Material.RED_CONCRETE, "Un-Trust player"));
if (openSystem.isPublic()) {
@@ -281,7 +282,9 @@ public class ESSystemSecurityGUI implements InventoryHolder, Listener {
}
} else {
// At main menu
- if (slot == 3) { // Add player
+ if (slot == 0) {
+ Reference.ES_TERMINAL_GUI.openInventory(player, openSystem);
+ } else if (slot == 3) { // Add player
new AnvilGUI.Builder()
.onComplete((plr, text) -> {
if (text != null && !text.isEmpty()) {
diff --git a/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java b/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java
index 82e5993..d7dcbae 100644
--- a/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java
+++ b/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java
@@ -2,6 +2,7 @@ package net.seanomik.energeticstorage.gui;
import net.seanomik.energeticstorage.EnergeticStorage;
import net.seanomik.energeticstorage.files.PlayersFile;
+import net.seanomik.energeticstorage.objects.ESDrive;
import net.seanomik.energeticstorage.objects.ESSystem;
import net.seanomik.energeticstorage.utils.Reference;
import net.seanomik.energeticstorage.utils.Utils;
@@ -131,6 +132,43 @@ public class ESTerminalGUI implements InventoryHolder, Listener {
} else {
inv.clear(i);
}
+
+
+ inv.setItem(45, createGuiItem(Material.IRON_BARS, "Security"));
+
+ // Create the lore for the drives
+ int maxSpace = 0;
+ int filledSpace = 0;
+ int filledTypes = 0;
+ for (ESDrive drive : openSystem.getESDrives()) {
+ maxSpace += drive.getSize();
+ filledSpace += drive.getFilledSpace();
+ filledTypes += drive.getFilledTypes();
+ }
+
+ // Get color of items text
+ ChatColor spaceColor = ChatColor.GREEN;
+ if (filledSpace >= maxSpace * 0.8) {
+ spaceColor = ChatColor.RED;
+ } else if (filledSpace >= maxSpace * 0.5) {
+ spaceColor = ChatColor.YELLOW;
+ }
+
+ // Max drive type count for each drive
+ int maxTypes = openSystem.getESDrives().size() * Reference.MAX_DRIVE_TYPES;
+
+ // Get color of types text
+ ChatColor itemsColor = ChatColor.GREEN;
+ if (filledTypes >= maxTypes * 0.8) {
+ itemsColor = ChatColor.RED;
+ } else if (filledTypes >= maxTypes * 0.5) {
+ itemsColor = ChatColor.YELLOW;
+ }
+
+ List lore = new ArrayList<>();
+ lore.add(ChatColor.BLUE + "Filled Items: " + spaceColor + filledSpace + ChatColor.BLUE + "/" + ChatColor.GREEN + maxSpace);
+ lore.add(ChatColor.BLUE + "Filled Types: " + itemsColor + filledTypes + ChatColor.BLUE + "/" + ChatColor.GREEN + maxTypes);
+ inv.setItem(46, createGuiItem(Material.CHEST, "Drives", lore));
}
}
@@ -143,6 +181,16 @@ public class ESTerminalGUI implements InventoryHolder, Listener {
return item;
}
+ private ItemStack createGuiItem(Material material, String name, List lore) {
+ ItemStack item = new ItemStack(material, 1);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(name);
+ meta.setLore(lore);
+ item.setItemMeta(meta);
+
+ return item;
+ }
+
private enum ClickType {
NONE,
SWAP,
@@ -278,7 +326,7 @@ public class ESTerminalGUI implements InventoryHolder, Listener {
.title("Search Terminal.")
.plugin(EnergeticStorage.getPlugin())
.open(player);
- } else if (slot == 50) {
+ } else if (slot == 50) { // Next page
Map items = openSystem.getAllItems();
if (items.size() > (pageIndex + 1) * 28 ) {
@@ -286,6 +334,10 @@ public class ESTerminalGUI implements InventoryHolder, Listener {
openPages.replace(player.getUniqueId(), pageIndex);
initializeItems(player, openSystem);
}
+ } else if (slot == 45) { // Security
+ Reference.ES_SYSTEM_SECURITY_GUI.openInventory(player, openSystem);
+ } else if (slot == 46) { // Drives
+ Reference.ES_DRIVE_GUI.openInventory(player, openSystem);
} else {
switch (clickType) {
case SHIFT_IN:
diff --git a/src/main/java/net/seanomik/energeticstorage/listeners/PlayerInteractListener.java b/src/main/java/net/seanomik/energeticstorage/listeners/PlayerInteractListener.java
index f6231f1..eaf05e6 100644
--- a/src/main/java/net/seanomik/energeticstorage/listeners/PlayerInteractListener.java
+++ b/src/main/java/net/seanomik/energeticstorage/listeners/PlayerInteractListener.java
@@ -28,8 +28,7 @@ public class PlayerInteractListener implements Listener {
ESSystem esSystem = Utils.findSystemAtLocation(block.getLocation());
if (esSystem != null) {
if (esSystem.isPlayerTrusted(player) || esSystem.isPublic() || esSystem.getOwner().equals(player.getUniqueId()) || PermissionChecks.canOpenUntrustedSystem(player)) {
- Reference.ES_SYSTEM_GUI.initializeItems(player, esSystem);
- Reference.ES_SYSTEM_GUI.openInventory(player, esSystem);
+ Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
} else {
player.sendMessage(Reference.PREFIX + ChatColor.RED + "You are not trusted to this system!");
}
diff --git a/src/main/java/net/seanomik/energeticstorage/utils/Reference.java b/src/main/java/net/seanomik/energeticstorage/utils/Reference.java
index e06c261..dcc7a04 100644
--- a/src/main/java/net/seanomik/energeticstorage/utils/Reference.java
+++ b/src/main/java/net/seanomik/energeticstorage/utils/Reference.java
@@ -2,7 +2,6 @@ package net.seanomik.energeticstorage.utils;
import net.seanomik.energeticstorage.files.ConfigFile;
import net.seanomik.energeticstorage.gui.ESDriveGUI;
-import net.seanomik.energeticstorage.gui.ESSystemGUI;
import net.seanomik.energeticstorage.gui.ESSystemSecurityGUI;
import net.seanomik.energeticstorage.gui.ESTerminalGUI;
import net.seanomik.energeticstorage.objects.ESSystem;
@@ -15,7 +14,6 @@ public class Reference {
public static String PREFIX = ChatColor.AQUA + "" + ChatColor.ITALIC + "[Energetic Storage] " + ChatColor.RESET;
public static ESTerminalGUI ES_TERMINAL_GUI = new ESTerminalGUI();
- public static ESSystemGUI ES_SYSTEM_GUI = new ESSystemGUI();
public static ESDriveGUI ES_DRIVE_GUI = new ESDriveGUI();
public static ESSystemSecurityGUI ES_SYSTEM_SECURITY_GUI = new ESSystemSecurityGUI();
diff --git a/src/main/java/net/seanomik/energeticstorage/utils/Utils.java b/src/main/java/net/seanomik/energeticstorage/utils/Utils.java
index 96d99d7..cc845df 100644
--- a/src/main/java/net/seanomik/energeticstorage/utils/Utils.java
+++ b/src/main/java/net/seanomik/energeticstorage/utils/Utils.java
@@ -1,5 +1,6 @@
package net.seanomik.energeticstorage.utils;
+import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBTTileEntity;
import net.seanomik.energeticstorage.Skulls;
import net.seanomik.energeticstorage.objects.ESSystem;
@@ -139,4 +140,9 @@ public class Utils {
return false;
}
+
+ public static boolean isItemADrive(ItemStack item) {
+ NBTItem nbtItem = new NBTItem(item);
+ return nbtItem.hasKey("ES_Drive");
+ }
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index bf9b9f8..4a83602 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -40,7 +40,7 @@ permissions:
default: op
energeticstorage.system.create:
description: Permission for creating new Energetic Storage.
- default: op
+ default: true
energeticstorage.system.destroy.untrusted:
description: Permission for destroying an ES System that the player is not trusted in.
default: op