delete CityBuildStuffAPIHook.java, create auction player migration for persistent filter

Took 5 minutes
This commit is contained in:
Kiran Hart 2022-08-17 11:20:34 -04:00
parent 2c3a11951c
commit 1a08e2690a
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 36 additions and 69 deletions

View File

@ -1,7 +1,6 @@
package ca.tweetzy.auctionhouse;
import ca.tweetzy.auctionhouse.api.UpdateChecker;
import ca.tweetzy.auctionhouse.api.hook.CityBuildStuffAPIHook;
import ca.tweetzy.auctionhouse.api.hook.PlaceholderAPIHook;
import ca.tweetzy.auctionhouse.api.hook.UltraEconomyHook;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
@ -137,7 +136,6 @@ public class AuctionHouse extends TweetyPlugin {
}
this.ultraEconomyHook = PluginHook.addHook(Economy.class, "UltraEconomy", UltraEconomyHook.class);
this.cityBuildStuff = PluginHook.addHook(Economy.class, "CityBuildStuff", CityBuildStuffAPIHook.class);
// Load Economy
EconomyManager.load();
@ -152,8 +150,6 @@ public class AuctionHouse extends TweetyPlugin {
if (ECO_PLUGIN.startsWith("UltraEconomy")) {
EconomyManager.getManager().setPreferredHook(this.ultraEconomyHook);
} else if (ECO_PLUGIN.equalsIgnoreCase("CityBuildStuff")) {
EconomyManager.getManager().setPreferredHook(this.cityBuildStuff);
} else {
EconomyManager.getManager().setPreferredHook(ECO_PLUGIN);
}
@ -193,7 +189,8 @@ public class AuctionHouse extends TweetyPlugin {
new _11_AdminLogMigration(),
new _12_SerializeFormatDropMigration(),
new _13_MinItemPriceMigration(),
new _14_PartialQtyBuyMigration()
new _14_PartialQtyBuyMigration(),
new _15_AuctionPlayerMigration()
);
dataMigrationManager.runMigrations();

View File

@ -1,64 +0,0 @@
package ca.tweetzy.auctionhouse.api.hook;
import at.blank.coinapi.Api.CoinAPI;
import ca.tweetzy.core.hooks.economies.Economy;
import ca.tweetzy.core.utils.TextUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
/**
* The current file has been created by Kiran Hart
* Date Created: October 05 2021
* Time Created: 9:18 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
public final class CityBuildStuffAPIHook extends Economy {
public CityBuildStuffAPIHook() {
if (!isEnabled()) {
Bukkit.getConsoleSender().sendMessage(TextUtils.formatText("&bCityBuildStuff &7hook cannot be created&f: &cCityBuildStuff not installed"));
return;
}
}
@Override
public double getBalance(OfflinePlayer player) {
return new CoinAPI(player.getUniqueId()).getCoins();
}
@Override
public boolean hasBalance(OfflinePlayer player, double cost) {
final CoinAPI api = new CoinAPI(player.getUniqueId());
return api.getCoins() >= cost;
}
@Override
public boolean withdrawBalance(OfflinePlayer player, double cost) {
final CoinAPI api = new CoinAPI(player.getUniqueId());
if (!api.hasAccount()) return false;
if (!hasBalance(player, cost)) return false;
api.setCoins(api.getCoins() - cost);
return true;
}
@Override
public boolean deposit(OfflinePlayer player, double amount) {
final CoinAPI api = new CoinAPI(player.getUniqueId());
if (!api.hasAccount()) return false;
api.setCoins(api.getCoins() + amount);
return true;
}
@Override
public String getName() {
return "CoinsAI";
}
@Override
public boolean isEnabled() {
return Bukkit.getPluginManager().getPlugin("CityBuildStuff") != null;
}
}

View File

@ -0,0 +1,34 @@
package ca.tweetzy.auctionhouse.database.migrations;
import ca.tweetzy.core.database.DataMigration;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
/**
* The current file has been created by Kiran Hart
* Date Created: August 12 2021
* Time Created: 11:58 a.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
public class _15_AuctionPlayerMigration extends DataMigration {
public _15_AuctionPlayerMigration() {
super(15);
}
@Override
public void migrate(Connection connection, String tablePrefix) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE TABLE " + tablePrefix + "player (" +
"uuid VARCHAR(36) PRIMARY KEY, " +
"filter_sale_type VARCHAR(32) NOT NULL, " +
"filter_item_category VARCHAR(16) NOT NULL, " +
"filter_sort_type VARCHAR(12) NOT NULL, " +
"last_listed_item LONG NOT NULL" +
")");
}
}
}