mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2025-10-02 12:37:27 +00:00
fix(ShopManager.java): 修复部分异步执行导致的错误
1.修复异步处理购买事件导致的状态错误 2.修复配置文件部分字段不存在导致的报错
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
package org.maxgamer.QuickShop.Config;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -51,7 +53,7 @@ public class ConfigManager {
|
||||
* A set of players who have been warned
|
||||
* ("Your shop isn't automatically locked")
|
||||
*/
|
||||
private final HashSet<String> warnings = new HashSet<>();
|
||||
private Set<String> warnings = new HashSet<>();
|
||||
|
||||
public ConfigManager(final QuickShop plugin) {
|
||||
final FileConfig config = (FileConfig) plugin.getConfig();
|
||||
@ -82,6 +84,7 @@ public class ConfigManager {
|
||||
this.feeForPriceChange = config.getDouble("shop.fee-for-price-change");
|
||||
this.preventhopper = config.getBoolean("preventhopper");
|
||||
this.guiTitle = config.getMessage("guititle", guiTitle);
|
||||
this.warnings = Collections.emptySet();
|
||||
if (config.getBoolean("fakeitem", true)) {
|
||||
try {
|
||||
plugin.getLogger().info("启用虚拟悬浮物 尝试启动中...");
|
||||
@ -144,7 +147,7 @@ public class ConfigManager {
|
||||
return taxAccount;
|
||||
}
|
||||
|
||||
public HashSet<String> getWarnings() {
|
||||
public Set<String> getWarnings() {
|
||||
return warnings;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package org.maxgamer.QuickShop.Shop;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -24,6 +24,8 @@ import org.maxgamer.QuickShop.Database.Database;
|
||||
import org.maxgamer.QuickShop.Util.MsgUtil;
|
||||
import org.maxgamer.QuickShop.Util.Util;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
|
||||
public class ShopManager {
|
||||
private final HashMap<String, Info> actions = new HashMap<String, Info>();
|
||||
|
||||
@ -282,34 +284,39 @@ public class ShopManager {
|
||||
if (!plugin.getConfig().getBoolean("shop.lock")) {
|
||||
// Warn them if they haven't been warned since
|
||||
// reboot
|
||||
final HashSet<String> warings = plugin.getConfigManager().getWarnings();
|
||||
final Set<String> warings = plugin.getConfigManager().getWarnings();
|
||||
if (!warings.contains(p.getName())) {
|
||||
p.sendMessage(MsgUtil.p("shops-arent-locked"));
|
||||
warings.add(p.getName());
|
||||
}
|
||||
}
|
||||
// Figures out which way we should put the sign on and
|
||||
// sets its text.
|
||||
if (info.getSignBlock() != null && info.getSignBlock().getType() == Material.AIR && plugin.getConfig().getBoolean("shop.auto-sign")) {
|
||||
final BlockState bs = info.getSignBlock().getState();
|
||||
final BlockFace bf = info.getLocation().getBlock().getFace(info.getSignBlock());
|
||||
bs.setType(Material.WALL_SIGN);
|
||||
final Sign sign = (Sign) bs.getData();
|
||||
sign.setFacingDirection(bf);
|
||||
bs.update(true);
|
||||
shop.setSignText();
|
||||
}
|
||||
if (shop instanceof ContainerShop) {
|
||||
final ContainerShop cs = (ContainerShop) shop;
|
||||
if (cs.isDoubleShop()) {
|
||||
final Shop nextTo = cs.getAttachedShop();
|
||||
if (nextTo.getPrice() > shop.getPrice()) {
|
||||
// The one next to it must always be a
|
||||
// buying shop.
|
||||
p.sendMessage(MsgUtil.p("buying-more-than-selling"));
|
||||
PluginKit.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Figures out which way we should put the sign on and
|
||||
// sets its text.
|
||||
if (info.getSignBlock() != null && info.getSignBlock().getType() == Material.AIR && plugin.getConfig().getBoolean("shop.auto-sign")) {
|
||||
final BlockState bs = info.getSignBlock().getState();
|
||||
final BlockFace bf = info.getLocation().getBlock().getFace(info.getSignBlock());
|
||||
bs.setType(Material.WALL_SIGN);
|
||||
final Sign sign = (Sign) bs.getData();
|
||||
sign.setFacingDirection(bf);
|
||||
bs.update(true);
|
||||
shop.setSignText();
|
||||
}
|
||||
if (shop instanceof ContainerShop) {
|
||||
final ContainerShop cs = (ContainerShop) shop;
|
||||
if (cs.isDoubleShop()) {
|
||||
final Shop nextTo = cs.getAttachedShop();
|
||||
if (nextTo.getPrice() > shop.getPrice()) {
|
||||
// The one next to it must always be a
|
||||
// buying shop.
|
||||
p.sendMessage(MsgUtil.p("buying-more-than-selling"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/* They didn't enter a number. */
|
||||
catch (final NumberFormatException ex) {
|
||||
|
Reference in New Issue
Block a user