2.7.0, command syntax and description can be translated, added an inventory check full setting

This commit is contained in:
Kiran Hart 2021-05-10 16:41:58 -04:00
parent c374af17e6
commit a6362a9972
16 changed files with 102 additions and 49 deletions

View File

@ -6,7 +6,7 @@
<groupId>ca.tweetzy</groupId>
<artifactId>auctionhouse</artifactId>
<version>2.6.3</version>
<version>2.7.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -126,7 +126,7 @@
<dependency>
<groupId>ca.tweetzy</groupId>
<artifactId>tweetycore</artifactId>
<version>2.0.0</version>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>

View File

@ -43,12 +43,12 @@ public class CommandActive extends AbstractCommand {
@Override
public String getSyntax() {
return "active";
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.active").getMessage();
}
@Override
public String getDescription() {
return "View all your auction listings";
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.active").getMessage();
}
@Override

View File

@ -51,11 +51,11 @@ public class CommandAuctionHouse extends AbstractCommand {
@Override
public String getSyntax() {
return "/ah";
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.auctionhouse").getMessage();
}
@Override
public String getDescription() {
return "Main command for the plugin, it opens the auction window.";
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.auctionhouse").getMessage();
}
}

View File

@ -28,6 +28,32 @@ public class CommandConvert extends AbstractCommand {
@Override
protected ReturnType runCommand(CommandSender sender, String... args) {
handleLegacyConversion(sender);
return ReturnType.SUCCESS;
}
@Override
public String getPermissionNode() {
return "auctionhouse.cmd.convert";
}
@Override
public String getSyntax() {
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.convert").getMessage();
}
@Override
public String getDescription() {
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.convert").getMessage();
}
@Override
protected List<String> onTab(CommandSender sender, String... args) {
return null;
}
private void handleLegacyConversion(CommandSender sender) {
AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&4Beginning the ATTEMPTED conversion process, this may take some time.")).sendPrefixedMessage(sender);
long start = System.currentTimeMillis();
Bukkit.getServer().getScheduler().runTaskLater(AuctionHouse.getInstance(), () -> {
@ -81,27 +107,5 @@ public class CommandConvert extends AbstractCommand {
AuctionHouse.getInstance().getData().save();
}, 1L);
return ReturnType.SUCCESS;
}
@Override
public String getPermissionNode() {
return "auctionhouse.cmd.convert";
}
@Override
public String getSyntax() {
return "convert";
}
@Override
public String getDescription() {
return "Used to make an attempted conversion from < 2.0.0+";
}
@Override
protected List<String> onTab(CommandSender sender, String... args) {
return null;
}
}

View File

@ -43,12 +43,12 @@ public class CommandExpired extends AbstractCommand {
@Override
public String getSyntax() {
return "expired";
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.expired").getMessage();
}
@Override
public String getDescription() {
return "View all your expired/cancelled listings";
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.expired").getMessage();
}
@Override

View File

@ -38,11 +38,11 @@ public class CommandReload extends AbstractCommand {
@Override
public String getSyntax() {
return "reload";
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.reload").getMessage();
}
@Override
public String getDescription() {
return "Reload plugin files";
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.reload").getMessage();
}
}

View File

@ -41,12 +41,12 @@ public class CommandSearch extends AbstractCommand {
@Override
public String getSyntax() {
return "search <keywords>";
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.search").getMessage();
}
@Override
public String getDescription() {
return "Search for specific item(s) in the auction house";
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.search").getMessage();
}
@Override

View File

@ -241,11 +241,11 @@ public class CommandSell extends AbstractCommand {
@Override
public String getSyntax() {
return "sell <basePrice> [bidStart] [bidIncr]";
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.sell").getMessage();
}
@Override
public String getDescription() {
return "Used to put an item up for auction";
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.sell").getMessage();
}
}

View File

@ -39,11 +39,11 @@ public class CommandSettings extends AbstractCommand {
@Override
public String getSyntax() {
return "settings";
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.settings").getMessage();
}
@Override
public String getDescription() {
return "Open the in-game config editor";
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.settings").getMessage();
}
}

View File

@ -34,12 +34,12 @@ public class CommandTransactions extends AbstractCommand {
@Override
public String getSyntax() {
return "transactions";
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.transactions").getMessage();
}
@Override
public String getDescription() {
return "Used to open the transactions menu";
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.transactions").getMessage();
}
@Override

View File

@ -59,12 +59,12 @@ public class CommandUpload extends AbstractCommand {
@Override
public String getSyntax() {
return "upload";
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.upload").getMessage();
}
@Override
public String getDescription() {
return "Used to upload flat file data to the database";
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.upload").getMessage();
}
@Override

View File

@ -1,18 +1,25 @@
package ca.tweetzy.auctionhouse.database;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionItem;
import ca.tweetzy.auctionhouse.auction.AuctionItemCategory;
import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer;
import ca.tweetzy.auctionhouse.transaction.Transaction;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.configuration.Config;
import ca.tweetzy.core.database.DataManagerAbstract;
import ca.tweetzy.core.database.DatabaseConnector;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.function.Consumer;
/**

View File

@ -89,6 +89,11 @@ public class GUIConfirmPurchase extends Gui {
if (auctionEndEvent.isCancelled()) return;
if (!Settings.ALLOW_PURCHASE_IF_INVENTORY_FULL.getBoolean() && e.player.getInventory().firstEmpty() == -1) {
AuctionHouse.getInstance().getLocale().getMessage("general.noroom").sendPrefixedMessage(e.player);
return;
}
if (this.buyingSpecificQuantity) {
ItemStack item = AuctionAPI.getInstance().deserializeItem(located.getRawItem());
// Bukkit.broadcastMessage(String.format("Total Item Qty: %d\nTotal Purchase Qty: %d\nAmount of purchase: %d", item.getAmount(), this.purchaseQuantity, item.getAmount() - this.purchaseQuantity));

View File

@ -53,6 +53,7 @@ public class Settings {
public static final ConfigSetting ALLOW_PURCHASE_OF_SPECIFIC_QUANTITIES = new ConfigSetting(config, "auction setting.allow purchase of specific quantities", false, "When a buy now item is right-clicked should it open a", "special gui to specify the quantity of items to buy from the stack?");
public static final ConfigSetting USE_REFRESH_COOL_DOWN = new ConfigSetting(config, "auction setting.use refresh cool down", true, "Should the refresh cooldown be enabled?");
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.");
/* ===============================
* DATABASE OPTIONS

View File

@ -65,8 +65,6 @@ public class TickAuctionsTask extends BukkitRunnable {
AuctionHouse.getInstance().getServer().getPluginManager().callEvent(auctionEndEvent);
if (!auctionEndEvent.isCancelled()) {
// since they're online, try to add the item to their inventory
PlayerUtils.giveItem(offlinePlayer.getPlayer(), AuctionAPI.getInstance().deserializeItem(item.getRawItem()));
// withdraw money and give to the owner
AuctionHouse.getInstance().getEconomy().withdrawPlayer(offlinePlayer, item.getCurrentPrice());
AuctionHouse.getInstance().getEconomy().depositPlayer(Bukkit.getOfflinePlayer(item.getOwner()), item.getCurrentPrice());
@ -87,7 +85,20 @@ public class TickAuctionsTask extends BukkitRunnable {
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", String.format("%,.2f", item.getCurrentPrice())).sendPrefixedMessage(Bukkit.getOfflinePlayer(item.getOwner()).getPlayer());
}
AuctionHouse.getInstance().getAuctionItemManager().removeItem(item.getKey());
// since they're online, try to add the item to their inventory
// TODO CLEAN THIS UP A BIT
if (Settings.ALLOW_PURCHASE_IF_INVENTORY_FULL.getBoolean()) {
PlayerUtils.giveItem(offlinePlayer.getPlayer(), AuctionAPI.getInstance().deserializeItem(item.getRawItem()));
AuctionHouse.getInstance().getAuctionItemManager().removeItem(item.getKey());
} else {
if (offlinePlayer.getPlayer().getInventory().firstEmpty() == -1) {
item.setOwner(offlinePlayer.getUniqueId());
item.setExpired(true);
} else {
PlayerUtils.giveItem(offlinePlayer.getPlayer(), AuctionAPI.getInstance().deserializeItem(item.getRawItem()));
AuctionHouse.getInstance().getAuctionItemManager().removeItem(item.getKey());
}
}
}
} else {

View File

@ -8,7 +8,8 @@ general:
blockeditem: "&cYou are not allowed to auction that item. (%item%)"
air: "&cSorry, but you cannot sell air o.O"
blocked: "&cSorry, you are not allowed to sell &e%item%"
sellinglimit: "You cannot sell more items, please remove/sell current active items"
sellinglimit: "&cYou cannot sell more items, please remove/sell current active items"
noroom: "&cPlease clear room in your inventory to purchase that item."
pricing:
minbaseprice: "&cThe minimum base price must be &a$%price%"
@ -52,4 +53,28 @@ auction:
nobid: "&e%player% listed &fx%amount% &6%item% &efor &a%base_price%"
bidwon: "&eYou won the bid for&fx%amount% &6%item% &efor &a%price%"
itemsold: "&eYou sold &6%item% &eto &6%buyer_name% &efor &a%price%"
itemnotavailable: "&cThat item is no longer available :("
itemnotavailable: "&cThat item is no longer available :("
commands:
syntax:
active: "active"
auctionhouse: "/ah"
convert: "convert"
expired: "expired"
reload: "reload"
search: "search <keywords>"
sell: "sell <basePrice> [bidStart] [bidIncr]"
settings: "settings"
transactions: "transactions"
upload: "upload"
description:
active: "View all your auction listings"
auctionhouse: "Main command for the plugin, it opens the auction window."
convert: "Used to make an attempted conversion from < 2.0.0+"
expired: "View all your expired/cancelled listings"
reload: "Reload plugin files"
search: "Search for specific item(s) in the auction house"
sell: "Used to put an item up for auction"
settings: "Open the in-game config editor"
transactions: "Used to open the transactions menu"
upload: "Used to upload flat file data to the database"