mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-22 05:25:11 +01:00
🗃️ statistic menus moved to new template & combine target/self view into one
Took 30 minutes
This commit is contained in:
parent
9f90b2aff0
commit
75b24c2b48
@ -20,7 +20,7 @@ package ca.tweetzy.auctionhouse.commands;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.guis.statistics.GUIStatisticTarget;
|
||||
import ca.tweetzy.auctionhouse.guis.statistics.GUIStatisticView;
|
||||
import ca.tweetzy.auctionhouse.guis.statistics.GUIStatisticViewSelect;
|
||||
import ca.tweetzy.core.commands.AbstractCommand;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
@ -49,11 +49,13 @@ public class CommandStats extends AbstractCommand {
|
||||
if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE;
|
||||
|
||||
final AuctionHouse instance = AuctionHouse.getInstance();
|
||||
final AuctionPlayer user = instance.getAuctionPlayerManager().getPlayer(player.getUniqueId());
|
||||
AuctionPlayer user = instance.getAuctionPlayerManager().getPlayer(player.getUniqueId());
|
||||
|
||||
if (user == null) {
|
||||
instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender());
|
||||
instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player));
|
||||
AuctionPlayer newAHPlayer = new AuctionPlayer(player);
|
||||
user = newAHPlayer;
|
||||
instance.getAuctionPlayerManager().addPlayer(newAHPlayer);
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
@ -69,7 +71,7 @@ public class CommandStats extends AbstractCommand {
|
||||
}
|
||||
|
||||
final AuctionPlayer targetAuctionPlayer = instance.getAuctionPlayerManager().getPlayer(target.getUniqueId());
|
||||
instance.getGuiManager().showGUI(player, new GUIStatisticTarget(user, targetAuctionPlayer));
|
||||
instance.getGuiManager().showGUI(player, new GUIStatisticView(user, targetAuctionPlayer));
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -22,97 +22,72 @@ import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionStatisticType;
|
||||
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.guis.abstraction.AuctionPagedGUI;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.compatibility.XSound;
|
||||
import ca.tweetzy.core.gui.events.GuiClickEvent;
|
||||
import ca.tweetzy.flight.utils.Pair;
|
||||
import ca.tweetzy.flight.utils.QuickItem;
|
||||
import ca.tweetzy.flight.utils.Replacer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class GUIStatisticLeaderboard extends AbstractPlaceholderGui {
|
||||
public final class GUIStatisticLeaderboard extends AuctionPagedGUI<Pair<UUID, Double>> {
|
||||
|
||||
private final AuctionPlayer auctionPlayer;
|
||||
private final AuctionStatisticType statisticType;
|
||||
|
||||
private Map<UUID, Double> statisticsMap;
|
||||
|
||||
public GUIStatisticLeaderboard(AuctionPlayer player, AuctionStatisticType statisticType) {
|
||||
super(player);
|
||||
super(new GUIStatisticViewSelect(player), player.getPlayer(), Settings.GUI_STATS_LEADERBOARD_TITLE.getString(), 6, new ArrayList<>());
|
||||
this.auctionPlayer = player;
|
||||
this.statisticType = statisticType;
|
||||
setTitle(Settings.GUI_STATS_LEADERBOARD_TITLE.getString());
|
||||
setDefaultItem(ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_LEADERBOARD_BG_ITEM.getString()));
|
||||
setUseLockedCells(true);
|
||||
setAcceptsItems(false);
|
||||
setAllowDrops(false);
|
||||
setRows(6);
|
||||
setNavigateSound(XSound.matchXSound(Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString()).orElse(XSound.ENTITY_BAT_TAKEOFF).parseSound());
|
||||
setDefaultItem(QuickItem.bg(QuickItem.of(Settings.GUI_STATS_LEADERBOARD_BG_ITEM.getString()).make()));
|
||||
draw();
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
|
||||
AuctionHouse.newChain().asyncFirst(() -> {
|
||||
this.statisticsMap = AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticMap(this.statisticType)
|
||||
.entrySet()
|
||||
.stream()
|
||||
.sorted(Map.Entry.<UUID, Double>comparingByValue().reversed())
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> b, LinkedHashMap::new));
|
||||
|
||||
|
||||
return this.statisticsMap.entrySet().stream().skip((page - 1) * 45L).limit(45L).collect(Collectors.toList());
|
||||
}).asyncLast((data) -> {
|
||||
pages = (int) Math.max(1, Math.ceil(this.statisticsMap.size() / (double) 45L));
|
||||
drawPaginationButtons();
|
||||
|
||||
int slot = 0;
|
||||
for (Map.Entry<UUID, Double> playerStat : data) {
|
||||
final OfflinePlayer targetUser = Bukkit.getOfflinePlayer(playerStat.getKey());
|
||||
|
||||
final ItemStack head = AuctionAPI.getInstance().getPlayerHead(targetUser.getName());
|
||||
|
||||
setItem(slot++, ConfigurationItemHelper.createConfigurationItem(this.player,
|
||||
head,
|
||||
Settings.GUI_STATS_LEADERBOARD_ITEMS_PLAYER_NAME.getString(),
|
||||
Settings.GUI_STATS_LEADERBOARD_ITEMS_PLAYER_LORE.getStringList(),
|
||||
new HashMap<String, Object>() {{
|
||||
put("%player_name%", targetUser.getName() == null ? "&e&lUsername not found" : targetUser.getName());
|
||||
put("%auction_statistic_name%", statisticType.getTranslatedType());
|
||||
put("%auction_statistic_value%", AuctionAPI.getInstance().formatNumber(playerStat.getValue()));
|
||||
}}
|
||||
));
|
||||
}
|
||||
}).execute();
|
||||
|
||||
setButton(5, 0, getBackButtonItem(), e -> {
|
||||
e.manager.showGUI(e.player, new GUIStatisticViewSelect(this.auctionPlayer));
|
||||
});
|
||||
|
||||
drawStatisticTypeButton();
|
||||
@Override
|
||||
protected void prePopulate() {
|
||||
AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticMap(this.statisticType)
|
||||
.entrySet()
|
||||
.stream()
|
||||
.sorted(Map.Entry.<UUID, Double>comparingByValue().reversed())
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> b, LinkedHashMap::new)).forEach((key, value) -> this.items.add(new Pair<>(key, value)));
|
||||
}
|
||||
|
||||
private void drawPaginationButtons() {
|
||||
setPrevPage(5, 3, getPreviousPageItem());
|
||||
setNextPage(5, 5, getNextPageItem());
|
||||
setOnPage(e -> draw());
|
||||
@Override
|
||||
protected void drawFixed() {
|
||||
applyBackExit();
|
||||
|
||||
setButton(5, 4, QuickItem.of(Settings.GUI_STATS_LEADERBOARD_ITEMS_STAT_ITEM.getString())
|
||||
.name(Settings.GUI_STATS_LEADERBOARD_ITEMS_STAT_NAME.getString())
|
||||
.lore(Replacer.replaceVariables(Settings.GUI_STATS_LEADERBOARD_ITEMS_STAT_LORE.getStringList(), "statistic_name", statisticType.getTranslatedType()))
|
||||
.make(), click -> click.manager.showGUI(click.player, new GUIStatisticLeaderboard(this.auctionPlayer, this.statisticType.next())));
|
||||
}
|
||||
|
||||
private void drawStatisticTypeButton() {
|
||||
setButton(5, 4, ConfigurationItemHelper.createConfigurationItem(this.player,
|
||||
Settings.GUI_STATS_LEADERBOARD_ITEMS_STAT_ITEM.getString(),
|
||||
Settings.GUI_STATS_LEADERBOARD_ITEMS_STAT_NAME.getString(),
|
||||
Settings.GUI_STATS_LEADERBOARD_ITEMS_STAT_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%statistic_name%", statisticType.getTranslatedType());
|
||||
}}), click -> {
|
||||
@Override
|
||||
protected ItemStack makeDisplayItem(Pair<UUID, Double> entry) {
|
||||
final OfflinePlayer targetUser = Bukkit.getOfflinePlayer(entry.getFirst());
|
||||
final ItemStack head = AuctionAPI.getInstance().getPlayerHead(targetUser.getName());
|
||||
|
||||
|
||||
return QuickItem
|
||||
.of(head)
|
||||
.name(Settings.GUI_STATS_LEADERBOARD_ITEMS_PLAYER_NAME.getString().replace("%player_name%", targetUser.getName() == null ? "&e&lUsername not found" : targetUser.getName()))
|
||||
.lore(Replacer.replaceVariables(Settings.GUI_STATS_LEADERBOARD_ITEMS_PLAYER_LORE.getStringList(),
|
||||
"player_name", targetUser.getName() == null ? "&e&lUsername not found" : targetUser.getName(),
|
||||
"auction_statistic_name", statisticType.getTranslatedType(),
|
||||
"auction_statistic_value", AuctionAPI.getInstance().formatNumber(entry.getSecond())
|
||||
)).make();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick(Pair<UUID, Double> object, GuiClickEvent clickEvent) {
|
||||
|
||||
click.manager.showGUI(click.player, new GUIStatisticLeaderboard(this.auctionPlayer, this.statisticType.next()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Auction House
|
||||
* Copyright 2018-2022 Kiran Hart
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package ca.tweetzy.auctionhouse.guis.statistics;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionStatisticType;
|
||||
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class GUIStatisticSelf extends AbstractPlaceholderGui {
|
||||
|
||||
private final AuctionPlayer auctionPlayer;
|
||||
|
||||
public GUIStatisticSelf(AuctionPlayer player) {
|
||||
super(player);
|
||||
this.auctionPlayer = player;
|
||||
setTitle(Settings.GUI_STATS_SELF_TITLE.getString());
|
||||
setDefaultItem(ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SELF_BG_ITEM.getString()));
|
||||
setUseLockedCells(true);
|
||||
setAcceptsItems(false);
|
||||
setAllowDrops(false);
|
||||
setRows(6);
|
||||
draw();
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
final AuctionHouse instance = AuctionHouse.getInstance();
|
||||
|
||||
// created auction
|
||||
setItem(1, 1, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SELF_ITEMS_CREATED_AUCTION_ITEM.getString(), Settings.GUI_STATS_SELF_ITEMS_CREATED_AUCTION_NAME.getString(), Settings.GUI_STATS_SELF_ITEMS_CREATED_AUCTION_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%created_auctions%", (int) instance.getAuctionStatisticManager().getStatisticByPlayer(player.getUniqueId(), AuctionStatisticType.CREATED_AUCTION));
|
||||
}}));
|
||||
|
||||
// sold auction
|
||||
setItem(3, 1, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SELF_ITEMS_SOLD_AUCTION_ITEM.getString(), Settings.GUI_STATS_SELF_ITEMS_SOLD_AUCTION_NAME.getString(), Settings.GUI_STATS_SELF_ITEMS_SOLD_AUCTION_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%sold_auctions%", (int) instance.getAuctionStatisticManager().getStatisticByPlayer(player.getUniqueId(), AuctionStatisticType.SOLD_AUCTION));
|
||||
}}));
|
||||
|
||||
// created bin
|
||||
setItem(1, 4, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SELF_ITEMS_CREATED_BIN_ITEM.getString(), Settings.GUI_STATS_SELF_ITEMS_CREATED_BIN_NAME.getString(), Settings.GUI_STATS_SELF_ITEMS_CREATED_BIN_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%created_bins%", (int) instance.getAuctionStatisticManager().getStatisticByPlayer(player.getUniqueId(), AuctionStatisticType.CREATED_BIN));
|
||||
}}));
|
||||
|
||||
// sold bin
|
||||
setItem(3, 4, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SELF_ITEMS_SOLD_BIN_ITEM.getString(), Settings.GUI_STATS_SELF_ITEMS_SOLD_BIN_NAME.getString(), Settings.GUI_STATS_SELF_ITEMS_SOLD_BIN_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%sold_bins%", (int) instance.getAuctionStatisticManager().getStatisticByPlayer(player.getUniqueId(), AuctionStatisticType.SOLD_BIN));
|
||||
}}));
|
||||
|
||||
// money earned
|
||||
setItem(1, 7, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SELF_ITEMS_MONEY_EARNED_ITEM.getString(), Settings.GUI_STATS_SELF_ITEMS_MONEY_EARNED_NAME.getString(), Settings.GUI_STATS_SELF_ITEMS_MONEY_EARNED_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%money_earned%", AuctionAPI.getInstance().formatNumber(instance.getAuctionStatisticManager().getStatisticByPlayer(player.getUniqueId(), AuctionStatisticType.MONEY_EARNED)));
|
||||
}}));
|
||||
|
||||
// money spent
|
||||
setItem(3, 7, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SELF_ITEMS_MONEY_SPENT_ITEM.getString(), Settings.GUI_STATS_SELF_ITEMS_MONEY_SPENT_NAME.getString(), Settings.GUI_STATS_SELF_ITEMS_MONEY_SPENT_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%money_spent%", AuctionAPI.getInstance().formatNumber(instance.getAuctionStatisticManager().getStatisticByPlayer(player.getUniqueId(), AuctionStatisticType.MONEY_SPENT)));
|
||||
}}));
|
||||
|
||||
setButton(5, 4, getBackButtonItem(), e -> {
|
||||
e.manager.showGUI(e.player, new GUIStatisticViewSelect(this.auctionPlayer));
|
||||
});
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Auction House
|
||||
* Copyright 2018-2022 Kiran Hart
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package ca.tweetzy.auctionhouse.guis.statistics;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionStatisticType;
|
||||
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class GUIStatisticTarget extends AbstractPlaceholderGui {
|
||||
|
||||
private final AuctionPlayer auctionPlayer;
|
||||
private final AuctionPlayer targetPlayer;
|
||||
|
||||
public GUIStatisticTarget(AuctionPlayer player, AuctionPlayer targetPlayer) {
|
||||
super(player);
|
||||
this.auctionPlayer = player;
|
||||
this.targetPlayer = targetPlayer;
|
||||
setTitle(Settings.GUI_STATS_SEARCH_TITLE.getString().replace("%player_name%", targetPlayer.getPlayer().getName()));
|
||||
setDefaultItem(ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SEARCH_BG_ITEM.getString()));
|
||||
setUseLockedCells(true);
|
||||
setAcceptsItems(false);
|
||||
setAllowDrops(false);
|
||||
setRows(6);
|
||||
draw();
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
|
||||
// created auction
|
||||
setItem(1, 1, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SEARCH_ITEMS_CREATED_AUCTION_ITEM.getString(), Settings.GUI_STATS_SEARCH_ITEMS_CREATED_AUCTION_NAME.getString(), Settings.GUI_STATS_SEARCH_ITEMS_CREATED_AUCTION_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%created_auctions%", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.CREATED_AUCTION));
|
||||
}}));
|
||||
|
||||
// sold auction
|
||||
setItem(3, 1, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SEARCH_ITEMS_SOLD_AUCTION_ITEM.getString(), Settings.GUI_STATS_SEARCH_ITEMS_SOLD_AUCTION_NAME.getString(), Settings.GUI_STATS_SEARCH_ITEMS_SOLD_AUCTION_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%sold_auctions%", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.SOLD_AUCTION));
|
||||
}}));
|
||||
|
||||
// created bin
|
||||
setItem(1, 4, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SEARCH_ITEMS_CREATED_BIN_ITEM.getString(), Settings.GUI_STATS_SEARCH_ITEMS_CREATED_BIN_NAME.getString(), Settings.GUI_STATS_SEARCH_ITEMS_CREATED_BIN_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%created_bins%", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.CREATED_BIN));
|
||||
}}));
|
||||
|
||||
// sold bin
|
||||
setItem(3, 4, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SEARCH_ITEMS_SOLD_BIN_ITEM.getString(), Settings.GUI_STATS_SEARCH_ITEMS_SOLD_BIN_NAME.getString(), Settings.GUI_STATS_SEARCH_ITEMS_SOLD_BIN_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%sold_bins%", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.SOLD_BIN));
|
||||
}}));
|
||||
|
||||
// money earned
|
||||
setItem(1, 7, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_ITEM.getString(), Settings.GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_NAME.getString(), Settings.GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%money_earned%", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.MONEY_EARNED)));
|
||||
}}));
|
||||
|
||||
// money spent
|
||||
setItem(3, 7, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_ITEM.getString(), Settings.GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_NAME.getString(), Settings.GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%money_spent%", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.MONEY_SPENT)));
|
||||
}}));
|
||||
|
||||
setButton(5, 4, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> {
|
||||
e.gui.close();
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Auction House
|
||||
* Copyright 2018-2022 Kiran Hart
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package ca.tweetzy.auctionhouse.guis.statistics;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionStatisticType;
|
||||
import ca.tweetzy.auctionhouse.guis.abstraction.AuctionBaseGUI;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.flight.utils.QuickItem;
|
||||
import ca.tweetzy.flight.utils.Replacer;
|
||||
|
||||
public final class GUIStatisticView extends AuctionBaseGUI {
|
||||
|
||||
private final AuctionPlayer targetPlayer;
|
||||
private final boolean isSelf;
|
||||
|
||||
public GUIStatisticView(AuctionPlayer player, AuctionPlayer targetPlayer) {
|
||||
super(new GUIStatisticViewSelect(player), player.getPlayer(), player.getUuid().equals(targetPlayer.getUuid()) ? Settings.GUI_STATS_SELF_TITLE.getString() : Settings.GUI_STATS_SEARCH_TITLE.getString().replace("%player_name%", targetPlayer.getPlayer().getName()), 6);
|
||||
this.targetPlayer = targetPlayer;
|
||||
this.isSelf = player.getUuid().equals(targetPlayer.getUuid());
|
||||
setDefaultItem(QuickItem.bg(QuickItem.of(isSelf ? Settings.GUI_STATS_SELF_BG_ITEM.getString() : Settings.GUI_STATS_SEARCH_BG_ITEM.getString()).make()));
|
||||
draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void draw() {
|
||||
applyBackExit();
|
||||
|
||||
// created auction
|
||||
setItem(1, 1, QuickItem
|
||||
.of(isSelf ? Settings.GUI_STATS_SELF_ITEMS_CREATED_AUCTION_ITEM.getString() : Settings.GUI_STATS_SEARCH_ITEMS_CREATED_AUCTION_ITEM.getString())
|
||||
.name(isSelf ? Settings.GUI_STATS_SELF_ITEMS_CREATED_AUCTION_NAME.getString() : Settings.GUI_STATS_SEARCH_ITEMS_CREATED_AUCTION_NAME.getString())
|
||||
.lore(Replacer.replaceVariables(isSelf ? Settings.GUI_STATS_SELF_ITEMS_CREATED_AUCTION_LORE.getStringList() : Settings.GUI_STATS_SEARCH_ITEMS_CREATED_AUCTION_LORE.getStringList(), "created_auctions", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.CREATED_AUCTION)))
|
||||
.make());
|
||||
|
||||
// sold auction
|
||||
setItem(3, 1, QuickItem
|
||||
.of(isSelf ? Settings.GUI_STATS_SELF_ITEMS_SOLD_AUCTION_ITEM.getString() : Settings.GUI_STATS_SEARCH_ITEMS_SOLD_AUCTION_ITEM.getString())
|
||||
.name(isSelf ? Settings.GUI_STATS_SELF_ITEMS_SOLD_AUCTION_NAME.getString() : Settings.GUI_STATS_SEARCH_ITEMS_SOLD_AUCTION_NAME.getString())
|
||||
.lore(Replacer.replaceVariables(isSelf ? Settings.GUI_STATS_SELF_ITEMS_SOLD_AUCTION_LORE.getStringList() : Settings.GUI_STATS_SEARCH_ITEMS_SOLD_AUCTION_LORE.getStringList(), "sold_auctions", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.SOLD_AUCTION)))
|
||||
.make());
|
||||
|
||||
// created bin
|
||||
setItem(1, 4, QuickItem
|
||||
.of(isSelf ? Settings.GUI_STATS_SELF_ITEMS_CREATED_BIN_ITEM.getString() : Settings.GUI_STATS_SEARCH_ITEMS_CREATED_BIN_ITEM.getString())
|
||||
.name(isSelf ? Settings.GUI_STATS_SELF_ITEMS_CREATED_BIN_NAME.getString() : Settings.GUI_STATS_SEARCH_ITEMS_CREATED_BIN_NAME.getString())
|
||||
.lore(Replacer.replaceVariables(isSelf ? Settings.GUI_STATS_SELF_ITEMS_CREATED_BIN_LORE.getStringList() : Settings.GUI_STATS_SEARCH_ITEMS_CREATED_BIN_LORE.getStringList(), "created_bins", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.CREATED_BIN)))
|
||||
.make());
|
||||
|
||||
// sold bin
|
||||
setItem(3, 4, QuickItem
|
||||
.of(isSelf ? Settings.GUI_STATS_SELF_ITEMS_SOLD_BIN_ITEM.getString() : Settings.GUI_STATS_SEARCH_ITEMS_SOLD_BIN_ITEM.getString())
|
||||
.name(isSelf ? Settings.GUI_STATS_SELF_ITEMS_SOLD_BIN_NAME.getString() : Settings.GUI_STATS_SEARCH_ITEMS_SOLD_BIN_NAME.getString())
|
||||
.lore(Replacer.replaceVariables(isSelf ? Settings.GUI_STATS_SELF_ITEMS_SOLD_BIN_LORE.getStringList() : Settings.GUI_STATS_SEARCH_ITEMS_SOLD_BIN_LORE.getStringList(), "sold_bins", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.SOLD_BIN)))
|
||||
.make());
|
||||
|
||||
// money earned
|
||||
setItem(1, 7, QuickItem
|
||||
.of(isSelf ? Settings.GUI_STATS_SELF_ITEMS_MONEY_EARNED_ITEM.getString() : Settings.GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_ITEM.getString())
|
||||
.name(isSelf ? Settings.GUI_STATS_SELF_ITEMS_MONEY_EARNED_NAME.getString() : Settings.GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_NAME.getString())
|
||||
.lore(Replacer.replaceVariables(isSelf ? Settings.GUI_STATS_SELF_ITEMS_MONEY_EARNED_LORE.getStringList() : Settings.GUI_STATS_SEARCH_ITEMS_MONEY_EARNED_LORE.getStringList(), "money_earned", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.MONEY_EARNED)))
|
||||
.make());
|
||||
|
||||
// money spent
|
||||
setItem(3, 7, QuickItem
|
||||
.of(isSelf ? Settings.GUI_STATS_SELF_ITEMS_MONEY_SPENT_ITEM.getString() : Settings.GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_ITEM.getString())
|
||||
.name(isSelf ? Settings.GUI_STATS_SELF_ITEMS_MONEY_SPENT_NAME.getString() : Settings.GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_NAME.getString())
|
||||
.lore(Replacer.replaceVariables(isSelf ? Settings.GUI_STATS_SELF_ITEMS_MONEY_SPENT_LORE.getStringList() : Settings.GUI_STATS_SEARCH_ITEMS_MONEY_SPENT_LORE.getStringList(), "money_spent", (int) AuctionHouse.getInstance().getAuctionStatisticManager().getStatisticByPlayer(targetPlayer.getUuid(), AuctionStatisticType.MONEY_SPENT)))
|
||||
.make());
|
||||
}
|
||||
}
|
@ -21,43 +21,32 @@ package ca.tweetzy.auctionhouse.guis.statistics;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionStatisticType;
|
||||
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.guis.abstraction.AuctionBaseGUI;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.compatibility.XMaterial;
|
||||
import ca.tweetzy.flight.utils.QuickItem;
|
||||
|
||||
public final class GUIStatisticViewSelect extends AbstractPlaceholderGui {
|
||||
public final class GUIStatisticViewSelect extends AuctionBaseGUI {
|
||||
|
||||
private final AuctionPlayer auctionPlayer;
|
||||
|
||||
public GUIStatisticViewSelect(AuctionPlayer player) {
|
||||
super(player);
|
||||
super(null, player.getPlayer(), Settings.GUI_STATS_VIEW_SELECT_TITLE.getString(), 3);
|
||||
this.auctionPlayer = player;
|
||||
setTitle(Settings.GUI_STATS_VIEW_SELECT_TITLE.getString());
|
||||
setDefaultItem(ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_STATS_VIEW_SELECT_BG_ITEM.getString()));
|
||||
setUseLockedCells(true);
|
||||
setAcceptsItems(false);
|
||||
setAllowDrops(false);
|
||||
setRows(3);
|
||||
setDefaultItem(QuickItem.bg(QuickItem.of(Settings.GUI_STATS_VIEW_SELECT_BG_ITEM.getString()).make()));
|
||||
draw();
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
|
||||
@Override
|
||||
protected void draw() {
|
||||
// self
|
||||
setButton(1, 2, ConfigurationItemHelper.createConfigurationItem(this.player,
|
||||
Settings.GUI_STATS_VIEW_SELECT_ITEMS_PERSONAL_USE_HEAD.getBoolean() ?
|
||||
AuctionAPI.getInstance().getPlayerHead(this.player.getName()) : XMaterial.matchXMaterial(Settings.GUI_STATS_VIEW_SELECT_ITEMS_PERSONAL_ITEM.getString()).orElse(XMaterial.STONE).parseItem(),
|
||||
Settings.GUI_STATS_VIEW_SELECT_ITEMS_PERSONAL_NAME.getString(),
|
||||
Settings.GUI_STATS_VIEW_SELECT_ITEMS_PERSONAL_LORE.getStringList(),
|
||||
null
|
||||
), click -> click.manager.showGUI(click.player, new GUIStatisticSelf(this.auctionPlayer)));
|
||||
setButton(1, 2, QuickItem.of(Settings.GUI_STATS_VIEW_SELECT_ITEMS_PERSONAL_USE_HEAD.getBoolean() ? AuctionAPI.getInstance().getPlayerHead(this.player.getName()) : QuickItem.of(Settings.GUI_STATS_VIEW_SELECT_ITEMS_PERSONAL_ITEM.getString()).make())
|
||||
.name(Settings.GUI_STATS_VIEW_SELECT_ITEMS_PERSONAL_NAME.getString())
|
||||
.lore(Settings.GUI_STATS_VIEW_SELECT_ITEMS_PERSONAL_LORE.getStringList())
|
||||
.make(), click -> click.manager.showGUI(click.player, new GUIStatisticView(this.auctionPlayer, this.auctionPlayer)));
|
||||
|
||||
setButton(1, 6, ConfigurationItemHelper.createConfigurationItem(this.player,
|
||||
XMaterial.matchXMaterial(Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_ITEM.getString()).orElse(XMaterial.STONE).parseItem(),
|
||||
Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_NAME.getString(),
|
||||
Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_LORE.getStringList(),
|
||||
null
|
||||
), click -> click.manager.showGUI(click.player, new GUIStatisticLeaderboard(this.auctionPlayer, AuctionStatisticType.MONEY_EARNED)));
|
||||
setButton(1, 6, QuickItem.of(Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_ITEM.getString())
|
||||
.name(Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_NAME.getString())
|
||||
.lore(Settings.GUI_STATS_VIEW_SELECT_ITEMS_LEADERBOARD_LORE.getStringList())
|
||||
.make(), click -> click.manager.showGUI(click.player, new GUIStatisticLeaderboard(this.auctionPlayer, AuctionStatisticType.MONEY_EARNED)));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user