This commit is contained in:
Kiran Hart 2021-09-27 11:41:35 -04:00
parent 99220912bb
commit 6ab12cae1c
15 changed files with 190 additions and 40 deletions

View File

@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.tweetzy</groupId>
<artifactId>auctionhouse</artifactId>
<version>2.35.0</version>
<version>2.36.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -91,6 +91,7 @@
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
</filters>

View File

@ -264,18 +264,57 @@ public class AuctionAPI {
ItemStack itemStack = auctionItem.getItem();
String itemName = MMOItems.isEnabled() ? MMOItems.getItemType(itemStack) : ChatColor.stripColor(getItemName(itemStack));
hook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle(isNew ? Settings.DISCORD_MSG_START_TITLE.getString() : Settings.DISCORD_MSG_FINISH_TITLE.getString())
.setColor(colour)
.addField(Settings.DISCORD_MSG_FIELD_SELLER_NAME.getString(), Settings.DISCORD_MSG_FIELD_SELLER_VALUE.getString().replace("%seller%", seller.getName() != null ? seller.getName() : AuctionHouse.getInstance().getLocale().getMessage("discord.player_lost").getMessage()), Settings.DISCORD_MSG_FIELD_SELLER_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_BUYER_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.no_buyer").getMessage() : Settings.DISCORD_MSG_FIELD_BUYER_VALUE.getString().replace("%buyer%", buyer.getName() != null ? buyer.getName() : AuctionHouse.getInstance().getLocale().getMessage("discord.player_lost").getMessage()), Settings.DISCORD_MSG_FIELD_BUYER_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_BUY_NOW_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_BUY_NOW_PRICE_VALUE.getString().replace("%buy_now_price%", this.getFriendlyNumber(auctionItem.getBasePrice())), Settings.DISCORD_MSG_FIELD_BUY_NOW_PRICE_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_FINAL_PRICE_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.not_sold").getMessage() : Settings.DISCORD_MSG_FIELD_FINAL_PRICE_VALUE.getString().replace("%final_price%", this.getFriendlyNumber(isBid ? auctionItem.getCurrentPrice() : auctionItem.getBasePrice())), Settings.DISCORD_MSG_FIELD_FINAL_PRICE_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_IS_BID_NAME.getString(), Settings.DISCORD_MSG_FIELD_IS_BID_VALUE.getString().replace("%is_bid%", isBid ? AuctionHouse.getInstance().getLocale().getMessage("discord.is_bid_true").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("discord.is_bid_false").getMessage()), Settings.DISCORD_MSG_FIELD_IS_BID_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.not_bought").getMessage() : Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_VALUE.getString().replace("%purchase_type%", saleType == AuctionSaleType.USED_BIDDING_SYSTEM ? AuctionHouse.getInstance().getLocale().getMessage("discord.sale_bid_win").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("discord.sale_immediate_buy").getMessage()), Settings.DISCORD_MSG_FIELD_PURCHASE_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_ITEM_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_VALUE.getString().replace("%item_name%", itemName), Settings.DISCORD_MSG_FIELD_ITEM_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_VALUE.getString().replace("%item_amount%", String.valueOf(itemStack.getAmount())), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_INLINE.getBoolean())
);
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject();
embedObject.setTitle(isNew ? Settings.DISCORD_MSG_START_TITLE.getString() : Settings.DISCORD_MSG_FINISH_TITLE.getString());
embedObject.setColor(colour);
embedObject.addField(Settings.DISCORD_MSG_FIELD_SELLER_NAME.getString(), Settings.DISCORD_MSG_FIELD_SELLER_VALUE.getString().replace("%seller%", seller.getName() != null ? seller.getName() : AuctionHouse.getInstance().getLocale().getMessage("discord.player_lost").getMessage()), Settings.DISCORD_MSG_FIELD_SELLER_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_BUYER_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.no_buyer").getMessage() : Settings.DISCORD_MSG_FIELD_BUYER_VALUE.getString().replace("%buyer%", buyer.getName() != null ? buyer.getName() : AuctionHouse.getInstance().getLocale().getMessage("discord.player_lost").getMessage()), Settings.DISCORD_MSG_FIELD_BUYER_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_BUY_NOW_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_BUY_NOW_PRICE_VALUE.getString().replace("%buy_now_price%", this.getFriendlyNumber(auctionItem.getBasePrice())), Settings.DISCORD_MSG_FIELD_BUY_NOW_PRICE_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_FINAL_PRICE_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.not_sold").getMessage() : Settings.DISCORD_MSG_FIELD_FINAL_PRICE_VALUE.getString().replace("%final_price%", this.getFriendlyNumber(isBid ? auctionItem.getCurrentPrice() : auctionItem.getBasePrice())), Settings.DISCORD_MSG_FIELD_FINAL_PRICE_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_IS_BID_NAME.getString(), Settings.DISCORD_MSG_FIELD_IS_BID_VALUE.getString().replace("%is_bid%", isBid ? AuctionHouse.getInstance().getLocale().getMessage("discord.is_bid_true").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("discord.is_bid_false").getMessage()), Settings.DISCORD_MSG_FIELD_IS_BID_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.not_bought").getMessage() : Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_VALUE.getString().replace("%purchase_type%", saleType == AuctionSaleType.USED_BIDDING_SYSTEM ? AuctionHouse.getInstance().getLocale().getMessage("discord.sale_bid_win").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("discord.sale_immediate_buy").getMessage()), Settings.DISCORD_MSG_FIELD_PURCHASE_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_ITEM_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_VALUE.getString().replace("%item_name%", itemName), Settings.DISCORD_MSG_FIELD_ITEM_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_VALUE.getString().replace("%item_amount%", String.valueOf(itemStack.getAmount())), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_INLINE.getBoolean());
hook.addEmbed(embedObject);
try {
hook.execute();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* A simplified version of {@link #sendDiscordMessage(String, OfflinePlayer, OfflinePlayer, AuctionedItem, AuctionSaleType, boolean, boolean)} used
* to just send bid updates
*
* @param webhook the webhook url
* @param auctionItem The object of the auction item
*/
public void sendDiscordBidMessage(String webhook, AuctionedItem auctionItem, double newBid) {
// oh boy the code repetition is high with this one
DiscordWebhook hook = new DiscordWebhook(webhook);
hook.setUsername(Settings.DISCORD_MSG_USERNAME.getString());
hook.setAvatarUrl(Settings.DISCORD_MSG_PFP.getString());
String[] possibleColours = Settings.DISCORD_MSG_DEFAULT_COLOUR.getString().split("-");
Color colour = Settings.DISCORD_MSG_USE_RANDOM_COLOUR.getBoolean()
? Color.getHSBColor(ThreadLocalRandom.current().nextFloat() * 360F, ThreadLocalRandom.current().nextFloat() * 101F, ThreadLocalRandom.current().nextFloat() * 101F)
: Color.getHSBColor(Float.parseFloat(possibleColours[0]) / 360, Float.parseFloat(possibleColours[1]) / 100, Float.parseFloat(possibleColours[2]) / 100);
ItemStack itemStack = auctionItem.getItem();
String itemName = MMOItems.isEnabled() ? MMOItems.getItemType(itemStack) : ChatColor.stripColor(getItemName(itemStack));
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject();
embedObject.setTitle(Settings.DISCORD_MSG_BID_TITLE.getString());
embedObject.setColor(colour);
embedObject.addField(Settings.DISCORD_MSG_FIELD_BIDDER_NAME.getString(), Settings.DISCORD_MSG_FIELD_BIDDER_VALUE.getString().replace("%bidder%", auctionItem.getHighestBidderName() != null ? auctionItem.getHighestBidderName() : AuctionHouse.getInstance().getLocale().getMessage("discord.player_lost").getMessage()), Settings.DISCORD_MSG_FIELD_BIDDER_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_BID_PRICE_NAME.getString(), Settings.DISCORD_MSG_FIELD_BID_PRICE_VALUE.getString().replace("%bid_price%", formatNumber(newBid)), Settings.DISCORD_MSG_FIELD_BID_PRICE_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_ITEM_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_VALUE.getString().replace("%item_name%", itemName), Settings.DISCORD_MSG_FIELD_ITEM_INLINE.getBoolean());
embedObject.addField(Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_VALUE.getString().replace("%item_amount%", String.valueOf(itemStack.getAmount())), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_INLINE.getBoolean());
hook.addEmbed(embedObject);
try {
hook.execute();

View File

@ -0,0 +1,46 @@
package ca.tweetzy.auctionhouse.api.events;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.OfflinePlayer;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* The current file has been created by Kiran Hart
* Date Created: September 27 2021
* Time Created: 11:18 a.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
@Getter
@Setter
public final class AuctionBidEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private final OfflinePlayer bidder;
private final AuctionedItem auctionedItem;
private final double newBidAmount;
public AuctionBidEvent(OfflinePlayer bidder, AuctionedItem auctionedItem, double newBidAmount, boolean async) {
super(async);
this.bidder = bidder;
this.auctionedItem = auctionedItem;
this.newBidAmount = newBidAmount;
}
public AuctionBidEvent(OfflinePlayer bidder, AuctionedItem auctionedItem, double newBidAmount) {
this(bidder, auctionedItem, newBidAmount, true);
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -83,7 +83,7 @@ public class AuctionPlayer {
return getSellLimit() - 1 < getItems(false).size();
}
public int getAllowedSellTime() {
public int getAllowedSellTime(AuctionSaleType auctionSaleType) {
List<Integer> possibleTimes = new ArrayList<>();
Settings.AUCTION_TIME.getStringList().forEach(line -> {
String[] split = line.split(":");
@ -92,6 +92,8 @@ public class AuctionPlayer {
}
});
return possibleTimes.size() <= 0 ? Settings.DEFAULT_AUCTION_TIME.getInt() : Math.max(Settings.DEFAULT_AUCTION_TIME.getInt(), Collections.max(possibleTimes));
int defaultTime = auctionSaleType == AuctionSaleType.USED_BIDDING_SYSTEM ? Settings.DEFAULT_AUCTION_LISTING_TIME.getInt() : Settings.DEFAULT_BIN_LISTING_TIME.getInt();
return possibleTimes.size() <= 0 ? defaultTime : Math.max(defaultTime, Collections.max(possibleTimes));
}
}

View File

@ -42,9 +42,10 @@ public class CommandAdmin extends AbstractCommand {
AuctionHouse.getInstance().getLocale().getMessage("general.endedallauctions").sendPrefixedMessage(sender);
break;
case "relistall":
int relistTime = args.length == 1 ? Settings.DEFAULT_AUCTION_TIME.getInt() : Integer.parseInt(args[1]);
for (UUID id : AuctionHouse.getInstance().getAuctionItemManager().getItems().keySet()) {
if (AuctionHouse.getInstance().getAuctionItemManager().getItems().get(id).isExpired()) {
int relistTime = args.length == 1 ? AuctionHouse.getInstance().getAuctionItemManager().getItems().get(id).isBidItem() ? Settings.DEFAULT_AUCTION_LISTING_TIME.getInt() : Settings.DEFAULT_BIN_LISTING_TIME.getInt() : Integer.parseInt(args[1]);
AuctionHouse.getInstance().getAuctionItemManager().getItems().get(id).setExpiresAt(System.currentTimeMillis() + 1000L * relistTime);
AuctionHouse.getInstance().getAuctionItemManager().getItems().get(id).setExpired(false);
}

View File

@ -3,6 +3,7 @@ package ca.tweetzy.auctionhouse.commands;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionSaleType;
import ca.tweetzy.auctionhouse.guis.GUISellItem;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmListing;
import ca.tweetzy.auctionhouse.helpers.PlayerHelper;
@ -125,7 +126,7 @@ public final class CommandSell extends AbstractCommand {
if (blocked) return ReturnType.FAILURE;
// get the max allowed time for this player.
int allowedTime = auctionPlayer.getAllowedSellTime();
int allowedTime = 0;
/*
================== BEGIN GATHERING NUMBERS / ARGUMENTS ==================
@ -168,12 +169,12 @@ public final class CommandSell extends AbstractCommand {
boolean isBiddingItem = Settings.FORCE_AUCTION_USAGE.getBoolean() || buyNowPrice != null && startingBid != null && Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean();
// NOT USING THE BIDDING SYSTEM
if (!isBiddingItem && buyNowPrice != null) {
if (!isBiddingItem /* && buyNowPrice != null */) {
// Check the if the price meets the min/max criteria
if (!checkBasePrice(player, buyNowPrice, false)) return ReturnType.FAILURE;
}
if (isBiddingItem && buyNowPrice != null && startingBid != null) {
if (isBiddingItem && /* buyNowPrice != null && */ startingBid != null) {
if (!checkBasePrice(player, buyNowPrice, true)) return ReturnType.FAILURE;
// check the starting bid values
if (startingBid < Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()) {
@ -208,7 +209,9 @@ public final class CommandSell extends AbstractCommand {
}
}
if (Settings.ALLOW_ITEM_BUNDLES.getBoolean() && isBundle) {
if (!Settings.ALLOW_ITEM_BUNDLES.getBoolean() && isBundle) {
return ReturnType.FAILURE;
} else {
if (NBTEditor.contains(itemToSell, "AuctionBundleItem")) {
AuctionHouse.getInstance().getLocale().getMessage("general.cannotsellbundleditem").sendPrefixedMessage(player);
return ReturnType.FAILURE;
@ -223,6 +226,10 @@ public final class CommandSell extends AbstractCommand {
return ReturnType.SYNTAX_ERROR;
}
// update the listing time to the max allowed time if it wasn't set using the command flag
allowedTime = auctionPlayer.getAllowedSellTime(isBiddingItem ? AuctionSaleType.USED_BIDDING_SYSTEM : AuctionSaleType.WITHOUT_BIDDING_SYSTEM);
if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) {
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIConfirmListing(
player,
@ -231,7 +238,7 @@ public final class CommandSell extends AbstractCommand {
allowedTime,
/* buy now price */ buyNowAllow ? buyNowPrice : -1,
/* start bid price */ isBiddingItem ? startingBid : 0,
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : 1 : 0,
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 1,
isBiddingItem,
isBundle,
true
@ -243,10 +250,10 @@ public final class CommandSell extends AbstractCommand {
itemToSell,
allowedTime,
/* buy now price */ buyNowAllow ? buyNowPrice : -1,
/* start bid price */ isBiddingItem ? startingBid : 0,
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : 1 : 0,
/* start bid price */ isBiddingItem ? startingBid : !buyNowAllow ? buyNowPrice : 0,
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 1,
/* current price */ isBiddingItem ? startingBid : buyNowPrice <= -1 ? startingBid : buyNowPrice,
isBiddingItem,
isBiddingItem || !buyNowAllow,
isBundle,
true
);

View File

@ -2,6 +2,7 @@ package ca.tweetzy.auctionhouse.commands;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.commands.AbstractCommand;
import ca.tweetzy.core.configuration.editor.PluginConfigGui;
import org.bukkit.command.CommandSender;
@ -23,6 +24,8 @@ public class CommandSettings extends AbstractCommand {
@Override
protected ReturnType runCommand(CommandSender sender, String... args) {
if (!Settings.ALLOW_USAGE_OF_IN_GAME_EDITOR.getBoolean()) return ReturnType.FAILURE;
Player player = (Player) sender;
if (AuctionAPI.tellMigrationStatus(player)) return ReturnType.FAILURE;

View File

@ -2,6 +2,7 @@ package ca.tweetzy.auctionhouse.guis;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.api.events.AuctionBidEvent;
import ca.tweetzy.auctionhouse.auction.*;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmBid;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmPurchase;
@ -254,6 +255,10 @@ public class GUIAuctionHouse extends Gui {
OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(auctionItem.getHighestBidder());
OfflinePlayer owner = Bukkit.getOfflinePlayer(auctionItem.getOwner());
AuctionBidEvent auctionBidEvent = new AuctionBidEvent(e.player, auctionItem, newBiddingAmount);
Bukkit.getServer().getPluginManager().callEvent(auctionBidEvent);
if (auctionBidEvent.isCancelled()) return;
auctionItem.setHighestBidder(e.player.getUniqueId());
auctionItem.setHighestBidderName(e.player.getName());
auctionItem.setCurrentPrice(newBiddingAmount);

View File

@ -2,6 +2,7 @@ package ca.tweetzy.auctionhouse.guis;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.api.events.AuctionBidEvent;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmBid;
@ -101,6 +102,10 @@ public class GUIBid extends Gui {
OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(auctionItem.getHighestBidder());
OfflinePlayer owner = Bukkit.getOfflinePlayer(auctionItem.getOwner());
AuctionBidEvent auctionBidEvent = new AuctionBidEvent(e.player, auctionItem, newBiddingAmount);
Bukkit.getServer().getPluginManager().callEvent(auctionBidEvent);
if (auctionBidEvent.isCancelled()) return;
auctionItem.setHighestBidder(e.player.getUniqueId());
auctionItem.setHighestBidderName(e.player.getName());
auctionItem.setCurrentPrice(newBiddingAmount);

View File

@ -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.auction.AuctionSaleType;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmListing;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.settings.Settings;
@ -107,13 +108,17 @@ public class GUISellItem extends Gui {
this.isBiddingItem = true;
}
if (!Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean()) {
this.isBiddingItem = true;
}
setUnlocked(1, 4);
setUnlockedRange(54, 89);
draw();
}
public GUISellItem(AuctionPlayer auctionPlayer, ItemStack itemToBeListed) {
this(auctionPlayer, itemToBeListed, Settings.MIN_AUCTION_PRICE.getDouble(), Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), Settings.MIN_AUCTION_START_PRICE.getDouble(), false, true, auctionPlayer.getAllowedSellTime());
this(auctionPlayer, itemToBeListed, Settings.MIN_AUCTION_PRICE.getDouble(), Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), Settings.MIN_AUCTION_START_PRICE.getDouble(), false, true, auctionPlayer.getAllowedSellTime(AuctionSaleType.WITHOUT_BIDDING_SYSTEM));
}
private void draw() {
@ -233,16 +238,12 @@ public class GUISellItem extends Gui {
}
}
setButton(3, 4, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> {
AuctionHouse.getInstance().getAuctionPlayerManager().getUsingSellGUI().remove(e.player.getUniqueId());
setAllowClose(true);
e.gui.close();
});
if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() || !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean()) {
setButton(3, 5, ConfigurationItemHelper.createConfigurationItem(this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_ITEM.getString() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_ITEM.getString(), this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_NAME.getString() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_NAME.getString(), this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_LORE.getStringList() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_LORE.getStringList(), null), e -> {
if (!Settings.FORCE_AUCTION_USAGE.getBoolean()) {
this.isBiddingItem = !this.isBiddingItem;
if (Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean()) {
this.isBiddingItem = !this.isBiddingItem;
}
}
setTheItemToBeListed();
draw();
@ -298,7 +299,7 @@ public class GUISellItem extends Gui {
return;
}
if (this.isAllowingBuyNow && this.isBiddingItem && this.buyNowPrice <= this.bidStartPrice && Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean()) {
if (Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() && this.isAllowingBuyNow && this.isBiddingItem && this.buyNowPrice <= this.bidStartPrice && Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean()) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.basepricetoolow").sendPrefixedMessage(e.player);
return;
}
@ -326,6 +327,13 @@ public class GUISellItem extends Gui {
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
}
});
setButton(3, 4, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> {
AuctionHouse.getInstance().getAuctionPlayerManager().getUsingSellGUI().remove(e.player.getUniqueId());
setAllowClose(true);
e.gui.close();
});
}
private boolean validateChatNumber(String input, double requirement, boolean checkMax) {

View File

@ -2,6 +2,7 @@ package ca.tweetzy.auctionhouse.guis.confirmation;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.api.events.AuctionBidEvent;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse;
@ -110,6 +111,10 @@ public class GUIConfirmBid extends Gui {
OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(auctionItem.getHighestBidder());
OfflinePlayer owner = Bukkit.getOfflinePlayer(auctionItem.getOwner());
AuctionBidEvent auctionBidEvent = new AuctionBidEvent(e.player, auctionItem, newBiddingAmount);
Bukkit.getServer().getPluginManager().callEvent(auctionBidEvent);
if (auctionBidEvent.isCancelled()) return;
auctionItem.setHighestBidder(e.player.getUniqueId());
auctionItem.setHighestBidderName(e.player.getName());
auctionItem.setCurrentPrice(newBiddingAmount);

View File

@ -56,7 +56,7 @@ public class GUITransactionList extends Gui {
setOnPage(e -> draw());
// Other Buttons
setButton(5, 0, 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(this.auctionPlayer)));
setButton(5, 0, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_BACK_BTN_ITEM.getString(), Settings.GUI_BACK_BTN_NAME.getString(), Settings.GUI_BACK_BTN_LORE.getStringList(), null), e -> e.manager.showGUI(e.player, new GUITransactionType()));
int slot = 0;
List<Transaction> data = this.transactions.stream().sorted(Comparator.comparingLong(Transaction::getTransactionTime).reversed()).skip((page - 1) * 45L).limit(45).collect(Collectors.toList());

View File

@ -1,5 +1,7 @@
package ca.tweetzy.auctionhouse.guis.transaction;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.gui.Gui;
@ -15,7 +17,7 @@ public final class GUITransactionType extends Gui {
public GUITransactionType() {
setTitle(TextUtils.formatText(Settings.GUI_TRANSACTIONS_TYPE_TITLE.getString()));
setRows(3);
setRows(5);
setAcceptsItems(false);
setUseLockedCells(true);
setDefaultItem(Settings.GUI_TRANSACTIONS_TYPE_BG_ITEM.getMaterial().parseItem());
@ -31,5 +33,7 @@ public final class GUITransactionType extends Gui {
setButton(15, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_ITEM.getString(), Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_NAME.getString(), Settings.GUI_TRANSACTIONS_TYPE_ITEMS_SELF_TRANSACTIONS_LORE.getStringList(), null), e -> {
e.manager.showGUI(e.player, new GUITransactionList(e.player, false));
});
setButton(4, 0, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_BACK_BTN_ITEM.getString(), Settings.GUI_BACK_BTN_NAME.getString(), Settings.GUI_BACK_BTN_LORE.getStringList(), null), e -> e.manager.showGUI(e.player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(e.player.getUniqueId()))));
}
}

View File

@ -2,6 +2,7 @@ package ca.tweetzy.auctionhouse.listeners;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.api.events.AuctionBidEvent;
import ca.tweetzy.auctionhouse.api.events.AuctionEndEvent;
import ca.tweetzy.auctionhouse.api.events.AuctionStartEvent;
import ca.tweetzy.auctionhouse.auction.AuctionSaleType;
@ -89,4 +90,12 @@ public class AuctionListeners implements Listener {
}
}, 1L);
}
@EventHandler
public void onAuctionBid(AuctionBidEvent e) {
if (!Settings.DISCORD_ENABLED.getBoolean() && Settings.DISCORD_ALERT_ON_AUCTION_BID.getBoolean()) return;
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(AuctionHouse.getInstance(), () -> Settings.DISCORD_WEBHOOKS.getStringList().forEach(hook -> {
AuctionAPI.getInstance().sendDiscordBidMessage(hook, e.getAuctionedItem(), e.getNewBidAmount());
}), 1L);
}
}

View File

@ -26,10 +26,15 @@ public class Settings {
"Which economy should auction house use?",
"You have the following supported economy plugins installed: \"" + EconomyManager.getManager().getPossiblePlugins().stream().collect(Collectors.joining("\", \"")) + "\"."
);
public static final ConfigSetting ALLOW_USAGE_OF_IN_GAME_EDITOR = new ConfigSetting(config, "Allow Usage Of This Menu In Game", true, "Once you set this to true, you will no longer be able to access it unless you enable it within the actual config.yml");
/* ===============================
* BASIC SETTINGS
* ===============================*/
public static final ConfigSetting DEFAULT_AUCTION_TIME = new ConfigSetting(config, "auction setting.default auction house", 604800, "The default auction time before an item expires (in seconds)");
public static final ConfigSetting DEFAULT_BIN_LISTING_TIME = new ConfigSetting(config, "auction setting.listings times.bin item", 86400, "The default listing time for bin items (buy only items) before they expire");
public static final ConfigSetting DEFAULT_AUCTION_LISTING_TIME = new ConfigSetting(config, "auction setting.listings times.auction item", 604800, "The default listing time for auction items before they expire");
public static final ConfigSetting MAX_AUCTION_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction price", 1000000000, "The max price for buy only / buy now items");
public static final ConfigSetting MAX_AUCTION_START_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction start price", 1000000000, "The max price starting a bidding auction");
public static final ConfigSetting MAX_AUCTION_INCREMENT_PRICE = new ConfigSetting(config, "auction setting.pricing.max auction increment price", 1000000000, "The max amount for incrementing a bid.");
@ -132,7 +137,7 @@ public class Settings {
"&cIf you overlap click types (ex. LEFT for both inspect and buy) things will go crazy."
);
public static final ConfigSetting CLICKS_NON_BID_ITEM_QTY_PURCHASE = new ConfigSetting(config, "auction setting.clicks.non bid item qty purchase", "RIGHT",
public static final ConfigSetting CLICKS_NON_BID_ITEM_QTY_PURCHASE = new ConfigSetting(config, "auction setting.clicks.non bid item qty purchase", "SHIFT_LEFT",
"Valid Click Types",
"LEFT",
"RIGHT",
@ -204,14 +209,16 @@ public class Settings {
* ===============================*/
public static final ConfigSetting DISCORD_ENABLED = new ConfigSetting(config, "discord.enabled", true, "Should the discord webhook feature be enabled?");
public static final ConfigSetting DISCORD_ALERT_ON_AUCTION_START = new ConfigSetting(config, "discord.alert on auction start", true, "Should a message be sent to the discord server when someone lists a new auction item");
public static final ConfigSetting DISCORD_ALERT_ON_AUCTION_FINISH = new ConfigSetting(config, "discord.alert on auction finish", true, "Should a message when an auction finishes?");
public static final ConfigSetting DISCORD_ALERT_ON_AUCTION_FINISH = new ConfigSetting(config, "discord.alert on auction finish", true, "Should a message be sent when an auction finishes?");
public static final ConfigSetting DISCORD_ALERT_ON_AUCTION_BID = new ConfigSetting(config, "discord.alert on auction bid", true, "Should a message be sent when a new bid is placed on an item?");
public static final ConfigSetting DISCORD_WEBHOOKS = new ConfigSetting(config, "discord.webhooks", Collections.singletonList("https://discord.com/api/webhooks/867470650112737311/kptC6U4rqVjDaJmquq-ijjsR41t1E4qxF94jwgp5zqYwLjbjo3a_Vqp_mhMWGbqYC-Ju"), "A list of webhook urls (channels) you want a message sent to");
public static final ConfigSetting DISCORD_MSG_USERNAME = new ConfigSetting(config, "discord.user.username", "Auction House", "The name of the user who will send the message");
public static final ConfigSetting DISCORD_MSG_PFP = new ConfigSetting(config, "discord.user.avatar picture", "https://cdn.kiranhart.com/spigot/auctionhouse/icon.png", "The avatar image of the discord user");
public static final ConfigSetting DISCORD_MSG_USE_RANDOM_COLOUR = new ConfigSetting(config, "discord.msg.use random colour", true, "colour of the message bar");
public static final ConfigSetting DISCORD_MSG_DEFAULT_COLOUR = new ConfigSetting(config, "discord.msg.default colour", "137-100-100", "The color of the embed, it needs to be in hsb format.", "Separate the numbers with a -");
public static final ConfigSetting DISCORD_MSG_START_TITLE = new ConfigSetting(config, "discord.msg.auction start title", "New Auction Available", "The title of the message when a new auction is made");
public static final ConfigSetting DISCORD_MSG_FINISH_TITLE = new ConfigSetting(config, "discord.msg.auction finish title", "Auction Finished", "The title of th message when an auction finishes");
public static final ConfigSetting DISCORD_MSG_FINISH_TITLE = new ConfigSetting(config, "discord.msg.auction finish title", "Auction Finished", "The title of the message when an auction finishes");
public static final ConfigSetting DISCORD_MSG_BID_TITLE = new ConfigSetting(config, "discord.msg.auction bid title", "New Bid Placed", "The title of the message when a new bid is placed");
public static final ConfigSetting DISCORD_MSG_FIELD_SELLER_NAME = new ConfigSetting(config, "discord.msg.seller.name", "Seller");
public static final ConfigSetting DISCORD_MSG_FIELD_SELLER_VALUE = new ConfigSetting(config, "discord.msg.seller.value", "%seller%");
@ -221,6 +228,14 @@ public class Settings {
public static final ConfigSetting DISCORD_MSG_FIELD_BUYER_VALUE = new ConfigSetting(config, "discord.msg.buyer.value", "%buyer%");
public static final ConfigSetting DISCORD_MSG_FIELD_BUYER_INLINE = new ConfigSetting(config, "discord.msg.buyer.inline", true);
public static final ConfigSetting DISCORD_MSG_FIELD_BIDDER_NAME = new ConfigSetting(config, "discord.msg.bidder.name", "Bidder");
public static final ConfigSetting DISCORD_MSG_FIELD_BIDDER_VALUE = new ConfigSetting(config, "discord.msg.bidder.value", "%bidder%");
public static final ConfigSetting DISCORD_MSG_FIELD_BIDDER_INLINE = new ConfigSetting(config, "discord.msg.bidder.inline", true);
public static final ConfigSetting DISCORD_MSG_FIELD_BID_PRICE_NAME = new ConfigSetting(config, "discord.msg.bid price.name", "Amount Bid");
public static final ConfigSetting DISCORD_MSG_FIELD_BID_PRICE_VALUE = new ConfigSetting(config, "discord.msg.bid price.value", "%bid_price%");
public static final ConfigSetting DISCORD_MSG_FIELD_BID_PRICE_INLINE = new ConfigSetting(config, "discord.msg.bid price.inline", true);
public static final ConfigSetting DISCORD_MSG_FIELD_BUY_NOW_PRICE_NAME = new ConfigSetting(config, "discord.msg.buy now price.name", "Buy Now Price");
public static final ConfigSetting DISCORD_MSG_FIELD_BUY_NOW_PRICE_VALUE = new ConfigSetting(config, "discord.msg.buy now price.value", "$%buy_now_price%");
public static final ConfigSetting DISCORD_MSG_FIELD_BUY_NOW_PRICE_INLINE = new ConfigSetting(config, "discord.msg.buy now price.inline", true);