you can now inspect shulker boxes

This commit is contained in:
Kiran Hart 2021-04-15 14:11:34 -04:00
parent c200c34099
commit 689548183f
4 changed files with 83 additions and 2 deletions

View File

@ -6,7 +6,7 @@
<groupId>ca.tweetzy</groupId>
<artifactId>auctionhouse</artifactId>
<version>2.1.1</version>
<version>2.2.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -7,11 +7,17 @@ import ca.tweetzy.auctionhouse.guis.transaction.GUITransactionList;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.managers.SoundManager;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.compatibility.ServerVersion;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.items.TItemBuilder;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.block.ShulkerBox;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import java.util.Comparator;
import java.util.HashMap;
@ -149,7 +155,7 @@ public class GUIAuctionHouse extends Gui {
return;
}
if(Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !AuctionHouse.getInstance().getEconomy().has(e.player, auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice())) {
if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !AuctionHouse.getInstance().getEconomy().has(e.player, auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice())) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
return;
}
@ -174,6 +180,19 @@ public class GUIAuctionHouse extends Gui {
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
}
break;
case SHIFT_RIGHT:
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) return;
if (e.player.isOp() || e.player.hasPermission("auctionhouse.admin") || e.player.hasPermission("auctionhouse.inspectshulker")) {
ItemStack clicked = e.clickedItem;
if (!(clicked.getItemMeta() instanceof BlockStateMeta)) return;
BlockStateMeta meta = (BlockStateMeta) clicked.getItemMeta();
if (!(meta.getBlockState() instanceof ShulkerBox)) return;
killTask();
e.manager.showGUI(e.player, new GUIShulkerInspect(e.clickedItem));
}
break;
case RIGHT:
if (auctionItem.getBidStartPrice() >= Settings.MIN_AUCTION_START_PRICE.getDouble()) {
if (e.player.getUniqueId().equals(auctionItem.getOwner()) && !Settings.OWNER_CAN_PURCHASE_OWN_ITEM.getBoolean()) {

View File

@ -0,0 +1,56 @@
package ca.tweetzy.auctionhouse.guis;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.utils.TextUtils;
import org.bukkit.block.ShulkerBox;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import java.util.Arrays;
/**
* The current file has been created by Kiran Hart
* Date Created: April 14 2021
* Time Created: 12:28 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
public class GUIShulkerInspect extends Gui {
final int[] fillSlots = {0, 1, 2, 3, 4, 5, 6, 7, 8, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 50, 51, 52, 53};
final ItemStack shulker;
/**
* Used to inspect a shulker box from it's item stack.
*
* @param shulker is the shulker box
*/
public GUIShulkerInspect(ItemStack shulker) {
this.shulker = shulker;
setTitle(TextUtils.formatText(Settings.GUI_SHULKER_INSPECT_TITLE.getString()));
setDefaultItem(Settings.GUI_SHULKER_INSPECT_BG_ITEM.getMaterial().parseItem());
setUseLockedCells(false);
setAcceptsItems(false);
setAllowDrops(false);
setRows(6);
draw();
setOnClose(close -> close.manager.showGUI(close.player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(close.player.getUniqueId()))));
}
private void draw() {
reset();
for (int i : fillSlots) setItem(i, getDefaultItem());
setButton(5, 4, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> e.manager.showGUI(e.player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(e.player.getUniqueId()))));
BlockStateMeta meta = (BlockStateMeta) this.shulker.getItemMeta();
ShulkerBox skulkerBox = (ShulkerBox) meta.getBlockState();
int slot = 9;
for (ItemStack item : skulkerBox.getInventory().getContents()) {
setItem(slot++, item);
}
}
}

View File

@ -277,6 +277,12 @@ public class Settings {
"&7Final Price&f: &e%final_price%"
));
/* ===============================
* MAIN AUCTION GUI
* ===============================*/
public static final ConfigSetting GUI_SHULKER_INSPECT_TITLE = new ConfigSetting(config, "gui.shulker inspect.title", "&7&LInspecting Shulker Box");
public static final ConfigSetting GUI_SHULKER_INSPECT_BG_ITEM = new ConfigSetting(config, "gui.shulker inspect.bg item", XMaterial.BLACK_STAINED_GLASS_PANE.name());
/* ===============================
* AUCTION STACKS
* ===============================*/