rename many config things

This commit is contained in:
hyperdefined
2025-05-06 20:05:13 -04:00
parent 5373792480
commit 70e19269ee
13 changed files with 401 additions and 243 deletions

View File

@@ -35,6 +35,7 @@ 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;
@@ -133,22 +134,45 @@ public class VillagerTrade implements Listener {
return null;
}
if (!toolStats.configTools.checkConfig(newItem.getType(), "traded-tag")) {
return null;
// get the current lore the item
List<Component> lore;
if (meta.hasLore()) {
lore = meta.lore();
} else {
lore = new ArrayList<>();
}
// only make the hash if it's enabled
if (toolStats.configTools.checkConfig(newItem.getType(), "traded-on")) {
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);
meta.lore(lore);
}
if (toolStats.configTools.checkConfig(newItem.getType(), "traded-by")) {
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);
meta.lore(lore);
}
// if hash is enabled, add it
if (toolStats.config.getBoolean("generate-hash-for-items")) {
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
container.set(toolStats.hash, PersistentDataType.STRING, hash);
}
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
List<Component> newLore = toolStats.itemLore.addNewOwner(meta, owner.getName(), formattedDate);
meta.lore(newLore);
newItem.setItemMeta(meta);
return newItem;
}