Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes BSU and HSU dupe #85

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.github.thebusybiscuit.sensibletoolbox.blocks.machines;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import javax.annotation.Nonnull;
Expand All @@ -24,6 +26,7 @@
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.RecipeChoice.MaterialChoice;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.metadata.FixedMetadataValue;

import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
Expand Down Expand Up @@ -135,6 +138,20 @@ public void setStoredItemType(ItemStack stored) {
updateSignItemLines();
}

@Nullable
private ItemStack getStoredItemDisplay() {
if (this.stored != null) {
ItemStack displayItemStack = stored.clone();
ItemMeta meta = displayItemStack.getItemMeta();
List<String> lore = meta != null && meta.getLore() != null ? meta.getLore() : new ArrayList<>();
lore.add(ChatColor.GRAY + "Stored Item");
meta.setLore(lore);
displayItemStack.setItemMeta(meta);
return displayItemStack;
}
return null;
}
Sefiraat marked this conversation as resolved.
Show resolved Hide resolved

private void updateSignQuantityLine() {
if (isLocked()) {
signLabel[1] = ChatColor.DARK_RED + Integer.toString(getTotalAmount());
Expand Down Expand Up @@ -322,7 +339,7 @@ public void onServerTick() {

Debugger.getInstance().debug(2, this + " amount changed! " + oldTotalAmount + " -> " + getTotalAmount());
getProgressMeter().setMaxProgress(maxCapacity);
setProcessing(stored);
setProcessing(getStoredItemDisplay());
setProgress(maxCapacity - (double) getStorageAmount());
update(false);
updateAttachedLabelSigns();
Expand Down Expand Up @@ -359,7 +376,7 @@ public void onBlockUnregistered(Location location) {
@Override
public void onBlockRegistered(Location location, boolean isPlacing) {
getProgressMeter().setMaxProgress(maxCapacity);
setProcessing(stored);
setProcessing(getStoredItemDisplay());
setProgress(maxCapacity - (double) storageAmount);
ItemStack output = getOutputItem();
outputAmount = output == null ? 0 : output.getAmount();
Expand Down