diff --git a/src/main/java/lol/hyper/toolstats/events/BlocksMined.java b/src/main/java/lol/hyper/toolstats/events/BlocksMined.java index 06df1fb..bbe404c 100644 --- a/src/main/java/lol/hyper/toolstats/events/BlocksMined.java +++ b/src/main/java/lol/hyper/toolstats/events/BlocksMined.java @@ -86,11 +86,6 @@ public class BlocksMined implements Listener { String blocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined); List newLore = toolStats.itemLore.addItemLore(meta, "{blocks}", blocksMinedFormatted, "blocks-mined"); - // if the list returned null, don't add it - if (newLore == null) { - return; - } - // do we add the lore based on the config? if (toolStats.checkConfig(playerTool, "blocks-mined")) { meta.setLore(newLore); diff --git a/src/main/java/lol/hyper/toolstats/events/ChunkPopulate.java b/src/main/java/lol/hyper/toolstats/events/ChunkPopulate.java index 7fb9a7a..4ee07fa 100644 --- a/src/main/java/lol/hyper/toolstats/events/ChunkPopulate.java +++ b/src/main/java/lol/hyper/toolstats/events/ChunkPopulate.java @@ -36,7 +36,7 @@ import org.bukkit.persistence.PersistentDataType; public class ChunkPopulate implements Listener { // this tags all elytras with a "new" tag - // this let's us track any new elytras player loot + // this lets us track any new elytras player loot private final ToolStats toolStats; @@ -55,21 +55,22 @@ public class ChunkPopulate implements Listener { Chunk chunk = event.getChunk(); for (Entity entity : chunk.getEntities()) { // if there is a new item frame - if (entity instanceof ItemFrame) { - ItemFrame itemFrame = (ItemFrame) entity; - // if the item frame has an elytra - if (itemFrame.getItem().getType() == Material.ELYTRA) { - ItemStack elytraCopy = itemFrame.getItem(); - ItemMeta meta = elytraCopy.getItemMeta(); - if (meta == null) { - return; - } - // add the new tag so we know it's new - PersistentDataContainer container = meta.getPersistentDataContainer(); - container.set(toolStats.newElytra, PersistentDataType.INTEGER, 1); - elytraCopy.setItemMeta(meta); - itemFrame.setItem(elytraCopy); + if (!(entity instanceof ItemFrame)) { + return; + } + ItemFrame itemFrame = (ItemFrame) entity; + // if the item frame has an elytra + if (itemFrame.getItem().getType() == Material.ELYTRA) { + ItemStack elytraCopy = itemFrame.getItem(); + ItemMeta meta = elytraCopy.getItemMeta(); + if (meta == null) { + return; } + // add the new tag so we know it's new + PersistentDataContainer container = meta.getPersistentDataContainer(); + container.set(toolStats.newElytra, PersistentDataType.INTEGER, 1); + elytraCopy.setItemMeta(meta); + itemFrame.setItem(elytraCopy); } } }, 20); diff --git a/src/main/java/lol/hyper/toolstats/events/EntityDamage.java b/src/main/java/lol/hyper/toolstats/events/EntityDamage.java index 6b59a44..3d8be5f 100644 --- a/src/main/java/lol/hyper/toolstats/events/EntityDamage.java +++ b/src/main/java/lol/hyper/toolstats/events/EntityDamage.java @@ -249,11 +249,6 @@ public class EntityDamage implements Listener { String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills); List newLore = toolStats.itemLore.addItemLore(meta, "{kills}", playerKillsFormatted, "kills.player"); - // if the list returned null, don't add it - if (newLore == null) { - return; - } - // do we add the lore based on the config? if (toolStats.checkConfig(itemStack, "player-kills")) { meta.setLore(newLore); @@ -289,11 +284,6 @@ public class EntityDamage implements Listener { String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills); List newLore = toolStats.itemLore.addItemLore(meta, "{kills}", mobKillsFormatted, "kills.mob"); - // if the list returned null, don't add it - if (newLore == null) { - return; - } - // do we add the lore based on the config? if (toolStats.checkConfig(itemStack, "mob-kills")) { meta.setLore(newLore); @@ -330,11 +320,6 @@ public class EntityDamage implements Listener { String damageTakenFormatted = toolStats.numberFormat.formatDouble(damageTaken); List newLore = toolStats.itemLore.addItemLore(meta, "{damage}", damageTakenFormatted, "damage-taken"); - // if the list returned null, don't add it - if (newLore == null) { - return; - } - if (toolStats.config.getBoolean("enabled.armor-damage")) { meta.setLore(newLore); } @@ -370,11 +355,6 @@ public class EntityDamage implements Listener { String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills); List newLore = toolStats.itemLore.addItemLore(meta, "{kills}", mobKillsFormatted, "kills.mob"); - // if the list returned null, don't add it - if (newLore == null) { - return null; - } - // do we add the lore based on the config? if (toolStats.checkConfig(newTrident, "mob-kills")) { meta.setLore(newLore); @@ -412,11 +392,6 @@ public class EntityDamage implements Listener { String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills); List newLore = toolStats.itemLore.addItemLore(meta, "{kills}", playerKillsFormatted, "kills.player"); - // if the list returned null, don't add it - if (newLore == null) { - return null; - } - // do we add the lore based on the config? if (toolStats.checkConfig(newTrident, "player-kills")) { meta.setLore(newLore); diff --git a/src/main/java/lol/hyper/toolstats/events/EntityDeath.java b/src/main/java/lol/hyper/toolstats/events/EntityDeath.java index f1b90a5..7af5f8c 100644 --- a/src/main/java/lol/hyper/toolstats/events/EntityDeath.java +++ b/src/main/java/lol/hyper/toolstats/events/EntityDeath.java @@ -85,11 +85,6 @@ public class EntityDeath implements Listener { List newLore = toolStats.itemLore.addItemLore(meta, "{name}", mob, "dropped-by"); - // if the list returned null, don't add it - if (newLore == null) { - return null; - } - if (toolStats.config.getBoolean("enabled.dropped-by")) { meta.setLore(newLore); } diff --git a/src/main/java/lol/hyper/toolstats/events/PlayerFish.java b/src/main/java/lol/hyper/toolstats/events/PlayerFish.java index f3dd2f3..52f26de 100644 --- a/src/main/java/lol/hyper/toolstats/events/PlayerFish.java +++ b/src/main/java/lol/hyper/toolstats/events/PlayerFish.java @@ -128,11 +128,6 @@ public class PlayerFish implements Listener { String fishCaughtFormatted = toolStats.numberFormat.formatInt(fishCaught); List newLore = toolStats.itemLore.addItemLore(meta, "{fish}", fishCaughtFormatted, "fished.fish-caught"); - // if the list returned null, don't add it - if (newLore == null) { - return; - } - if (toolStats.config.getBoolean("enabled.fish-caught")) { meta.setLore(newLore); } diff --git a/src/main/java/lol/hyper/toolstats/events/SheepShear.java b/src/main/java/lol/hyper/toolstats/events/SheepShear.java index d770e60..9c53c74 100644 --- a/src/main/java/lol/hyper/toolstats/events/SheepShear.java +++ b/src/main/java/lol/hyper/toolstats/events/SheepShear.java @@ -120,10 +120,6 @@ public class SheepShear implements Listener { String sheepShearedFormatted = toolStats.numberFormat.formatInt(sheepSheared); List newLore = toolStats.itemLore.addItemLore(meta, "{sheep}", sheepShearedFormatted, "sheep-sheared"); - // if the list returned null, don't add it - if (newLore == null) { - return; - } if (toolStats.config.getBoolean("enabled.sheep-sheared")) { meta.setLore(newLore); } diff --git a/src/main/java/lol/hyper/toolstats/tools/ItemLore.java b/src/main/java/lol/hyper/toolstats/tools/ItemLore.java index 7c7cf35..cd587b0 100644 --- a/src/main/java/lol/hyper/toolstats/tools/ItemLore.java +++ b/src/main/java/lol/hyper/toolstats/tools/ItemLore.java @@ -21,6 +21,7 @@ import lol.hyper.toolstats.ToolStats; import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Locale; @@ -47,7 +48,7 @@ public class ItemLore { if (configLore == null || configLoreRaw == null) { toolStats.logger.warning("There is no lore message for messages." + configLorePath + "!"); toolStats.logger.warning("Unable to update lore for item."); - return null; + return itemMeta.getLore(); } List newLore; @@ -118,7 +119,7 @@ public class ItemLore { if (dateCreated == null || itemOwner == null) { toolStats.logger.warning("There is no lore message for messages." + type.toLowerCase(Locale.ENGLISH) + "!"); toolStats.logger.warning("Unable to update lore for item."); - return null; + return itemMeta.getLore(); } List newLore;