mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-22 05:25:11 +01:00
✈️ begin flight migration
This commit is contained in:
parent
070a38e1e3
commit
f07c8e7639
10
pom.xml
10
pom.xml
@ -116,11 +116,6 @@
|
|||||||
<version>1.7</version>
|
<version>1.7</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>ca.tweetzy</groupId>
|
|
||||||
<artifactId>tweetycore</artifactId>
|
|
||||||
<version>3.7.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mineacademy.plugin</groupId>
|
<groupId>org.mineacademy.plugin</groupId>
|
||||||
<artifactId>CMI-API</artifactId>
|
<artifactId>CMI-API</artifactId>
|
||||||
@ -270,7 +265,6 @@
|
|||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>${flight.path}:flight*</include>
|
<include>${flight.path}:flight*</include>
|
||||||
<include>ca.tweetzy:tweetycore</include>
|
|
||||||
<include>com.zaxxer:HikariCP</include>
|
<include>com.zaxxer:HikariCP</include>
|
||||||
<include>org.slf4j:slf4j-api</include>
|
<include>org.slf4j:slf4j-api</include>
|
||||||
<include>org.slf4j:slf4j-nop</include>
|
<include>org.slf4j:slf4j-nop</include>
|
||||||
@ -290,10 +284,6 @@
|
|||||||
</filter>
|
</filter>
|
||||||
</filters>
|
</filters>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
|
||||||
<pattern>ca.tweetzy.core</pattern>
|
|
||||||
<shadedPattern>${project.groupId}.${project.artifactId}.core</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>ca.tweetzy.flight</pattern>
|
<pattern>ca.tweetzy.flight</pattern>
|
||||||
<shadedPattern>${project.groupId}.${project.artifactId}.flight</shadedPattern>
|
<shadedPattern>${project.groupId}.${project.artifactId}.flight</shadedPattern>
|
||||||
|
@ -18,47 +18,21 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse;
|
package ca.tweetzy.auctionhouse;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
|
|
||||||
import ca.tweetzy.auctionhouse.commands.*;
|
|
||||||
import ca.tweetzy.auctionhouse.database.DataManager;
|
import ca.tweetzy.auctionhouse.database.DataManager;
|
||||||
import ca.tweetzy.auctionhouse.database.migrations.*;
|
import ca.tweetzy.auctionhouse.database.migrations.*;
|
||||||
import ca.tweetzy.auctionhouse.helpers.UpdateChecker;
|
import ca.tweetzy.auctionhouse.helpers.UpdateChecker;
|
||||||
import ca.tweetzy.auctionhouse.hooks.PlaceholderAPIHook;
|
|
||||||
import ca.tweetzy.auctionhouse.hooks.UltraEconomyHook;
|
|
||||||
import ca.tweetzy.auctionhouse.listeners.*;
|
|
||||||
import ca.tweetzy.auctionhouse.managers.*;
|
import ca.tweetzy.auctionhouse.managers.*;
|
||||||
import ca.tweetzy.auctionhouse.settings.LocaleSettings;
|
import ca.tweetzy.auctionhouse.settings.v3.Settings;
|
||||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
import ca.tweetzy.auctionhouse.settings.v3.Translations;
|
||||||
import ca.tweetzy.auctionhouse.tasks.AutoSaveTask;
|
import ca.tweetzy.flight.FlightPlugin;
|
||||||
import ca.tweetzy.auctionhouse.tasks.TickAuctionsTask;
|
import ca.tweetzy.flight.database.DataMigrationManager;
|
||||||
import ca.tweetzy.core.TweetyCore;
|
import ca.tweetzy.flight.database.DatabaseConnector;
|
||||||
import ca.tweetzy.core.TweetyPlugin;
|
import ca.tweetzy.flight.database.SQLiteConnector;
|
||||||
import ca.tweetzy.core.commands.CommandManager;
|
import ca.tweetzy.flight.utils.Common;
|
||||||
import ca.tweetzy.core.compatibility.ServerProject;
|
|
||||||
import ca.tweetzy.core.compatibility.ServerVersion;
|
|
||||||
import ca.tweetzy.core.configuration.Config;
|
|
||||||
import ca.tweetzy.core.database.DataMigrationManager;
|
|
||||||
import ca.tweetzy.core.database.DatabaseConnector;
|
|
||||||
import ca.tweetzy.core.database.MySQLConnector;
|
|
||||||
import ca.tweetzy.core.database.SQLiteConnector;
|
|
||||||
import ca.tweetzy.core.gui.GuiManager;
|
|
||||||
import ca.tweetzy.core.hooks.EconomyManager;
|
|
||||||
import ca.tweetzy.core.hooks.PluginHook;
|
|
||||||
import ca.tweetzy.core.hooks.economies.Economy;
|
|
||||||
import ca.tweetzy.core.utils.Metrics;
|
|
||||||
import ca.tweetzy.core.utils.TextUtils;
|
|
||||||
import co.aikar.taskchain.BukkitTaskChainFactory;
|
|
||||||
import co.aikar.taskchain.TaskChain;
|
import co.aikar.taskchain.TaskChain;
|
||||||
import co.aikar.taskchain.TaskChainFactory;
|
import co.aikar.taskchain.TaskChainFactory;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,26 +42,27 @@ import java.util.stream.Collectors;
|
|||||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AuctionHouse extends TweetyPlugin {
|
public class AuctionHouse extends FlightPlugin {
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
private DatabaseConnector databaseConnector;
|
||||||
|
private DataManager dataManager;
|
||||||
|
|
||||||
private static TaskChainFactory taskChainFactory;
|
private static TaskChainFactory taskChainFactory;
|
||||||
private static AuctionHouse instance;
|
private static AuctionHouse instance;
|
||||||
private PluginHook ultraEconomyHook;
|
// private PluginHook ultraEconomyHook;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private boolean migrating = false;
|
private boolean migrating = false;
|
||||||
|
|
||||||
@Getter
|
// @Getter
|
||||||
private final GuiManager guiManager = new GuiManager(this);
|
// private final GuiManager guiManager = new GuiManager(this);
|
||||||
|
//
|
||||||
protected Metrics metrics;
|
// protected Metrics metrics;
|
||||||
|
//
|
||||||
@Getter
|
// @Getter
|
||||||
private CommandManager commandManager;
|
// private CommandManager commandManager;
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -114,101 +89,19 @@ public class AuctionHouse extends TweetyPlugin {
|
|||||||
@Getter
|
@Getter
|
||||||
private PaymentsManager paymentsManager;
|
private PaymentsManager paymentsManager;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private DatabaseConnector databaseConnector;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private DataManager dataManager;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private UpdateChecker.UpdateStatus status;
|
private UpdateChecker.UpdateStatus status;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginLoad() {
|
protected void onFlight() {
|
||||||
instance = this;
|
Settings.init();
|
||||||
}
|
Translations.init();
|
||||||
|
|
||||||
@Override
|
Common.setPrefix(Settings.PREFIX.getStringOr("&8[&EAuctionHouse&8]"));
|
||||||
public void onPluginEnable() {
|
|
||||||
TweetyCore.registerPlugin(this, 1, "CHEST");
|
|
||||||
|
|
||||||
// Check server version
|
// Set up the database if enabled
|
||||||
if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_7)) {
|
this.databaseConnector = new SQLiteConnector(this);
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
this.dataManager = new DataManager(this.databaseConnector, this, null);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
taskChainFactory = BukkitTaskChainFactory.create(this);
|
|
||||||
|
|
||||||
// Settings
|
|
||||||
Settings.setup();
|
|
||||||
|
|
||||||
if (Settings.AUTO_BSTATS.getBoolean()) {
|
|
||||||
final File file = new File("plugins" + File.separator + "bStats" + File.separator + "config.yml");
|
|
||||||
if (file.exists()) {
|
|
||||||
final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
|
|
||||||
configuration.set("enabled", true);
|
|
||||||
try {
|
|
||||||
configuration.save(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ultraEconomyHook = PluginHook.addHook(Economy.class, "UltraEconomy", UltraEconomyHook.class);
|
|
||||||
|
|
||||||
// v3 translations & Settings
|
|
||||||
// Translations.init();
|
|
||||||
|
|
||||||
// Load Economy
|
|
||||||
EconomyManager.load();
|
|
||||||
|
|
||||||
// local
|
|
||||||
setLocale(Settings.LANG.getString());
|
|
||||||
LocaleSettings.setup();
|
|
||||||
|
|
||||||
// Setup Economy
|
|
||||||
final String ECO_PLUGIN = Settings.ECONOMY_PLUGIN.getString();
|
|
||||||
|
|
||||||
|
|
||||||
if (ECO_PLUGIN.startsWith("UltraEconomy")) {
|
|
||||||
EconomyManager.getManager().setPreferredHook(this.ultraEconomyHook);
|
|
||||||
} else {
|
|
||||||
EconomyManager.getManager().setPreferredHook(ECO_PLUGIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!EconomyManager.getManager().isEnabled()) {
|
|
||||||
getLogger().severe("Could not find a valid economy provider for Auction House");
|
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// listeners
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new PlayerListeners(), this);
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new MeteorClientListeners(), this);
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new AuctionListeners(), this);
|
|
||||||
|
|
||||||
if (getServer().getPluginManager().isPluginEnabled("ChestShop"))
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new ChestShopListener(), this);
|
|
||||||
|
|
||||||
if (getServer().getPluginManager().isPluginEnabled("CMI"))
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new CMIListener(), this);
|
|
||||||
|
|
||||||
// Setup the database if enabled
|
|
||||||
this.databaseConnector = Settings.DATABASE_USE.getBoolean() ? new MySQLConnector(
|
|
||||||
this,
|
|
||||||
Settings.DATABASE_HOST.getString(),
|
|
||||||
Settings.DATABASE_PORT.getInt(),
|
|
||||||
Settings.DATABASE_NAME.getString(),
|
|
||||||
Settings.DATABASE_USERNAME.getString(),
|
|
||||||
Settings.DATABASE_PASSWORD.getString(),
|
|
||||||
Settings.DATABASE_CUSTOM_PARAMS.getString().equalsIgnoreCase("None") ? "" : Settings.DATABASE_CUSTOM_PARAMS.getString()
|
|
||||||
) : new SQLiteConnector(this);
|
|
||||||
|
|
||||||
// Use a custom table prefix if using a remote database. The default prefix setting acts exactly like if the prefix is null
|
|
||||||
final String tablePrefix = Settings.DATABASE_USE.getBoolean() ? Settings.DATABASE_TABLE_PREFIX.getString() : null;
|
|
||||||
this.dataManager = new DataManager(this.databaseConnector, this, tablePrefix);
|
|
||||||
|
|
||||||
DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager,
|
DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager,
|
||||||
new _1_InitialMigration(),
|
new _1_InitialMigration(),
|
||||||
@ -235,152 +128,269 @@ public class AuctionHouse extends TweetyPlugin {
|
|||||||
);
|
);
|
||||||
|
|
||||||
dataMigrationManager.runMigrations();
|
dataMigrationManager.runMigrations();
|
||||||
|
|
||||||
// load auction items
|
|
||||||
this.auctionItemManager = new AuctionItemManager();
|
|
||||||
this.auctionItemManager.start();
|
|
||||||
|
|
||||||
// load transactions
|
|
||||||
this.transactionManager = new TransactionManager();
|
|
||||||
this.transactionManager.loadTransactions();
|
|
||||||
|
|
||||||
// load the filter whitelist items
|
|
||||||
this.filterManager = new FilterManager();
|
|
||||||
this.filterManager.loadItems();
|
|
||||||
|
|
||||||
// load the bans
|
|
||||||
this.auctionBanManager = new AuctionBanManager();
|
|
||||||
this.auctionBanManager.loadBans();
|
|
||||||
|
|
||||||
this.minItemPriceManager = new MinItemPriceManager();
|
|
||||||
this.minItemPriceManager.loadMinPrices();
|
|
||||||
|
|
||||||
this.auctionStatisticManager = new AuctionStatisticManager();
|
|
||||||
this.auctionStatisticManager.loadStatistics();
|
|
||||||
|
|
||||||
// auction players
|
|
||||||
this.auctionPlayerManager = new AuctionPlayerManager();
|
|
||||||
this.auctionPlayerManager.loadPlayers();
|
|
||||||
|
|
||||||
// payments
|
|
||||||
this.paymentsManager = new PaymentsManager();
|
|
||||||
this.paymentsManager.loadPayments();
|
|
||||||
|
|
||||||
// gui manager
|
|
||||||
this.guiManager.init();
|
|
||||||
|
|
||||||
// commands
|
|
||||||
this.commandManager = new CommandManager(this);
|
|
||||||
this.commandManager.setSyntaxErrorMessage(TextUtils.formatText(getLocale().getMessage("commands.invalid_syntax").getMessage().split("\n")));
|
|
||||||
this.commandManager.setNoPermsMessage(TextUtils.formatText(getLocale().getMessage("commands.no_permission").getMessage()));
|
|
||||||
this.commandManager.addCommand(new CommandAuctionHouse()).addSubCommands(
|
|
||||||
new CommandSell(),
|
|
||||||
new CommandActive(),
|
|
||||||
new CommandExpired(),
|
|
||||||
new CommandTransactions(),
|
|
||||||
new CommandSearch(),
|
|
||||||
new CommandSettings(),
|
|
||||||
new CommandToggleListInfo(),
|
|
||||||
new CommandMigrate(),
|
|
||||||
new CommandReload(),
|
|
||||||
new CommandFilter(),
|
|
||||||
new CommandAdmin(),
|
|
||||||
new CommandBan(),
|
|
||||||
new CommandUnban(),
|
|
||||||
new CommandMarkChest(),
|
|
||||||
new CommandUpload(),
|
|
||||||
new CommandMinPrice(),
|
|
||||||
new CommandStats(),
|
|
||||||
new CommandPayments(),
|
|
||||||
new CommandBids(),
|
|
||||||
new CommandConfirm(),
|
|
||||||
new CommandRequest()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Placeholder API
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
|
||||||
new PlaceholderAPIHook(this).register();
|
|
||||||
}
|
|
||||||
|
|
||||||
// start the auction tick task
|
|
||||||
TickAuctionsTask.startTask();
|
|
||||||
|
|
||||||
// auto save task
|
|
||||||
if (Settings.AUTO_SAVE_ENABLED.getBoolean()) {
|
|
||||||
AutoSaveTask.startTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
// update check
|
|
||||||
if (Settings.UPDATE_CHECKER.getBoolean() && ServerProject.getServerVersion() != ServerProject.UNKNOWN)
|
|
||||||
getServer().getScheduler().runTaskLaterAsynchronously(this, () -> this.status = new UpdateChecker(this, 60325, getConsole()).check().getStatus(), 1L);
|
|
||||||
|
|
||||||
// metrics
|
|
||||||
this.metrics = new Metrics(this, 6806);
|
|
||||||
this.metrics.addCustomChart(new Metrics.SimplePie("using_mysql", () -> String.valueOf(Settings.DATABASE_USE.getBoolean())));
|
|
||||||
|
|
||||||
getServer().getScheduler().runTaskLater(this, () -> {
|
|
||||||
if (!ServerProject.isServer(ServerProject.SPIGOT, ServerProject.PAPER)) {
|
|
||||||
getLogger().severe("You're running Auction House on a non-supported Jar");
|
|
||||||
getLogger().severe("You will not receive any support while using a non-supported jar, support jars: Spigot or Paper");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_16)) {
|
|
||||||
getLogger().severe("You are receiving this message because you're running Auction House on a Minecraft version older than 1.16. As a heads up, Auction House 3.0 is going to be for 1.16+ only");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ServerProject.isServer(ServerProject.PAPER, ServerProject.SPIGOT)) {
|
|
||||||
getLogger().warning("You're running Auction House on a non supported server jar, although small, there's a chance somethings will not work or just entirely break.");
|
|
||||||
}
|
|
||||||
|
|
||||||
final String uIDPartOne = "%%__US";
|
|
||||||
final String uIDPartTwo = "ER__%%";
|
|
||||||
|
|
||||||
if (USER.contains(uIDPartOne) && USER.contains(uIDPartTwo)) {
|
|
||||||
getLogger().severe("Could not detect user ID, are you running a cracked / self-compiled copy of auction house?");
|
|
||||||
} else {
|
|
||||||
getConsole().sendMessage(TextUtils.formatText("&e&m--------------------------------------------------------"));
|
|
||||||
getConsole().sendMessage(TextUtils.formatText(""));
|
|
||||||
getConsole().sendMessage(TextUtils.formatText("&aThank you for purchasing Auction House, it means a lot"));
|
|
||||||
getConsole().sendMessage(TextUtils.formatText("&7 - Kiran Hart"));
|
|
||||||
getConsole().sendMessage(TextUtils.formatText(""));
|
|
||||||
getConsole().sendMessage(TextUtils.formatText("&e&m--------------------------------------------------------"));
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void onPluginDisable() {
|
// public void onPluginEnable() {
|
||||||
if (this.dataManager != null) {
|
// TweetyCore.registerPlugin(this, 1, "CHEST");
|
||||||
// clean up the garbage items
|
//
|
||||||
AuctionHouse.getInstance().getDataManager().deleteItems(AuctionHouse.getInstance().getAuctionItemManager().getDeletedItems().values().stream().map(AuctionedItem::getId).collect(Collectors.toList()));
|
// // Check server version
|
||||||
|
// if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_7)) {
|
||||||
|
// getServer().getPluginManager().disablePlugin(this);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taskChainFactory = BukkitTaskChainFactory.create(this);
|
||||||
|
//
|
||||||
|
// // Settings
|
||||||
|
// Settings.setup();
|
||||||
|
//
|
||||||
|
// if (Settings.AUTO_BSTATS.getBoolean()) {
|
||||||
|
// final File file = new File("plugins" + File.separator + "bStats" + File.separator + "config.yml");
|
||||||
|
// if (file.exists()) {
|
||||||
|
// final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
|
||||||
|
// configuration.set("enabled", true);
|
||||||
|
// try {
|
||||||
|
// configuration.save(file);
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// this.ultraEconomyHook = PluginHook.addHook(Economy.class, "UltraEconomy", UltraEconomyHook.class);
|
||||||
|
//
|
||||||
|
// // v3 translations & Settings
|
||||||
|
//// Translations.init();
|
||||||
|
//
|
||||||
|
// // Load Economy
|
||||||
|
// EconomyManager.load();
|
||||||
|
//
|
||||||
|
// // local
|
||||||
|
//// setLocale(Settings.LANG.getString());
|
||||||
|
//// LocaleSettings.setup();
|
||||||
|
//
|
||||||
|
// // Setup Economy
|
||||||
|
// final String ECO_PLUGIN = Settings.ECONOMY_PLUGIN.getString();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if (ECO_PLUGIN.startsWith("UltraEconomy")) {
|
||||||
|
// EconomyManager.getManager().setPreferredHook(this.ultraEconomyHook);
|
||||||
|
// } else {
|
||||||
|
// EconomyManager.getManager().setPreferredHook(ECO_PLUGIN);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!EconomyManager.getManager().isEnabled()) {
|
||||||
|
// getLogger().severe("Could not find a valid economy provider for Auction House");
|
||||||
|
// getServer().getPluginManager().disablePlugin(this);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // listeners
|
||||||
|
// Bukkit.getServer().getPluginManager().registerEvents(new PlayerListeners(), this);
|
||||||
|
// Bukkit.getServer().getPluginManager().registerEvents(new MeteorClientListeners(), this);
|
||||||
|
// Bukkit.getServer().getPluginManager().registerEvents(new AuctionListeners(), this);
|
||||||
|
//
|
||||||
|
// if (getServer().getPluginManager().isPluginEnabled("ChestShop"))
|
||||||
|
// Bukkit.getServer().getPluginManager().registerEvents(new ChestShopListener(), this);
|
||||||
|
//
|
||||||
|
// if (getServer().getPluginManager().isPluginEnabled("CMI"))
|
||||||
|
// Bukkit.getServer().getPluginManager().registerEvents(new CMIListener(), this);
|
||||||
|
//
|
||||||
|
// // Setup the database if enabled
|
||||||
|
// this.databaseConnector = Settings.DATABASE_USE.getBoolean() ? new MySQLConnector(
|
||||||
|
// this,
|
||||||
|
// Settings.DATABASE_HOST.getString(),
|
||||||
|
// Settings.DATABASE_PORT.getInt(),
|
||||||
|
// Settings.DATABASE_NAME.getString(),
|
||||||
|
// Settings.DATABASE_USERNAME.getString(),
|
||||||
|
// Settings.DATABASE_PASSWORD.getString(),
|
||||||
|
// Settings.DATABASE_CUSTOM_PARAMS.getString().equalsIgnoreCase("None") ? "" : Settings.DATABASE_CUSTOM_PARAMS.getString()
|
||||||
|
// ) : new SQLiteConnector(this);
|
||||||
|
//
|
||||||
|
// // Use a custom table prefix if using a remote database. The default prefix setting acts exactly like if the prefix is null
|
||||||
|
// final String tablePrefix = Settings.DATABASE_USE.getBoolean() ? Settings.DATABASE_TABLE_PREFIX.getString() : null;
|
||||||
|
// this.dataManager = new DataManager(this.databaseConnector, this, tablePrefix);
|
||||||
|
//
|
||||||
|
// DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager,
|
||||||
|
// new _1_InitialMigration(),
|
||||||
|
// new _2_FilterWhitelistMigration(),
|
||||||
|
// new _3_BansMigration(),
|
||||||
|
// new _4_ItemsChangeMigration(),
|
||||||
|
// new _5_TransactionChangeMigration(),
|
||||||
|
// new _6_BigIntMigration(),
|
||||||
|
// new _7_TransactionBigIntMigration(),
|
||||||
|
// new _8_ItemPerWorldMigration(),
|
||||||
|
// new _9_StatsMigration(),
|
||||||
|
// new _10_InfiniteItemsMigration(),
|
||||||
|
// new _11_AdminLogMigration(),
|
||||||
|
// new _12_SerializeFormatDropMigration(),
|
||||||
|
// new _13_MinItemPriceMigration(),
|
||||||
|
// new _14_PartialQtyBuyMigration(),
|
||||||
|
// new _15_AuctionPlayerMigration(),
|
||||||
|
// new _16_StatisticVersionTwoMigration(),
|
||||||
|
// new _17_PaymentsMigration(),
|
||||||
|
// new _18_PaymentsItemMigration(),
|
||||||
|
// new _19_ServerAuctionMigration(),
|
||||||
|
// new _20_AuctionRequestsMigration(),
|
||||||
|
// new _21_RequestsDynAmtMigration()
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// dataMigrationManager.runMigrations();
|
||||||
|
//
|
||||||
|
// // load auction items
|
||||||
|
// this.auctionItemManager = new AuctionItemManager();
|
||||||
|
// this.auctionItemManager.start();
|
||||||
|
//
|
||||||
|
// // load transactions
|
||||||
|
// this.transactionManager = new TransactionManager();
|
||||||
|
// this.transactionManager.loadTransactions();
|
||||||
|
//
|
||||||
|
// // load the filter whitelist items
|
||||||
|
// this.filterManager = new FilterManager();
|
||||||
|
// this.filterManager.loadItems();
|
||||||
|
//
|
||||||
|
// // load the bans
|
||||||
|
// this.auctionBanManager = new AuctionBanManager();
|
||||||
|
// this.auctionBanManager.loadBans();
|
||||||
|
//
|
||||||
|
// this.minItemPriceManager = new MinItemPriceManager();
|
||||||
|
// this.minItemPriceManager.loadMinPrices();
|
||||||
|
//
|
||||||
|
// this.auctionStatisticManager = new AuctionStatisticManager();
|
||||||
|
// this.auctionStatisticManager.loadStatistics();
|
||||||
|
//
|
||||||
|
// // auction players
|
||||||
|
// this.auctionPlayerManager = new AuctionPlayerManager();
|
||||||
|
// this.auctionPlayerManager.loadPlayers();
|
||||||
|
//
|
||||||
|
// // payments
|
||||||
|
// this.paymentsManager = new PaymentsManager();
|
||||||
|
// this.paymentsManager.loadPayments();
|
||||||
|
//
|
||||||
|
// // gui manager
|
||||||
|
// this.guiManager.init();
|
||||||
|
//
|
||||||
|
// // commands
|
||||||
|
// this.commandManager = new CommandManager(this);
|
||||||
|
//// this.commandManager.setSyntaxErrorMessage(TextUtils.formatText(getLocale().getMessage("commands.invalid_syntax").getMessage().split("\n")));
|
||||||
|
//// this.commandManager.setNoPermsMessage(TextUtils.formatText(getLocale().getMessage("commands.no_permission").getMessage()));
|
||||||
|
// this.commandManager.addCommand(new CommandAuctionHouse()).addSubCommands(
|
||||||
|
// new CommandSell(),
|
||||||
|
// new CommandActive(),
|
||||||
|
// new CommandExpired(),
|
||||||
|
// new CommandTransactions(),
|
||||||
|
// new CommandSearch(),
|
||||||
|
// new CommandSettings(),
|
||||||
|
// new CommandToggleListInfo(),
|
||||||
|
// new CommandMigrate(),
|
||||||
|
// new CommandReload(),
|
||||||
|
// new CommandFilter(),
|
||||||
|
// new CommandAdmin(),
|
||||||
|
// new CommandBan(),
|
||||||
|
// new CommandUnban(),
|
||||||
|
// new CommandMarkChest(),
|
||||||
|
// new CommandUpload(),
|
||||||
|
// new CommandMinPrice(),
|
||||||
|
// new CommandStats(),
|
||||||
|
// new CommandPayments(),
|
||||||
|
// new CommandBids(),
|
||||||
|
// new CommandConfirm(),
|
||||||
|
// new CommandRequest()
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// // Placeholder API
|
||||||
|
// if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
|
// new PlaceholderAPIHook(this).register();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // start the auction tick task
|
||||||
|
// TickAuctionsTask.startTask();
|
||||||
|
//
|
||||||
|
// // auto save task
|
||||||
|
// if (Settings.AUTO_SAVE_ENABLED.getBoolean()) {
|
||||||
|
// AutoSaveTask.startTask();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // update check
|
||||||
|
//// if (Settings.UPDATE_CHECKER.getBoolean() && ServerProject.getServerVersion() != ServerProject.UNKNOWN)
|
||||||
|
//// getServer().getScheduler().runTaskLaterAsynchronously(this, () -> this.status = new UpdateChecker(this, 60325, getConsole()).check().getStatus(), 1L);
|
||||||
|
//
|
||||||
|
// // metrics
|
||||||
|
// this.metrics = new Metrics(this, 6806);
|
||||||
|
// this.metrics.addCustomChart(new Metrics.SimplePie("using_mysql", () -> String.valueOf(Settings.DATABASE_USE.getBoolean())));
|
||||||
|
//
|
||||||
|
// getServer().getScheduler().runTaskLater(this, () -> {
|
||||||
|
// if (!ServerProject.isServer(ServerProject.SPIGOT, ServerProject.PAPER)) {
|
||||||
|
// getLogger().severe("You're running Auction House on a non-supported Jar");
|
||||||
|
// getLogger().severe("You will not receive any support while using a non-supported jar, support jars: Spigot or Paper");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (ServerVersion.isServerVersionBelow(ServerVersion.V1_16)) {
|
||||||
|
// getLogger().severe("You are receiving this message because you're running Auction House on a Minecraft version older than 1.16. As a heads up, Auction House 3.0 is going to be for 1.16+ only");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!ServerProject.isServer(ServerProject.PAPER, ServerProject.SPIGOT)) {
|
||||||
|
// getLogger().warning("You're running Auction House on a non supported server jar, although small, there's a chance somethings will not work or just entirely break.");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final String uIDPartOne = "%%__US";
|
||||||
|
// final String uIDPartTwo = "ER__%%";
|
||||||
|
//
|
||||||
|
// if (USER.contains(uIDPartOne) && USER.contains(uIDPartTwo)) {
|
||||||
|
// getLogger().severe("Could not detect user ID, are you running a cracked / self-compiled copy of auction house?");
|
||||||
|
// } else {
|
||||||
|
//// getConsole().sendMessage(TextUtils.formatText("&e&m--------------------------------------------------------"));
|
||||||
|
//// getConsole().sendMessage(TextUtils.formatText(""));
|
||||||
|
//// getConsole().sendMessage(TextUtils.formatText("&aThank you for purchasing Auction House, it means a lot"));
|
||||||
|
//// getConsole().sendMessage(TextUtils.formatText("&7 - Kiran Hart"));
|
||||||
|
//// getConsole().sendMessage(TextUtils.formatText(""));
|
||||||
|
//// getConsole().sendMessage(TextUtils.formatText("&e&m--------------------------------------------------------"));
|
||||||
|
// }
|
||||||
|
// }, 1L);
|
||||||
|
// }
|
||||||
|
|
||||||
this.auctionItemManager.end();
|
// @Override
|
||||||
this.filterManager.saveFilterWhitelist(false);
|
// public void onPluginDisable() {
|
||||||
this.auctionBanManager.saveBans(false);
|
// if (this.dataManager != null) {
|
||||||
this.dataManager.close();
|
// // clean up the garbage items
|
||||||
}
|
// AuctionHouse.getInstance().getDataManager().deleteItems(AuctionHouse.getInstance().getAuctionItemManager().getDeletedItems().values().stream().map(AuctionedItem::getId).collect(Collectors.toList()));
|
||||||
|
//
|
||||||
|
// this.auctionItemManager.end();
|
||||||
|
// this.filterManager.saveFilterWhitelist(false);
|
||||||
|
// this.auctionBanManager.saveBans(false);
|
||||||
|
// this.dataManager.close();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// getServer().getScheduler().cancelTasks(this);
|
||||||
|
// }
|
||||||
|
|
||||||
getServer().getScheduler().cancelTasks(this);
|
// @Override
|
||||||
}
|
// public void onConfigReload() {
|
||||||
|
// EconomyManager.load();
|
||||||
|
// Settings.setup();
|
||||||
|
// EconomyManager.getManager().setPreferredHook(Settings.ECONOMY_PLUGIN.getString());
|
||||||
|
// setLocale(Settings.LANG.getString());
|
||||||
|
// LocaleSettings.setup();
|
||||||
|
// this.commandManager.setSyntaxErrorMessage(TextUtils.formatText(getLocale().getMessage("commands.invalid_syntax").getMessage().split("\n")));
|
||||||
|
// this.commandManager.setNoPermsMessage(TextUtils.formatText(getLocale().getMessage("commands.no_permission").getMessage()));
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void onConfigReload() {
|
// public List<Config> getExtraConfig() {
|
||||||
EconomyManager.load();
|
// return null;
|
||||||
Settings.setup();
|
// }
|
||||||
EconomyManager.getManager().setPreferredHook(Settings.ECONOMY_PLUGIN.getString());
|
|
||||||
setLocale(Settings.LANG.getString());
|
|
||||||
LocaleSettings.setup();
|
|
||||||
this.commandManager.setSyntaxErrorMessage(TextUtils.formatText(getLocale().getMessage("commands.invalid_syntax").getMessage().split("\n")));
|
|
||||||
this.commandManager.setNoPermsMessage(TextUtils.formatText(getLocale().getMessage("commands.no_permission").getMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Config> getExtraConfig() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AuctionHouse getInstance() {
|
public static AuctionHouse getInstance() {
|
||||||
return instance;
|
return (AuctionHouse) FlightPlugin.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DatabaseConnector getDatabaseConnector() {
|
||||||
|
return getInstance().databaseConnector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataManager getDataManager() {
|
||||||
|
return getInstance().dataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> TaskChain<T> newChain() {
|
public static <T> TaskChain<T> newChain() {
|
||||||
|
@ -21,9 +21,9 @@ package ca.tweetzy.auctionhouse.commands;
|
|||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.auctionhouse.database.DataManager;
|
import ca.tweetzy.auctionhouse.database.DataManager;
|
||||||
import ca.tweetzy.core.commands.AbstractCommand;
|
import ca.tweetzy.core.commands.AbstractCommand;
|
||||||
import ca.tweetzy.core.database.DatabaseConnector;
|
|
||||||
import ca.tweetzy.core.database.SQLiteConnector;
|
|
||||||
import ca.tweetzy.core.utils.TextUtils;
|
import ca.tweetzy.core.utils.TextUtils;
|
||||||
|
import ca.tweetzy.flight.database.DatabaseConnector;
|
||||||
|
import ca.tweetzy.flight.database.SQLiteConnector;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -25,9 +25,9 @@ import ca.tweetzy.auctionhouse.auction.enums.*;
|
|||||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||||
import ca.tweetzy.auctionhouse.transaction.Transaction;
|
import ca.tweetzy.auctionhouse.transaction.Transaction;
|
||||||
import ca.tweetzy.auctionhouse.transaction.TransactionViewFilter;
|
import ca.tweetzy.auctionhouse.transaction.TransactionViewFilter;
|
||||||
import ca.tweetzy.core.database.DataManagerAbstract;
|
import ca.tweetzy.flight.database.DataManagerAbstract;
|
||||||
import ca.tweetzy.core.database.DatabaseConnector;
|
import ca.tweetzy.flight.database.DatabaseConnector;
|
||||||
import ca.tweetzy.core.database.MySQLConnector;
|
import ca.tweetzy.flight.database.MySQLConnector;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
import ca.tweetzy.core.database.MySQLConnector;
|
import ca.tweetzy.flight.database.MySQLConnector;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
import ca.tweetzy.core.database.MySQLConnector;
|
import ca.tweetzy.flight.database.MySQLConnector;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -40,7 +40,7 @@ public class _1_InitialMigration extends DataMigration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
||||||
String autoIncrement = AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : "";
|
String autoIncrement = AuctionHouse.getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : "";
|
||||||
|
|
||||||
try (Statement statement = connection.createStatement()) {
|
try (Statement statement = connection.createStatement()) {
|
||||||
statement.execute("CREATE TABLE " + tablePrefix + "items (" +
|
statement.execute("CREATE TABLE " + tablePrefix + "items (" +
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
import ca.tweetzy.core.database.MySQLConnector;
|
import ca.tweetzy.flight.database.MySQLConnector;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
import ca.tweetzy.core.database.MySQLConnector;
|
import ca.tweetzy.flight.database.MySQLConnector;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
import ca.tweetzy.core.database.MySQLConnector;
|
import ca.tweetzy.flight.database.MySQLConnector;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
import ca.tweetzy.core.database.MySQLConnector;
|
import ca.tweetzy.flight.database.MySQLConnector;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.database.migrations;
|
package ca.tweetzy.auctionhouse.database.migrations;
|
||||||
|
|
||||||
import ca.tweetzy.core.database.DataMigration;
|
import ca.tweetzy.flight.database.DataMigration;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -1,106 +0,0 @@
|
|||||||
/*
|
|
||||||
* Auction House
|
|
||||||
* Copyright 2023 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.abstraction;
|
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
|
||||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
|
||||||
import ca.tweetzy.flight.comp.enums.CompSound;
|
|
||||||
import ca.tweetzy.flight.gui.Gui;
|
|
||||||
import ca.tweetzy.flight.gui.template.BaseGUI;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public abstract class AuctionBaseGUI extends BaseGUI {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
protected final Player player;
|
|
||||||
|
|
||||||
public AuctionBaseGUI(Gui parent, @NonNull final Player player, @NonNull String title, int rows) {
|
|
||||||
super(parent, title, rows);
|
|
||||||
this.player = player;
|
|
||||||
setTitle(title);
|
|
||||||
applyDefaults();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuctionBaseGUI(Gui parent, @NonNull final Player player, @NonNull String title) {
|
|
||||||
super(parent, title);
|
|
||||||
this.player = player;
|
|
||||||
setTitle(title);
|
|
||||||
applyDefaults();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuctionBaseGUI(@NonNull final Player player, @NonNull String title) {
|
|
||||||
super(title);
|
|
||||||
this.player = player;
|
|
||||||
setTitle(title);
|
|
||||||
applyDefaults();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyDefaults() {
|
|
||||||
setDefaultItem(ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_FILLER.getString()));
|
|
||||||
setNavigateSound(CompSound.matchCompSound(Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString()).orElse(CompSound.ENTITY_BAT_TAKEOFF));
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected ItemStack getBackButton() {
|
|
||||||
// return QuickItem
|
|
||||||
// .of(Settings.GUI_SHARED_ITEMS_BACK_BUTTON.getItemStack())
|
|
||||||
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_BACK_BUTTON_NAME))
|
|
||||||
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_BACK_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
|
||||||
// .make();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected ItemStack getExitButton() {
|
|
||||||
// return QuickItem
|
|
||||||
// .of(Settings.GUI_SHARED_ITEMS_EXIT_BUTTON.getItemStack())
|
|
||||||
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_EXIT_BUTTON_NAME))
|
|
||||||
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_EXIT_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
|
||||||
// .make();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected ItemStack getPreviousButton() {
|
|
||||||
// return QuickItem
|
|
||||||
// .of(Settings.GUI_BACK_BTN_ITEM.getString())
|
|
||||||
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_PREVIOUS_BUTTON_NAME))
|
|
||||||
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_PREVIOUS_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
|
||||||
// .make();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected ItemStack getNextButton() {
|
|
||||||
// return QuickItem
|
|
||||||
// .of(Settings.GUI_SHARED_ITEMS_NEXT_BUTTON.getItemStack())
|
|
||||||
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_NEXT_BUTTON_NAME))
|
|
||||||
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_NEXT_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
|
||||||
// .make();
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getPreviousButtonSlot() {
|
|
||||||
return 48;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getNextButtonSlot() {
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,5 +18,160 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.guis.abstraction;
|
package ca.tweetzy.auctionhouse.guis.abstraction;
|
||||||
|
|
||||||
public final class AuctionPagedGUI {
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
}
|
import ca.tweetzy.auctionhouse.settings.v3.Settings;
|
||||||
|
import ca.tweetzy.flight.comp.enums.CompMaterial;
|
||||||
|
import ca.tweetzy.flight.gui.Gui;
|
||||||
|
import ca.tweetzy.flight.gui.events.GuiClickEvent;
|
||||||
|
import ca.tweetzy.flight.gui.template.BaseGUI;
|
||||||
|
import ca.tweetzy.flight.utils.Common;
|
||||||
|
import ca.tweetzy.flight.utils.QuickItem;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public abstract class AuctionPagedGUI<T> extends BaseGUI {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
protected final Player player;
|
||||||
|
protected final Gui parent;
|
||||||
|
protected List<T> items;
|
||||||
|
protected final int updateDelay;
|
||||||
|
protected BukkitTask task;
|
||||||
|
|
||||||
|
public AuctionPagedGUI(final Gui parent, @NonNull final Player player, @NonNull final String title, final int rows, int updateDelay, @NonNull final List<T> items) {
|
||||||
|
super(parent, title, rows);
|
||||||
|
this.parent = parent;
|
||||||
|
this.player = player;
|
||||||
|
this.items = items;
|
||||||
|
this.updateDelay = updateDelay;
|
||||||
|
applyDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuctionPagedGUI(@NonNull final Player player, @NonNull final String title, final int rows, int updateDelay, @NonNull final List<T> items) {
|
||||||
|
this(null, player, title, rows, updateDelay, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyDefaults() {
|
||||||
|
setDefaultItem(QuickItem.bg(Settings.GUI_SHARED_FILLER.getItemStack()));
|
||||||
|
// setNavigateSound(CompSound.matchCompSound(Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString()).orElse(CompSound.ENTITY_BAT_TAKEOFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void draw() {
|
||||||
|
reset();
|
||||||
|
populateItems();
|
||||||
|
drawFixed();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startTask() {
|
||||||
|
this.task = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(AuctionHouse.getInstance(), () -> {
|
||||||
|
// this.fillSlots().forEach(slot -> setItem(slot, getDefaultItem()));
|
||||||
|
populateItems();
|
||||||
|
}, 0L, updateDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void applyClose() {
|
||||||
|
setOnClose(close -> cancelTask());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void prePopulate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawFixed() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void cancelTask() {
|
||||||
|
if (this.task != null) {
|
||||||
|
this.task.cancel();
|
||||||
|
Common.log("Cancelled updating task in menu");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateItems() {
|
||||||
|
if (this.items != null) {
|
||||||
|
AuctionHouse.newChain().asyncFirst(() -> {
|
||||||
|
this.fillSlots().forEach(slot -> setItem(slot, getDefaultItem()));
|
||||||
|
prePopulate();
|
||||||
|
|
||||||
|
final List<T> itemsToFill = this.items.stream().skip((page - 1) * (long) this.fillSlots().size()).limit(this.fillSlots().size()).collect(Collectors.toList());
|
||||||
|
return itemsToFill;
|
||||||
|
}).asyncLast((data) -> {
|
||||||
|
pages = (int) Math.max(1, Math.ceil(this.items.size() / (double) this.fillSlots().size()));
|
||||||
|
|
||||||
|
setPrevPage(getPreviousButtonSlot(), getPreviousButton());
|
||||||
|
setNextPage(getNextButtonSlot(), getNextButton());
|
||||||
|
setOnPage(e -> draw());
|
||||||
|
|
||||||
|
for (int i = 0; i < this.rows * 9; i++) {
|
||||||
|
if (this.fillSlots().contains(i) && this.fillSlots().indexOf(i) < data.size()) {
|
||||||
|
final T object = data.get(this.fillSlots().indexOf(i));
|
||||||
|
setButton(i, this.makeDisplayItem(object), click -> this.onClick(object, click));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract ItemStack makeDisplayItem(final T object);
|
||||||
|
|
||||||
|
protected abstract void onClick(final T object, final GuiClickEvent clickEvent);
|
||||||
|
|
||||||
|
protected ItemStack getPreviousButton() {
|
||||||
|
return QuickItem.of(CompMaterial.ARROW, "&ePrevious").make();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ItemStack getNextButton() {
|
||||||
|
return QuickItem.of(CompMaterial.ARROW, "&eNext").make();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getPreviousButtonSlot() {
|
||||||
|
return 48;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getNextButtonSlot() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// protected ItemStack getBackButton() {
|
||||||
|
// return QuickItem
|
||||||
|
// .of(Settings.GUI_SHARED_ITEMS_BACK_BUTTON.getItemStack())
|
||||||
|
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_BACK_BUTTON_NAME))
|
||||||
|
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_BACK_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
||||||
|
// .make();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected ItemStack getExitButton() {
|
||||||
|
// return QuickItem
|
||||||
|
// .of(Settings.GUI_SHARED_ITEMS_EXIT_BUTTON.getItemStack())
|
||||||
|
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_EXIT_BUTTON_NAME))
|
||||||
|
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_EXIT_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
||||||
|
// .make();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected ItemStack getPreviousPageButton() {
|
||||||
|
// return QuickItem
|
||||||
|
// .of(Settings.GUI_SHARED_ITEMS_PREVIOUS_BUTTON.getItemStack())
|
||||||
|
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_PREVIOUS_BUTTON_NAME))
|
||||||
|
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_PREVIOUS_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
||||||
|
// .make();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected ItemStack getNextPageButton() {
|
||||||
|
// return QuickItem
|
||||||
|
// .of(Settings.GUI_SHARED_ITEMS_NEXT_BUTTON.getItemStack())
|
||||||
|
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_NEXT_BUTTON_NAME))
|
||||||
|
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_NEXT_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
||||||
|
// .make();
|
||||||
|
// }
|
||||||
|
}
|
@ -1,170 +0,0 @@
|
|||||||
/*
|
|
||||||
* Auction House
|
|
||||||
* Copyright 2023 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.abstraction;
|
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
|
||||||
import ca.tweetzy.flight.comp.enums.CompMaterial;
|
|
||||||
import ca.tweetzy.core.gui.Gui;
|
|
||||||
import ca.tweetzy.core.gui.events.GuiClickEvent;
|
|
||||||
import ca.tweetzy.core.gui.BaseGUI;
|
|
||||||
import ca.tweetzy.flight.utils.Common;
|
|
||||||
import ca.tweetzy.flight.utils.QuickItem;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public abstract class AuctionUpdatingPagedGUI<T> extends BaseGUI {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
protected final Player player;
|
|
||||||
protected final Gui parent;
|
|
||||||
protected List<T> items;
|
|
||||||
protected final int updateDelay;
|
|
||||||
protected BukkitTask task;
|
|
||||||
|
|
||||||
public AuctionUpdatingPagedGUI(final Gui parent, @NonNull final Player player, @NonNull final String title, final int rows, int updateDelay, @NonNull final List<T> items) {
|
|
||||||
super(parent, title, rows);
|
|
||||||
this.parent = parent;
|
|
||||||
this.player = player;
|
|
||||||
this.items = items;
|
|
||||||
this.updateDelay = updateDelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuctionUpdatingPagedGUI(@NonNull final Player player, @NonNull final String title, final int rows, int updateDelay, @NonNull final List<T> items) {
|
|
||||||
this(null, player, title, rows, updateDelay, items);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void draw() {
|
|
||||||
reset();
|
|
||||||
drawFixed();
|
|
||||||
populateItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void startTask() {
|
|
||||||
this.task = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(AuctionHouse.getInstance(), () -> {
|
|
||||||
// this.fillSlots().forEach(slot -> setItem(slot, getDefaultItem()));
|
|
||||||
populateItems();
|
|
||||||
}, 0L, updateDelay);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void applyClose() {
|
|
||||||
setOnClose(close -> cancelTask());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void prePopulate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void drawFixed() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void cancelTask() {
|
|
||||||
if (this.task != null) {
|
|
||||||
this.task.cancel();
|
|
||||||
Common.log("Cancelled updating task in menu");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateItems() {
|
|
||||||
if (this.items != null) {
|
|
||||||
AuctionHouse.newChain().asyncFirst(() -> {
|
|
||||||
this.fillSlots().forEach(slot -> setItem(slot, getDefaultItem()));
|
|
||||||
prePopulate();
|
|
||||||
|
|
||||||
final List<T> itemsToFill = this.items.stream().skip((page - 1) * (long) this.fillSlots().size()).limit(this.fillSlots().size()).collect(Collectors.toList());
|
|
||||||
return itemsToFill;
|
|
||||||
}).asyncLast((data) -> {
|
|
||||||
pages = (int) Math.max(1, Math.ceil(this.items.size() / (double) this.fillSlots().size()));
|
|
||||||
|
|
||||||
setPrevPage(getPreviousButtonSlot(), getPreviousButton());
|
|
||||||
setNextPage(getNextButtonSlot(), getNextButton());
|
|
||||||
setOnPage(e -> draw());
|
|
||||||
|
|
||||||
for (int i = 0; i < this.rows * 9; i++) {
|
|
||||||
if (this.fillSlots().contains(i) && this.fillSlots().indexOf(i) < data.size()) {
|
|
||||||
final T object = data.get(this.fillSlots().indexOf(i));
|
|
||||||
setButton(i, this.makeDisplayItem(object), click -> this.onClick(object, click));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract ItemStack makeDisplayItem(final T object);
|
|
||||||
|
|
||||||
protected abstract void onClick(final T object, final GuiClickEvent clickEvent);
|
|
||||||
|
|
||||||
protected ItemStack getPreviousButton() {
|
|
||||||
return QuickItem.of(CompMaterial.ARROW, "&ePrevious").make();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ItemStack getNextButton() {
|
|
||||||
return QuickItem.of(CompMaterial.ARROW, "&eNext").make();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getPreviousButtonSlot() {
|
|
||||||
return 48;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getNextButtonSlot() {
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected ItemStack getBackButton() {
|
|
||||||
// return QuickItem
|
|
||||||
// .of(Settings.GUI_SHARED_ITEMS_BACK_BUTTON.getItemStack())
|
|
||||||
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_BACK_BUTTON_NAME))
|
|
||||||
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_BACK_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
|
||||||
// .make();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected ItemStack getExitButton() {
|
|
||||||
// return QuickItem
|
|
||||||
// .of(Settings.GUI_SHARED_ITEMS_EXIT_BUTTON.getItemStack())
|
|
||||||
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_EXIT_BUTTON_NAME))
|
|
||||||
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_EXIT_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
|
||||||
// .make();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected ItemStack getPreviousPageButton() {
|
|
||||||
// return QuickItem
|
|
||||||
// .of(Settings.GUI_SHARED_ITEMS_PREVIOUS_BUTTON.getItemStack())
|
|
||||||
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_PREVIOUS_BUTTON_NAME))
|
|
||||||
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_PREVIOUS_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
|
||||||
// .make();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected ItemStack getNextPageButton() {
|
|
||||||
// return QuickItem
|
|
||||||
// .of(Settings.GUI_SHARED_ITEMS_NEXT_BUTTON.getItemStack())
|
|
||||||
// .name(TranslationManager.string(this.player, Translations.GUI_SHARED_ITEMS_NEXT_BUTTON_NAME))
|
|
||||||
// .lore(TranslationManager.list(this.player, Translations.GUI_SHARED_ITEMS_NEXT_BUTTON_LORE, "left_click", TranslationManager.string(this.player, Translations.MOUSE_LEFT_CLICK)))
|
|
||||||
// .make();
|
|
||||||
// }
|
|
||||||
}
|
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package ca.tweetzy.auctionhouse.settings.v3;
|
package ca.tweetzy.auctionhouse.settings.v3;
|
||||||
|
|
||||||
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
import ca.tweetzy.auctionhouse.api.AuctionUsageMode;
|
import ca.tweetzy.auctionhouse.api.AuctionUsageMode;
|
||||||
import ca.tweetzy.flight.comp.enums.CompMaterial;
|
import ca.tweetzy.flight.comp.enums.CompMaterial;
|
||||||
import ca.tweetzy.flight.config.ConfigEntry;
|
import ca.tweetzy.flight.config.ConfigEntry;
|
||||||
@ -114,6 +115,9 @@ public final class Settings extends FlightSettings {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// ==================== Main Auction Menu ==================== //
|
// ==================== Main Auction Menu ==================== //
|
||||||
|
public static ConfigEntry GUI_SHARED_FILLER = create("gui.shared options.filler item", CompMaterial.BLACK_STAINED_GLASS_PANE.name(), "The filler item for menus");
|
||||||
|
|
||||||
|
|
||||||
public static ConfigEntry GUI_MAIN_ROWS = create("gui.main.rows", 6, "How many rows should the gui have");
|
public static ConfigEntry GUI_MAIN_ROWS = create("gui.main.rows", 6, "How many rows should the gui have");
|
||||||
public static ConfigEntry GUI_MAIN_FILL_SLOTS = create("gui.main.fill slots", IntStream.rangeClosed(0, 44).boxed().collect(Collectors.toList()), "Slot numbers where auction items will be placed");
|
public static ConfigEntry GUI_MAIN_FILL_SLOTS = create("gui.main.fill slots", IntStream.rangeClosed(0, 44).boxed().collect(Collectors.toList()), "Slot numbers where auction items will be placed");
|
||||||
public static ConfigEntry GUI_MAIN_DECORATION = create("gui.main.decoration", Collections.singletonList(""), "Additional Decoration Items, format is MATERIAL_NAME:slot so ex. DIAMOND:1");
|
public static ConfigEntry GUI_MAIN_DECORATION = create("gui.main.decoration", Collections.singletonList(""), "Additional Decoration Items, format is MATERIAL_NAME:slot so ex. DIAMOND:1");
|
||||||
@ -173,4 +177,7 @@ public final class Settings extends FlightSettings {
|
|||||||
public static ConfigEntry CONFIRM_ACCEPT_BID = create("settings.confirmation.accept bid", false, "Ask for confirmation before accepting current bid?");
|
public static ConfigEntry CONFIRM_ACCEPT_BID = create("settings.confirmation.accept bid", false, "Ask for confirmation before accepting current bid?");
|
||||||
public static ConfigEntry CONFIRM_CANCEL_LISTING = create("settings.confirmation.cancel listing", false, "Ask for confirmation before canceling a listing?");
|
public static ConfigEntry CONFIRM_CANCEL_LISTING = create("settings.confirmation.cancel listing", false, "Ask for confirmation before canceling a listing?");
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
AuctionHouse.getCoreConfig().init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user