mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
return item lore back rather than nulling it
This commit is contained in:
@@ -86,11 +86,6 @@ public class BlocksMined implements Listener {
|
||||
String blocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
||||
List<String> 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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -249,11 +249,6 @@ public class EntityDamage implements Listener {
|
||||
String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||
List<String> 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<String> 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<String> 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<String> 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<String> 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);
|
||||
|
||||
@@ -85,11 +85,6 @@ public class EntityDeath implements Listener {
|
||||
|
||||
List<String> 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);
|
||||
}
|
||||
|
||||
@@ -128,11 +128,6 @@ public class PlayerFish implements Listener {
|
||||
String fishCaughtFormatted = toolStats.numberFormat.formatInt(fishCaught);
|
||||
List<String> 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);
|
||||
}
|
||||
|
||||
@@ -120,10 +120,6 @@ public class SheepShear implements Listener {
|
||||
String sheepShearedFormatted = toolStats.numberFormat.formatInt(sheepSheared);
|
||||
List<String> 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);
|
||||
}
|
||||
|
||||
@@ -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<String> 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<String> newLore;
|
||||
|
||||
Reference in New Issue
Block a user