fix(ShopManager.java): 修复部分异步执行导致的错误
1.修复异步处理购买事件导致的状态错误 2.修复配置文件部分字段不存在导致的报错pull/3/HEAD
parent
918c329b2c
commit
abe7fd3412
7
pom.xml
7
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.maxgamer</groupId>
|
||||
<artifactId>QuickShop</artifactId>
|
||||
<version>1.8.7</version>
|
||||
<version>1.8.8</version>
|
||||
<description>快捷商店重置版本...</description>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
|
@ -60,10 +60,11 @@
|
|||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||
<update.description>&a全新版本 &c虚拟悬浮物(橙子提供 对 就是那个汉化COI的逗比)&e7老板修复逗比BUG...</update.description>
|
||||
<update.changes>
|
||||
&b1.8.8 - &c修复异步处理购买事件导致的状态错误...;
|
||||
- &c修复配置文件部分字段不存在导致的报错...;
|
||||
&b1.8.7 - &e异步处理getOfflinePlayer 只能保证不卡服 连不上MOJANG-API还是一样...;
|
||||
- &c修复部分情况下可以跳过AuthMe和Residence的事件拦截...;
|
||||
- &c修复部分情况下可以跳过AuthMe和Residence的事件拦截...;
|
||||
&b1.8.6 - &c修复getOfflinePlayer导致的服务器卡顿(连不上MOJANG...);
|
||||
&b1.8.4 - &7清理多余的监听事件,修复部分版本不兼容问题 支持1.9...;
|
||||
</update.changes>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue