From 062534af1f851f69b43590eca3f38449eac8b64c Mon Sep 17 00:00:00 2001 From: 502647092 Date: Thu, 14 Jan 2016 22:58:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=99=9A=E6=8B=9F=E7=89=A9?= =?UTF-8?q?=E5=93=81=E6=B6=88=E9=99=A4=E9=94=99=E8=AF=AF...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../org/maxgamer/QuickShop/Shop/FakeItem.java | 3 +- .../maxgamer/QuickShop/Shop/ShopManager.java | 134 +++++++++--------- src/main/resources/config.yml | 4 +- 3 files changed, 71 insertions(+), 70 deletions(-) diff --git a/src/main/java/org/maxgamer/QuickShop/Shop/FakeItem.java b/src/main/java/org/maxgamer/QuickShop/Shop/FakeItem.java index b97f48e..d5755ac 100644 --- a/src/main/java/org/maxgamer/QuickShop/Shop/FakeItem.java +++ b/src/main/java/org/maxgamer/QuickShop/Shop/FakeItem.java @@ -203,8 +203,7 @@ public class FakeItem implements DisplayItem { } private PacketContainer getDestoryPacket() { - final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_DESTROY); - fakePacket.getIntegers().write(0, 1); + final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_DESTROY, true); fakePacket.getIntegerArrays().write(0, new int[] { eid }); return fakePacket; } diff --git a/src/main/java/org/maxgamer/QuickShop/Shop/ShopManager.java b/src/main/java/org/maxgamer/QuickShop/Shop/ShopManager.java index 9259093..953144d 100644 --- a/src/main/java/org/maxgamer/QuickShop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/QuickShop/Shop/ShopManager.java @@ -25,71 +25,9 @@ import org.maxgamer.QuickShop.Util.MsgUtil; import org.maxgamer.QuickShop.Util.Util; public class ShopManager { - public class ShopIterator implements Iterator { - private Iterator> chunks; - private Shop current; - private Iterator shops; - private final Iterator>> worlds; - - public ShopIterator() { - worlds = getShops().values().iterator(); - } - - /** - * Returns true if there is still more shops to iterate over. - */ - @Override - public boolean hasNext() { - if (shops == null || !shops.hasNext()) { - if (chunks == null || !chunks.hasNext()) { - if (!worlds.hasNext()) { - return false; - } - chunks = worlds.next().values().iterator(); - return hasNext(); - } - shops = chunks.next().values().iterator(); - return hasNext(); - } - return true; - } - - /** - * Fetches the next shop. Throws NoSuchElementException if there are no - * more shops. - */ - @Override - public Shop next() { - if (shops == null || !shops.hasNext()) { - if (chunks == null || !chunks.hasNext()) { - if (!worlds.hasNext()) { - throw new NoSuchElementException("No more shops to iterate over!"); - } - chunks = worlds.next().values().iterator(); - } - shops = chunks.next().values().iterator(); - } - if (!shops.hasNext()) { - return this.next(); // Skip to the next one (Empty iterator?) - } - current = shops.next(); - return current; - } - - /** - * Removes the current shop. This method will delete the shop from - * memory and the database. - */ - @Override - public void remove() { - current.delete(false); - shops.remove(); - } - } - private final HashMap actions = new HashMap(); - private final QuickShop plugin; + private final QuickShop plugin; private final HashMap>> shops = new HashMap>>(); public ShopManager(final QuickShop plugin) { @@ -366,9 +304,11 @@ public class ShopManager { 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 (sign != null && bf != null) { + sign.setFacingDirection(bf); + bs.update(true); + shop.setSignText(); + } } if (shop instanceof ContainerShop) { final ContainerShop cs = (ContainerShop) shop; @@ -614,4 +554,66 @@ public class ShopManager { // Put the shop in its location in the chunk list. inChunk.put(shop.getLocation(), shop); } + + public class ShopIterator implements Iterator { + private Iterator> chunks; + private Shop current; + private Iterator shops; + private final Iterator>> worlds; + + public ShopIterator() { + worlds = getShops().values().iterator(); + } + + /** + * Returns true if there is still more shops to iterate over. + */ + @Override + public boolean hasNext() { + if (shops == null || !shops.hasNext()) { + if (chunks == null || !chunks.hasNext()) { + if (!worlds.hasNext()) { + return false; + } + chunks = worlds.next().values().iterator(); + return hasNext(); + } + shops = chunks.next().values().iterator(); + return hasNext(); + } + return true; + } + + /** + * Fetches the next shop. Throws NoSuchElementException if there are no + * more shops. + */ + @Override + public Shop next() { + if (shops == null || !shops.hasNext()) { + if (chunks == null || !chunks.hasNext()) { + if (!worlds.hasNext()) { + throw new NoSuchElementException("No more shops to iterate over!"); + } + chunks = worlds.next().values().iterator(); + } + shops = chunks.next().values().iterator(); + } + if (!shops.hasNext()) { + return this.next(); // Skip to the next one (Empty iterator?) + } + current = shops.next(); + return current; + } + + /** + * Removes the current shop. This method will delete the shop from + * memory and the database. + */ + @Override + public void remove() { + current.delete(false); + shops.remove(); + } + } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f263692..55909a9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,4 +1,4 @@ -Version: 1.1 +Version: 1.7 #超级工具(OP可以用该工具在创造模式打破所有商店) superitem: GOLD_AXE @@ -8,7 +8,7 @@ preventhopper: false guititle: '&6[&b快捷商店&6]&r' #启用魔改库支持 usemagiclib: true -#启用魔改库支持 +#启用虚拟悬浮物 fakeitem: true #税收数量 (decimal) - 例如 税收是0.05 玩家1 在玩家2的商店 购买了 50元的东西,那么,玩家1 减少 50, 玩家2 账户增加(1-0.05)*50, 并且 玩家2税收账户增加 (0.05)*50.