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

View File

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

View File

@ -24,8 +24,6 @@ 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>();
@ -290,33 +288,28 @@ public class ShopManager {
warings.add(p.getName()); warings.add(p.getName());
} }
} }
PluginKit.scheduleTask(new Runnable() { // Figures out which way we should put the sign on and
@Override // sets its text.
public void run() { if (info.getSignBlock() != null && info.getSignBlock().getType() == Material.AIR && plugin.getConfig().getBoolean("shop.auto-sign")) {
// Figures out which way we should put the sign on and final BlockState bs = info.getSignBlock().getState();
// sets its text. final BlockFace bf = info.getLocation().getBlock().getFace(info.getSignBlock());
if (info.getSignBlock() != null && info.getSignBlock().getType() == Material.AIR && plugin.getConfig().getBoolean("shop.auto-sign")) { bs.setType(Material.WALL_SIGN);
final BlockState bs = info.getSignBlock().getState(); final Sign sign = (Sign) bs.getData();
final BlockFace bf = info.getLocation().getBlock().getFace(info.getSignBlock()); sign.setFacingDirection(bf);
bs.setType(Material.WALL_SIGN); bs.update(true);
final Sign sign = (Sign) bs.getData(); shop.setSignText();
sign.setFacingDirection(bf); }
bs.update(true); if (shop instanceof ContainerShop) {
shop.setSignText(); final ContainerShop cs = (ContainerShop) shop;
} if (cs.isDoubleShop()) {
if (shop instanceof ContainerShop) { final Shop nextTo = cs.getAttachedShop();
final ContainerShop cs = (ContainerShop) shop; if (nextTo.getPrice() > shop.getPrice()) {
if (cs.isDoubleShop()) { // The one next to it must always be a
final Shop nextTo = cs.getAttachedShop(); // buying shop.
if (nextTo.getPrice() > shop.getPrice()) { p.sendMessage(MsgUtil.p("buying-more-than-selling"));
// 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) {
@ -325,7 +318,9 @@ public class ShopManager {
} }
} }
/* Purchase Handling */ /* Purchase Handling */
else if (info.getAction() == ShopAction.BUY) { else if (info.getAction() == ShopAction.BUY)
{
int amount = 0; int amount = 0;
try { try {
amount = Integer.parseInt(message); amount = Integer.parseInt(message);
@ -473,9 +468,12 @@ public class ShopManager {
shop.setSignText(); // Update the signs count shop.setSignText(); // Update the signs count
} }
/* If it was already cancelled (from destroyed) */ /* If it was already cancelled (from destroyed) */
else { else
{
return; // It was cancelled, go away. return; // It was cancelled, go away.
} }
} }
/** /**