diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index e3ca652..b903c17 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -4,7 +4,7 @@
net.seanomik
energeticstorage
EnergeticStorage
- 0.7.4-SNAPSHOT
+ 0.7.5-SNAPSHOT
clean package
diff --git a/pom.xml b/pom.xml
index 5039b3b..a509643 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
net.seanomik
energeticstorage
- 0.7.4-SNAPSHOT
+ 0.7.5-SNAPSHOT
jar
EnergeticStorage
diff --git a/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java b/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java
index 9d9a29c..7e4204f 100644
--- a/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java
+++ b/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java
@@ -452,15 +452,40 @@ public class ESTerminalGUI implements InventoryHolder, Listener {
}
break;
- case OUT_HALF:
case SHIFT_OUT:
+ if (Utils.isItemValid(clickedItem)) {
+ ItemStack toRemoveStack = clickedItem.clone();
+
+ ItemStack addingItem = clickedItem.clone();
+ addingItem = Utils.removeAmountFromLore(addingItem);
+
+ HashMap leftOverItems = player.getInventory().addItem(addingItem);
+ ItemStack leftOver = leftOverItems.get(0);
+
+ if (leftOver != null) {
+ toRemoveStack.setAmount(toRemoveStack.getAmount() - leftOver.getAmount());
+ }
+
+ openSystem.removeItem(toRemoveStack);
+
+ Bukkit.getScheduler().runTaskLater(EnergeticStorage.getPlugin(), () -> {
+ initializeItems(player, openSystem);
+ }, (long) 0.1);
+
+
+ /*for (Map.Entry item : leftOverItems.entrySet()) {
+ System.out.println(item.getKey() + ", " + item.getValue());
+ }*/
+ }
+ break;
+ case OUT_HALF:
case OUT:
if (Utils.isItemValid(clickedItem)) {
ItemStack takingItem = clickedItem.clone();
takingItem.setAmount((clickType == ClickType.OUT_HALF && clickedItem.getAmount() / 2 > 0) ? clickedItem.getAmount() / 2 : clickedItem.getMaxStackSize());
takingItem = openSystem.removeItem(takingItem);
- // Remove the item from the search map if its in there
+ // Remove the item from the search map if it's in there
if (openSearches.containsKey(player.getUniqueId())) {
for (ItemStack item : openSearches.get(player.getUniqueId()).keySet()) {
ItemStack clone = item.clone();
diff --git a/src/main/java/net/seanomik/energeticstorage/objects/ESDrive.java b/src/main/java/net/seanomik/energeticstorage/objects/ESDrive.java
index 401ac22..0acda26 100644
--- a/src/main/java/net/seanomik/energeticstorage/objects/ESDrive.java
+++ b/src/main/java/net/seanomik/energeticstorage/objects/ESDrive.java
@@ -191,6 +191,10 @@ public class ESDrive implements Cloneable, ConfigurationSerializable {
return item;
}
+ public int getItemAmount(ItemStack item) {
+ return (int) items.values().toArray()[Utils.indexOfSimilarItem(new ArrayList<>(items.keySet()), item)];
+ }
+
private String exceptionMessage(Exception e) {
return "An exception occurred in ESDrive (UUID:" + uuid + ", Exception: " + e.getMessage() + ")";
}
diff --git a/src/main/java/net/seanomik/energeticstorage/objects/ESSystem.java b/src/main/java/net/seanomik/energeticstorage/objects/ESSystem.java
index 67e03e3..0702201 100644
--- a/src/main/java/net/seanomik/energeticstorage/objects/ESSystem.java
+++ b/src/main/java/net/seanomik/energeticstorage/objects/ESSystem.java
@@ -219,6 +219,18 @@ public class ESSystem implements Cloneable, ConfigurationSerializable {
return drive.removeItem(item);
}
+ public int getItemAmount(ItemStack item) {
+ ESDrive drive = null;
+ for (ESDrive esDrive : esDrives) {
+ for (Map.Entry entry : esDrive.getItems().entrySet()) {
+ if (Utils.removeAmountFromLore(entry.getKey()).isSimilar(Utils.removeAmountFromLore(item))) {
+ return entry.getValue();
+ }
+ }
+ }
+
+ return 0;
+ }
// @TODO: Implement (has not been tested)
@NotNull