mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-29 06:35:28 +01:00
2.68.0
Took 23 minutes
This commit is contained in:
parent
adc51dfe8f
commit
d5e4a3dc51
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>ca.tweetzy</groupId>
|
<groupId>ca.tweetzy</groupId>
|
||||||
<artifactId>auctionhouse</artifactId>
|
<artifactId>auctionhouse</artifactId>
|
||||||
<version>2.67.0</version>
|
<version>2.68.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -3,6 +3,7 @@ package ca.tweetzy.auctionhouse.commands;
|
|||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||||
import ca.tweetzy.auctionhouse.guis.GUISellItem;
|
import ca.tweetzy.auctionhouse.guis.GUISellItem;
|
||||||
|
import ca.tweetzy.auctionhouse.guis.admin.GUIAdminExpired;
|
||||||
import ca.tweetzy.auctionhouse.guis.admin.GUIAdminLogs;
|
import ca.tweetzy.auctionhouse.guis.admin.GUIAdminLogs;
|
||||||
import ca.tweetzy.auctionhouse.helpers.PlayerHelper;
|
import ca.tweetzy.auctionhouse.helpers.PlayerHelper;
|
||||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||||
@ -11,6 +12,7 @@ import ca.tweetzy.core.compatibility.CompatibleHand;
|
|||||||
import ca.tweetzy.core.compatibility.XMaterial;
|
import ca.tweetzy.core.compatibility.XMaterial;
|
||||||
import ca.tweetzy.core.utils.PlayerUtils;
|
import ca.tweetzy.core.utils.PlayerUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -18,6 +20,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current file has been created by Kiran Hart
|
* The current file has been created by Kiran Hart
|
||||||
@ -47,6 +50,29 @@ public class CommandAdmin extends AbstractCommand {
|
|||||||
else
|
else
|
||||||
error.printStackTrace();
|
error.printStackTrace();
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
case "viewexpired":
|
||||||
|
if (!(sender instanceof Player)) break;
|
||||||
|
player = (Player) sender;
|
||||||
|
|
||||||
|
if (args.length < 2) return ReturnType.FAILURE;
|
||||||
|
OfflinePlayer target = Bukkit.getPlayerExact(args[1]);
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
for (OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
|
||||||
|
if (offlinePlayer.getName() != null && offlinePlayer.getName().equalsIgnoreCase(args[1])) {
|
||||||
|
target = offlinePlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
AuctionHouse.getInstance().getLocale().getMessage("general.playernotfound").processPlaceholder("player", args[1]).sendPrefixedMessage(sender);
|
||||||
|
return ReturnType.FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIAdminExpired(player, target));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "endall":
|
case "endall":
|
||||||
for (UUID id : AuctionHouse.getInstance().getAuctionItemManager().getItems().keySet()) {
|
for (UUID id : AuctionHouse.getInstance().getAuctionItemManager().getItems().keySet()) {
|
||||||
@ -97,8 +123,9 @@ public class CommandAdmin extends AbstractCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> onTab(CommandSender sender, String... args) {
|
protected List<String> onTab(CommandSender sender, String... args) {
|
||||||
if (args.length == 1) return Arrays.asList("endall", "relistall", "logs");
|
if (args.length == 1) return Arrays.asList("endall", "relistall", "logs", "viewexpired");
|
||||||
if (args.length == 2 && args[0].equalsIgnoreCase("relistAll")) return Arrays.asList("1", "2", "3", "4", "5");
|
if (args.length == 2 && args[0].equalsIgnoreCase("relistAll")) return Arrays.asList("1", "2", "3", "4", "5");
|
||||||
|
if (args.length == 2 && args[0].equalsIgnoreCase("viewexpired")) return Bukkit.getOnlinePlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toList());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ public class DataManager extends DataManagerAbstract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saveBans(List<AuctionBan> bans, boolean async) {
|
public void saveBans(List<AuctionBan> bans, boolean async) {
|
||||||
;
|
|
||||||
String saveItems = "INSERT INTO " + this.getTablePrefix() + "bans(user, reason, time) VALUES(?, ?, ?)";
|
String saveItems = "INSERT INTO " + this.getTablePrefix() + "bans(user, reason, time) VALUES(?, ?, ?)";
|
||||||
String truncate = AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector ? "TRUNCATE TABLE " + this.getTablePrefix() + "bans" : "DELETE FROM " + this.getTablePrefix() + "bans";
|
String truncate = AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector ? "TRUNCATE TABLE " + this.getTablePrefix() + "bans" : "DELETE FROM " + this.getTablePrefix() + "bans";
|
||||||
|
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Auction House
|
||||||
|
* Copyright 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.admin;
|
||||||
|
|
||||||
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
|
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
|
||||||
|
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
|
||||||
|
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||||
|
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||||
|
import ca.tweetzy.core.utils.TextUtils;
|
||||||
|
import ca.tweetzy.core.utils.items.TItemBuilder;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public final class GUIAdminExpired extends AbstractPlaceholderGui {
|
||||||
|
|
||||||
|
final OfflinePlayer targetUser;
|
||||||
|
List<AuctionedItem> items;
|
||||||
|
|
||||||
|
public GUIAdminExpired(Player viewer, OfflinePlayer targetUser) {
|
||||||
|
super(viewer);
|
||||||
|
this.targetUser = targetUser;
|
||||||
|
this.items = AuctionHouse.getInstance().getAuctionItemManager().getItems().values().stream().filter(item -> item.isExpired() && item.getOwner().equals(targetUser.getUniqueId())).collect(Collectors.toList());
|
||||||
|
setTitle(Settings.GUI_EXPIRED_ITEMS_ADMIN_TITLE.getString());
|
||||||
|
setRows(6);
|
||||||
|
setAcceptsItems(false);
|
||||||
|
draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void draw() {
|
||||||
|
reset();
|
||||||
|
|
||||||
|
setButton(5, 4, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> e.gui.close());
|
||||||
|
|
||||||
|
AuctionHouse.newChain().asyncFirst(() -> this.items.stream().sorted(Comparator.comparingLong(AuctionedItem::getExpiresAt).reversed()).skip((page - 1) * 45L).limit(45).collect(Collectors.toList())).asyncLast(data -> {
|
||||||
|
pages = (int) Math.max(1, Math.ceil(this.items.size() / (double) 45));
|
||||||
|
setPrevPage(5, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_BACK_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_BACK_BTN_NAME.getString()).setLore(Settings.GUI_BACK_BTN_LORE.getStringList()).toItemStack());
|
||||||
|
setNextPage(5, 5, new TItemBuilder(Objects.requireNonNull(Settings.GUI_NEXT_BTN_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_NEXT_BTN_NAME.getString()).setLore(Settings.GUI_NEXT_BTN_LORE.getStringList()).toItemStack());
|
||||||
|
|
||||||
|
setOnPage(e -> {
|
||||||
|
draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
int slot = 0;
|
||||||
|
for (AuctionedItem auctionItem : data) {
|
||||||
|
ItemStack item = auctionItem.getItem().clone();
|
||||||
|
|
||||||
|
ItemMeta meta = item.hasItemMeta() ? item.getItemMeta() : Bukkit.getItemFactory().getItemMeta(item.getType());
|
||||||
|
List<String> lore = (meta.hasLore()) ? meta.getLore() : new ArrayList<>();
|
||||||
|
|
||||||
|
lore.addAll(TextUtils.formatText(Settings.GUI_EXPIRED_ITEMS_ADMIN_ITEMS_LORE.getStringList()));
|
||||||
|
meta.setLore(lore);
|
||||||
|
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
setButton(slot++, item, ClickType.LEFT, e -> {
|
||||||
|
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(auctionItem);
|
||||||
|
e.manager.showGUI(e.player, new GUIAdminExpired(e.player, this.targetUser));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}).execute();
|
||||||
|
}
|
||||||
|
}
|
@ -855,6 +855,12 @@ public class Settings {
|
|||||||
"&7Money Spent: &a$%auctions_money_spent%"
|
"&7Money Spent: &a$%auctions_money_spent%"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
/* ===============================
|
||||||
|
* EXPIRED ITEMS ADMIN GUI
|
||||||
|
* ===============================*/
|
||||||
|
public static final ConfigSetting GUI_EXPIRED_ITEMS_ADMIN_TITLE = new ConfigSetting(config, "gui.expired items admin.title", "&7Auction House - &eAdmin Expired");
|
||||||
|
public static final ConfigSetting GUI_EXPIRED_ITEMS_ADMIN_BG_ITEM = new ConfigSetting(config, "gui.expired items admin.bg item", XMaterial.BLACK_STAINED_GLASS_PANE.name());
|
||||||
|
public static final ConfigSetting GUI_EXPIRED_ITEMS_ADMIN_ITEMS_LORE = new ConfigSetting(config, "gui.expired items admin.item lore", Collections.singletonList("&7Click to delete this item"));
|
||||||
|
|
||||||
/* ===============================
|
/* ===============================
|
||||||
* ITEM ADMIN GUI
|
* ITEM ADMIN GUI
|
||||||
|
Loading…
Reference in New Issue
Block a user