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:
7
pom.xml
7
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.maxgamer</groupId>
|
<groupId>org.maxgamer</groupId>
|
||||||
<artifactId>QuickShop</artifactId>
|
<artifactId>QuickShop</artifactId>
|
||||||
<version>1.8.7</version>
|
<version>1.8.8</version>
|
||||||
<description>快捷商店重置版本...</description>
|
<description>快捷商店重置版本...</description>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.name}</finalName>
|
<finalName>${project.name}</finalName>
|
||||||
@ -60,10 +60,11 @@
|
|||||||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||||
<update.description>&a全新版本 &c虚拟悬浮物(橙子提供 对 就是那个汉化COI的逗比)&e7老板修复逗比BUG...</update.description>
|
<update.description>&a全新版本 &c虚拟悬浮物(橙子提供 对 就是那个汉化COI的逗比)&e7老板修复逗比BUG...</update.description>
|
||||||
<update.changes>
|
<update.changes>
|
||||||
|
&b1.8.8 - &c修复异步处理购买事件导致的状态错误...;
|
||||||
|
- &c修复配置文件部分字段不存在导致的报错...;
|
||||||
&b1.8.7 - &e异步处理getOfflinePlayer 只能保证不卡服 连不上MOJANG-API还是一样...;
|
&b1.8.7 - &e异步处理getOfflinePlayer 只能保证不卡服 连不上MOJANG-API还是一样...;
|
||||||
- &c修复部分情况下可以跳过AuthMe和Residence的事件拦截...;
|
- &c修复部分情况下可以跳过AuthMe和Residence的事件拦截...;
|
||||||
&b1.8.6 - &c修复getOfflinePlayer导致的服务器卡顿(连不上MOJANG...);
|
&b1.8.6 - &c修复getOfflinePlayer导致的服务器卡顿(连不上MOJANG...);
|
||||||
&b1.8.4 - &7清理多余的监听事件,修复部分版本不兼容问题 支持1.9...;
|
|
||||||
</update.changes>
|
</update.changes>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package org.maxgamer.QuickShop.Config;
|
package org.maxgamer.QuickShop.Config;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -51,7 +53,7 @@ public class ConfigManager {
|
|||||||
* A set of players who have been warned
|
* A set of players who have been warned
|
||||||
* ("Your shop isn't automatically locked")
|
* ("Your shop isn't automatically locked")
|
||||||
*/
|
*/
|
||||||
private final HashSet<String> warnings = new HashSet<>();
|
private Set<String> warnings = new HashSet<>();
|
||||||
|
|
||||||
public ConfigManager(final QuickShop plugin) {
|
public ConfigManager(final QuickShop plugin) {
|
||||||
final FileConfig config = (FileConfig) plugin.getConfig();
|
final FileConfig config = (FileConfig) plugin.getConfig();
|
||||||
@ -82,6 +84,7 @@ public class ConfigManager {
|
|||||||
this.feeForPriceChange = config.getDouble("shop.fee-for-price-change");
|
this.feeForPriceChange = config.getDouble("shop.fee-for-price-change");
|
||||||
this.preventhopper = config.getBoolean("preventhopper");
|
this.preventhopper = config.getBoolean("preventhopper");
|
||||||
this.guiTitle = config.getMessage("guititle", guiTitle);
|
this.guiTitle = config.getMessage("guititle", guiTitle);
|
||||||
|
this.warnings = Collections.emptySet();
|
||||||
if (config.getBoolean("fakeitem", true)) {
|
if (config.getBoolean("fakeitem", true)) {
|
||||||
try {
|
try {
|
||||||
plugin.getLogger().info("启用虚拟悬浮物 尝试启动中...");
|
plugin.getLogger().info("启用虚拟悬浮物 尝试启动中...");
|
||||||
@ -144,7 +147,7 @@ public class ConfigManager {
|
|||||||
return taxAccount;
|
return taxAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<String> getWarnings() {
|
public Set<String> getWarnings() {
|
||||||
return warnings;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package org.maxgamer.QuickShop.Shop;
|
package org.maxgamer.QuickShop.Shop;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
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.MsgUtil;
|
||||||
import org.maxgamer.QuickShop.Util.Util;
|
import org.maxgamer.QuickShop.Util.Util;
|
||||||
|
|
||||||
|
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||||
|
|
||||||
public class ShopManager {
|
public class ShopManager {
|
||||||
private final HashMap<String, Info> actions = new HashMap<String, Info>();
|
private final HashMap<String, Info> actions = new HashMap<String, Info>();
|
||||||
|
|
||||||
@ -282,34 +284,39 @@ public class ShopManager {
|
|||||||
if (!plugin.getConfig().getBoolean("shop.lock")) {
|
if (!plugin.getConfig().getBoolean("shop.lock")) {
|
||||||
// Warn them if they haven't been warned since
|
// Warn them if they haven't been warned since
|
||||||
// reboot
|
// reboot
|
||||||
final HashSet<String> warings = plugin.getConfigManager().getWarnings();
|
final Set<String> warings = plugin.getConfigManager().getWarnings();
|
||||||
if (!warings.contains(p.getName())) {
|
if (!warings.contains(p.getName())) {
|
||||||
p.sendMessage(MsgUtil.p("shops-arent-locked"));
|
p.sendMessage(MsgUtil.p("shops-arent-locked"));
|
||||||
warings.add(p.getName());
|
warings.add(p.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Figures out which way we should put the sign on and
|
PluginKit.scheduleTask(new Runnable() {
|
||||||
// sets its text.
|
@Override
|
||||||
if (info.getSignBlock() != null && info.getSignBlock().getType() == Material.AIR && plugin.getConfig().getBoolean("shop.auto-sign")) {
|
public void run() {
|
||||||
final BlockState bs = info.getSignBlock().getState();
|
// Figures out which way we should put the sign on and
|
||||||
final BlockFace bf = info.getLocation().getBlock().getFace(info.getSignBlock());
|
// sets its text.
|
||||||
bs.setType(Material.WALL_SIGN);
|
if (info.getSignBlock() != null && info.getSignBlock().getType() == Material.AIR && plugin.getConfig().getBoolean("shop.auto-sign")) {
|
||||||
final Sign sign = (Sign) bs.getData();
|
final BlockState bs = info.getSignBlock().getState();
|
||||||
sign.setFacingDirection(bf);
|
final BlockFace bf = info.getLocation().getBlock().getFace(info.getSignBlock());
|
||||||
bs.update(true);
|
bs.setType(Material.WALL_SIGN);
|
||||||
shop.setSignText();
|
final Sign sign = (Sign) bs.getData();
|
||||||
}
|
sign.setFacingDirection(bf);
|
||||||
if (shop instanceof ContainerShop) {
|
bs.update(true);
|
||||||
final ContainerShop cs = (ContainerShop) shop;
|
shop.setSignText();
|
||||||
if (cs.isDoubleShop()) {
|
}
|
||||||
final Shop nextTo = cs.getAttachedShop();
|
if (shop instanceof ContainerShop) {
|
||||||
if (nextTo.getPrice() > shop.getPrice()) {
|
final ContainerShop cs = (ContainerShop) shop;
|
||||||
// The one next to it must always be a
|
if (cs.isDoubleShop()) {
|
||||||
// buying shop.
|
final Shop nextTo = cs.getAttachedShop();
|
||||||
p.sendMessage(MsgUtil.p("buying-more-than-selling"));
|
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. */
|
/* They didn't enter a number. */
|
||||||
catch (final NumberFormatException ex) {
|
catch (final NumberFormatException ex) {
|
||||||
|
Reference in New Issue
Block a user