mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
Cache unlimited shop account
This commit is contained in:
1 parent
84904fda56
commit
08c30abebd
5 files changed
+21
-33
No files matched your search
+1
-1
@@ -55,7 +55,7 @@ public class SubCommand_SilentUnlimited implements CommandHandler<Player> {
|
||||
if (shop.isUnlimited()) {
|
||||
MsgUtil.sendMessage(sender, "command.toggle-unlimited.unlimited");
|
||||
if (plugin.getConfig().getBoolean("unlimited-shop-owner-change")) {
|
||||
shop.migrateOwnerToUnlimitedShopOwner();
|
||||
plugin.getShopManager().migrateOwnerToUnlimitedShopOwner(shop);
|
||||
MsgUtil.sendMessage(sender, "unlimited-shop-owner-changed");
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class SubCommand_Unlimited implements CommandHandler<Player> {
|
||||
if (shop.isUnlimited()) {
|
||||
MsgUtil.sendMessage(sender, "command.toggle-unlimited.unlimited");
|
||||
if (plugin.getConfig().getBoolean("unlimited-shop-owner-change")) {
|
||||
shop.migrateOwnerToUnlimitedShopOwner();
|
||||
plugin.getShopManager().migrateOwnerToUnlimitedShopOwner(shop);
|
||||
MsgUtil.sendMessage(sender, "unlimited-shop-owner-changed");
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -22,7 +22,6 @@ package org.maxgamer.quickshop.shop;
|
||||
import com.lishid.openinv.OpenInv;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -1438,29 +1437,4 @@ public class ContainerShop implements Shop {
|
||||
public ShopInfoStorage saveToInfoStorage() {
|
||||
return new ShopInfoStorage(ShopModerator.serialize(getModerator()), getPrice(), Util.serialize(getItem()), isUnlimited() ? 1 : 0, getShopType().toID(), saveExtraToYaml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the owner to unlimited shop owner.
|
||||
* It defined in configuration.
|
||||
*/
|
||||
@Override
|
||||
public void migrateOwnerToUnlimitedShopOwner() {
|
||||
String account = plugin.getConfig().getString("unlimited-shop-owner-change-account");
|
||||
OfflinePlayer player;
|
||||
if (Util.isUUID(account)) {
|
||||
player = Bukkit.getOfflinePlayer(UUID.fromString(account));
|
||||
} else {
|
||||
player = Bukkit.getOfflinePlayer(plugin.getConfig().getString("unlimited-shop-owner-change-account"));
|
||||
}
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
setOwner(player.getUniqueId());
|
||||
setSignText();
|
||||
} else {
|
||||
Util.mainThreadRun(() -> {
|
||||
setOwner(player.getUniqueId());
|
||||
setSignText();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -495,9 +495,5 @@ public interface Shop {
|
||||
*/
|
||||
ShopInfoStorage saveToInfoStorage();
|
||||
|
||||
/**
|
||||
* Change the owner to unlimited shop owner.
|
||||
* It defined in configuration.
|
||||
*/
|
||||
void migrateOwnerToUnlimitedShopOwner();
|
||||
|
||||
}
|
||||
@@ -68,6 +68,8 @@ public class ShopManager {
|
||||
@Getter
|
||||
private final Trader cacheTaxAccount;
|
||||
@Getter
|
||||
private final Trader cacheUnlimitedShopAccount;
|
||||
@Getter
|
||||
private final PriceLimiter priceLimiter;
|
||||
private final boolean useFastShopSearchAlgorithm;
|
||||
private final boolean useOldCanBuildAlgorithm;
|
||||
@@ -80,6 +82,7 @@ public class ShopManager {
|
||||
.initialCapacity(50)
|
||||
.build();
|
||||
|
||||
|
||||
public ShopManager(@NotNull QuickShop plugin) {
|
||||
Util.ensureThread(false);
|
||||
this.plugin = plugin;
|
||||
@@ -99,6 +102,12 @@ public class ShopManager {
|
||||
// disable tax account
|
||||
cacheTaxAccount = null;
|
||||
}
|
||||
String uAccount = plugin.getConfig().getString("unlimited-shop-owner-change-account");
|
||||
if (Util.isUUID(uAccount)) {
|
||||
cacheUnlimitedShopAccount = new Trader(uAccount, Bukkit.getOfflinePlayer(UUID.fromString(uAccount)));
|
||||
} else {
|
||||
cacheUnlimitedShopAccount = new Trader(uAccount, Bukkit.getOfflinePlayer(uAccount));
|
||||
}
|
||||
this.priceLimiter = new PriceLimiter(
|
||||
plugin.getConfig().getDouble("shop.minimum-price"),
|
||||
plugin.getConfig().getInt("shop.maximum-price"),
|
||||
@@ -1311,6 +1320,15 @@ public class ShopManager {
|
||||
return shop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the owner to unlimited shop owner.
|
||||
* It defined in configuration.
|
||||
*/
|
||||
public void migrateOwnerToUnlimitedShopOwner(Shop shop) {
|
||||
shop.setOwner(this.cacheUnlimitedShopAccount.getUniqueId());
|
||||
shop.setSignText();
|
||||
}
|
||||
|
||||
public class ShopIterator implements Iterator<Shop> {
|
||||
|
||||
private final Iterator<Map<ShopChunk, Map<Location, Shop>>> worlds;
|
||||
|
||||
Reference in new issue
Block a user