Support unlimited shop account, Closed #90 #163 #601

This commit is contained in:
Ghost_chu committed 2021-06-15 18:25:13 +08:00
1 parent 3ce6da7965
commit cb33cdc8d2
8 files changed
+59 -2

No files matched your search

@@ -1796,6 +1796,8 @@ public class QuickShop extends JavaPlugin {
}
if (selectedVersion == 131) {
getConfig().set("custom-commands", ImmutableList.of("shop", "chestshop", "cshop"));
getConfig().set("unlimited-shop-owner-change", false);
getConfig().set("unlimited-shop-owner-change-account", "quickshop");
getConfig().set("config-version", ++selectedVersion);
}
@@ -54,10 +54,16 @@ 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();
MsgUtil.sendMessage(sender, "unlimited-shop-owner-changed");
}
return;
}
MsgUtil.sendMessage(sender, "command.toggle-unlimited.limited");
if (plugin.getConfig().getBoolean("unlimited-shop-owner-change")) {
MsgUtil.sendMessage(sender, "unlimited-shop-owner-keeped");
}
}
}
@@ -53,9 +53,16 @@ public class SubCommand_Unlimited implements CommandHandler<Player> {
shop.update();
if (shop.isUnlimited()) {
MsgUtil.sendMessage(sender, "command.toggle-unlimited.unlimited");
if (plugin.getConfig().getBoolean("unlimited-shop-owner-change")) {
shop.migrateOwnerToUnlimitedShopOwner();
MsgUtil.sendMessage(sender, "unlimited-shop-owner-changed");
}
return;
}
MsgUtil.sendMessage(sender, "command.toggle-unlimited.limited");
if (plugin.getConfig().getBoolean("unlimited-shop-owner-change")) {
MsgUtil.sendMessage(sender, "unlimited-shop-owner-keeped");
}
return;
}
MsgUtil.sendMessage(sender, "not-looking-at-shop");
@@ -22,6 +22,7 @@ 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;
@@ -1436,4 +1437,28 @@ public class ContainerShop implements Shop {
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();
});
}
}
}
@@ -485,4 +485,10 @@ public interface Shop {
* @return ShopInfoStorage
*/
ShopInfoStorage saveToInfoStorage();
/**
* Change the owner to unlimited shop owner.
* It defined in configuration.
*/
void migrateOwnerToUnlimitedShopOwner();
}
@@ -1453,6 +1453,8 @@ public class MsgUtil {
}
if (selectedVersion == 56) {
setAndUpdate("command-type-mismatch");
setAndUpdate("unlimited-shop-owner-keeped");
setAndUpdate("unlimited-shop-owner-changed");
setAndUpdate("language-version", ++selectedVersion);
}
+7
View File
@@ -77,6 +77,13 @@ tax: 0.05
#Set this to "" to disable it (Taxing will still work but not deposit to any account)
tax-account: tax
#Turn on this option will migrate shop owner to specified account when you set a shop to unlimited.
#It won't affect exists shops, you will need switch to unlimited again to apply it.
unlimited-shop-owner-change: false
#This account will used for unlimited shop if you have turned on unlimited-shop-owner-change.
unlimited-shop-owner-change-account: quickshop
#Whether to show taxes paid when selling to a shop
show-tax: false
@@ -320,5 +320,7 @@
"shop-creation-failed": "&cShop creation failed, please contact with server administrator.",
"shop-owner-self-trade": "&eYou trading with yourself shop, so you might won't gain any balance.",
"chest-title": "QuickShop Store",
"command-type-mismatch": "&cThis command only can executed by &b{0}."
"command-type-mismatch": "&cThis command only can executed by &b{0}.",
"unlimited-shop-owner-changed": "&eThis unlimited shop owner has been changed to {0}.",
"unlimited-shop-owner-keeped": "&eAttention: The shop owner still is unlimited shop owner, you need re-set new shop owner by yourself."
}