Compare commits

..
2 Commits
3 changed files with 16 additions and 21 deletions
@@ -4,29 +4,21 @@ import com.alttd.playershops.shop.PlayerShop;
import com.alttd.playershops.shop.ShopType;
import com.alttd.playershops.utils.EconomyUtils;
import com.alttd.playershops.utils.ShopUtil;
import com.alttd.playershops.utils.Util;
import io.papermc.paper.dialog.Dialog;
import io.papermc.paper.registry.data.dialog.ActionButton;
import io.papermc.paper.registry.data.dialog.DialogBase;
import io.papermc.paper.registry.data.dialog.action.DialogAction;
import io.papermc.paper.registry.data.dialog.body.DialogBody;
import io.papermc.paper.registry.data.dialog.input.DialogInput;
import io.papermc.paper.registry.data.dialog.input.SingleOptionDialogInput;
import io.papermc.paper.registry.data.dialog.type.DialogType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickCallback;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class ManageShopDialog extends AbstractDialog {
@@ -109,17 +109,20 @@ public class InventoryUtils {
if (itemStack.getAmount() <= 0)
return true;
int overflow = addItem(inventory, itemStack);
int remaining = itemStack.getAmount();
//revert back if inventory cannot hold all of the items
if (overflow > 0) {
ItemStack revert = itemStack.clone();
revert.setAmount(revert.getAmount() - overflow);
InventoryUtils.removeItem(inventory, revert);
return false;
for (ItemStack stack : inventory.getStorageContents()) {
if (stack == null || stack.getType().isAir()) {
remaining -= itemStack.getMaxStackSize();
} else if (stack.isSimilar(itemStack)) {
remaining -= stack.getMaxStackSize() - stack.getAmount();
}
if (remaining <= 0)
return true;
}
removeItem(inventory, itemStack);
return true;
return false;
}
}
@@ -266,8 +266,8 @@ public class ItemMatcher {
return false; // not the same color
// Do we need all of the above checks inside the shulker?
if (Arrays.equals(shulkerBox1.getInventory().getContents(), shulkerBox2.getInventory().getContents()))
return true; // same content
// same content if true
return Arrays.equals(shulkerBox1.getInventory().getContents(), shulkerBox2.getInventory().getContents());
}
}
return true;
@@ -295,7 +295,7 @@ public class ItemMatcher {
}
if (item1 == null || item2 == null) {
return true;
return false;
}
if (!item1.getType().equals(item2.getType())) {
@@ -310,7 +310,7 @@ public class ItemMatcher {
return metaMatches(item1, item2);
}
return !item1.hasItemMeta() && !item1.hasItemMeta();
return !item1.hasItemMeta() && !item2.hasItemMeta();
}
protected static boolean metaMatches(ItemStack item1, ItemStack item2) {