🈂️ server listing migration

Took 2 minutes

Took 12 seconds
This commit is contained in:
Kiran Hart 2023-09-11 19:18:55 -04:00
parent 99fac3c589
commit 7b5e4c93f0
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
5 changed files with 70 additions and 21 deletions

View File

@ -221,7 +221,8 @@ public class AuctionHouse extends TweetyPlugin {
new _15_AuctionPlayerMigration(),
new _16_StatisticVersionTwoMigration(),
new _17_PaymentsMigration(),
new _18_PaymentsItemMigration()
new _18_PaymentsItemMigration(),
new _19_ServerAuctionMigration()
);
dataMigrationManager.runMigrations();

View File

@ -70,6 +70,7 @@ public class AuctionedItem {
private String listedWorld = null;
private boolean infinite = false;
private boolean allowPartialBuy = false;
private boolean serverItem = false;
public AuctionedItem() {
}
@ -104,6 +105,7 @@ public class AuctionedItem {
this.isBidItem = isBidItem;
this.expired = expired;
this.expiresAt = expiresAt;
this.serverItem = false;
}
public ItemStack getBidStack() {

View File

@ -379,27 +379,27 @@ public final class CommandSell extends AbstractCommand {
}));
} else {
// Bukkit.getScheduler().runTaskLaterAsynchronously(AuctionHouse.getInstance(), () -> {
if (auctionPlayer.getPlayer() == null || !auctionPlayer.getPlayer().isOnline()) {
return ReturnType.FAILURE;
if (auctionPlayer.getPlayer() == null || !auctionPlayer.getPlayer().isOnline()) {
return ReturnType.FAILURE;
}
player.getInventory().setItemInHand(XMaterial.AIR.parseItem());
AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> {
AuctionHouse.getInstance().getAuctionPlayerManager().processSell(player);
if (listingResult != ListingResult.SUCCESS) {
PlayerUtils.giveItem(player, auction.getItem());
auctionPlayer.setItemBeingListed(null);
return;
}
player.getInventory().setItemInHand(XMaterial.AIR.parseItem());
AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> {
AuctionHouse.getInstance().getAuctionPlayerManager().processSell(player);
if (listingResult != ListingResult.SUCCESS) {
PlayerUtils.giveItem(player, auction.getItem());
auctionPlayer.setItemBeingListed(null);
return;
}
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) {
player.removeMetadata("AuctionHouseConfirmListing", AuctionHouse.getInstance());
instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer));
} else
AuctionHouse.newChain().sync(player::closeInventory).execute();
});
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) {
player.removeMetadata("AuctionHouseConfirmListing", AuctionHouse.getInstance());
instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer));
} else
AuctionHouse.newChain().sync(player::closeInventory).execute();
});
// }, Settings.INTERNAL_CREATE_DELAY.getInt());

View File

@ -0,0 +1,46 @@
/*
* 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.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 _19_ServerAuctionMigration extends DataMigration {
public _19_ServerAuctionMigration() {
super(19);
}
@Override
public void migrate(Connection connection, String tablePrefix) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("ALTER TABLE " + tablePrefix + "auctions ADD server_auction BOOLEAN NOT NULL DEFAULT 0");
}
}
}

View File

@ -23,8 +23,8 @@ import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.utils.NumberUtils;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.flight.comp.enums.ServerVersion;
import ca.tweetzy.flight.utils.QuickItem;
import ca.tweetzy.flight.nbtapi.NBT;
import ca.tweetzy.flight.utils.QuickItem;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;