1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-22 01:58:54 +00:00

fix: 修复1.9不能异步操作方块的问题

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-06-06 20:32:33 +08:00
parent e3223aa25f
commit bbea4b57f8
3 changed files with 63 additions and 50 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId>
<version>1.8.9</version>
<version>1.9.0</version>
<description>快捷商店重置版本...</description>
<build>
<finalName>${project.name}</finalName>
@ -60,11 +60,10 @@
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<update.description>&amp;a全新版本 &amp;c虚拟悬浮物(橙子提供 对 就是那个汉化COI的逗比)&amp;e7老板修复逗比BUG...</update.description>
<update.changes>
&amp;b1.9.0 - &amp;c修复1.9开始以后不允许异步更新木牌的问题...;
&amp;b1.8.9 - &amp;c修复虚拟物品产生的异常...;
&amp;b1.8.8 - &amp;c修复异步处理购买事件导致的状态错误...;
- &amp;c修复配置文件部分字段不存在导致的报错...;
&amp;b1.8.7 - &amp;e异步处理getOfflinePlayer 只能保证不卡服 连不上MOJANG-API还是一样...;
- &amp;c修复部分情况下可以跳过AuthMe和Residence的事件拦截...;
</update.changes>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@ -22,6 +22,8 @@ import org.maxgamer.QuickShop.QuickShop;
import org.maxgamer.QuickShop.Util.MsgUtil;
import org.maxgamer.QuickShop.Util.Util;
import cn.citycraft.PluginHelper.kit.PluginKit;
public class ContainerShop implements Shop {
private DisplayItem displayItem;
private final ItemStack item;
@ -602,19 +604,26 @@ public class ContainerShop implements Shop {
if (Util.isLoaded(this.getLocation()) == false) {
return;
}
final ContainerShop shop = this;
// 1.9不能异步修改木牌
PluginKit.runTask(new Runnable() {
@Override
public void run() {
final String[] lines = new String[4];
lines[0] = ChatColor.RED + "[QuickShop]";
if (this.isBuying()) {
final int remsp = this.getRemainingSpace();
if (shop.isBuying()) {
final int remsp = shop.getRemainingSpace();
lines[1] = MsgUtil.p("signs.buying", "" + (remsp == 10000 ? "无限" : remsp));
}
if (this.isSelling()) {
final int remst = this.getRemainingStock();
if (shop.isSelling()) {
final int remst = shop.getRemainingStock();
lines[1] = MsgUtil.p("signs.selling", "" + (remst == 10000 ? "无限" : remst));
}
lines[2] = Util.getNameForSign(this.item);
lines[3] = MsgUtil.p("signs.price", "" + this.getPrice());
this.setSignText(lines);
lines[2] = Util.getNameForSign(shop.item);
lines[3] = MsgUtil.p("signs.price", "" + shop.getPrice());
shop.setSignText(lines);
}
});
}
/**
@ -628,13 +637,20 @@ public class ContainerShop implements Shop {
if (Util.isLoaded(this.getLocation()) == false) {
return;
}
for (final Sign sign : this.getSigns()) {
final List<Sign> signs = this.getSigns();
// 1.9不能异步修改木牌
PluginKit.runTask(new Runnable() {
@Override
public void run() {
for (final Sign sign : signs) {
for (int i = 0; i < lines.length; i++) {
sign.setLine(i, lines[i]);
}
sign.update();
}
}
});
}
@Override
public void setUnlimited(final boolean unlimited) {

View File

@ -24,8 +24,6 @@ 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>();
@ -290,9 +288,6 @@ public class ShopManager {
warings.add(p.getName());
}
}
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")) {
@ -316,8 +311,6 @@ public class ShopManager {
}
}
}
});
}
/* They didn't enter a number. */
catch (final NumberFormatException ex) {
p.sendMessage(MsgUtil.p("shop-creation-cancelled"));
@ -325,7 +318,9 @@ public class ShopManager {
}
}
/* Purchase Handling */
else if (info.getAction() == ShopAction.BUY) {
else if (info.getAction() == ShopAction.BUY)
{
int amount = 0;
try {
amount = Integer.parseInt(message);
@ -473,9 +468,12 @@ public class ShopManager {
shop.setSignText(); // Update the signs count
}
/* If it was already cancelled (from destroyed) */
else {
else
{
return; // It was cancelled, go away.
}
}
/**