mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-22 05:25:11 +01:00
2.34.0
This commit is contained in:
parent
6e759f1f83
commit
b26d08b848
4
pom.xml
4
pom.xml
@ -6,7 +6,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ca.tweetzy</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<version>2.33.1</version>
|
||||
<version>2.34.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -162,7 +162,7 @@
|
||||
<dependency>
|
||||
<groupId>ca.tweetzy</groupId>
|
||||
<artifactId>tweetycore</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
@ -3,6 +3,7 @@ package ca.tweetzy.auctionhouse.api;
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.events.AuctionStartEvent;
|
||||
import ca.tweetzy.auctionhouse.api.hook.MMOItems;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItem;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionSaleType;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
|
||||
@ -548,6 +549,10 @@ public class AuctionAPI {
|
||||
}
|
||||
}
|
||||
|
||||
public void listAuction(Player seller, AuctionedItem item, boolean bundle, boolean requiresHandRemove) {
|
||||
listAuction(seller, item.getItem(), item.getItem(), (int) ((item.getExpiresAt() - System.currentTimeMillis()) / 1000), item.getBasePrice(), item.getBidStartingPrice(), item.getBidIncrementPrice(), item.getCurrentPrice(), item.isBidItem(), bundle, requiresHandRemove);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to insert an auction into the database
|
||||
*
|
||||
|
@ -4,6 +4,7 @@ import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.guis.GUISellItem;
|
||||
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmListing;
|
||||
import ca.tweetzy.auctionhouse.helpers.PlayerHelper;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.commands.AbstractCommand;
|
||||
@ -222,19 +223,34 @@ public final class CommandSell extends AbstractCommand {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
AuctionAPI.getInstance().listAuction(
|
||||
player,
|
||||
originalItem,
|
||||
itemToSell,
|
||||
allowedTime,
|
||||
/* buy now price */ buyNowAllow ? buyNowPrice : -1,
|
||||
/* start bid price */ isBiddingItem ? startingBid : 0,
|
||||
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : 1 : 0,
|
||||
/* current price */ isBiddingItem ? startingBid : buyNowPrice <= -1 ? startingBid : buyNowPrice,
|
||||
isBiddingItem,
|
||||
isBundle,
|
||||
true
|
||||
);
|
||||
if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) {
|
||||
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIConfirmListing(
|
||||
player,
|
||||
originalItem,
|
||||
itemToSell,
|
||||
allowedTime,
|
||||
/* buy now price */ buyNowAllow ? buyNowPrice : -1,
|
||||
/* start bid price */ isBiddingItem ? startingBid : 0,
|
||||
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : 1 : 0,
|
||||
isBiddingItem,
|
||||
isBundle,
|
||||
true
|
||||
));
|
||||
} else {
|
||||
AuctionAPI.getInstance().listAuction(
|
||||
player,
|
||||
originalItem,
|
||||
itemToSell,
|
||||
allowedTime,
|
||||
/* buy now price */ buyNowAllow ? buyNowPrice : -1,
|
||||
/* start bid price */ isBiddingItem ? startingBid : 0,
|
||||
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : 1 : 0,
|
||||
/* current price */ isBiddingItem ? startingBid : buyNowPrice <= -1 ? startingBid : buyNowPrice,
|
||||
isBiddingItem,
|
||||
isBundle,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -306,7 +306,6 @@ public class GUIAuctionHouse extends Gui {
|
||||
}
|
||||
|
||||
private void handleContainerInspect(GuiClickEvent e) {
|
||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) return;
|
||||
ItemStack clicked = e.clickedItem;
|
||||
|
||||
if (NBTEditor.contains(clicked, "AuctionBundleItem")) {
|
||||
@ -315,6 +314,7 @@ public class GUIAuctionHouse extends Gui {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) return;
|
||||
if (e.player.isOp() || e.player.hasPermission("auctionhouse.admin") || e.player.hasPermission("auctionhouse.inspectshulker")) {
|
||||
if (!(clicked.getItemMeta() instanceof BlockStateMeta)) return;
|
||||
|
||||
|
@ -3,6 +3,7 @@ package ca.tweetzy.auctionhouse.guis;
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmListing;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.compatibility.XMaterial;
|
||||
|
@ -0,0 +1,84 @@
|
||||
package ca.tweetzy.auctionhouse.guis.confirmation;
|
||||
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.gui.Gui;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.items.TItemBuilder;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: March 17 2021
|
||||
* Time Created: 11:18 p.m.
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||
*/
|
||||
public class GUIConfirmListing extends Gui {
|
||||
|
||||
private final Player player;
|
||||
private final ItemStack originalItem;
|
||||
private final ItemStack itemToSell;
|
||||
private final int allowedTime;
|
||||
private final Double basePrice;
|
||||
private final Double startingBid;
|
||||
private final Double bidIncrement;
|
||||
private final boolean isBiddingItem;
|
||||
private final boolean isBundle;
|
||||
private final boolean requiresHandRemove;
|
||||
|
||||
|
||||
public GUIConfirmListing(Player player, ItemStack originalItem, ItemStack itemToSell, int allowedTime, double basePrice, double startingBid, double bidIncrement, boolean isBiddingItem, boolean bundle, boolean requiresHandRemove) {
|
||||
this.player = player;
|
||||
this.originalItem = originalItem;
|
||||
this.itemToSell = itemToSell;
|
||||
this.allowedTime = allowedTime;
|
||||
this.basePrice = basePrice;
|
||||
this.startingBid = startingBid;
|
||||
this.bidIncrement = bidIncrement;
|
||||
this.isBiddingItem = isBiddingItem;
|
||||
this.isBundle = bundle;
|
||||
this.requiresHandRemove = requiresHandRemove;
|
||||
|
||||
|
||||
setTitle(TextUtils.formatText(Settings.GUI_CONFIRM_LISTING_TITLE.getString()));
|
||||
setAcceptsItems(false);
|
||||
setRows(1);
|
||||
draw();
|
||||
}
|
||||
|
||||
private void placeAuctionItem() {
|
||||
setItem(0, 4, this.itemToSell);
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
setItems(0, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_LISTING_YES_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_LISTING_YES_NAME.getString()).setLore(Settings.GUI_CONFIRM_LISTING_YES_LORE.getStringList()).toItemStack());
|
||||
placeAuctionItem();
|
||||
setItems(5, 8, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_LISTING_NO_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_LISTING_NO_NAME.getString()).setLore(Settings.GUI_CONFIRM_LISTING_NO_LORE.getStringList()).toItemStack());
|
||||
|
||||
setActionForRange(5, 8, ClickType.LEFT, e -> {
|
||||
e.gui.close();
|
||||
});
|
||||
|
||||
setActionForRange(0, 3, ClickType.LEFT, e -> {
|
||||
AuctionAPI.getInstance().listAuction(
|
||||
this.player,
|
||||
this.originalItem,
|
||||
this.itemToSell,
|
||||
this.allowedTime,
|
||||
/* buy now price */ Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? this.basePrice : -1,
|
||||
/* start bid price */ this.isBiddingItem ? this.startingBid : 0,
|
||||
/* bid inc price */ this.isBiddingItem ? this.bidIncrement != null ? this.bidIncrement : 1 : 0,
|
||||
/* current price */ this.isBiddingItem ? this.startingBid : this.basePrice <= -1 ? this.startingBid : this.basePrice,
|
||||
this.isBiddingItem,
|
||||
this.isBundle,
|
||||
this.requiresHandRemove
|
||||
);
|
||||
e.gui.close();
|
||||
});
|
||||
}
|
||||
}
|
@ -69,6 +69,7 @@ public class Settings {
|
||||
public static final ConfigSetting REFRESH_COOL_DOWN = new ConfigSetting(config, "auction setting.refresh cool down", 2, "How many seconds should pass before the player can refresh the auction house again?");
|
||||
public static final ConfigSetting ALLOW_PURCHASE_IF_INVENTORY_FULL = new ConfigSetting(config, "auction setting.allow purchase with full inventory", true, "Should auction house allow players to buy items even if their", "inventory is full, if true, items will be dropped on the floor if there is no room.");
|
||||
public static final ConfigSetting ASK_FOR_BID_CONFIRMATION = new ConfigSetting(config, "auction setting.ask for bid confirmation", true, "Should Auction House open the confirmation menu for the user to confirm", "whether they actually meant to place a bid or not?");
|
||||
public static final ConfigSetting ASK_FOR_LISTING_CONFIRMATION = new ConfigSetting(config, "auction setting.ask for listing confirmation", false, "Should Auction House ask the user to confirm the listing?");
|
||||
public static final ConfigSetting REPLACE_HOW_TO_SELL_WITH_LIST_BUTTON = new ConfigSetting(config, "auction setting.replace how to sell with list button", false, "This will replace the \"How to Sell\" button with a List Item button");
|
||||
public static final ConfigSetting ALLOW_USAGE_OF_SELL_GUI = new ConfigSetting(config, "auction setting.allow usage of sell gui", true, "Should the sell menu be enabled?");
|
||||
public static final ConfigSetting FORCE_AUCTION_USAGE = new ConfigSetting(config, "auction setting.force auction usage", false, "If enabled, all items sold on the auction house must be an auction (biddable) items");
|
||||
@ -434,6 +435,22 @@ public class Settings {
|
||||
"&7Click to confirm your purchase"
|
||||
));
|
||||
|
||||
/* ===============================
|
||||
* CONFIRM LISTING GUI
|
||||
* ===============================*/
|
||||
public static final ConfigSetting GUI_CONFIRM_LISTING_TITLE = new ConfigSetting(config, "gui.confirm listing.title", "&7Are you sure?");
|
||||
public static final ConfigSetting GUI_CONFIRM_LISTING_NO_ITEM = new ConfigSetting(config, "gui.confirm listing.no.item", "RED_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GUI_CONFIRM_LISTING_NO_NAME = new ConfigSetting(config, "gui.confirm listing.no.name", "&c&LCancel");
|
||||
public static final ConfigSetting GUI_CONFIRM_LISTING_NO_LORE = new ConfigSetting(config, "gui.confirm listing.no.lore", Collections.singletonList(
|
||||
"&7Click to cancel listing"
|
||||
));
|
||||
|
||||
public static final ConfigSetting GUI_CONFIRM_LISTING_YES_ITEM = new ConfigSetting(config, "gui.confirm listing.yes.item", "LIME_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GUI_CONFIRM_LISTING_YES_NAME = new ConfigSetting(config, "gui.confirm listing.yes.name", "&a&lConfirm");
|
||||
public static final ConfigSetting GUI_CONFIRM_LISTING_YES_LORE = new ConfigSetting(config, "gui.confirm listing.yes.lore", Collections.singletonList(
|
||||
"&7Click to list your item"
|
||||
));
|
||||
|
||||
/* ===============================
|
||||
* CONFIRM BID GUI
|
||||
* ===============================*/
|
||||
|
@ -34,9 +34,13 @@ public class Test {
|
||||
|
||||
// System.out.println(AuctionAPI.toTicks("1 day"));
|
||||
|
||||
String arguments = "3d";
|
||||
// String arguments = "3d";
|
||||
//
|
||||
// System.out.println(getSecondsFromString(arguments));
|
||||
|
||||
System.out.println(getSecondsFromString(arguments));
|
||||
long future = System.currentTimeMillis() + 1000L * 10;
|
||||
|
||||
System.out.println((future - System.currentTimeMillis()) / 1000);
|
||||
}
|
||||
|
||||
public static long getSecondsFromString(String time) {
|
||||
|
Loading…
Reference in New Issue
Block a user