custom model data & massive cleanup

closes #105
This commit is contained in:
hyperdefined
2025-05-15 17:59:44 -04:00
parent 67d141c452
commit c7cd25e866
5 changed files with 166 additions and 360 deletions

View File

@@ -25,7 +25,6 @@ import lol.hyper.toolstats.events.*;
import lol.hyper.toolstats.tools.*;
import lol.hyper.toolstats.tools.config.ConfigTools;
import lol.hyper.toolstats.tools.config.ConfigUpdater;
import lol.hyper.toolstats.tools.config.TokenItems;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
@@ -150,8 +149,7 @@ public final class ToolStats extends JavaPlugin {
public ItemChecker itemChecker;
public ShootBow shootBow;
public ConfigTools configTools;
public TokenItems tokenItems;
public TokenCrafting tokenCrafting;
public TokenData tokenData;
public AnvilEvent anvilEvent;
public PrepareCraft prepareCraft;
@@ -164,10 +162,9 @@ public final class ToolStats extends JavaPlugin {
loadConfig();
configTools = new ConfigTools(this);
tokenItems = new TokenItems(this);
tokenCrafting = new TokenCrafting(this);
tokenCrafting.setup();
for (ShapedRecipe recipe : tokenCrafting.getRecipes()) {
tokenData = new TokenData(this);
tokenData.setup();
for (ShapedRecipe recipe : tokenData.getRecipes()) {
if (tokens && config.getBoolean("tokens.craft-tokens")) {
Bukkit.addRecipe(recipe);
}

View File

@@ -30,7 +30,6 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
@@ -64,8 +63,8 @@ public class CommandToolStats implements TabExecutor {
if (sender.hasPermission("toolstats.reload")) {
boolean oldTokensStatus = toolStats.tokens;
toolStats.loadConfig();
toolStats.tokenCrafting.getRecipes().clear();
toolStats.tokenCrafting.setup();
toolStats.tokenData.getRecipes().clear();
toolStats.tokenData.setup();
// if the server went from tokens off -> on, add the recipes
// if the server went from tokens on -> off, remove the recipes
if (toolStats.tokens != oldTokensStatus) {
@@ -73,14 +72,14 @@ public class CommandToolStats implements TabExecutor {
if (toolStats.tokens) {
sender.sendMessage(Component.text("It looks like you ENABLED the token system. While this is fine, it can break. Please restart your server instead.", NamedTextColor.YELLOW));
if (toolStats.config.getBoolean("tokens.craft-token")) {
for (ShapedRecipe recipe : toolStats.tokenCrafting.getRecipes()) {
for (ShapedRecipe recipe : toolStats.tokenData.getRecipes()) {
Bukkit.addRecipe(recipe);
}
}
} else {
// tokens are now disabled
sender.sendMessage(Component.text("It looks like you DISABLED the token system. While this is fine, it can break. Please restart your server instead.", NamedTextColor.YELLOW));
for (ShapedRecipe recipe : toolStats.tokenCrafting.getRecipes()) {
for (ShapedRecipe recipe : toolStats.tokenData.getRecipes()) {
Bukkit.removeRecipe(recipe.getKey());
}
}
@@ -172,7 +171,7 @@ public class CommandToolStats implements TabExecutor {
return true;
}
String tokenType = args[2];
if (!toolStats.tokenCrafting.getTokenTypes().contains(tokenType)) {
if (!toolStats.tokenData.getTokenTypes().contains(tokenType)) {
sender.sendMessage(Component.text("Invalid token type.", NamedTextColor.RED));
return true;
}
@@ -458,80 +457,9 @@ public class CommandToolStats implements TabExecutor {
* @param tokenType The token type.
*/
private void giveToken(Player target, String tokenType, int amount) {
switch (tokenType) {
case "crops-mined": {
ItemStack itemStack = toolStats.tokenItems.cropsMined();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "blocks-mined": {
ItemStack itemStack = toolStats.tokenItems.blocksMined();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "damage-taken": {
ItemStack itemStack = toolStats.tokenItems.damageTaken();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "damage-done": {
ItemStack itemStack = toolStats.tokenItems.damageDone();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "mob-kills": {
ItemStack itemStack = toolStats.tokenItems.mobKills();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "player-kills": {
ItemStack itemStack = toolStats.tokenItems.playerKills();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "arrows-shot": {
ItemStack itemStack = toolStats.tokenItems.arrowsShot();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "sheep-sheared": {
ItemStack itemStack = toolStats.tokenItems.sheepSheared();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "flight-time": {
ItemStack itemStack = toolStats.tokenItems.flightTime();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "fish-caught": {
ItemStack itemStack = toolStats.tokenItems.fishCaught();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "reset": {
ItemStack itemStack = toolStats.tokenItems.resetToken();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
case "remove": {
ItemStack itemStack = toolStats.tokenItems.removeToken();
itemStack.setAmount(amount);
target.getInventory().addItem(itemStack);
break;
}
}
ItemStack token = toolStats.tokenData.createToken(tokenType);
token.setAmount(amount);
target.getInventory().addItem(token);
}
/**
@@ -1154,20 +1082,20 @@ public class CommandToolStats implements TabExecutor {
}
if (args.length == 2 && args[0].equalsIgnoreCase("edit") && sender.hasPermission("toolstats.edit")) {
// yes I am lazy
return toolStats.tokenCrafting.getTokenTypes().stream()
return toolStats.tokenData.getTokenTypes().stream()
.filter(s -> !s.equals("remove") && !s.equals("reset"))
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
.collect(Collectors.toList());
}
if (args.length == 2 && args[0].equalsIgnoreCase("remove") && sender.hasPermission("toolstats.remove")) {
// yes I am lazy
return toolStats.tokenCrafting.getTokenTypes().stream()
return toolStats.tokenData.getTokenTypes().stream()
.filter(s -> !s.equals("remove") && !s.equals("reset"))
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
.collect(Collectors.toList());
}
if (args.length == 3 && args[0].equalsIgnoreCase("givetokens") && sender.hasPermission("toolstats.givetokens")) {
return toolStats.tokenCrafting.getTokenTypes();
return toolStats.tokenData.getTokenTypes();
}
return null;

View File

@@ -17,104 +17,111 @@
package lol.hyper.toolstats.tools;
import io.papermc.paper.datacomponent.DataComponentTypes;
import io.papermc.paper.datacomponent.item.CustomModelData;
import lol.hyper.toolstats.ToolStats;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.components.CustomModelDataComponent;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
public class TokenCrafting {
public class TokenData {
private final ToolStats toolStats;
private final Set<ShapedRecipe> recipes = new HashSet<>();
private final ArrayList<String> tokenTypes = new ArrayList<>();
public TokenCrafting(ToolStats toolStats) {
public TokenData(ToolStats toolStats) {
this.toolStats = toolStats;
}
public void setup() {
NamespacedKey playerKillsKey = new NamespacedKey(toolStats, "player-kills-token");
ShapedRecipe playerKillRecipe = new ShapedRecipe(playerKillsKey, toolStats.tokenItems.playerKills());
ShapedRecipe playerKillRecipe = new ShapedRecipe(playerKillsKey, createToken("player-kills"));
playerKillRecipe.shape(" P ", "PSP", " P ");
playerKillRecipe.setIngredient('P', Material.PAPER);
playerKillRecipe.setIngredient('S', Material.WOODEN_SWORD);
recipes.add(playerKillRecipe);
NamespacedKey mobKillsKey = new NamespacedKey(toolStats, "mob-kills-token");
ShapedRecipe mobKillsRecipe = new ShapedRecipe(mobKillsKey, toolStats.tokenItems.mobKills());
ShapedRecipe mobKillsRecipe = new ShapedRecipe(mobKillsKey, createToken("mob-kills"));
mobKillsRecipe.shape(" P ", "PRP", " P ");
mobKillsRecipe.setIngredient('P', Material.PAPER);
mobKillsRecipe.setIngredient('R', Material.ROTTEN_FLESH);
recipes.add(mobKillsRecipe);
NamespacedKey blocksMinedKey = new NamespacedKey(toolStats, "blocks-mined-token");
ShapedRecipe blocksMinedRecipe = new ShapedRecipe(blocksMinedKey, toolStats.tokenItems.blocksMined());
ShapedRecipe blocksMinedRecipe = new ShapedRecipe(blocksMinedKey, createToken("blocks-mined"));
blocksMinedRecipe.shape(" P ", "PSP", " P ");
blocksMinedRecipe.setIngredient('P', Material.PAPER);
blocksMinedRecipe.setIngredient('S', Material.WOODEN_PICKAXE);
recipes.add(blocksMinedRecipe);
NamespacedKey cropsMinedKey = new NamespacedKey(toolStats, "crops-mined-token");
ShapedRecipe cropsMinedRecipe = new ShapedRecipe(cropsMinedKey, toolStats.tokenItems.cropsMined());
ShapedRecipe cropsMinedRecipe = new ShapedRecipe(cropsMinedKey, createToken("crops-mined"));
cropsMinedRecipe.shape(" P ", "PHP", " P ");
cropsMinedRecipe.setIngredient('P', Material.PAPER);
cropsMinedRecipe.setIngredient('H', Material.WOODEN_HOE);
recipes.add(cropsMinedRecipe);
NamespacedKey fishCaughtKey = new NamespacedKey(toolStats, "fish-caught-token");
ShapedRecipe fishCaughtRecipe = new ShapedRecipe(fishCaughtKey, toolStats.tokenItems.fishCaught());
ShapedRecipe fishCaughtRecipe = new ShapedRecipe(fishCaughtKey, createToken("fish-caught"));
fishCaughtRecipe.shape(" P ", "PCP", " P ");
fishCaughtRecipe.setIngredient('P', Material.PAPER);
fishCaughtRecipe.setIngredient('C', Material.COD);
recipes.add(fishCaughtRecipe);
NamespacedKey sheepShearedKey = new NamespacedKey(toolStats, "sheep-sheared-token");
ShapedRecipe sheepShearedRecipe = new ShapedRecipe(sheepShearedKey, toolStats.tokenItems.sheepSheared());
ShapedRecipe sheepShearedRecipe = new ShapedRecipe(sheepShearedKey, createToken("sheep-sheared"));
sheepShearedRecipe.shape(" P ", "PWP", " P ");
sheepShearedRecipe.setIngredient('P', Material.PAPER);
sheepShearedRecipe.setIngredient('W', Material.WHITE_WOOL);
recipes.add(sheepShearedRecipe);
NamespacedKey armorDamageKey = new NamespacedKey(toolStats, "damage-taken-token");
ShapedRecipe armorDamageRecipe = new ShapedRecipe(armorDamageKey, toolStats.tokenItems.damageTaken());
ShapedRecipe armorDamageRecipe = new ShapedRecipe(armorDamageKey, createToken("damage-taken"));
armorDamageRecipe.shape(" P ", "PCP", " P ");
armorDamageRecipe.setIngredient('P', Material.PAPER);
armorDamageRecipe.setIngredient('C', Material.LEATHER_CHESTPLATE);
recipes.add(armorDamageRecipe);
NamespacedKey damageDoneKey = new NamespacedKey(toolStats, "damage-done-token");
ShapedRecipe damageDoneRecipe = new ShapedRecipe(damageDoneKey, toolStats.tokenItems.damageDone());
ShapedRecipe damageDoneRecipe = new ShapedRecipe(damageDoneKey, createToken("damage-done"));
damageDoneRecipe.shape(" P ", "PSP", " P ");
damageDoneRecipe.setIngredient('P', Material.PAPER);
damageDoneRecipe.setIngredient('S', Material.SHIELD);
recipes.add(damageDoneRecipe);
NamespacedKey arrowsShotKey = new NamespacedKey(toolStats, "arrows-shot-token");
ShapedRecipe arrowsShotRecipe = new ShapedRecipe(arrowsShotKey, toolStats.tokenItems.arrowsShot());
ShapedRecipe arrowsShotRecipe = new ShapedRecipe(arrowsShotKey, createToken("arrows-shot"));
arrowsShotRecipe.shape(" P ", "PAP", " P ");
arrowsShotRecipe.setIngredient('P', Material.PAPER);
arrowsShotRecipe.setIngredient('A', Material.ARROW);
recipes.add(arrowsShotRecipe);
NamespacedKey flightTimeKey = new NamespacedKey(toolStats, "flight-time-token");
ShapedRecipe flightTimeRecipe = new ShapedRecipe(flightTimeKey, toolStats.tokenItems.flightTime());
ShapedRecipe flightTimeRecipe = new ShapedRecipe(flightTimeKey, createToken("flight-time"));
flightTimeRecipe.shape(" P ", "PFP", " P ");
flightTimeRecipe.setIngredient('P', Material.PAPER);
flightTimeRecipe.setIngredient('F', Material.FEATHER);
recipes.add(flightTimeRecipe);
NamespacedKey resetKey = new NamespacedKey(toolStats, "reset-token");
ShapedRecipe resetRecipe = new ShapedRecipe(resetKey, toolStats.tokenItems.resetToken());
ShapedRecipe resetRecipe = new ShapedRecipe(resetKey, createToken("reset"));
resetRecipe.shape(" P ", "PPP", " P ");
resetRecipe.setIngredient('P', Material.PAPER);
recipes.add(resetRecipe);
NamespacedKey removeKey = new NamespacedKey(toolStats, "remove-token");
ShapedRecipe removeRecipe = new ShapedRecipe(removeKey, toolStats.tokenItems.removeToken());
ShapedRecipe removeRecipe = new ShapedRecipe(removeKey, createToken("remove"));
removeRecipe.shape(" P ", "P P", " P ");
removeRecipe.setIngredient('P', Material.PAPER);
recipes.add(removeRecipe);
@@ -140,4 +147,83 @@ public class TokenCrafting {
public ArrayList<String> getTokenTypes() {
return tokenTypes;
}
public ItemStack createToken(String tokenType) {
// we don't have to check if the token exists
// we do that prior
ConfigurationSection tokenConfig = toolStats.config.getConfigurationSection("tokens.data." + tokenType);
String materialFromConfig = tokenConfig.getString("material");
if (materialFromConfig == null) {
toolStats.logger.warning("Could not find material config for token " + tokenType);
return null;
}
Material material = Material.getMaterial(materialFromConfig);
if (material == null) {
toolStats.logger.warning("Material " + materialFromConfig + " is not a valid Minecraft material.");
return null;
}
ItemStack token = new ItemStack(material);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data." + tokenType + ".title");
List<Component> lore = toolStats.configTools.getTokenLore(tokenType);
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the custom model data
if (tokenConfig.getBoolean("custom-model-data.enabled")) {
String type = tokenConfig.getString("custom-model-data.type");
Object value = tokenConfig.get("custom-model-data.value");
if (type == null || value == null) {
toolStats.logger.info("Could not find custom model data for token " + tokenType);
toolStats.logger.info("Type: " + type);
toolStats.logger.info("Value: " + value);
return null;
}
CustomModelData data = setData(type, value);
if (data != null) {
token.setData(DataComponentTypes.CUSTOM_MODEL_DATA, data);
} else {
return null;
}
}
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, tokenType);
token.setItemMeta(tokenMeta);
return token;
}
private CustomModelData setData(String type, Object data) {
switch (type.toLowerCase(Locale.ROOT)) {
case "float": {
Float f;
if (data instanceof Float) {
f = (Float) data;
} else {
toolStats.logger.info(type + " is not a valid float!");
return null;
}
return CustomModelData.customModelData().addFloat(f).build();
}
case "string": {
String s;
if (data instanceof String) {
s = (String) data;
} else {
toolStats.logger.info(type + " is not a valid string!");
return null;
}
return CustomModelData.customModelData().addString(s).build();
}
default: {
toolStats.logger.info(type + " is not a valid data type!");
return null;
}
}
}
}

View File

@@ -1,253 +0,0 @@
/*
* This file is part of ToolStats.
*
* ToolStats is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ToolStats is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ToolStats. If not, see <https://www.gnu.org/licenses/>.
*/
package lol.hyper.toolstats.tools.config;
import lol.hyper.toolstats.ToolStats;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import java.util.List;
public class TokenItems {
private final ToolStats toolStats;
public TokenItems(ToolStats toolStats) {
this.toolStats = toolStats;
}
public ItemStack playerKills() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.player-kills.title");
List<Component> lore = toolStats.configTools.getTokenLore("player-kills");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "player-kills");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack mobKills() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.mob-kills.title");
List<Component> lore = toolStats.configTools.getTokenLore("mob-kills");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "mob-kills");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack blocksMined() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.blocks-mined.title");
List<Component> lore = toolStats.configTools.getTokenLore("blocks-mined");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "blocks-mined");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack cropsMined() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.crops-mined.title");
List<Component> lore = toolStats.configTools.getTokenLore("crops-mined");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "crops-mined");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack fishCaught() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.fish-caught.title");
List<Component> lore = toolStats.configTools.getTokenLore("fight-caught");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "fish-caught");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack sheepSheared() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.sheep-sheared.title");
List<Component> lore = toolStats.configTools.getTokenLore("sheep-sheared");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "sheep-sheared");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack damageTaken() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.damage-taken.title");
List<Component> lore = toolStats.configTools.getTokenLore("damage-taken");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "damage-taken");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack damageDone() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.damage-done.title");
List<Component> lore = toolStats.configTools.getTokenLore("damage-done");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "damage-done");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack arrowsShot() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.arrows-shot.title");
List<Component> lore = toolStats.configTools.getTokenLore("arrows-shot");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "arrows-shot");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack flightTime() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.flight-time.title");
List<Component> lore = toolStats.configTools.getTokenLore("flight-time");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "flight-time");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack resetToken() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.reset.title");
List<Component> lore = toolStats.configTools.getTokenLore("reset");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "reset");
token.setItemMeta(tokenMeta);
return token;
}
public ItemStack removeToken() {
// set up the item
ItemStack token = new ItemStack(Material.PAPER);
ItemMeta tokenMeta = token.getItemMeta();
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
// set the title and lore
Component title = toolStats.configTools.format("tokens.data.remove.title");
List<Component> lore = toolStats.configTools.getTokenLore("remove");
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, "remove");
token.setItemMeta(tokenMeta);
return token;
}
}

View File

@@ -9,61 +9,109 @@ tokens:
lore:
- "&8Combine with a melee or ranged weapon in an anvil to track player kills."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
mob-kills:
title: "&7ToolStats: &8Mob Kills Token"
lore:
- "&8Combine with a melee or ranged weapon in an anvil to track mob kills."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
blocks-mined:
title: "&7ToolStats: &8Blocks Mined Token"
lore:
- "&8Combine with a pickaxe, axe, shovel, or shears in an anvil to track blocks mined."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
crops-mined:
title: "&7ToolStats: &8Crops Mined Token"
lore:
- "&8Combine with a hoe in an anvil to track crops broken."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
fish-caught:
title: "&7ToolStats: &8Fish Caught Token"
lore:
- "&8Combine with a fishing rod in an anvil to track fish caught."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
sheep-sheared:
title: "&7ToolStats: &8Sheep Sheared Token"
lore:
- "&8Combine with shears in an anvil to track sheep sheared."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
damage-taken:
title: "&7ToolStats: &8Damage Taken Token"
lore:
- "&8Combine with an armor piece in an anvil to track damage taken."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
damage-done:
title: "&7ToolStats: &8Damage Done Token"
lore:
- "&8Combine with a melee or ranged weapon in an anvil to track damage done."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
arrows-shot:
title: "&7ToolStats: &8Arrows Shot Token"
lore:
- "&8Combine with a bow or crossbow in an anvil to track arrows shot."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
flight-time:
title: "&7ToolStats: &8Flight Time Token"
lore:
- "&8Combine with an elytra in an anvil to track flight time."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
reset:
title: "&7ToolStats: &8Reset Token"
lore:
- "&8Combine in an anvil with to reset ALL stats for this item. Tokens on this item stay."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
remove:
title: "&7ToolStats: &8Remove Token"
lore:
- "&8Combine in an anvil with to REMOVE ALL stats and tokens for this item."
levels: 1
custom-model-data:
enabled: false
type: float
value: 1001
enabled:
# Will show "Crafted by <player>"