Fixed /ah test not checking for item in hand.

This commit is contained in:
BadBones69 2020-04-22 02:35:48 -04:00
parent 43abfb72fe
commit 0492cb9557

View File

@ -96,40 +96,45 @@ public class Main extends JavaPlugin implements Listener {
int price = 10; int price = 10;
int amount = 1; int amount = 1;
ItemStack item = Methods.getItemInHand((Player) sender); ItemStack item = Methods.getItemInHand((Player) sender);
// For testing as another player if (item != null && item.getType() != Material.AIR) {
String seller = "Test-Account"; // For testing as another player
for (int it = 1; it <= times; it++) { String seller = "Test-Account";
int num = 1; for (int it = 1; it <= times; it++) {
Random r = new Random(); int num = 1;
for (; Files.DATA.getFile().contains("Items." + num); num++) ; Random r = new Random();
Files.DATA.getFile().set("Items." + num + ".Price", price); for (; Files.DATA.getFile().contains("Items." + num); num++) ;
Files.DATA.getFile().set("Items." + num + ".Seller", seller); Files.DATA.getFile().set("Items." + num + ".Price", price);
if (args[0].equalsIgnoreCase("Bid")) { Files.DATA.getFile().set("Items." + num + ".Seller", seller);
Files.DATA.getFile().set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Bid-Time"))); if (args[0].equalsIgnoreCase("Bid")) {
} else { Files.DATA.getFile().set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Bid-Time")));
Files.DATA.getFile().set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Sell-Time"))); } else {
Files.DATA.getFile().set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Sell-Time")));
}
Files.DATA.getFile().set("Items." + num + ".Full-Time", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Full-Expire-Time")));
int id = r.nextInt(Integer.MAX_VALUE);
for (String i : Files.DATA.getFile().getConfigurationSection("Items").getKeys(false))
if (Files.DATA.getFile().getInt("Items." + i + ".StoreID") == id) id = r.nextInt(Integer.MAX_VALUE);
Files.DATA.getFile().set("Items." + num + ".StoreID", id);
ShopType type = ShopType.SELL;
Files.DATA.getFile().set("Items." + num + ".Biddable", args[0].equalsIgnoreCase("Bid"));
Files.DATA.getFile().set("Items." + num + ".TopBidder", "None");
ItemStack I = item.clone();
I.setAmount(amount);
Files.DATA.getFile().set("Items." + num + ".Item", I);
}
Files.DATA.saveFile();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Price%", price + "");
placeholders.put("%price%", price + "");
sender.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(placeholders));
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
Methods.setItemInHand((Player) sender, new ItemStack(Material.AIR));
} else {
item.setAmount(item.getAmount() - amount);
} }
Files.DATA.getFile().set("Items." + num + ".Full-Time", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Full-Expire-Time")));
int id = r.nextInt(Integer.MAX_VALUE);
for (String i : Files.DATA.getFile().getConfigurationSection("Items").getKeys(false))
if (Files.DATA.getFile().getInt("Items." + i + ".StoreID") == id) id = r.nextInt(Integer.MAX_VALUE);
Files.DATA.getFile().set("Items." + num + ".StoreID", id);
ShopType type = ShopType.SELL;
Files.DATA.getFile().set("Items." + num + ".Biddable", args[0].equalsIgnoreCase("Bid"));
Files.DATA.getFile().set("Items." + num + ".TopBidder", "None");
ItemStack I = item.clone();
I.setAmount(amount);
Files.DATA.getFile().set("Items." + num + ".Item", I);
}
Files.DATA.saveFile();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Price%", price + "");
placeholders.put("%price%", price + "");
sender.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(placeholders));
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
Methods.setItemInHand((Player) sender, new ItemStack(Material.AIR));
} else { } else {
item.setAmount(item.getAmount() - amount); sender.sendMessage(Messages.DOSENT_HAVE_ITEM_IN_HAND.getMessage());
return true;
} }
} }
if (args[0].equalsIgnoreCase("Reload")) {// CA Reload if (args[0].equalsIgnoreCase("Reload")) {// CA Reload