mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-22 05:25:11 +01:00
Added a configuration item loader, AuctionPlayerManager now manages auction players
This commit is contained in:
parent
d0e1eec790
commit
deca6a56ac
@ -2,7 +2,9 @@ package ca.tweetzy.auctionhouse;
|
||||
|
||||
import ca.tweetzy.auctionhouse.commands.CommandAuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.commands.CommandSell;
|
||||
import ca.tweetzy.auctionhouse.listeners.PlayerListeners;
|
||||
import ca.tweetzy.auctionhouse.managers.AuctionItemManager;
|
||||
import ca.tweetzy.auctionhouse.managers.AuctionPlayerManager;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.TweetyCore;
|
||||
import ca.tweetzy.core.TweetyPlugin;
|
||||
@ -14,6 +16,7 @@ import ca.tweetzy.core.core.PluginID;
|
||||
import ca.tweetzy.core.utils.Metrics;
|
||||
import ca.tweetzy.core.utils.nms.NBTEditor;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import java.util.List;
|
||||
@ -34,6 +37,7 @@ public class AuctionHouse extends TweetyPlugin {
|
||||
|
||||
protected Metrics metrics;
|
||||
private CommandManager commandManager;
|
||||
private AuctionPlayerManager auctionPlayerManager;
|
||||
private AuctionItemManager auctionItemManager;
|
||||
|
||||
@Override
|
||||
@ -64,18 +68,25 @@ public class AuctionHouse extends TweetyPlugin {
|
||||
// local
|
||||
setLocale(Settings.LANG.getString(), false);
|
||||
|
||||
// listeners
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PlayerListeners(), this);
|
||||
|
||||
this.data.load();
|
||||
|
||||
// auction players
|
||||
this.auctionPlayerManager = new AuctionPlayerManager();
|
||||
Bukkit.getOnlinePlayers().forEach(p -> this.auctionPlayerManager.addSpeedyPlayer(p));
|
||||
|
||||
// load auction items
|
||||
this.auctionItemManager = new AuctionItemManager();
|
||||
this.auctionItemManager.loadItems();
|
||||
|
||||
// commands
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.commandManager.addCommand(new CommandAuctionHouse(this)).addSubCommands(
|
||||
new CommandSell(this)
|
||||
);
|
||||
|
||||
this.data.load();
|
||||
|
||||
// load auction items
|
||||
this.auctionItemManager = new AuctionItemManager();
|
||||
this.auctionItemManager.loadItems();
|
||||
|
||||
// metrics
|
||||
if (Settings.METRICS.getBoolean()) {
|
||||
this.metrics = new Metrics(this, (int) PluginID.AUCTION_HOUSE.getbStatsID());
|
||||
@ -84,6 +95,7 @@ public class AuctionHouse extends TweetyPlugin {
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
this.auctionPlayerManager.closeAuctionHouse();
|
||||
instance = null;
|
||||
}
|
||||
|
||||
@ -119,4 +131,8 @@ public class AuctionHouse extends TweetyPlugin {
|
||||
public AuctionItemManager getAuctionItemManager() {
|
||||
return auctionItemManager;
|
||||
}
|
||||
|
||||
public AuctionPlayerManager getAuctionPlayerManager() {
|
||||
return auctionPlayerManager;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
package ca.tweetzy.auctionhouse.api;
|
||||
|
||||
import ca.tweetzy.core.utils.items.ItemUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
@ -39,12 +43,22 @@ public class AuctionAPI {
|
||||
return formattedNumber.length() > 4 ? formattedNumber.replaceAll("\\.[0-9]+", "") : formattedNumber;
|
||||
}
|
||||
|
||||
public double[] getRemainingTimeValues(long seconds) {
|
||||
double[] vals = new double[4];
|
||||
vals[0] = (double) seconds / 86400; // days
|
||||
vals[1] = (double) seconds / 3600; // hours
|
||||
vals[2] = (double) (seconds % 3600) / 60; // minutes
|
||||
vals[3] = seconds % 60; // seconds
|
||||
/**
|
||||
* Used to convert seconds to days, hours, minutes, and seconds
|
||||
*
|
||||
* @param seconds is the amount of seconds to convert
|
||||
* @return an array containing the total number of days, hours, minutes, and seconds remaining
|
||||
*/
|
||||
public long[] getRemainingTimeValues(long seconds) {
|
||||
long[] vals = new long[4];
|
||||
int day = (int) TimeUnit.SECONDS.toDays(seconds);
|
||||
long hours = TimeUnit.SECONDS.toHours(seconds) - (day *24);
|
||||
long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds)* 60);
|
||||
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60);
|
||||
vals[0] = day;
|
||||
vals[1] = hours;
|
||||
vals[2] = minute;
|
||||
vals[3] = second;
|
||||
return vals;
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class AuctionItem {
|
||||
String bidIncPrice = (this.bidStartPrice <= 0) ? "0" : Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.bidIncPrice) : String.format("%,.2f", this.bidIncPrice);
|
||||
String currentPrice = (this.bidStartPrice <= 0) ? "0" : Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.currentPrice) : String.format("%,.2f", this.currentPrice);
|
||||
|
||||
double[] times = AuctionAPI.getInstance().getRemainingTimeValues(this.remainingTime);
|
||||
long[] times = AuctionAPI.getInstance().getRemainingTimeValues(this.remainingTime);
|
||||
|
||||
if (type == AuctionStackType.MAIN_AUCTION_HOUSE) {
|
||||
Settings.AUCTION_ITEM_AUCTION_STACK.getStringList().forEach(line -> {
|
||||
@ -110,8 +110,8 @@ public class AuctionItem {
|
||||
.replace("%highestbidder%", highestBidder)
|
||||
.replace("%remaining_days%", String.valueOf(times[0]))
|
||||
.replace("%remaining_hours%", String.valueOf(times[1]))
|
||||
.replace("%remaining_minutes", String.valueOf(times[2]))
|
||||
.replace("%remaining_seconds", String.valueOf(times[3]))
|
||||
.replace("%remaining_minutes%", String.valueOf(times[2]))
|
||||
.replace("%remaining_seconds%", String.valueOf(times[3]))
|
||||
));
|
||||
});
|
||||
|
||||
@ -134,8 +134,8 @@ public class AuctionItem {
|
||||
|
||||
meta.setLore(lore);
|
||||
itemStack.setItemMeta(meta);
|
||||
itemStack = NBTEditor.set(itemStack, getKey(), "AuctionItemKey");
|
||||
itemStack = NBTEditor.set(itemStack, this.bidStartPrice <= 0 ? "NOT_BID_ITEM" : "IS_BID_ITEM", "AuctionItemType");
|
||||
// itemStack = NBTEditor.set(itemStack, getKey(), "AuctionItemKey");
|
||||
// itemStack = NBTEditor.set(itemStack, this.bidStartPrice <= 0 ? "NOT_BID_ITEM" : "IS_BID_ITEM", "AuctionItemType");
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ package ca.tweetzy.auctionhouse.auction;
|
||||
*/
|
||||
public enum AuctionItemCategory {
|
||||
|
||||
ALL("All"),
|
||||
FOOD("Food"),
|
||||
ARMOR("Armor"),
|
||||
BLOCKS("Blocks"),
|
||||
|
@ -2,9 +2,11 @@ package ca.tweetzy.auctionhouse.auction;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -13,13 +15,24 @@ import java.util.stream.Collectors;
|
||||
* Time Created: 6:26 p.m.
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AuctionPlayer {
|
||||
|
||||
@Getter
|
||||
private Player player;
|
||||
private final UUID id;
|
||||
private final Player player;
|
||||
|
||||
private boolean viewingAuctionHouse;
|
||||
private int currentAuctionPage;
|
||||
private AuctionItemCategory preferredCategory;
|
||||
|
||||
public AuctionPlayer(Player player) {
|
||||
this.player = player;
|
||||
this.id = player.getUniqueId();
|
||||
this.viewingAuctionHouse = false;
|
||||
this.currentAuctionPage = 1;
|
||||
this.preferredCategory = AuctionItemCategory.ALL;
|
||||
}
|
||||
|
||||
public List<AuctionItem> getActiveItems() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ca.tweetzy.auctionhouse.commands;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.guis.AuctionHouseGUI;
|
||||
import ca.tweetzy.core.commands.AbstractCommand;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -26,8 +27,9 @@ public class CommandAuctionHouse extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length == 0) {
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
player.openInventory(new AuctionHouseGUI(instance.getAuctionPlayerManager().locateAndSelectPlayer(player)).getInventory());
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class CommandSell extends AbstractCommand {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length <= 0) return ReturnType.SYNTAX_ERROR;
|
||||
Player player = (Player) sender;
|
||||
AuctionPlayer auctionPlayer = new AuctionPlayer(player);
|
||||
AuctionPlayer auctionPlayer = this.instance.getAuctionPlayerManager().locateAndSelectPlayer(player);
|
||||
|
||||
ItemStack itemToSell = PlayerHelper.getHeldItem(player);
|
||||
|
||||
@ -171,7 +171,7 @@ public class CommandSell extends AbstractCommand {
|
||||
basePrice,
|
||||
bidStartPrice,
|
||||
bidIncPrice,
|
||||
basePrice,
|
||||
bidStartPrice,
|
||||
allowedTime
|
||||
));
|
||||
|
||||
|
@ -0,0 +1,67 @@
|
||||
package ca.tweetzy.auctionhouse.guis;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItem;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionStackType;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.inventory.TInventory;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: February 10 2021
|
||||
* Time Created: 12:56 p.m.
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||
*/
|
||||
public class AuctionHouseGUI extends TInventory {
|
||||
|
||||
private final AuctionPlayer auctionPlayer;
|
||||
private List<List<AuctionItem>> items;
|
||||
|
||||
public AuctionHouseGUI(AuctionPlayer auctionPlayer) {
|
||||
this.auctionPlayer = auctionPlayer;
|
||||
this.items = Lists.partition(AuctionHouse.getInstance().getAuctionItemManager().getFilteredItems(auctionPlayer.getPreferredCategory()), 45);
|
||||
setTitle(Settings.GUI_AUCTION_HOUSE_TITLE.getString());
|
||||
setPage(1);
|
||||
setRows(6);
|
||||
setDynamic(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e, int slot) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
Inventory inventory = Bukkit.createInventory(this, getSize(), getTitle());
|
||||
// fill the bottom bar first, then load items
|
||||
inventory.setItem(45, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_LORE.getStringList(), new HashMap<String, Object>(){{
|
||||
put("%active_player_auctions%", auctionPlayer.getActiveItems().size());
|
||||
}}));
|
||||
inventory.setItem(46, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_COLLECTION_BIN_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_COLLECTION_BIN_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_COLLECTION_BIN_LORE.getStringList(), null));
|
||||
inventory.setItem(48, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_BACK_BTN_ITEM.getString(), Settings.GUI_BACK_BTN_NAME.getString(), Settings.GUI_BACK_BTN_LORE.getStringList(), null));
|
||||
inventory.setItem(49, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_REFRESH_BTN_ITEM.getString(), Settings.GUI_REFRESH_BTN_NAME.getString(), Settings.GUI_REFRESH_BTN_LORE.getStringList(), null));
|
||||
inventory.setItem(50, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_NEXT_BTN_ITEM.getString(), Settings.GUI_NEXT_BTN_NAME.getString(), Settings.GUI_NEXT_BTN_LORE.getStringList(), null));
|
||||
inventory.setItem(51, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_LORE.getStringList(), null));
|
||||
inventory.setItem(52, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_LORE.getStringList(), null));
|
||||
inventory.setItem(53, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_LORE.getStringList(), null));
|
||||
|
||||
// load in the auction items
|
||||
if (items.size() != 0) {
|
||||
int currPage = auctionPlayer.getCurrentAuctionPage() > items.size() ? 0 : auctionPlayer.getCurrentAuctionPage() - 1;
|
||||
items.get(currPage).forEach(item -> inventory.setItem(inventory.firstEmpty(), item.getDisplayStack(AuctionStackType.MAIN_AUCTION_HOUSE)));
|
||||
}
|
||||
|
||||
return inventory;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package ca.tweetzy.auctionhouse.helpers;
|
||||
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.compatibility.XMaterial;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.items.ItemUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: February 10 2021
|
||||
* Time Created: 1:03 p.m.
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||
*/
|
||||
public class ConfigurationItemHelper {
|
||||
|
||||
public static ItemStack createConfigurationItem(String item, String title, List<String> lore, HashMap<String, Object> replacements) {
|
||||
ItemStack stack = XMaterial.matchXMaterial(item.toUpperCase()).orElse(XMaterial.RED_STAINED_GLASS_PANE).parseItem();
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
meta.setDisplayName(TextUtils.formatText(title));
|
||||
|
||||
if (replacements != null) {
|
||||
for (int i = 0; i < lore.size(); i++) {
|
||||
for (String key : replacements.keySet()) {
|
||||
if (lore.get(i).contains(key)) {
|
||||
lore.set(i, lore.get(i).replace(key, String.valueOf(replacements.get(key))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
meta.setLore(lore.stream().map(TextUtils::formatText).collect(Collectors.toList()));
|
||||
stack.setItemMeta(meta);
|
||||
return stack;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package ca.tweetzy.auctionhouse.listeners;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: February 10 2021
|
||||
* Time Created: 1:33 p.m.
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||
*/
|
||||
public class PlayerListeners implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(AuctionHouse.getInstance(), () -> {
|
||||
if (AuctionHouse.getInstance().getAuctionPlayerManager().getAuctionPlayers().stream().noneMatch(players -> players.getId().equals(player.getUniqueId()))) {
|
||||
AuctionHouse.getInstance().getAuctionPlayerManager().addPlayer(new AuctionPlayer(player));
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
AuctionHouse.getInstance().getAuctionPlayerManager().removePlayer(AuctionHouse.getInstance().getAuctionPlayerManager().locateAndSelectPlayer(player));
|
||||
}
|
||||
}
|
@ -2,10 +2,14 @@ package ca.tweetzy.auctionhouse.managers;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItem;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItemCategory;
|
||||
import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
@ -22,6 +26,22 @@ public class AuctionItemManager {
|
||||
|
||||
}
|
||||
|
||||
public List<AuctionItem> getFilteredItems(AuctionItemCategory category) {
|
||||
switch(category){
|
||||
case BLOCKS:
|
||||
return auctionItems.stream().filter(auctionItem -> MaterialCategorizer.getMaterialCategory(auctionItem.getOriginalItem()) == AuctionItemCategory.BLOCKS).collect(Collectors.toList());
|
||||
case ARMOR:
|
||||
return auctionItems.stream().filter(auctionItem -> MaterialCategorizer.getMaterialCategory(auctionItem.getOriginalItem()) == AuctionItemCategory.ARMOR).collect(Collectors.toList());
|
||||
case FOOD:
|
||||
return auctionItems.stream().filter(auctionItem -> MaterialCategorizer.getMaterialCategory(auctionItem.getOriginalItem()) == AuctionItemCategory.FOOD).collect(Collectors.toList());
|
||||
case TOOLS:
|
||||
return auctionItems.stream().filter(auctionItem -> MaterialCategorizer.getMaterialCategory(auctionItem.getOriginalItem()) == AuctionItemCategory.TOOLS).collect(Collectors.toList());
|
||||
case MISC:
|
||||
return auctionItems.stream().filter(auctionItem -> MaterialCategorizer.getMaterialCategory(auctionItem.getOriginalItem()) == AuctionItemCategory.MISC).collect(Collectors.toList());
|
||||
}
|
||||
return auctionItems;
|
||||
}
|
||||
|
||||
public void addItem(AuctionItem item) {
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(AuctionHouse.getInstance(), () -> {
|
||||
auctionItems.add(item);
|
||||
|
@ -0,0 +1,53 @@
|
||||
package ca.tweetzy.auctionhouse.managers;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: February 10 2021
|
||||
* Time Created: 1:27 p.m.
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public class AuctionPlayerManager {
|
||||
|
||||
private final LinkedList<AuctionPlayer> auctionPlayers = new LinkedList<>();
|
||||
|
||||
public void closeAuctionHouse() {
|
||||
auctionPlayers.stream().filter(AuctionPlayer::isViewingAuctionHouse).map(AuctionPlayer::getPlayer).forEach(Player::closeInventory);
|
||||
}
|
||||
|
||||
public void addPlayer(AuctionPlayer player) {
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(AuctionHouse.getInstance(), () -> {
|
||||
if (auctionPlayers.stream().noneMatch(players -> players.getId().equals(player.getId()))) {
|
||||
auctionPlayers.add(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addSpeedyPlayer(Player player) {
|
||||
if (auctionPlayers.stream().noneMatch(p -> p.getId().equals(player.getUniqueId()))) {
|
||||
auctionPlayers.add(new AuctionPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayer(AuctionPlayer player) {
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(AuctionHouse.getInstance(), () -> {
|
||||
auctionPlayers.remove(player);
|
||||
});
|
||||
}
|
||||
|
||||
public AuctionPlayer locateAndSelectPlayer(Player player) {
|
||||
if (auctionPlayers.stream().anyMatch(players -> players.getId().equals(player.getUniqueId()))) {
|
||||
return auctionPlayers.stream().filter(players -> players.getId().equals(player.getUniqueId())).findFirst().get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package ca.tweetzy.auctionhouse.settings;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.core.compatibility.XSound;
|
||||
import ca.tweetzy.core.configuration.Config;
|
||||
import ca.tweetzy.core.configuration.ConfigSetting;
|
||||
|
||||
@ -139,7 +140,7 @@ public class Settings {
|
||||
"&eBid Increment: &a$%bidincrement%",
|
||||
"&eHighest Bidder: &a$%highestbidder%",
|
||||
"",
|
||||
"&eTime Left: &b%remaining_days%&f:&b%remaining_hours%&f:&b%remaining_minutes%&f:&b%remaining_seconds%"
|
||||
"&eTime Left: &b%remaining_days%&f days &b%remaining_hours%&f hours &b%remaining_minutes%&f minutes &b%remaining_seconds% seconds"
|
||||
), "This the item stack lore that will be appended to", "auction items in /ah (lore will be applied first, then these)");
|
||||
|
||||
public static final ConfigSetting AUCTION_ITEM_LISTING_STACK = new ConfigSetting(config, "auction items.listing stack", Arrays.asList(
|
||||
@ -164,6 +165,13 @@ public class Settings {
|
||||
"&7-------------------------"
|
||||
), "This will be appended at the end of the lore", "If the auction item is not using a bid, this will show");
|
||||
|
||||
/* ===============================
|
||||
* AUCTION STACKS
|
||||
* ===============================*/
|
||||
public static final ConfigSetting SOUNDS_LISTED_ITEM_ON_AUCTION_HOUSE = new ConfigSetting(config, "sounds.listed item on the auction house", XSound.ENTITY_EXPERIENCE_ORB_PICKUP.parseSound().name());
|
||||
public static final ConfigSetting SOUNDS_NAVIGATE_GUI_PAGES = new ConfigSetting(config, "sounds.navigated between gui pages", XSound.ENTITY_BAT_TAKEOFF.parseSound().name());
|
||||
public static final ConfigSetting SOUNDS_NOT_ENOUGH_MONEY = new ConfigSetting(config, "sounds.not enough money", XSound.ENTITY_ITEM_BREAK.parseSound().name());
|
||||
|
||||
public static void setup() {
|
||||
config.load();
|
||||
config.setAutoremove(true).setAutosave(true);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Wed Feb 10 12:48:44 EST 2021
|
||||
#Wed Feb 10 16:24:17 EST 2021
|
||||
version=2.0.0
|
||||
groupId=ca.tweetzy
|
||||
artifactId=AuctionHouse
|
||||
|
@ -6,8 +6,14 @@ ca\tweetzy\auctionhouse\auction\AuctionSaleType.class
|
||||
ca\tweetzy\auctionhouse\helpers\MaterialCategorizer.class
|
||||
ca\tweetzy\auctionhouse\settings\Settings.class
|
||||
ca\tweetzy\auctionhouse\AuctionHouse.class
|
||||
ca\tweetzy\auctionhouse\guis\AuctionHouseGUI$1.class
|
||||
ca\tweetzy\auctionhouse\listeners\PlayerListeners.class
|
||||
ca\tweetzy\auctionhouse\api\AuctionAPI.class
|
||||
ca\tweetzy\auctionhouse\commands\CommandAuctionHouse.class
|
||||
ca\tweetzy\auctionhouse\managers\AuctionItemManager.class
|
||||
ca\tweetzy\auctionhouse\auction\AuctionStackType.class
|
||||
ca\tweetzy\auctionhouse\guis\AuctionHouseGUI.class
|
||||
ca\tweetzy\auctionhouse\helpers\ConfigurationItemHelper.class
|
||||
ca\tweetzy\auctionhouse\managers\AuctionPlayerManager.class
|
||||
ca\tweetzy\auctionhouse\helpers\PlayerHelper.class
|
||||
ca\tweetzy\auctionhouse\managers\AuctionItemManager$1.class
|
||||
|
@ -2,12 +2,16 @@ C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\ja
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\settings\Settings.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\auction\AuctionItemCategory.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\helpers\PlayerHelper.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\guis\AuctionHouseGUI.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\commands\CommandSell.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\api\AuctionAPI.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\AuctionHouse.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\listeners\PlayerListeners.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\auction\AuctionStackType.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\auction\AuctionItem.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\managers\AuctionItemManager.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\helpers\MaterialCategorizer.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\managers\AuctionPlayerManager.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\auction\AuctionSaleType.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\auction\AuctionPlayer.java
|
||||
C:\Users\Kiran\Documents\Development\Minecraft Plugins\Auction House\src\main\java\ca\tweetzy\auctionhouse\helpers\ConfigurationItemHelper.java
|
||||
|
Loading…
Reference in New Issue
Block a user