修复虚拟物品消除错误...

Signed-off-by: 502647092 <jtb1@163.com>
pull/3/HEAD
502647092 2016-01-14 22:58:40 +08:00
parent 56503fee2b
commit 062534af1f
3 changed files with 71 additions and 70 deletions

View File

@ -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;
}

View File

@ -25,71 +25,9 @@ import org.maxgamer.QuickShop.Util.MsgUtil;
import org.maxgamer.QuickShop.Util.Util;
public class ShopManager {
public class ShopIterator implements Iterator<Shop> {
private Iterator<HashMap<Location, Shop>> chunks;
private Shop current;
private Iterator<Shop> shops;
private final Iterator<HashMap<ShopChunk, HashMap<Location, Shop>>> 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<String, Info> actions = new HashMap<String, Info>();
private final QuickShop plugin;
private final QuickShop plugin;
private final HashMap<String, HashMap<ShopChunk, HashMap<Location, Shop>>> shops = new HashMap<String, HashMap<ShopChunk, HashMap<Location, Shop>>>();
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<Shop> {
private Iterator<HashMap<Location, Shop>> chunks;
private Shop current;
private Iterator<Shop> shops;
private final Iterator<HashMap<ShopChunk, HashMap<Location, Shop>>> 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();
}
}
}

View File

@ -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.