Skip to content

Commit

Permalink
Don't create empty lines of lore on random items
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Jun 11, 2015
1 parent 84f26ef commit 53d4494
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -31,13 +31,12 @@ public static void enable() {
@Override
public void a(PacketPlayInSetCreativeSlot packet) {
ItemStack itemStack = packet.getItemStack();
if (itemStack != null && itemStack.getTag() != null && !itemStack.getTag().isEmpty()) {
if (itemStack != null && itemStack.hasTag() && !itemStack.getTag().isEmpty()) {
NBTTagCompound tag = itemStack.getTag();
String hash = tag.getString("Denizen Item Script");
if (hash != null) {
if (tag.hasKey("Denizen Item Script")) {
NBTTagCompound display = tag.getCompound("display");
NBTTagList nbtLore = display.hasKey("Lore") ? (NBTTagList) display.get("Lore") : new NBTTagList();
nbtLore.add(new NBTTagString(hash));
nbtLore.add(new NBTTagString(tag.getString("Denizen Item Script")));
display.set("Lore", nbtLore);
tag.set("display", display);
itemStack.setTag(tag);
Expand Down
Expand Up @@ -44,6 +44,7 @@ else if (packet instanceof PacketPlayOutWindowItems) {
for (int i = 0; i < itemStacks.length; i++) {
itemStacks[i] = removeItemScriptLore(itemStacks[i]);
}
window_items_itemStackArray.set(wiPacket, itemStacks);
}
else if (packet instanceof PacketPlayOutNamedEntitySpawn) {
PacketPlayOutNamedEntitySpawn nesPacket = (PacketPlayOutNamedEntitySpawn) packet;
Expand Down Expand Up @@ -74,7 +75,7 @@ else if (packet instanceof PacketPlayOutPlayerInfo) {
}

private static ItemStack removeItemScriptLore(ItemStack itemStack) throws Exception{
if (itemStack != null && itemStack.getTag() != null && !itemStack.getTag().isEmpty()) {
if (itemStack != null && itemStack.hasTag() && !itemStack.getTag().isEmpty()) {
NBTTagCompound tag = itemStack.getTag();
NBTTagCompound display = tag.getCompound("display");
NBTTagList lore = (NBTTagList) display.get("Lore");
Expand Down

0 comments on commit 53d4494

Please sign in to comment.