mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-02-03 17:11:20 +01:00
2.28.0
This commit is contained in:
parent
56ed206425
commit
bc65b90625
11
pom.xml
11
pom.xml
@ -6,7 +6,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ca.tweetzy</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<version>2.27.0</version>
|
||||
<version>2.28.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -24,6 +24,7 @@
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>Auction House-${project.version}</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -108,6 +109,12 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
@ -138,7 +145,6 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
@ -178,4 +184,5 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -8,12 +8,16 @@ import ca.tweetzy.auctionhouse.guis.GUIBans;
|
||||
import ca.tweetzy.core.commands.AbstractCommand;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import ca.tweetzy.core.utils.TimeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -50,11 +54,19 @@ public class CommandBan extends AbstractCommand {
|
||||
reason.append(args[i]).append(" ");
|
||||
}
|
||||
|
||||
OfflinePlayer offlinePlayer = null;
|
||||
|
||||
if (target == null) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
// try and look for an offline player
|
||||
offlinePlayer = Bukkit.getOfflinePlayer(args[0]);
|
||||
if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore()) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
UUID toBan = target == null ? offlinePlayer.getUniqueId() : target.getUniqueId();
|
||||
|
||||
if (!AuctionAPI.getInstance().isValidTimeString(timeString)) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.invalidtimestring").sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
@ -65,27 +77,36 @@ public class CommandBan extends AbstractCommand {
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (AuctionHouse.getInstance().getAuctionBanManager().getBans().containsKey(target.getUniqueId())) {
|
||||
if (AuctionHouse.getInstance().getAuctionBanManager().getBans().containsKey(toBan)) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("bans.playeralreadybanned").processPlaceholder("player", args[0]).sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
long bannedSeconds = AuctionAPI.getInstance().getSecondsFromString(timeString);
|
||||
|
||||
AuctionBanPlayerEvent auctionBanPlayerEvent = new AuctionBanPlayerEvent(player, target.getUniqueId(), reason.toString().trim(), bannedSeconds, false);
|
||||
AuctionBanPlayerEvent auctionBanPlayerEvent = new AuctionBanPlayerEvent(player, toBan, reason.toString().trim(), bannedSeconds, false);
|
||||
Bukkit.getServer().getPluginManager().callEvent(auctionBanPlayerEvent);
|
||||
if (auctionBanPlayerEvent.isCancelled()) return ReturnType.FAILURE;
|
||||
|
||||
AuctionBan auctionBan = new AuctionBan(target.getUniqueId(), reason.toString().trim(), System.currentTimeMillis() + bannedSeconds * 1000);
|
||||
AuctionBan auctionBan = new AuctionBan(toBan, reason.toString().trim(), System.currentTimeMillis() + bannedSeconds * 1000);
|
||||
AuctionHouse.getInstance().getAuctionBanManager().addBan(auctionBan);
|
||||
AuctionHouse.getInstance().getLocale().getMessage("bans.bannedplayer").processPlaceholder("player", args[0]).processPlaceholder("ban_amount", TimeUtils.makeReadable(bannedSeconds * 1000)).sendPrefixedMessage(player);
|
||||
AuctionHouse.getInstance().getLocale().getMessage("bans.remainingtime").processPlaceholder("ban_amount", TimeUtils.makeReadable(bannedSeconds * 1000)).sendPrefixedMessage(target);
|
||||
|
||||
if (target != null) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("bans.remainingtime").processPlaceholder("ban_amount", TimeUtils.makeReadable(bannedSeconds * 1000)).sendPrefixedMessage(target);
|
||||
}
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
if (args.length == 1) {
|
||||
List<String> players = Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
players.addAll(Arrays.stream(Bukkit.getOfflinePlayers()).map(OfflinePlayer::getName).collect(Collectors.toList()));
|
||||
return players;
|
||||
}
|
||||
|
||||
if (args.length == 2) return Arrays.asList("1m", "1h", "1d", "1y");
|
||||
return null;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -242,6 +243,7 @@ public class CommandSell extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length <= 3) return Arrays.asList("1", "2", "3", "4", "5");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,17 @@ package ca.tweetzy.auctionhouse.commands;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionBan;
|
||||
import ca.tweetzy.core.commands.AbstractCommand;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
@ -27,25 +32,35 @@ public class CommandUnban extends AbstractCommand {
|
||||
if (AuctionAPI.tellMigrationStatus(sender)) return ReturnType.FAILURE;
|
||||
|
||||
Player target = PlayerUtils.findPlayer(args[0]);
|
||||
OfflinePlayer offlinePlayer = null;
|
||||
|
||||
if (target == null) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
offlinePlayer = Bukkit.getOfflinePlayer(args[0]);
|
||||
if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore()) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[0]).sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!AuctionHouse.getInstance().getAuctionBanManager().getBans().containsKey(target.getUniqueId())) {
|
||||
UUID toUnBan = target == null ? offlinePlayer.getUniqueId() : target.getUniqueId();
|
||||
|
||||
if (!AuctionHouse.getInstance().getAuctionBanManager().getBans().containsKey(toUnBan)) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("bans.playernotbanned").processPlaceholder("player", args[0]).sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
AuctionHouse.getInstance().getAuctionBanManager().removeBan(target.getUniqueId());
|
||||
AuctionHouse.getInstance().getAuctionBanManager().removeBan(toUnBan);
|
||||
AuctionHouse.getInstance().getLocale().getMessage("bans.playerunbanned").processPlaceholder("player", args[0]).sendPrefixedMessage(sender);
|
||||
AuctionHouse.getInstance().getLocale().getMessage("bans.unbanned").sendPrefixedMessage(target);
|
||||
if (target != null) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("bans.unbanned").sendPrefixedMessage(target);
|
||||
}
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) return AuctionHouse.getInstance().getAuctionBanManager().getBans().values().stream().map(ban -> Bukkit.getOfflinePlayer(ban.getBannedPlayer()).getName()).collect(Collectors.toList());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -207,6 +207,7 @@ public class GUIAuctionHouse extends Gui {
|
||||
PlayerChatInput.PlayerChatInputBuilder<Double> builder = new PlayerChatInput.PlayerChatInputBuilder<>(AuctionHouse.getInstance(), e.player);
|
||||
builder.isValidInput((p, str) -> NumberUtils.isDouble(str) && Double.parseDouble(str) >= auctionItem.getBidIncrementPrice());
|
||||
builder.sendValueMessage(TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter bid amount").getMessage()));
|
||||
builder.invalidInputMessage(TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter valid bid amount").getMessage()));
|
||||
builder.toCancel("cancel");
|
||||
builder.onCancel(p -> e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)));
|
||||
builder.setValue((p, value) -> Double.parseDouble(value));
|
||||
|
@ -74,7 +74,6 @@ public class GUISellItem extends Gui {
|
||||
|
||||
setOnClose(close -> {
|
||||
if (!AuctionHouse.getInstance().getAuctionPlayerManager().getUsingSellGUI().contains(close.player.getUniqueId())) {
|
||||
|
||||
ItemStack toGiveBack = AuctionHouse.getInstance().getAuctionPlayerManager().getSellHolding().get(close.player.getUniqueId());
|
||||
PlayerUtils.giveItem(close.player, toGiveBack); // this could give them air
|
||||
|
||||
@ -85,6 +84,9 @@ public class GUISellItem extends Gui {
|
||||
}
|
||||
|
||||
AuctionHouse.getInstance().getAuctionPlayerManager().removeItemFromSellHolding(close.player.getUniqueId());
|
||||
if (Settings.SELL_MENU_CLOSE_SENDS_TO_LISTING.getBoolean()) {
|
||||
close.manager.showGUI(close.player, new GUIAuctionHouse(this.auctionPlayer));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -157,20 +159,22 @@ public class GUISellItem extends Gui {
|
||||
}).setOnCancel(() -> reopen(e)).setOnClose(() -> reopen(e));
|
||||
});
|
||||
|
||||
setButton(3, 3, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_ITEMS_BID_INC_ITEM.getString(), Settings.GUI_SELL_ITEMS_BID_INC_NAME.getString(), Settings.GUI_SELL_ITEMS_BID_INC_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%bid_increment_price%", AuctionAPI.getInstance().formatNumber(bidIncrementPrice));
|
||||
}}), ClickType.LEFT, e -> {
|
||||
setTheItemToBeListed();
|
||||
setAllowClose(true);
|
||||
e.gui.close();
|
||||
ChatPrompt.showPrompt(AuctionHouse.getInstance(), this.auctionPlayer.getPlayer(), TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new bid increment").getMessage()), chat -> {
|
||||
String msg = chat.getMessage();
|
||||
if (validateChatNumber(msg, Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), false) && validateChatNumber(msg, Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble(), true)) {
|
||||
this.bidIncrementPrice = Double.parseDouble(msg);
|
||||
}
|
||||
reopen(e);
|
||||
}).setOnCancel(() -> reopen(e)).setOnClose(() -> reopen(e));
|
||||
});
|
||||
if (!Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean()) {
|
||||
setButton(3, 3, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_ITEMS_BID_INC_ITEM.getString(), Settings.GUI_SELL_ITEMS_BID_INC_NAME.getString(), Settings.GUI_SELL_ITEMS_BID_INC_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%bid_increment_price%", AuctionAPI.getInstance().formatNumber(bidIncrementPrice));
|
||||
}}), ClickType.LEFT, e -> {
|
||||
setTheItemToBeListed();
|
||||
setAllowClose(true);
|
||||
e.gui.close();
|
||||
ChatPrompt.showPrompt(AuctionHouse.getInstance(), this.auctionPlayer.getPlayer(), TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new bid increment").getMessage()), chat -> {
|
||||
String msg = chat.getMessage();
|
||||
if (validateChatNumber(msg, Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), false) && validateChatNumber(msg, Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble(), true)) {
|
||||
this.bidIncrementPrice = Double.parseDouble(msg);
|
||||
}
|
||||
reopen(e);
|
||||
}).setOnCancel(() -> reopen(e)).setOnClose(() -> reopen(e));
|
||||
});
|
||||
}
|
||||
|
||||
if (Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean()) {
|
||||
setButton(3, 6, ConfigurationItemHelper.createConfigurationItem(this.isAllowingBuyNow ? Settings.GUI_SELL_ITEMS_BUY_NOW_ENABLED_ITEM.getString() : Settings.GUI_SELL_ITEMS_BUY_NOW_DISABLED_ITEM.getString(), this.isAllowingBuyNow ? Settings.GUI_SELL_ITEMS_BUY_NOW_ENABLED_NAME.getString() : Settings.GUI_SELL_ITEMS_BUY_NOW_DISABLED_NAME.getString(), this.isAllowingBuyNow ? Settings.GUI_SELL_ITEMS_BUY_NOW_ENABLED_LORE.getStringList() : Settings.GUI_SELL_ITEMS_BUY_NOW_DISABLED_LORE.getStringList(), null), ClickType.LEFT, e -> {
|
||||
@ -182,12 +186,8 @@ 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().removeFromUsingSellGUI(e.player.getUniqueId());
|
||||
AuctionHouse.getInstance().getAuctionPlayerManager().getUsingSellGUI().remove(e.player.getUniqueId());
|
||||
setAllowClose(true);
|
||||
if (Settings.SELL_MENU_CLOSE_SENDS_TO_LISTING.getBoolean()) {
|
||||
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
|
||||
return;
|
||||
}
|
||||
e.gui.close();
|
||||
});
|
||||
|
||||
@ -219,7 +219,7 @@ public class GUISellItem extends Gui {
|
||||
this.auctionPlayer.getAllowedSellTime(),
|
||||
this.isBiddingItem && !isAllowingBuyNow || !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? -1 : buyNowPrice,
|
||||
this.isBiddingItem ? bidStartPrice : 0,
|
||||
this.isBiddingItem ? bidIncrementPrice : 0,
|
||||
Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean() ? 1 : this.isBiddingItem ? bidIncrementPrice : 0,
|
||||
this.isBiddingItem ? bidStartPrice : buyNowPrice,
|
||||
this.isBiddingItem,
|
||||
false,
|
||||
|
@ -201,7 +201,8 @@ public class GUIConfirmPurchase extends Gui {
|
||||
|
||||
if (Bukkit.getOfflinePlayer(located.getOwner()).isOnline()) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold")
|
||||
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(this.auctionItem.getItem()))
|
||||
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(located.getItem()))
|
||||
.processPlaceholder("amount", located.getItem().getAmount())
|
||||
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax))
|
||||
.processPlaceholder("buyer_name", e.player.getName())
|
||||
.sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer());
|
||||
|
@ -60,6 +60,7 @@ public class LocaleSettings {
|
||||
languageNodes.put("prompts.enter new starting bid", "&aPlease enter the new starting bid in chat:");
|
||||
languageNodes.put("prompts.enter new bid increment", "&aPlease enter the new bid increment in chat:");
|
||||
languageNodes.put("prompts.enter bid amount", "&aPlease enter bid amount in chat:");
|
||||
languageNodes.put("prompts.enter valid bid amount", "&cBid either too low or too high");
|
||||
|
||||
languageNodes.put("transaction.sale_type.bid_won", "Won Auction");
|
||||
languageNodes.put("transaction.sale_type.immediate_buy", "Bought Immediately");
|
||||
@ -133,7 +134,7 @@ public class LocaleSettings {
|
||||
languageNodes.put("commands.syntax.upload", "upload");
|
||||
languageNodes.put("commands.syntax.filter", "filter [additem] [category]");
|
||||
languageNodes.put("commands.syntax.ban", "ban [player] [time] [reason]");
|
||||
languageNodes.put("commands.syntax.unban", "ban <player>");
|
||||
languageNodes.put("commands.syntax.unban", "unban <player>");
|
||||
languageNodes.put("commands.syntax.togglelistinfo", "togglelistinfo");
|
||||
|
||||
languageNodes.put("commands.description.active", "View all your auction listings");
|
||||
|
@ -95,6 +95,7 @@ public class TickAuctionsTask extends BukkitRunnable {
|
||||
if (Bukkit.getOfflinePlayer(auctionItem.getOwner()).isOnline()) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold")
|
||||
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
|
||||
.processPlaceholder("amount", itemStack.getAmount())
|
||||
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax))
|
||||
.processPlaceholder("buyer_name", Bukkit.getOfflinePlayer(auctionItem.getHighestBidder()).getName())
|
||||
.sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer());
|
||||
|
@ -13,12 +13,19 @@ public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// System.out.println(TimeUtils.makeReadable(getSecondsFromString("2y")*1000));
|
||||
List<String> enchants = new ArrayList<>();
|
||||
enchants.add("Sharpness V");
|
||||
enchants.add("Sharpness I");
|
||||
enchants.add("Fire Aspect IV");
|
||||
// List<String> enchants = new ArrayList<>();
|
||||
// enchants.add("Sharpness V");
|
||||
// enchants.add("Sharpness I");
|
||||
// enchants.add("Fire Aspect IV");
|
||||
|
||||
System.out.println(StringUtils.join(enchants, ";=;"));
|
||||
// System.out.println(StringUtils.join(enchants, ";=;"));
|
||||
|
||||
final String uIDPartOne = "%%__US";
|
||||
final String uIDPartTwo = "ER__%%";
|
||||
|
||||
final String UID = "%%__USER_%%";
|
||||
|
||||
System.out.println(UID.contains(uIDPartOne) && UID.contains(uIDPartTwo));
|
||||
}
|
||||
|
||||
public static long getSecondsFromString(String time) {
|
||||
|
Loading…
Reference in New Issue
Block a user