mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2025-10-02 12:37:27 +00:00
@ -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 String[] lines = new String[4];
|
||||
lines[0] = ChatColor.RED + "[QuickShop]";
|
||||
if (this.isBuying()) {
|
||||
final int remsp = this.getRemainingSpace();
|
||||
lines[1] = MsgUtil.p("signs.buying", "" + (remsp == 10000 ? "无限" : remsp));
|
||||
}
|
||||
if (this.isSelling()) {
|
||||
final int remst = this.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);
|
||||
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 (shop.isBuying()) {
|
||||
final int remsp = shop.getRemainingSpace();
|
||||
lines[1] = MsgUtil.p("signs.buying", "" + (remsp == 10000 ? "无限" : remsp));
|
||||
}
|
||||
if (shop.isSelling()) {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
for (final Sign sign : this.getSigns()) {
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
sign.setLine(i, lines[i]);
|
||||
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();
|
||||
}
|
||||
}
|
||||
sign.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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,33 +288,28 @@ 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")) {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
// 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) {
|
||||
@ -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.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user