Fixed FriendsGUI not removing ghost items when redrawing page

This commit is contained in:
libraryaddict 2015-02-12 04:08:43 +13:00
parent 9bdf248643
commit 858a6fb674

View File

@ -111,7 +111,18 @@ public class FriendsGUI implements Listener
if (friendSlot >= friends.size()) if (friendSlot >= friends.size())
{ {
break; ItemStack item = _inventory.getItem(slot);
if (item == null || item.getType() == Material.AIR)
{
break;
}
else
{
_inventory.setItem(slot, new ItemStack(Material.AIR));
continue;
}
} }
FriendStatus friend = friends.get(friendSlot); FriendStatus friend = friends.get(friendSlot);
@ -119,7 +130,7 @@ public class FriendsGUI implements Listener
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name); builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name); builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
@ -245,7 +256,18 @@ public class FriendsGUI implements Listener
if (friendSlot >= friends.size()) if (friendSlot >= friends.size())
{ {
break; ItemStack item = _inventory.getItem(slot);
if (item == null || item.getType() == Material.AIR)
{
break;
}
else
{
_inventory.setItem(slot, new ItemStack(Material.AIR));
continue;
}
} }
FriendStatus friend = friends.get(friendSlot); FriendStatus friend = friends.get(friendSlot);
@ -253,7 +275,7 @@ public class FriendsGUI implements Listener
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name); builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name); builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
@ -446,7 +468,18 @@ public class FriendsGUI implements Listener
if (friendSlot >= friends.size()) if (friendSlot >= friends.size())
{ {
break; ItemStack item = _inventory.getItem(slot);
if (item == null || item.getType() == Material.AIR)
{
break;
}
else
{
_inventory.setItem(slot, new ItemStack(Material.AIR));
continue;
}
} }
FriendStatus friend = friends.get(friendSlot); FriendStatus friend = friends.get(friendSlot);