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

🐛 fix(#198) #199

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from all commits
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,12 +1,14 @@
package me.profelements.dynatech.items.electric.machines;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.bukkit.Material;
import org.bukkit.block.Beehive;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

Expand Down Expand Up @@ -138,13 +140,25 @@ public boolean isSynchronized() {
return true;
}

private void updateInfoStack(BlockMenu menu, int beeCount) {
private static void updateInfoStack(BlockMenu menu, int beeCount) {
Inventory inv = menu.toInventory();

if (inv == null || inv.getViewers().isEmpty()) {
return;
}

int currSpeed = 100;
if (beeCount > 0) {
currSpeed = 30 - ((beeCount - 1) * 10);
}

ItemStack infoStack = new CustomItemStack(Material.BEACON, "&fINFO", "&fBee Count: " + String.valueOf(beeCount), "&fCurrent Speed: " + String.valueOf(currSpeed) + "s");
menu.replaceExistingItem(20, infoStack);
ItemStack item = PROGRESS_STACK.clone();
ItemMeta meta = item.getItemMeta();

meta.setDisplayName("&fInfo");
meta.setLore(Arrays.asList("&fBee Count: " + beeCount, "&fCurrent Speed: " + currSpeed + "s"));
item.setItemMeta(meta);

menu.replaceExistingItem(20, item);
}
}
Loading