Fix #35
This commit is contained in:
parent
340c8caaea
commit
834935ec9d
|
@ -4,7 +4,7 @@
|
|||
<groupId>net.seanomik</groupId>
|
||||
<artifactId>energeticstorage</artifactId>
|
||||
<name>EnergeticStorage</name>
|
||||
<version>0.7.4-SNAPSHOT</version>
|
||||
<version>0.7.5-SNAPSHOT</version>
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<resources>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>net.seanomik</groupId>
|
||||
<artifactId>energeticstorage</artifactId>
|
||||
<version>0.7.4-SNAPSHOT</version>
|
||||
<version>0.7.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EnergeticStorage</name>
|
||||
|
|
|
@ -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<Integer, ItemStack> 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<Integer, ItemStack> 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();
|
||||
|
|
|
@ -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() + ")";
|
||||
}
|
||||
|
|
|
@ -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<ItemStack, Integer> 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
|
||||
|
|
Loading…
Reference in New Issue