mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-01-09 13:07:41 +01:00
container changes
This commit is contained in:
parent
765eb3903f
commit
5e2772a5f5
@ -2,6 +2,8 @@ package ca.tweetzy.auctionhouse.auction;
|
||||
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.compatibility.ServerVersion;
|
||||
import ca.tweetzy.core.compatibility.XMaterial;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.nms.NBTEditor;
|
||||
import lombok.Getter;
|
||||
@ -10,6 +12,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@ -83,63 +86,28 @@ public class AuctionItem implements Serializable {
|
||||
String currentPrice = (this.bidStartPrice <= 0 || this.bidIncPrice <= 0) ? "0" : Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.currentPrice) : String.format("%,.2f", this.currentPrice);
|
||||
|
||||
long[] times = AuctionAPI.getInstance().getRemainingTimeValues(this.remainingTime);
|
||||
List<String> preLore = type == AuctionStackType.MAIN_AUCTION_HOUSE ? this.bidStartPrice <= 0 || this.bidIncPrice <= 0 ? Settings.AUCTION_ITEM_AUCTION_STACK.getStringList() : Settings.AUCTION_ITEM_AUCTION_STACK_WITH_BID.getStringList() : this.bidStartPrice <= 0 ? Settings.AUCTION_ITEM_LISTING_STACK.getStringList() : Settings.AUCTION_ITEM_LISTING_STACK_WITH_BID.getStringList();
|
||||
|
||||
lore.addAll(preLore.stream().map(line -> TextUtils.formatText(line
|
||||
.replace("%seller%", theSeller != null ? theSeller : "&eUnknown Seller")
|
||||
.replace("%buynowprice%", basePrice)
|
||||
.replace("%currentprice%", currentPrice)
|
||||
.replace("%bidincrement%", bidIncPrice)
|
||||
.replace("%highestbidder%", highestBidder)
|
||||
.replace("%remaining_days%", String.valueOf(times[0]))
|
||||
.replace("%remaining_hours%", String.valueOf(times[1]))
|
||||
.replace("%remaining_minutes%", String.valueOf(times[2]))
|
||||
.replace("%remaining_seconds%", String.valueOf(times[3])))).collect(Collectors.toList()));
|
||||
|
||||
if (type == AuctionStackType.MAIN_AUCTION_HOUSE) {
|
||||
if (this.bidStartPrice <= 0 || this.bidIncPrice <= 0) {
|
||||
Settings.AUCTION_ITEM_AUCTION_STACK.getStringList().forEach(line -> {
|
||||
lore.add(TextUtils.formatText(line
|
||||
.replace("%seller%", theSeller != null ? theSeller : "&eUnknown Seller")
|
||||
.replace("%buynowprice%", basePrice)
|
||||
.replace("%remaining_days%", String.valueOf(times[0]))
|
||||
.replace("%remaining_hours%", String.valueOf(times[1]))
|
||||
.replace("%remaining_minutes%", String.valueOf(times[2]))
|
||||
.replace("%remaining_seconds%", String.valueOf(times[3]))
|
||||
));
|
||||
});
|
||||
} else {
|
||||
Settings.AUCTION_ITEM_AUCTION_STACK_WITH_BID.getStringList().forEach(line -> {
|
||||
lore.add(TextUtils.formatText(line
|
||||
.replace("%seller%", theSeller != null ? theSeller : "&eUnknown Seller")
|
||||
.replace("%buynowprice%", basePrice)
|
||||
.replace("%currentprice%", currentPrice)
|
||||
.replace("%bidincrement%", bidIncPrice)
|
||||
.replace("%highestbidder%", highestBidder)
|
||||
.replace("%remaining_days%", String.valueOf(times[0]))
|
||||
.replace("%remaining_hours%", String.valueOf(times[1]))
|
||||
.replace("%remaining_minutes%", String.valueOf(times[2]))
|
||||
.replace("%remaining_seconds%", String.valueOf(times[3]))
|
||||
));
|
||||
});
|
||||
lore.addAll(Settings.AUCTION_PURCHASE_CONTROL_HEADER.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()));
|
||||
lore.addAll(this.bidStartPrice <= 0 || this.bidIncPrice <= 0 ? Settings.AUCTION_PURCHASE_CONTROLS_BID_OFF.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()) : Settings.AUCTION_PURCHASE_CONTROLS_BID_ON.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()));
|
||||
|
||||
if ((ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11) && itemStack.getType() == XMaterial.SHULKER_BOX.parseMaterial()) || (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14) && itemStack.getType() == XMaterial.SHULKER_BOX.parseMaterial() || itemStack.getType() == XMaterial.BARREL.parseMaterial())) {
|
||||
lore.addAll(Settings.AUCTION_PURCHASE_CONTROLS_INSPECTION.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
lore.addAll(this.bidStartPrice <= 0 || this.bidIncPrice <= 0 ? Settings.AUCTION_PURCHASE_CONTROLS_BID_OFF.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()) : Settings.AUCTION_PURCHASE_CONTROLS_BID_ON.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()));
|
||||
} else {
|
||||
if (this.bidStartPrice <= 0) {
|
||||
Settings.AUCTION_ITEM_LISTING_STACK.getStringList().forEach(line -> {
|
||||
lore.add(TextUtils.formatText(line
|
||||
.replace("%seller%", theSeller)
|
||||
.replace("%buynowprice%", basePrice)
|
||||
.replace("%remaining_days%", String.valueOf(times[0]))
|
||||
.replace("%remaining_hours%", String.valueOf(times[1]))
|
||||
.replace("%remaining_minutes%", String.valueOf(times[2]))
|
||||
.replace("%remaining_seconds%", String.valueOf(times[3]))
|
||||
));
|
||||
});
|
||||
} else {
|
||||
Settings.AUCTION_ITEM_LISTING_STACK_WITH_BID.getStringList().forEach(line -> {
|
||||
lore.add(TextUtils.formatText(line
|
||||
.replace("%seller%", theSeller)
|
||||
.replace("%buynowprice%", basePrice)
|
||||
.replace("%currentprice%", currentPrice)
|
||||
.replace("%bidincrement%", bidIncPrice)
|
||||
.replace("%highestbidder%", highestBidder)
|
||||
.replace("%remaining_days%", String.valueOf(times[0]))
|
||||
.replace("%remaining_hours%", String.valueOf(times[1]))
|
||||
.replace("%remaining_minutes%", String.valueOf(times[2]))
|
||||
.replace("%remaining_seconds%", String.valueOf(times[3]))
|
||||
));
|
||||
});
|
||||
}
|
||||
lore.addAll(Settings.AUCTION_PURCHASE_CONTROL_FOOTER.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
meta.setLore(lore);
|
||||
|
@ -216,7 +216,7 @@ public class GUIAuctionHouse extends Gui {
|
||||
break;
|
||||
case SHIFT_RIGHT:
|
||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) return;
|
||||
if (e.player.isOp() || e.player.hasPermission("auctionhouse.admin") || e.player.hasPermission("auctionhouse.inspectcontainer")) {
|
||||
if (e.player.isOp() || e.player.hasPermission("auctionhouse.admin") || e.player.hasPermission("auctionhouse.inspectshulker")) {
|
||||
ItemStack clicked = e.clickedItem;
|
||||
if (!(clicked.getItemMeta() instanceof BlockStateMeta)) return;
|
||||
|
||||
|
@ -20,15 +20,15 @@ import java.util.Arrays;
|
||||
public class GUIContainerInspect 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 container;
|
||||
final ItemStack shulker;
|
||||
|
||||
/**
|
||||
* Used to inspect a shulker box from it's item stack.
|
||||
*
|
||||
* @param container is the shulker box
|
||||
* @param shulker is the shulker box
|
||||
*/
|
||||
public GUIContainerInspect(ItemStack container) {
|
||||
this.container = container;
|
||||
public GUIContainerInspect(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);
|
||||
@ -45,7 +45,7 @@ public class GUIContainerInspect extends Gui {
|
||||
|
||||
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.container.getItemMeta();
|
||||
BlockStateMeta meta = (BlockStateMeta) this.shulker.getItemMeta();
|
||||
ShulkerBox skulkerBox = (ShulkerBox) meta.getBlockState();
|
||||
|
||||
int slot = 9;
|
||||
|
@ -341,11 +341,12 @@ public class Settings {
|
||||
));
|
||||
|
||||
/* ===============================
|
||||
* MAIN AUCTION GUI
|
||||
* INSPECTION 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
|
||||
* ===============================*/
|
||||
@ -385,19 +386,20 @@ public class Settings {
|
||||
"&eTime Left: &b%remaining_days%&fd &b%remaining_hours%&fh &b%remaining_minutes%&fm &b%remaining_seconds%s"
|
||||
), "This the item stack lore that will be appended to", "auction items in /ah listings (lore will be applied first, then these)");
|
||||
|
||||
public static final ConfigSetting AUCTION_PURCHASE_CONTROL_HEADER = new ConfigSetting(config, "auction items.controls.header", Collections.singletonList("&7-------------------------"));
|
||||
public static final ConfigSetting AUCTION_PURCHASE_CONTROL_FOOTER = new ConfigSetting(config, "auction items.controls.footer", Collections.singletonList("&7-------------------------"));
|
||||
|
||||
public static final ConfigSetting AUCTION_PURCHASE_CONTROLS_BID_ON = new ConfigSetting(config, "auction items.controls.using bid", Arrays.asList(
|
||||
"&7-------------------------",
|
||||
"&eLeft-Click&f: &bBid",
|
||||
"&eRight-Click&f: &bBuy Now",
|
||||
"&7-------------------------"
|
||||
"&eRight-Click&f: &bBuy Now"
|
||||
), "This will be appended at the end of the lore", "If the auction item is using a bid, this will show");
|
||||
|
||||
public static final ConfigSetting AUCTION_PURCHASE_CONTROLS_BID_OFF = new ConfigSetting(config, "auction items.controls.not using bid", Arrays.asList(
|
||||
"&7-------------------------",
|
||||
"&eLeft-Click&f: &bBuy Now",
|
||||
"&7-------------------------"
|
||||
public static final ConfigSetting AUCTION_PURCHASE_CONTROLS_BID_OFF = new ConfigSetting(config, "auction items.controls.not using bid", Collections.singletonList(
|
||||
"&eLeft-Click&f: &bBuy Now"
|
||||
), "This will be appended at the end of the lore", "If the auction item is not using a bid, this will show");
|
||||
|
||||
public static final ConfigSetting AUCTION_PURCHASE_CONTROLS_INSPECTION = new ConfigSetting(config, "auction items.controls.inspection", Collections.singletonList("&eShift Right-Click to inspect"), "This will only be added to the control lore if the item can be inspected (skulker box or barrel)");
|
||||
|
||||
/* ===============================
|
||||
* AUCTION STACKS
|
||||
* ===============================*/
|
||||
|
Loading…
Reference in New Issue
Block a user