mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-05 22:31:45 +00:00
unify owner and timestamp creation
This commit is contained in:
@@ -233,38 +233,6 @@ public class CommandToolStats implements TabExecutor {
|
||||
origin = -1;
|
||||
}
|
||||
|
||||
// hard code elytras
|
||||
if (finalItem.getType() == Material.ELYTRA) {
|
||||
Long flightTime = null;
|
||||
Long timeCreated = null;
|
||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG)) {
|
||||
timeCreated = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
||||
}
|
||||
if (container.has(toolStats.flightTime, PersistentDataType.LONG)) {
|
||||
flightTime = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
||||
}
|
||||
|
||||
if (flightTime != null) {
|
||||
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
||||
Map<String, String> flightTimeFormatted = toolStats.numberFormat.formatTime(flightTime);
|
||||
Component line = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", flightTimeFormatted);
|
||||
lore.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (timeCreated != null) {
|
||||
Component timeCreatedLine = toolStats.configTools.formatLore("looted.found-by", "{player}", player.getName());
|
||||
Component playerOwnerLine = toolStats.configTools.formatLore("looted.found-on", "{date}", toolStats.numberFormat.formatDate(new Date(timeCreated)));
|
||||
lore.add(timeCreatedLine);
|
||||
lore.add(playerOwnerLine);
|
||||
}
|
||||
|
||||
finalMeta.lore(lore);
|
||||
finalItem.setItemMeta(finalMeta);
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
player.getInventory().setItem(slot, finalItem);
|
||||
}
|
||||
|
||||
if (container.has(toolStats.droppedBy, PersistentDataType.STRING)) {
|
||||
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
||||
if (container.has(toolStats.droppedBy)) {
|
||||
@@ -293,82 +261,30 @@ public class CommandToolStats implements TabExecutor {
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), player.getUniqueId());
|
||||
}
|
||||
|
||||
// show how the item was created based on the previous lore
|
||||
switch (origin) {
|
||||
case 0: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "crafted-by")) {
|
||||
lore.add(toolStats.configTools.formatLore("crafted.crafted-by", "{player}", ownerName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "looted-by")) {
|
||||
lore.add(toolStats.configTools.formatLore("looted.looted-by", "{player}", ownerName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "traded-by")) {
|
||||
lore.add(toolStats.configTools.formatLore("traded.traded-by", "{player}", ownerName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "fished-by")) {
|
||||
lore.add(toolStats.configTools.formatLore("fished.caught-by", "{player}", ownerName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "spawned-in-by")) {
|
||||
lore.add(toolStats.configTools.formatLore("spawned-in.spawned-by", "{player}", ownerName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
// add the ownership lore
|
||||
Component ownerLore = toolStats.itemLore.formatOwner(ownerName, origin, original);
|
||||
if (ownerLore != null) {
|
||||
lore.add(ownerLore);
|
||||
}
|
||||
|
||||
}
|
||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG)) {
|
||||
Long time = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
||||
if (time != null) {
|
||||
String date = toolStats.numberFormat.formatDate(new Date(time));
|
||||
// show how when the item was created based on the previous lore
|
||||
switch (origin) {
|
||||
case 0: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "crafted-on")) {
|
||||
lore.add(toolStats.configTools.formatLore("crafted.crafted-on", "{date}", date));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if (toolStats.config.getBoolean("enabled.dropped-on")) {
|
||||
lore.add(toolStats.configTools.formatLore("dropped-on", "{date}", date));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "looted-on")) {
|
||||
lore.add(toolStats.configTools.formatLore("looted.looted-on", "{date}", date));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "traded-on")) {
|
||||
lore.add(toolStats.configTools.formatLore("traded.traded-on", "{date}", date));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "fished-on")) {
|
||||
lore.add(toolStats.configTools.formatLore("fished.caught-on", "{date}", date));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "spawned-in-on")) {
|
||||
lore.add(toolStats.configTools.formatLore("spawned-in.spawned-on", "{date}", date));
|
||||
}
|
||||
break;
|
||||
}
|
||||
// add the creation time lore
|
||||
Component creationTimeLore = toolStats.itemLore.formatCreationTime(time, origin, original);
|
||||
if (creationTimeLore != null) {
|
||||
lore.add(creationTimeLore);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
||||
if (container.has(toolStats.flightTime, PersistentDataType.LONG)) {
|
||||
Long flightTime = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
||||
if (flightTime != null) {
|
||||
Map<String, String> flightTimeFormatted = toolStats.numberFormat.formatTime(flightTime);
|
||||
Component line = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", flightTimeFormatted);
|
||||
lore.add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +125,6 @@ public class CraftItem implements Listener {
|
||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||
timeCreated = finalDate.getTime();
|
||||
} else {
|
||||
finalDate = new Date(timeCreated);
|
||||
}
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
@@ -145,29 +143,20 @@ public class CraftItem implements Listener {
|
||||
}
|
||||
|
||||
// if creation date is enabled, add it
|
||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "crafted-on")) {
|
||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 0, newItem);
|
||||
if (creationDate != null) {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
||||
|
||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
||||
Component newLine = toolStats.configTools.formatLore("crafted.crafted-on", "{date}", date);
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(creationDate);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
// if creation owner is enabled, add it
|
||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "crafted-by")) {
|
||||
// if ownership is enabled, add it
|
||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 0, newItem);
|
||||
if (itemOwner != null) {
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
||||
|
||||
Component newLine = toolStats.configTools.formatLore("crafted.crafted-by", "{player}", owner.getName());
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(itemOwner);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +92,6 @@ public class CreativeEvent implements Listener {
|
||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||
timeCreated = finalDate.getTime();
|
||||
} else {
|
||||
finalDate = new Date(timeCreated);
|
||||
}
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
@@ -111,28 +109,21 @@ public class CreativeEvent implements Listener {
|
||||
lore = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "spawned-in-on")) {
|
||||
// if creation date is enabled, add it
|
||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 6, newSpawnedItem);
|
||||
if (creationDate != null) {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
||||
|
||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
||||
Component newLine = toolStats.configTools.formatLore("spawned-in.spawned-on", "{date}", date);
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(creationDate);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "spawned-in-by")) {
|
||||
// if ownership is enabled, add it
|
||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 6, newSpawnedItem);
|
||||
if (itemOwner != null) {
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
||||
|
||||
Component newLine = toolStats.configTools.formatLore("spawned-in.spawned-by", "{player}", owner.getName());
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(itemOwner);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package lol.hyper.toolstats.events;
|
||||
|
||||
import lol.hyper.toolstats.ToolStats;
|
||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -91,8 +92,6 @@ public class EntityDeath implements Listener {
|
||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||
timeCreated = finalDate.getTime();
|
||||
} else {
|
||||
finalDate = new Date(timeCreated);
|
||||
}
|
||||
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
@@ -108,12 +107,13 @@ public class EntityDeath implements Listener {
|
||||
lore = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (toolStats.config.getBoolean("enabled.dropped-on")) {
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 1);
|
||||
// if creation date is enabled, add it
|
||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 1, newItem);
|
||||
if (creationDate != null) {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
||||
Component droppedOn = toolStats.configTools.formatLore("dropped-on", "{date}", date);
|
||||
lore.add(droppedOn);
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 1);
|
||||
lore.add(creationDate);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
||||
|
||||
@@ -104,8 +104,6 @@ public class GenerateLoot implements Listener {
|
||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||
timeCreated = finalDate.getTime();
|
||||
} else {
|
||||
finalDate = new Date(timeCreated);
|
||||
}
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
@@ -121,28 +119,21 @@ public class GenerateLoot implements Listener {
|
||||
lore = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "looted-on")) {
|
||||
// if creation date is enabled, add it
|
||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 2, newItem);
|
||||
if (creationDate != null) {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
||||
|
||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
||||
Component newLine = toolStats.configTools.formatLore("looted.looted-on", "{date}", date);
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(creationDate);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "looted-by")) {
|
||||
// if ownership is enabled, add it
|
||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 2, newItem);
|
||||
if (itemOwner != null) {
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
||||
|
||||
Component newLine = toolStats.configTools.formatLore("looted.looted-by", "{player}", owner.getName());
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(itemOwner);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +95,6 @@ public class PickupItem implements Listener {
|
||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||
timeCreated = finalDate.getTime();
|
||||
} else {
|
||||
finalDate = new Date(timeCreated);
|
||||
}
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
@@ -123,12 +121,22 @@ public class PickupItem implements Listener {
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
||||
container.remove(toolStats.newElytra);
|
||||
|
||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
||||
Component dateCreatedLore = toolStats.configTools.formatLore("looted.found-on", "{date}", formattedDate);
|
||||
Component itemOwnerLore = toolStats.configTools.formatLore("looted.found-by", "{player}", owner.getName());
|
||||
lore.add(dateCreatedLore);
|
||||
lore.add(itemOwnerLore);
|
||||
meta.lore(lore);
|
||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 4, finalItem);
|
||||
if (creationDate != null) {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
||||
lore.add(creationDate);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 4, finalItem);
|
||||
if (itemOwner != null) {
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
||||
lore.add(itemOwner);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
finalItem.setItemMeta(meta);
|
||||
return finalItem;
|
||||
}
|
||||
|
||||
@@ -114,8 +114,6 @@ public class PlayerFish implements Listener {
|
||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||
timeCreated = finalDate.getTime();
|
||||
} else {
|
||||
finalDate = new Date(timeCreated);
|
||||
}
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
@@ -131,28 +129,21 @@ public class PlayerFish implements Listener {
|
||||
lore = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "fished-on")) {
|
||||
// if creation date is enabled, add it
|
||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 5, newItem);
|
||||
if (creationDate != null) {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 5);
|
||||
|
||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
||||
Component newLine = toolStats.configTools.formatLore("fished.caught-on", "{date}", date);
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(creationDate);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "fished-by")) {
|
||||
// if ownership is enabled, add it
|
||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 5, newItem);
|
||||
if (itemOwner != null) {
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 5);
|
||||
|
||||
Component newLine = toolStats.configTools.formatLore("fished.caught-by", "{player}", owner.getName());
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(itemOwner);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
|
||||
@@ -131,8 +131,6 @@ public class VillagerTrade implements Listener {
|
||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||
timeCreated = finalDate.getTime();
|
||||
} else {
|
||||
finalDate = new Date(timeCreated);
|
||||
}
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
|
||||
@@ -148,28 +146,22 @@ public class VillagerTrade implements Listener {
|
||||
lore = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "traded-on")) {
|
||||
|
||||
// if creation date is enabled, add it
|
||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 3, newItem);
|
||||
if (creationDate != null) {
|
||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
|
||||
|
||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
||||
Component newLine = toolStats.configTools.formatLore("traded.traded-on", "{date}", date);
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(creationDate);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "traded-by")) {
|
||||
// if ownership is enabled, add it
|
||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 3, newItem);
|
||||
if (itemOwner != null) {
|
||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
|
||||
|
||||
Component newLine = toolStats.configTools.formatLore("traded.traded-by", "{player}", owner.getName());
|
||||
if (newLine == null) {
|
||||
return null;
|
||||
}
|
||||
lore.add(newLine);
|
||||
lore.add(itemOwner);
|
||||
meta.lore(lore);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,14 @@ package lol.hyper.toolstats.tools;
|
||||
import lol.hyper.toolstats.ToolStats;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1119,4 +1121,111 @@ public class ItemLore {
|
||||
meta.lore(newLore);
|
||||
return meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the item owner lore.
|
||||
*
|
||||
* @param playerName The player's name who owns the items.
|
||||
* @param origin The origin type.
|
||||
* @param item The item.
|
||||
* @return A component with the lore.
|
||||
*/
|
||||
public Component formatOwner(String playerName, int origin, ItemStack item) {
|
||||
switch (origin) {
|
||||
case 0: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "crafted-by")) {
|
||||
return toolStats.configTools.formatLore("crafted.crafted-by", "{player}", playerName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "looted-by")) {
|
||||
return toolStats.configTools.formatLore("looted.looted-by", "{player}", playerName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "traded-by")) {
|
||||
return toolStats.configTools.formatLore("traded.traded-by", "{player}", playerName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
if (toolStats.config.getBoolean("enabled.elytra-tag")) {
|
||||
return toolStats.configTools.formatLore("looted.found-by", "{player}", playerName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "fished-by")) {
|
||||
return toolStats.configTools.formatLore("fished.caught-by", "{player}", playerName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "spawned-in-by")) {
|
||||
return toolStats.configTools.formatLore("spawned-in.spawned-by", "{player}", playerName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the item creation time.
|
||||
*
|
||||
* @param creationDate When the item was created.
|
||||
* @param origin The origin type.
|
||||
* @param item The item.
|
||||
* @return A component with the lore.
|
||||
*/
|
||||
public Component formatCreationTime(long creationDate, int origin, ItemStack item) {
|
||||
String date = toolStats.numberFormat.formatDate(new Date(creationDate));
|
||||
switch (origin) {
|
||||
case 0: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "crafted-on")) {
|
||||
return toolStats.configTools.formatLore("crafted.crafted-on", "{date}", date);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if (toolStats.config.getBoolean("enabled.dropped-on")) {
|
||||
return toolStats.configTools.formatLore("dropped-on", "{date}", date);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "looted-on")) {
|
||||
return toolStats.configTools.formatLore("looted.looted-on", "{date}", date);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "traded-on")) {
|
||||
return toolStats.configTools.formatLore("traded.traded-on", "{date}", date);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
if (toolStats.config.getBoolean("enabled.elytra-tag")) {
|
||||
return toolStats.configTools.formatLore("looted.found-on", "{date}", date);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "fished-on")) {
|
||||
return toolStats.configTools.formatLore("fished.caught-on", "{date}", date);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
if (toolStats.configTools.checkConfig(item.getType(), "spawned-in-on")) {
|
||||
return toolStats.configTools.formatLore("spawned-in.spawned-on", "{date}", date);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user