Modify the GUI a bit to make it easier to move around in
This commit is contained in:
parent
0c24e0bd31
commit
0241704cf6
|
@ -4,7 +4,7 @@
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<artifactId>energeticstorage</artifactId>
|
<artifactId>energeticstorage</artifactId>
|
||||||
<name>EnergeticStorage</name>
|
<name>EnergeticStorage</name>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.4-SNAPSHOT</version>
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -25,22 +25,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<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>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.1</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>shade</id>
|
<id>shade</id>
|
||||||
|
@ -48,16 +32,16 @@
|
||||||
<goals>
|
<goals>
|
||||||
<goal>shade</goal>
|
<goal>shade</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>de.tr7zw.changeme.nbtapi</pattern>
|
||||||
|
<shadedPattern>de.tr7zw.nbtapi.energeticstorage</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>de.tr7zw.changeme.nbtapi</pattern>
|
|
||||||
<shadedPattern>de.tr7zw.nbtapi</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
@ -75,38 +59,16 @@
|
||||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>maven-repository</id>
|
<id>jitpack.io</id>
|
||||||
<url>file:///${project.basedir}/maven-repository</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
<version>1.14-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>commons-lang</artifactId>
|
|
||||||
<groupId>commons-lang</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>bungeecord-chat</artifactId>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>snakeyaml</artifactId>
|
|
||||||
<groupId>org.yaml</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -114,3 +76,4 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
8
pom.xml
8
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<artifactId>energeticstorage</artifactId>
|
<artifactId>energeticstorage</artifactId>
|
||||||
<version>0.4-SNAPSHOT</version>
|
<version>0.4.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>EnergeticStorage</name>
|
<name>EnergeticStorage</name>
|
||||||
|
@ -47,10 +47,12 @@
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
|
|
||||||
<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.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.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>-->
|
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.1_\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_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.2_\plugins\EnergeticStorage-v${project.version}.jar</outputFile>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
@ -99,7 +101,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.WesJD.AnvilGUI</groupId>
|
<groupId>com.github.WesJD.AnvilGUI</groupId>
|
||||||
<artifactId>anvilgui</artifactId>
|
<artifactId>anvilgui</artifactId>
|
||||||
<version>ef71db62ec</version>
|
<version>master-cee0befbaf-1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -39,7 +39,6 @@ public final class EnergeticStorage extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
private void registerListener() {
|
private void registerListener() {
|
||||||
getServer().getPluginManager().registerEvents(Reference.ES_TERMINAL_GUI, this);
|
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_DRIVE_GUI, this);
|
||||||
getServer().getPluginManager().registerEvents(Reference.ES_SYSTEM_SECURITY_GUI, this);
|
getServer().getPluginManager().registerEvents(Reference.ES_SYSTEM_SECURITY_GUI, this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerInteractListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerInteractListener(), this);
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
||||||
case SWAP:
|
case SWAP:
|
||||||
break;
|
break;
|
||||||
case SHIFT_IN:
|
case SHIFT_IN:
|
||||||
if (Utils.isItemValid(clickedItem)) {
|
if (Utils.isItemValid(clickedItem) && Utils.isItemADrive(clickedItem)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Add the item into the player's inventory
|
// Add the item into the player's inventory
|
||||||
|
@ -199,7 +199,7 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
||||||
break;
|
break;
|
||||||
case INTO_HALF:
|
case INTO_HALF:
|
||||||
case INTO:
|
case INTO:
|
||||||
if (Utils.isItemValid(cursor)) {
|
if (Utils.isItemValid(cursor) && Utils.isItemADrive(cursor)) {
|
||||||
NBTItem clickedNBT = new NBTItem(cursor);
|
NBTItem clickedNBT = new NBTItem(cursor);
|
||||||
|
|
||||||
if (clickedNBT.hasKey("ES_Drive") && clickedNBT.getBoolean("ES_Drive")) {
|
if (clickedNBT.hasKey("ES_Drive") && clickedNBT.getBoolean("ES_Drive")) {
|
||||||
|
@ -214,17 +214,18 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
||||||
case SHIFT_OUT:
|
case SHIFT_OUT:
|
||||||
case OUT_HALF:
|
case OUT_HALF:
|
||||||
case OUT:
|
case OUT:
|
||||||
if (slot == 0) {
|
if (slot == 0) { // Back button.
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
|
||||||
Reference.ES_SYSTEM_GUI.initializeItems(player, esSystem);
|
Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
|
||||||
Reference.ES_SYSTEM_GUI.openInventory(player, esSystem);
|
|
||||||
} else if (slot != 1 && slot != 7 && slot != 8) {
|
} else if (slot != 1 && slot != 7 && slot != 8) {
|
||||||
event.setCancelled(false);
|
if (Utils.isItemADrive(cursor)) {
|
||||||
|
event.setCancelled(false);
|
||||||
|
|
||||||
List<ESDrive> drives = esSystem.getESDrives();
|
List<ESDrive> drives = esSystem.getESDrives();
|
||||||
drives.remove(slot - 2);
|
drives.remove(slot - 2);
|
||||||
esSystem.setESDrives(drives);
|
esSystem.setESDrives(drives);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INVENTORY_CLICK:
|
case INVENTORY_CLICK:
|
||||||
|
|
|
@ -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<Player, ESSystem> 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<String> 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<String> 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<String> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -48,6 +48,7 @@ public class ESSystemSecurityGUI implements InventoryHolder, Listener {
|
||||||
inv.setItem(i, createGuiItem(Material.BLACK_STAINED_GLASS_PANE, ""));
|
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(3, createGuiItem(Material.LIME_CONCRETE, "Trust player"));
|
||||||
inv.setItem(4, createGuiItem(Material.RED_CONCRETE, "Un-Trust player"));
|
inv.setItem(4, createGuiItem(Material.RED_CONCRETE, "Un-Trust player"));
|
||||||
if (openSystem.isPublic()) {
|
if (openSystem.isPublic()) {
|
||||||
|
@ -281,7 +282,9 @@ public class ESSystemSecurityGUI implements InventoryHolder, Listener {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// At main menu
|
// 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()
|
new AnvilGUI.Builder()
|
||||||
.onComplete((plr, text) -> {
|
.onComplete((plr, text) -> {
|
||||||
if (text != null && !text.isEmpty()) {
|
if (text != null && !text.isEmpty()) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.seanomik.energeticstorage.gui;
|
||||||
|
|
||||||
import net.seanomik.energeticstorage.EnergeticStorage;
|
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.ESSystem;
|
import net.seanomik.energeticstorage.objects.ESSystem;
|
||||||
import net.seanomik.energeticstorage.utils.Reference;
|
import net.seanomik.energeticstorage.utils.Reference;
|
||||||
import net.seanomik.energeticstorage.utils.Utils;
|
import net.seanomik.energeticstorage.utils.Utils;
|
||||||
|
@ -131,6 +132,43 @@ public class ESTerminalGUI implements InventoryHolder, Listener {
|
||||||
} else {
|
} else {
|
||||||
inv.clear(i);
|
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<String> 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;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ItemStack createGuiItem(Material material, String name, List<String> 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 {
|
private enum ClickType {
|
||||||
NONE,
|
NONE,
|
||||||
SWAP,
|
SWAP,
|
||||||
|
@ -278,7 +326,7 @@ public class ESTerminalGUI implements InventoryHolder, Listener {
|
||||||
.title("Search Terminal.")
|
.title("Search Terminal.")
|
||||||
.plugin(EnergeticStorage.getPlugin())
|
.plugin(EnergeticStorage.getPlugin())
|
||||||
.open(player);
|
.open(player);
|
||||||
} else if (slot == 50) {
|
} else if (slot == 50) { // Next page
|
||||||
Map<ItemStack, Integer> items = openSystem.getAllItems();
|
Map<ItemStack, Integer> items = openSystem.getAllItems();
|
||||||
|
|
||||||
if (items.size() > (pageIndex + 1) * 28 ) {
|
if (items.size() > (pageIndex + 1) * 28 ) {
|
||||||
|
@ -286,6 +334,10 @@ public class ESTerminalGUI implements InventoryHolder, Listener {
|
||||||
openPages.replace(player.getUniqueId(), pageIndex);
|
openPages.replace(player.getUniqueId(), pageIndex);
|
||||||
initializeItems(player, openSystem);
|
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 {
|
} else {
|
||||||
switch (clickType) {
|
switch (clickType) {
|
||||||
case SHIFT_IN:
|
case SHIFT_IN:
|
||||||
|
|
|
@ -28,8 +28,7 @@ public class PlayerInteractListener implements Listener {
|
||||||
ESSystem esSystem = Utils.findSystemAtLocation(block.getLocation());
|
ESSystem esSystem = Utils.findSystemAtLocation(block.getLocation());
|
||||||
if (esSystem != null) {
|
if (esSystem != null) {
|
||||||
if (esSystem.isPlayerTrusted(player) || esSystem.isPublic() || esSystem.getOwner().equals(player.getUniqueId()) || PermissionChecks.canOpenUntrustedSystem(player)) {
|
if (esSystem.isPlayerTrusted(player) || esSystem.isPublic() || esSystem.getOwner().equals(player.getUniqueId()) || PermissionChecks.canOpenUntrustedSystem(player)) {
|
||||||
Reference.ES_SYSTEM_GUI.initializeItems(player, esSystem);
|
Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
|
||||||
Reference.ES_SYSTEM_GUI.openInventory(player, esSystem);
|
|
||||||
} else {
|
} else {
|
||||||
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!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package net.seanomik.energeticstorage.utils;
|
||||||
|
|
||||||
import net.seanomik.energeticstorage.files.ConfigFile;
|
import net.seanomik.energeticstorage.files.ConfigFile;
|
||||||
import net.seanomik.energeticstorage.gui.ESDriveGUI;
|
import net.seanomik.energeticstorage.gui.ESDriveGUI;
|
||||||
import net.seanomik.energeticstorage.gui.ESSystemGUI;
|
|
||||||
import net.seanomik.energeticstorage.gui.ESSystemSecurityGUI;
|
import net.seanomik.energeticstorage.gui.ESSystemSecurityGUI;
|
||||||
import net.seanomik.energeticstorage.gui.ESTerminalGUI;
|
import net.seanomik.energeticstorage.gui.ESTerminalGUI;
|
||||||
import net.seanomik.energeticstorage.objects.ESSystem;
|
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 String PREFIX = ChatColor.AQUA + "" + ChatColor.ITALIC + "[Energetic Storage] " + ChatColor.RESET;
|
||||||
|
|
||||||
public static ESTerminalGUI ES_TERMINAL_GUI = new ESTerminalGUI();
|
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 ESDriveGUI ES_DRIVE_GUI = new ESDriveGUI();
|
||||||
public static ESSystemSecurityGUI ES_SYSTEM_SECURITY_GUI = new ESSystemSecurityGUI();
|
public static ESSystemSecurityGUI ES_SYSTEM_SECURITY_GUI = new ESSystemSecurityGUI();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.seanomik.energeticstorage.utils;
|
package net.seanomik.energeticstorage.utils;
|
||||||
|
|
||||||
|
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;
|
||||||
import net.seanomik.energeticstorage.objects.ESSystem;
|
import net.seanomik.energeticstorage.objects.ESSystem;
|
||||||
|
@ -139,4 +140,9 @@ public class Utils {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isItemADrive(ItemStack item) {
|
||||||
|
NBTItem nbtItem = new NBTItem(item);
|
||||||
|
return nbtItem.hasKey("ES_Drive");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ permissions:
|
||||||
default: op
|
default: op
|
||||||
energeticstorage.system.create:
|
energeticstorage.system.create:
|
||||||
description: Permission for creating new Energetic Storage.
|
description: Permission for creating new Energetic Storage.
|
||||||
default: op
|
default: true
|
||||||
energeticstorage.system.destroy.untrusted:
|
energeticstorage.system.destroy.untrusted:
|
||||||
description: Permission for destroying an ES System that the player is not trusted in.
|
description: Permission for destroying an ES System that the player is not trusted in.
|
||||||
default: op
|
default: op
|
||||||
|
|
Loading…
Reference in New Issue