mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2026-01-27 07:55:59 +00:00
move keys to own class
this took forever
This commit is contained in:
@@ -28,119 +28,18 @@ import lol.hyper.toolstats.tools.config.ConfigTools;
|
|||||||
import lol.hyper.toolstats.tools.config.ConfigUpdater;
|
import lol.hyper.toolstats.tools.config.ConfigUpdater;
|
||||||
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
|
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.inventory.ShapedRecipe;
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public final class ToolStats extends JavaPlugin {
|
public final class ToolStats extends JavaPlugin {
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores who created an item.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey itemOwner = new NamespacedKey(this, "owner");
|
|
||||||
/**
|
|
||||||
* Stores when the item was created.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey timeCreated = new NamespacedKey(this, "time-created");
|
|
||||||
/**
|
|
||||||
* Stores how many player kills.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey playerKills = new NamespacedKey(this, "player-kills");
|
|
||||||
/**
|
|
||||||
* Stores how many mob kills.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey mobKills = new NamespacedKey(this, "mob-kills");
|
|
||||||
/**
|
|
||||||
* Stores how many blocks were mined.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey blocksMined = new NamespacedKey(this, "generic-mined");
|
|
||||||
/**
|
|
||||||
* Stores how many crops were harvested.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey cropsHarvested = new NamespacedKey(this, "crops-mined");
|
|
||||||
/**
|
|
||||||
* Stores how many fish were caught.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey fishCaught = new NamespacedKey(this, "fish-caught");
|
|
||||||
/**
|
|
||||||
* Stores how many sheep were sheared.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey sheepSheared = new NamespacedKey(this, "sheared");
|
|
||||||
/**
|
|
||||||
* Stores how much damage an armor piece has taken.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey armorDamage = new NamespacedKey(this, "damage-taken");
|
|
||||||
/**
|
|
||||||
* Stores how much damage a weapon has done.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey damageDone = new NamespacedKey(this, "damage-done");
|
|
||||||
/**
|
|
||||||
* Key for tracking new elytras that spawn.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey newElytra = new NamespacedKey(this, "new");
|
|
||||||
/**
|
|
||||||
* Key for item has.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey hash = new NamespacedKey(this, "hash");
|
|
||||||
/**
|
|
||||||
* Key for arrows shot.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey arrowsShot = new NamespacedKey(this, "arrows-shot");
|
|
||||||
/**
|
|
||||||
* Key for arrows shot.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey droppedBy = new NamespacedKey(this, "dropped-by");
|
|
||||||
/**
|
|
||||||
* Key for tracking flight time.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey flightTime = new NamespacedKey(this, "flightTime");
|
|
||||||
/**
|
|
||||||
* Key for token type. This is for the token itself.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey tokenType = new NamespacedKey(this, "token-type");
|
|
||||||
/**
|
|
||||||
* Key for applied token. This is what goes onto the tool/armor to record the type.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey tokenApplied = new NamespacedKey(this, "token-applied");
|
|
||||||
/**
|
|
||||||
* Key for withers killed.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey witherKills = new NamespacedKey(this, "wither-kills");
|
|
||||||
/**
|
|
||||||
* Key for withers killed.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey enderDragonKills = new NamespacedKey(this, "enderdragon-kills");
|
|
||||||
/**
|
|
||||||
* Key for critical strikes.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey criticalStrikes = new NamespacedKey(this, "critical-strikes");
|
|
||||||
/**
|
|
||||||
* Key for trident throws.
|
|
||||||
*/
|
|
||||||
public final NamespacedKey tridentThrows = new NamespacedKey(this, "trident-throws");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores how an item was created.
|
|
||||||
* 0 = crafted.
|
|
||||||
* 1 = dropped.
|
|
||||||
* 2 = looted.
|
|
||||||
* 3 = traded.
|
|
||||||
* 4 = founded (for elytras).
|
|
||||||
* 5 = fished.
|
|
||||||
* 6 = spawned in (creative).
|
|
||||||
*/
|
|
||||||
public final NamespacedKey originType = new NamespacedKey(this, "origin");
|
|
||||||
|
|
||||||
public final int CONFIG_VERSION = 14;
|
public final int CONFIG_VERSION = 14;
|
||||||
public final ComponentLogger logger = this.getComponentLogger();
|
public final ComponentLogger logger = this.getComponentLogger();
|
||||||
public final File configFile = new File(this.getDataFolder(), "config.yml");
|
public final File configFile = new File(this.getDataFolder(), "config.yml");
|
||||||
public boolean tokens = false;
|
public boolean tokens = false;
|
||||||
public final Set<NamespacedKey> tokenKeys = new HashSet<>();
|
|
||||||
|
|
||||||
public BlockBreak blockBreak;
|
public BlockBreak blockBreak;
|
||||||
public ChunkPopulate chunkPopulate;
|
public ChunkPopulate chunkPopulate;
|
||||||
@@ -172,6 +71,7 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
public HyperLib hyperLib;
|
public HyperLib hyperLib;
|
||||||
public TextUtils textUtils;
|
public TextUtils textUtils;
|
||||||
public ProjectileShoot projectileShoot;
|
public ProjectileShoot projectileShoot;
|
||||||
|
public ToolStatsKeys toolStatsKeys;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@@ -190,6 +90,8 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
configTools = new ConfigTools(this);
|
configTools = new ConfigTools(this);
|
||||||
|
toolStatsKeys = new ToolStatsKeys(this);
|
||||||
|
toolStatsKeys.make();
|
||||||
tokenData = new TokenData(this);
|
tokenData = new TokenData(this);
|
||||||
tokenData.setup();
|
tokenData.setup();
|
||||||
for (ShapedRecipe recipe : tokenData.getRecipes()) {
|
for (ShapedRecipe recipe : tokenData.getRecipes()) {
|
||||||
@@ -223,21 +125,6 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
blockDispenseEvent = new BlockDispenseEvent(this);
|
blockDispenseEvent = new BlockDispenseEvent(this);
|
||||||
projectileShoot = new ProjectileShoot(this);
|
projectileShoot = new ProjectileShoot(this);
|
||||||
|
|
||||||
// save which stat can be used by a reset token
|
|
||||||
tokenKeys.add(blocksMined);
|
|
||||||
tokenKeys.add(playerKills);
|
|
||||||
tokenKeys.add(mobKills);
|
|
||||||
tokenKeys.add(cropsHarvested);
|
|
||||||
tokenKeys.add(sheepSheared);
|
|
||||||
tokenKeys.add(fishCaught);
|
|
||||||
tokenKeys.add(flightTime);
|
|
||||||
tokenKeys.add(arrowsShot);
|
|
||||||
tokenKeys.add(armorDamage);
|
|
||||||
tokenKeys.add(witherKills);
|
|
||||||
tokenKeys.add(enderDragonKills);
|
|
||||||
tokenKeys.add(criticalStrikes);
|
|
||||||
tokenKeys.add(tridentThrows);
|
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(blockBreak, this);
|
Bukkit.getServer().getPluginManager().registerEvents(blockBreak, this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(chunkPopulate, this);
|
Bukkit.getServer().getPluginManager().registerEvents(chunkPopulate, this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(craftItem, this);
|
Bukkit.getServer().getPluginManager().registerEvents(craftItem, this);
|
||||||
|
|||||||
@@ -254,8 +254,8 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
|
|
||||||
// set how the item was obtained
|
// set how the item was obtained
|
||||||
Integer origin = -1;
|
Integer origin = -1;
|
||||||
if (container.has(toolStats.originType, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER)) {
|
||||||
origin = container.get(toolStats.originType, PersistentDataType.INTEGER);
|
origin = container.get(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set to -1 if it's invalid
|
// set to -1 if it's invalid
|
||||||
@@ -263,10 +263,10 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
origin = -1;
|
origin = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container.has(toolStats.droppedBy, PersistentDataType.STRING)) {
|
if (container.has(toolStats.toolStatsKeys.getDroppedBy(), PersistentDataType.STRING)) {
|
||||||
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
||||||
if (container.has(toolStats.droppedBy)) {
|
if (container.has(toolStats.toolStatsKeys.getDroppedBy())) {
|
||||||
String droppedBy = container.get(toolStats.droppedBy, PersistentDataType.STRING);
|
String droppedBy = container.get(toolStats.toolStatsKeys.getDroppedBy(), PersistentDataType.STRING);
|
||||||
lore.add(toolStats.configTools.formatLore("dropped-by", "{name}", droppedBy));
|
lore.add(toolStats.configTools.formatLore("dropped-by", "{name}", droppedBy));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("Unable to set 'dropped-by', as this item has no record of it."));
|
player.sendMessage(Component.text("Unable to set 'dropped-by', as this item has no record of it."));
|
||||||
@@ -274,8 +274,8 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container.has(toolStats.itemOwner, new UUIDDataType())) {
|
if (container.has(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType())) {
|
||||||
UUID owner = container.get(toolStats.itemOwner, new UUIDDataType());
|
UUID owner = container.get(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType());
|
||||||
String ownerName = null;
|
String ownerName = null;
|
||||||
// if we can read the current owner
|
// if we can read the current owner
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
@@ -288,7 +288,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
if (ownerName == null) {
|
if (ownerName == null) {
|
||||||
player.sendMessage(Component.text("The owner of this item is null. Setting to " + player.getName() + ".", NamedTextColor.RED));
|
player.sendMessage(Component.text("The owner of this item is null. Setting to " + player.getName() + ".", NamedTextColor.RED));
|
||||||
ownerName = player.getName();
|
ownerName = player.getName();
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), player.getUniqueId());
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the ownership lore
|
// add the ownership lore
|
||||||
@@ -298,8 +298,8 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG)) {
|
if (container.has(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG)) {
|
||||||
Long time = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
Long time = container.get(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG);
|
||||||
if (time != null) {
|
if (time != null) {
|
||||||
// add the creation time lore
|
// add the creation time lore
|
||||||
Component creationTimeLore = toolStats.itemLore.formatCreationTime(time, origin, original);
|
Component creationTimeLore = toolStats.itemLore.formatCreationTime(time, origin, original);
|
||||||
@@ -309,8 +309,8 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
||||||
if (container.has(toolStats.flightTime, PersistentDataType.LONG)) {
|
if (container.has(toolStats.toolStatsKeys.getFlightTime(), PersistentDataType.LONG)) {
|
||||||
Long flightTime = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
Long flightTime = container.get(toolStats.toolStatsKeys.getFlightTime(), PersistentDataType.LONG);
|
||||||
if (flightTime != null) {
|
if (flightTime != null) {
|
||||||
Map<String, String> flightTimeFormatted = toolStats.numberFormat.formatTime(flightTime);
|
Map<String, String> flightTimeFormatted = toolStats.numberFormat.formatTime(flightTime);
|
||||||
Component line = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", flightTimeFormatted);
|
Component line = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", flightTimeFormatted);
|
||||||
@@ -319,16 +319,16 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "player-kills")) {
|
if (toolStats.configTools.checkConfig(original.getType(), "player-kills")) {
|
||||||
if (container.has(toolStats.playerKills, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getPlayerKills(), PersistentDataType.INTEGER)) {
|
||||||
Integer kills = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
Integer kills = container.get(toolStats.toolStatsKeys.getPlayerKills(), PersistentDataType.INTEGER);
|
||||||
if (kills != null) {
|
if (kills != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("kills.player", "{kills}", toolStats.numberFormat.formatInt(kills)));
|
lore.add(toolStats.configTools.formatLore("kills.player", "{kills}", toolStats.numberFormat.formatInt(kills)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "mob-kills")) {
|
if (toolStats.configTools.checkConfig(original.getType(), "mob-kills")) {
|
||||||
if (container.has(toolStats.mobKills, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getMobKills(), PersistentDataType.INTEGER)) {
|
||||||
Integer kills = container.get(toolStats.mobKills, PersistentDataType.INTEGER);
|
Integer kills = container.get(toolStats.toolStatsKeys.getMobKills(), PersistentDataType.INTEGER);
|
||||||
if (kills != null) {
|
if (kills != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("kills.mob", "{kills}", toolStats.numberFormat.formatInt(kills)));
|
lore.add(toolStats.configTools.formatLore("kills.mob", "{kills}", toolStats.numberFormat.formatInt(kills)));
|
||||||
}
|
}
|
||||||
@@ -336,87 +336,87 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
}
|
}
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "blocks-mined")) {
|
if (toolStats.configTools.checkConfig(original.getType(), "blocks-mined")) {
|
||||||
if (original.getType().toString().toLowerCase(Locale.ROOT).contains("hoe")) {
|
if (original.getType().toString().toLowerCase(Locale.ROOT).contains("hoe")) {
|
||||||
if (container.has(toolStats.cropsHarvested, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getCropsHarvested(), PersistentDataType.INTEGER)) {
|
||||||
Integer crops = container.get(toolStats.cropsHarvested, PersistentDataType.INTEGER);
|
Integer crops = container.get(toolStats.toolStatsKeys.getCropsHarvested(), PersistentDataType.INTEGER);
|
||||||
if (crops != null) {
|
if (crops != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("crops-harvested", "{crops}", toolStats.numberFormat.formatInt(crops)));
|
lore.add(toolStats.configTools.formatLore("crops-harvested", "{crops}", toolStats.numberFormat.formatInt(crops)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.blocksMined, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getBlocksMined(), PersistentDataType.INTEGER)) {
|
||||||
Integer blocksMined = container.get(toolStats.blocksMined, PersistentDataType.INTEGER);
|
Integer blocksMined = container.get(toolStats.toolStatsKeys.getBlocksMined(), PersistentDataType.INTEGER);
|
||||||
if (blocksMined != null) {
|
if (blocksMined != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("blocks-mined", "{blocks}", toolStats.numberFormat.formatInt(blocksMined)));
|
lore.add(toolStats.configTools.formatLore("blocks-mined", "{blocks}", toolStats.numberFormat.formatInt(blocksMined)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.config.getBoolean("enabled.fish-caught")) {
|
if (toolStats.config.getBoolean("enabled.fish-caught")) {
|
||||||
if (container.has(toolStats.fishCaught, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getFishCaught(), PersistentDataType.INTEGER)) {
|
||||||
Integer fish = container.get(toolStats.fishCaught, PersistentDataType.INTEGER);
|
Integer fish = container.get(toolStats.toolStatsKeys.getFishCaught(), PersistentDataType.INTEGER);
|
||||||
if (fish != null) {
|
if (fish != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("fished.fish-caught", "{fish}", toolStats.numberFormat.formatInt(fish)));
|
lore.add(toolStats.configTools.formatLore("fished.fish-caught", "{fish}", toolStats.numberFormat.formatInt(fish)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.config.getBoolean("enabled.sheep-sheared")) {
|
if (toolStats.config.getBoolean("enabled.sheep-sheared")) {
|
||||||
if (container.has(toolStats.sheepSheared, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getSheepSheared(), PersistentDataType.INTEGER)) {
|
||||||
Integer sheep = container.get(toolStats.sheepSheared, PersistentDataType.INTEGER);
|
Integer sheep = container.get(toolStats.toolStatsKeys.getSheepSheared(), PersistentDataType.INTEGER);
|
||||||
if (sheep != null) {
|
if (sheep != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("sheep-sheared", "{sheep}", toolStats.numberFormat.formatInt(sheep)));
|
lore.add(toolStats.configTools.formatLore("sheep-sheared", "{sheep}", toolStats.numberFormat.formatInt(sheep)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.config.getBoolean("enabled.armor-damage")) {
|
if (toolStats.config.getBoolean("enabled.armor-damage")) {
|
||||||
if (container.has(toolStats.armorDamage, PersistentDataType.DOUBLE)) {
|
if (container.has(toolStats.toolStatsKeys.getArmorDamage(), PersistentDataType.DOUBLE)) {
|
||||||
Double damage = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
Double damage = container.get(toolStats.toolStatsKeys.getArmorDamage(), PersistentDataType.DOUBLE);
|
||||||
if (damage != null) {
|
if (damage != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("damage-taken", "{damage}", toolStats.numberFormat.formatDouble(damage)));
|
lore.add(toolStats.configTools.formatLore("damage-taken", "{damage}", toolStats.numberFormat.formatDouble(damage)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "damage-done")) {
|
if (toolStats.configTools.checkConfig(original.getType(), "damage-done")) {
|
||||||
if (container.has(toolStats.damageDone, PersistentDataType.DOUBLE)) {
|
if (container.has(toolStats.toolStatsKeys.getDamageDone(), PersistentDataType.DOUBLE)) {
|
||||||
Double damage = container.get(toolStats.damageDone, PersistentDataType.DOUBLE);
|
Double damage = container.get(toolStats.toolStatsKeys.getDamageDone(), PersistentDataType.DOUBLE);
|
||||||
if (damage != null) {
|
if (damage != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("damage-done", "{damage}", toolStats.numberFormat.formatDouble(damage)));
|
lore.add(toolStats.configTools.formatLore("damage-done", "{damage}", toolStats.numberFormat.formatDouble(damage)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.config.getBoolean("enabled.arrows-shot")) {
|
if (toolStats.config.getBoolean("enabled.arrows-shot")) {
|
||||||
if (container.has(toolStats.arrowsShot, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getArrowsShot(), PersistentDataType.INTEGER)) {
|
||||||
Integer arrows = container.get(toolStats.arrowsShot, PersistentDataType.INTEGER);
|
Integer arrows = container.get(toolStats.toolStatsKeys.getArrowsShot(), PersistentDataType.INTEGER);
|
||||||
if (arrows != null) {
|
if (arrows != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("arrows-shot", "{arrows}", toolStats.numberFormat.formatInt(arrows)));
|
lore.add(toolStats.configTools.formatLore("arrows-shot", "{arrows}", toolStats.numberFormat.formatInt(arrows)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.config.getBoolean("enabled.bosses-killed.wither")) {
|
if (toolStats.config.getBoolean("enabled.bosses-killed.wither")) {
|
||||||
if (container.has(toolStats.witherKills, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getWitherKills(), PersistentDataType.INTEGER)) {
|
||||||
Integer kills = container.get(toolStats.witherKills, PersistentDataType.INTEGER);
|
Integer kills = container.get(toolStats.toolStatsKeys.getWitherKills(), PersistentDataType.INTEGER);
|
||||||
if (kills != null) {
|
if (kills != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("bosses-killed.wither", "{kills}", toolStats.numberFormat.formatInt(kills)));
|
lore.add(toolStats.configTools.formatLore("bosses-killed.wither", "{kills}", toolStats.numberFormat.formatInt(kills)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.config.getBoolean("enabled.bosses-killed.enderdragon")) {
|
if (toolStats.config.getBoolean("enabled.bosses-killed.enderdragon")) {
|
||||||
if (container.has(toolStats.enderDragonKills, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getEnderDragonKills(), PersistentDataType.INTEGER)) {
|
||||||
Integer kills = container.get(toolStats.enderDragonKills, PersistentDataType.INTEGER);
|
Integer kills = container.get(toolStats.toolStatsKeys.getEnderDragonKills(), PersistentDataType.INTEGER);
|
||||||
if (kills != null) {
|
if (kills != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("bosses-killed.enderdragon", "{kills}", toolStats.numberFormat.formatInt(kills)));
|
lore.add(toolStats.configTools.formatLore("bosses-killed.enderdragon", "{kills}", toolStats.numberFormat.formatInt(kills)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.config.getBoolean("enabled.critical-strikes")) {
|
if (toolStats.config.getBoolean("enabled.critical-strikes")) {
|
||||||
if (container.has(toolStats.criticalStrikes, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getCriticalStrikes(), PersistentDataType.INTEGER)) {
|
||||||
Integer strikes = container.get(toolStats.criticalStrikes, PersistentDataType.INTEGER);
|
Integer strikes = container.get(toolStats.toolStatsKeys.getCriticalStrikes(), PersistentDataType.INTEGER);
|
||||||
if (strikes != null) {
|
if (strikes != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("critical-strikes", "{strikes}", toolStats.numberFormat.formatInt(strikes)));
|
lore.add(toolStats.configTools.formatLore("critical-strikes", "{strikes}", toolStats.numberFormat.formatInt(strikes)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toolStats.config.getBoolean("enabled.trident-throws")) {
|
if (toolStats.config.getBoolean("enabled.trident-throws")) {
|
||||||
if (container.has(toolStats.tridentThrows, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getTridentThrows(), PersistentDataType.INTEGER)) {
|
||||||
Integer tridentThrows = container.get(toolStats.tridentThrows, PersistentDataType.INTEGER);
|
Integer tridentThrows = container.get(toolStats.toolStatsKeys.getTridentThrows(), PersistentDataType.INTEGER);
|
||||||
if (tridentThrows != null) {
|
if (tridentThrows != null) {
|
||||||
lore.add(toolStats.configTools.formatLore("trident-throws", "{times}", toolStats.numberFormat.formatInt(tridentThrows)));
|
lore.add(toolStats.configTools.formatLore("trident-throws", "{times}", toolStats.numberFormat.formatInt(tridentThrows)));
|
||||||
}
|
}
|
||||||
@@ -461,7 +461,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.cropsHarvested)) {
|
if (container.has(toolStats.toolStatsKeys.getCropsHarvested())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -473,7 +473,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.cropsHarvested, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getCropsHarvested(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -490,7 +490,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.blocksMined)) {
|
if (container.has(toolStats.toolStatsKeys.getBlocksMined())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -502,7 +502,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.blocksMined, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getBlocksMined(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -519,7 +519,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.armorDamage)) {
|
if (container.has(toolStats.toolStatsKeys.getArmorDamage())) {
|
||||||
double value;
|
double value;
|
||||||
try {
|
try {
|
||||||
value = Double.parseDouble((String) userValue);
|
value = Double.parseDouble((String) userValue);
|
||||||
@@ -531,7 +531,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Double statValue = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
Double statValue = container.get(toolStats.toolStatsKeys.getArmorDamage(), PersistentDataType.DOUBLE);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -548,7 +548,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.damageDone)) {
|
if (container.has(toolStats.toolStatsKeys.getDamageDone())) {
|
||||||
double value;
|
double value;
|
||||||
try {
|
try {
|
||||||
value = Double.parseDouble((String) userValue);
|
value = Double.parseDouble((String) userValue);
|
||||||
@@ -560,7 +560,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Double statValue = container.get(toolStats.damageDone, PersistentDataType.DOUBLE);
|
Double statValue = container.get(toolStats.toolStatsKeys.getDamageDone(), PersistentDataType.DOUBLE);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -577,7 +577,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.mobKills)) {
|
if (container.has(toolStats.toolStatsKeys.getMobKills())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -589,7 +589,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.mobKills, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getMobKills(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -606,7 +606,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.playerKills)) {
|
if (container.has(toolStats.toolStatsKeys.getPlayerKills())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -618,7 +618,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getPlayerKills(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -635,7 +635,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.arrowsShot)) {
|
if (container.has(toolStats.toolStatsKeys.getArrowsShot())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -647,7 +647,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.arrowsShot, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getArrowsShot(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -664,7 +664,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.sheepSheared)) {
|
if (container.has(toolStats.toolStatsKeys.getSheepSheared())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -676,7 +676,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.sheepSheared, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getSheepSheared(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -693,7 +693,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.flightTime)) {
|
if (container.has(toolStats.toolStatsKeys.getFlightTime())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -705,7 +705,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Long statValue = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
Long statValue = container.get(toolStats.toolStatsKeys.getFlightTime(), PersistentDataType.LONG);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -722,7 +722,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.fishCaught)) {
|
if (container.has(toolStats.toolStatsKeys.getFishCaught())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -734,7 +734,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.fishCaught, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getFishCaught(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -751,7 +751,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.witherKills)) {
|
if (container.has(toolStats.toolStatsKeys.getWitherKills())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -763,7 +763,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.witherKills, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getWitherKills(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -780,7 +780,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.enderDragonKills)) {
|
if (container.has(toolStats.toolStatsKeys.getEnderDragonKills())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -792,7 +792,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.enderDragonKills, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getEnderDragonKills(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -809,7 +809,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.criticalStrikes)) {
|
if (container.has(toolStats.toolStatsKeys.getCriticalStrikes())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -821,7 +821,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.criticalStrikes, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getCriticalStrikes(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -838,7 +838,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.tridentThrows)) {
|
if (container.has(toolStats.toolStatsKeys.getTridentThrows())) {
|
||||||
int value;
|
int value;
|
||||||
try {
|
try {
|
||||||
value = Integer.parseInt((String) userValue);
|
value = Integer.parseInt((String) userValue);
|
||||||
@@ -850,7 +850,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Number must be positive.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer statValue = container.get(toolStats.tridentThrows, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getTridentThrows(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
@@ -888,23 +888,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
PersistentDataContainer container = editedItemMeta.getPersistentDataContainer();
|
PersistentDataContainer container = editedItemMeta.getPersistentDataContainer();
|
||||||
switch (stat) {
|
switch (stat) {
|
||||||
case "crops-harvested": {
|
case "crops-harvested": {
|
||||||
if (container.has(toolStats.cropsHarvested)) {
|
if (container.has(toolStats.toolStatsKeys.getCropsHarvested())) {
|
||||||
Integer statValue = container.get(toolStats.cropsHarvested, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getCropsHarvested(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.cropsHarvested);
|
container.remove(toolStats.toolStatsKeys.getCropsHarvested());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "crops-mined");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "crops-mined");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("crops-harvested", "{crops}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("crops-harvested", "{crops}", toolStats.numberFormat.formatInt(statValue));
|
||||||
@@ -916,23 +916,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "blocks-mined": {
|
case "blocks-mined": {
|
||||||
if (container.has(toolStats.blocksMined)) {
|
if (container.has(toolStats.toolStatsKeys.getBlocksMined())) {
|
||||||
Integer statValue = container.get(toolStats.blocksMined, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getBlocksMined(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.blocksMined);
|
container.remove(toolStats.toolStatsKeys.getBlocksMined());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "blocks-mined");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "blocks-mined");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("blocks-mined", "{blocks}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("blocks-mined", "{blocks}", toolStats.numberFormat.formatInt(statValue));
|
||||||
@@ -944,23 +944,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "damage-taken": {
|
case "damage-taken": {
|
||||||
if (container.has(toolStats.armorDamage)) {
|
if (container.has(toolStats.toolStatsKeys.getArmorDamage())) {
|
||||||
Double statValue = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
Double statValue = container.get(toolStats.toolStatsKeys.getArmorDamage(), PersistentDataType.DOUBLE);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.armorDamage);
|
container.remove(toolStats.toolStatsKeys.getArmorDamage());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "damage-taken");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "damage-taken");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("damage-taken", "{damage}", toolStats.numberFormat.formatDouble(statValue));
|
Component oldLine = toolStats.configTools.formatLore("damage-taken", "{damage}", toolStats.numberFormat.formatDouble(statValue));
|
||||||
@@ -972,23 +972,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "damage-done": {
|
case "damage-done": {
|
||||||
if (container.has(toolStats.damageDone)) {
|
if (container.has(toolStats.toolStatsKeys.getDamageDone())) {
|
||||||
Double statValue = container.get(toolStats.damageDone, PersistentDataType.DOUBLE);
|
Double statValue = container.get(toolStats.toolStatsKeys.getDamageDone(), PersistentDataType.DOUBLE);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.damageDone);
|
container.remove(toolStats.toolStatsKeys.getDamageDone());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "damage-done");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "damage-done");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("damage-done", "{damage}", toolStats.numberFormat.formatDouble(statValue));
|
Component oldLine = toolStats.configTools.formatLore("damage-done", "{damage}", toolStats.numberFormat.formatDouble(statValue));
|
||||||
@@ -1000,23 +1000,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "mob-kills": {
|
case "mob-kills": {
|
||||||
if (container.has(toolStats.mobKills)) {
|
if (container.has(toolStats.toolStatsKeys.getMobKills())) {
|
||||||
Integer statValue = container.get(toolStats.mobKills, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getMobKills(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.mobKills);
|
container.remove(toolStats.toolStatsKeys.getMobKills());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "mob-kills");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "mob-kills");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("kills.mob", "{kills}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("kills.mob", "{kills}", toolStats.numberFormat.formatInt(statValue));
|
||||||
@@ -1028,23 +1028,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "player-kills": {
|
case "player-kills": {
|
||||||
if (container.has(toolStats.playerKills)) {
|
if (container.has(toolStats.toolStatsKeys.getPlayerKills())) {
|
||||||
Integer statValue = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getPlayerKills(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.playerKills);
|
container.remove(toolStats.toolStatsKeys.getPlayerKills());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "player-kills");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "player-kills");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("kills.player", "{kills}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("kills.player", "{kills}", toolStats.numberFormat.formatInt(statValue));
|
||||||
@@ -1056,23 +1056,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "sheep-sheared": {
|
case "sheep-sheared": {
|
||||||
if (container.has(toolStats.sheepSheared)) {
|
if (container.has(toolStats.toolStatsKeys.getSheepSheared())) {
|
||||||
Integer statValue = container.get(toolStats.sheepSheared, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getSheepSheared(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.sheepSheared);
|
container.remove(toolStats.toolStatsKeys.getSheepSheared());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "sheep-sheared");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "sheep-sheared");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("sheep-sheared", "{sheep}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("sheep-sheared", "{sheep}", toolStats.numberFormat.formatInt(statValue));
|
||||||
@@ -1084,23 +1084,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "flight-time": {
|
case "flight-time": {
|
||||||
if (container.has(toolStats.flightTime)) {
|
if (container.has(toolStats.toolStatsKeys.getFlightTime())) {
|
||||||
Long statValue = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
Long statValue = container.get(toolStats.toolStatsKeys.getFlightTime(), PersistentDataType.LONG);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.flightTime);
|
container.remove(toolStats.toolStatsKeys.getFlightTime());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "flight-time");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "flight-time");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> timeFormatted = toolStats.numberFormat.formatTime(statValue);
|
Map<String, String> timeFormatted = toolStats.numberFormat.formatTime(statValue);
|
||||||
@@ -1113,23 +1113,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "fight-caught": {
|
case "fight-caught": {
|
||||||
if (container.has(toolStats.fishCaught)) {
|
if (container.has(toolStats.toolStatsKeys.getFishCaught())) {
|
||||||
Integer statValue = container.get(toolStats.fishCaught, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getFishCaught(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.fishCaught);
|
container.remove(toolStats.toolStatsKeys.getFishCaught());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "fight-caught");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "fight-caught");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", toolStats.numberFormat.formatInt(statValue));
|
||||||
@@ -1141,23 +1141,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "wither-kills": {
|
case "wither-kills": {
|
||||||
if (container.has(toolStats.witherKills)) {
|
if (container.has(toolStats.toolStatsKeys.getWitherKills())) {
|
||||||
Integer statValue = container.get(toolStats.witherKills, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getWitherKills(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.witherKills);
|
container.remove(toolStats.toolStatsKeys.getWitherKills());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "wither-kills");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "wither-kills");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("bosses-killed.wither", "{kills}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("bosses-killed.wither", "{kills}", toolStats.numberFormat.formatInt(statValue));
|
||||||
@@ -1169,23 +1169,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "enderdragon-kills": {
|
case "enderdragon-kills": {
|
||||||
if (container.has(toolStats.enderDragonKills)) {
|
if (container.has(toolStats.toolStatsKeys.getEnderDragonKills())) {
|
||||||
Integer statValue = container.get(toolStats.enderDragonKills, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getEnderDragonKills(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.enderDragonKills);
|
container.remove(toolStats.toolStatsKeys.getEnderDragonKills());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "enderdragon-kills");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "enderdragon-kills");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("bosses-killed.enderdragon", "{kills}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("bosses-killed.enderdragon", "{kills}", toolStats.numberFormat.formatInt(statValue));
|
||||||
@@ -1197,23 +1197,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "critical-strikes": {
|
case "critical-strikes": {
|
||||||
if (container.has(toolStats.criticalStrikes)) {
|
if (container.has(toolStats.toolStatsKeys.getCriticalStrikes())) {
|
||||||
Integer statValue = container.get(toolStats.criticalStrikes, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getCriticalStrikes(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.criticalStrikes);
|
container.remove(toolStats.toolStatsKeys.getCriticalStrikes());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "critical-strikes");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "critical-strikes");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("critical-strikes", "{strikes}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("critical-strikes", "{strikes}", toolStats.numberFormat.formatInt(statValue));
|
||||||
@@ -1225,23 +1225,23 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "trident-throws": {
|
case "trident-throws": {
|
||||||
if (container.has(toolStats.tridentThrows)) {
|
if (container.has(toolStats.toolStatsKeys.getTridentThrows())) {
|
||||||
Integer statValue = container.get(toolStats.tridentThrows, PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getTridentThrows(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get stat from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("Unable to get tokens from item.", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.tridentThrows);
|
container.remove(toolStats.toolStatsKeys.getTridentThrows());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "trident-throws");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "trident-throws");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.tokenApplied);
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Component oldLine = toolStats.configTools.formatLore("trident-throws", "{times}", toolStats.numberFormat.formatInt(statValue));
|
Component oldLine = toolStats.configTools.formatLore("trident-throws", "{times}", toolStats.numberFormat.formatInt(statValue));
|
||||||
|
|||||||
@@ -65,12 +65,12 @@ public class AnvilEvent implements Listener {
|
|||||||
PersistentDataContainer secondSlotContainer = secondSlot.getItemMeta().getPersistentDataContainer();
|
PersistentDataContainer secondSlotContainer = secondSlot.getItemMeta().getPersistentDataContainer();
|
||||||
|
|
||||||
// make sure the 2nd item is one of ours
|
// make sure the 2nd item is one of ours
|
||||||
if (!secondSlotContainer.has(toolStats.tokenType, PersistentDataType.STRING)) {
|
if (!secondSlotContainer.has(toolStats.toolStatsKeys.getTokenType(), PersistentDataType.STRING)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the type from the token
|
// get the type from the token
|
||||||
String tokenType = secondSlotContainer.get(toolStats.tokenType, PersistentDataType.STRING);
|
String tokenType = secondSlotContainer.get(toolStats.toolStatsKeys.getTokenType(), PersistentDataType.STRING);
|
||||||
if (tokenType == null) {
|
if (tokenType == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -384,112 +384,112 @@ public class AnvilEvent implements Listener {
|
|||||||
ItemMeta meta = finalItem.getItemMeta();
|
ItemMeta meta = finalItem.getItemMeta();
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
if (container.has(toolStats.playerKills)) {
|
if (container.has(toolStats.toolStatsKeys.getPlayerKills())) {
|
||||||
Integer playerKills = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
Integer playerKills = container.get(toolStats.toolStatsKeys.getPlayerKills(), PersistentDataType.INTEGER);
|
||||||
if (playerKills == null) {
|
if (playerKills == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updatePlayerKills(finalItem, -playerKills);
|
meta = toolStats.itemLore.updatePlayerKills(finalItem, -playerKills);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.mobKills)) {
|
if (container.has(toolStats.toolStatsKeys.getMobKills())) {
|
||||||
Integer mobKills = container.get(toolStats.mobKills, PersistentDataType.INTEGER);
|
Integer mobKills = container.get(toolStats.toolStatsKeys.getMobKills(), PersistentDataType.INTEGER);
|
||||||
if (mobKills == null) {
|
if (mobKills == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateMobKills(finalItem, -mobKills);
|
meta = toolStats.itemLore.updateMobKills(finalItem, -mobKills);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.blocksMined)) {
|
if (container.has(toolStats.toolStatsKeys.getBlocksMined())) {
|
||||||
Integer blocksMined = container.get(toolStats.blocksMined, PersistentDataType.INTEGER);
|
Integer blocksMined = container.get(toolStats.toolStatsKeys.getBlocksMined(), PersistentDataType.INTEGER);
|
||||||
if (blocksMined == null) {
|
if (blocksMined == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateBlocksMined(finalItem, -blocksMined);
|
meta = toolStats.itemLore.updateBlocksMined(finalItem, -blocksMined);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.cropsHarvested)) {
|
if (container.has(toolStats.toolStatsKeys.getCropsHarvested())) {
|
||||||
Integer cropsHarvested = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
Integer cropsHarvested = container.get(toolStats.toolStatsKeys.getCropsHarvested(), PersistentDataType.INTEGER);
|
||||||
if (cropsHarvested == null) {
|
if (cropsHarvested == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateCropsMined(finalItem, -cropsHarvested);
|
meta = toolStats.itemLore.updateCropsMined(finalItem, -cropsHarvested);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.fishCaught)) {
|
if (container.has(toolStats.toolStatsKeys.getFishCaught())) {
|
||||||
Integer fishCaught = container.get(toolStats.fishCaught, PersistentDataType.INTEGER);
|
Integer fishCaught = container.get(toolStats.toolStatsKeys.getFishCaught(), PersistentDataType.INTEGER);
|
||||||
if (fishCaught == null) {
|
if (fishCaught == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateFishCaught(finalItem, -fishCaught);
|
meta = toolStats.itemLore.updateFishCaught(finalItem, -fishCaught);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.sheepSheared)) {
|
if (container.has(toolStats.toolStatsKeys.getSheepSheared())) {
|
||||||
Integer sheepSheared = container.get(toolStats.sheepSheared, PersistentDataType.INTEGER);
|
Integer sheepSheared = container.get(toolStats.toolStatsKeys.getSheepSheared(), PersistentDataType.INTEGER);
|
||||||
if (sheepSheared == null) {
|
if (sheepSheared == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateSheepSheared(finalItem, -sheepSheared);
|
meta = toolStats.itemLore.updateSheepSheared(finalItem, -sheepSheared);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.armorDamage)) {
|
if (container.has(toolStats.toolStatsKeys.getArmorDamage())) {
|
||||||
Double armorDamage = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
Double armorDamage = container.get(toolStats.toolStatsKeys.getArmorDamage(), PersistentDataType.DOUBLE);
|
||||||
if (armorDamage == null) {
|
if (armorDamage == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateArmorDamage(finalItem, -armorDamage, true);
|
meta = toolStats.itemLore.updateArmorDamage(finalItem, -armorDamage, true);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.damageDone)) {
|
if (container.has(toolStats.toolStatsKeys.getDamageDone())) {
|
||||||
Double damageDone = container.get(toolStats.damageDone, PersistentDataType.DOUBLE);
|
Double damageDone = container.get(toolStats.toolStatsKeys.getDamageDone(), PersistentDataType.DOUBLE);
|
||||||
if (damageDone == null) {
|
if (damageDone == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateArmorDamage(finalItem, -damageDone, true);
|
meta = toolStats.itemLore.updateArmorDamage(finalItem, -damageDone, true);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.arrowsShot)) {
|
if (container.has(toolStats.toolStatsKeys.getArrowsShot())) {
|
||||||
Integer arrowsShot = container.get(toolStats.arrowsShot, PersistentDataType.INTEGER);
|
Integer arrowsShot = container.get(toolStats.toolStatsKeys.getArrowsShot(), PersistentDataType.INTEGER);
|
||||||
if (arrowsShot == null) {
|
if (arrowsShot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateArrowsShot(finalItem, -arrowsShot);
|
meta = toolStats.itemLore.updateArrowsShot(finalItem, -arrowsShot);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.flightTime)) {
|
if (container.has(toolStats.toolStatsKeys.getFlightTime())) {
|
||||||
Long flightTime = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
Long flightTime = container.get(toolStats.toolStatsKeys.getFlightTime(), PersistentDataType.LONG);
|
||||||
if (flightTime == null) {
|
if (flightTime == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateFlightTime(finalItem, -flightTime);
|
meta = toolStats.itemLore.updateFlightTime(finalItem, -flightTime);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.witherKills)) {
|
if (container.has(toolStats.toolStatsKeys.getWitherKills())) {
|
||||||
Integer witherKills = container.get(toolStats.witherKills, PersistentDataType.INTEGER);
|
Integer witherKills = container.get(toolStats.toolStatsKeys.getWitherKills(), PersistentDataType.INTEGER);
|
||||||
if (witherKills == null) {
|
if (witherKills == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateBossesKilled(finalItem, -witherKills, "wither");
|
meta = toolStats.itemLore.updateBossesKilled(finalItem, -witherKills, "wither");
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.enderDragonKills)) {
|
if (container.has(toolStats.toolStatsKeys.getEnderDragonKills())) {
|
||||||
Integer enderDragonKills = container.get(toolStats.enderDragonKills, PersistentDataType.INTEGER);
|
Integer enderDragonKills = container.get(toolStats.toolStatsKeys.getEnderDragonKills(), PersistentDataType.INTEGER);
|
||||||
if (enderDragonKills == null) {
|
if (enderDragonKills == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateBossesKilled(finalItem, -enderDragonKills, "enderdragon");
|
meta = toolStats.itemLore.updateBossesKilled(finalItem, -enderDragonKills, "enderdragon");
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.criticalStrikes)) {
|
if (container.has(toolStats.toolStatsKeys.getCriticalStrikes())) {
|
||||||
Integer criticalStrikes = container.get(toolStats.criticalStrikes, PersistentDataType.INTEGER);
|
Integer criticalStrikes = container.get(toolStats.toolStatsKeys.getCriticalStrikes(), PersistentDataType.INTEGER);
|
||||||
if (criticalStrikes == null) {
|
if (criticalStrikes == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
meta = toolStats.itemLore.updateCriticalStrikes(finalItem, -criticalStrikes);
|
meta = toolStats.itemLore.updateCriticalStrikes(finalItem, -criticalStrikes);
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.tridentThrows)) {
|
if (container.has(toolStats.toolStatsKeys.getTridentThrows())) {
|
||||||
Integer tridentThrows = container.get(toolStats.tridentThrows, PersistentDataType.INTEGER);
|
Integer tridentThrows = container.get(toolStats.toolStatsKeys.getTridentThrows(), PersistentDataType.INTEGER);
|
||||||
if (tridentThrows == null) {
|
if (tridentThrows == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class BlockDispenseEvent implements Listener {
|
|||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) {
|
if (container.has(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG) || container.has(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,8 +114,8 @@ public class BlockDispenseEvent implements Listener {
|
|||||||
// if creation date is enabled, add it
|
// if creation date is enabled, add it
|
||||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 2, newItem);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 2, newItem);
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 2);
|
||||||
lore.add(creationDate);
|
lore.add(creationDate);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -123,8 +123,8 @@ public class BlockDispenseEvent implements Listener {
|
|||||||
// if ownership is enabled, add it
|
// if ownership is enabled, add it
|
||||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 2, newItem);
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 2, newItem);
|
||||||
if (itemOwner != null) {
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 2);
|
||||||
lore.add(itemOwner);
|
lore.add(itemOwner);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ public class BlockDispenseEvent implements Listener {
|
|||||||
// if hash is enabled, add it
|
// if hash is enabled, add it
|
||||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
container.set(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
newItem.setItemMeta(meta);
|
newItem.setItemMeta(meta);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class ChunkPopulate implements Listener {
|
|||||||
}
|
}
|
||||||
// add the new tag so we know it's new
|
// add the new tag so we know it's new
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
container.set(toolStats.newElytra, PersistentDataType.INTEGER, 1);
|
container.set(toolStats.toolStatsKeys.getElytraKey(), PersistentDataType.INTEGER, 1);
|
||||||
elytraCopy.setItemMeta(meta);
|
elytraCopy.setItemMeta(meta);
|
||||||
itemFrame.setItem(elytraCopy);
|
itemFrame.setItem(elytraCopy);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class CraftItem implements Listener {
|
|||||||
|
|
||||||
// if the item already has the tag
|
// if the item already has the tag
|
||||||
// this is to prevent duplicate tags
|
// this is to prevent duplicate tags
|
||||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) {
|
if (container.has(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG) || container.has(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,8 +145,8 @@ public class CraftItem implements Listener {
|
|||||||
// if creation date is enabled, add it
|
// if creation date is enabled, add it
|
||||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 0, newItem);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 0, newItem);
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 0);
|
||||||
lore.add(creationDate);
|
lore.add(creationDate);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -154,8 +154,8 @@ public class CraftItem implements Listener {
|
|||||||
// if ownership is enabled, add it
|
// if ownership is enabled, add it
|
||||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 0, newItem);
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 0, newItem);
|
||||||
if (itemOwner != null) {
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 0);
|
||||||
lore.add(itemOwner);
|
lore.add(itemOwner);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ public class CraftItem implements Listener {
|
|||||||
// if hash is enabled, add it
|
// if hash is enabled, add it
|
||||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
container.set(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING, hash);
|
||||||
}
|
}
|
||||||
newItem.setItemMeta(meta);
|
newItem.setItemMeta(meta);
|
||||||
return newItem;
|
return newItem;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class CreativeEvent implements Listener {
|
|||||||
// if the item already has an origin set, don't add it again
|
// if the item already has an origin set, don't add it again
|
||||||
// this is needed since you can spam click an item and the event will fire again
|
// this is needed since you can spam click an item and the event will fire again
|
||||||
PersistentDataContainer container = spawnedItemMeta.getPersistentDataContainer();
|
PersistentDataContainer container = spawnedItemMeta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.originType, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ public class CreativeEvent implements Listener {
|
|||||||
|
|
||||||
// if the item already has the tag
|
// if the item already has the tag
|
||||||
// this is to prevent duplicate tags
|
// this is to prevent duplicate tags
|
||||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) {
|
if (container.has(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG) || container.has(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ public class CreativeEvent implements Listener {
|
|||||||
// if creation date is enabled, add it
|
// if creation date is enabled, add it
|
||||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 6, newSpawnedItem);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 6, newSpawnedItem);
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 6);
|
||||||
lore.add(creationDate);
|
lore.add(creationDate);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -121,8 +121,8 @@ public class CreativeEvent implements Listener {
|
|||||||
// if ownership is enabled, add it
|
// if ownership is enabled, add it
|
||||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 6, newSpawnedItem);
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 6, newSpawnedItem);
|
||||||
if (itemOwner != null) {
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 6);
|
||||||
lore.add(itemOwner);
|
lore.add(itemOwner);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ public class CreativeEvent implements Listener {
|
|||||||
// if hash is enabled, add it
|
// if hash is enabled, add it
|
||||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||||
String hash = toolStats.hashMaker.makeHash(newSpawnedItem.getType(), owner.getUniqueId(), timeCreated);
|
String hash = toolStats.hashMaker.makeHash(newSpawnedItem.getType(), owner.getUniqueId(), timeCreated);
|
||||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
container.set(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
newSpawnedItem.setItemMeta(meta);
|
newSpawnedItem.setItemMeta(meta);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class EntityDeath implements Listener {
|
|||||||
ItemMeta droppedItemMeta = droppedItem.getItemMeta();
|
ItemMeta droppedItemMeta = droppedItem.getItemMeta();
|
||||||
if (droppedItemMeta != null) {
|
if (droppedItemMeta != null) {
|
||||||
PersistentDataContainer container = droppedItemMeta.getPersistentDataContainer();
|
PersistentDataContainer container = droppedItemMeta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.originType, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER)) {
|
||||||
continue; // ignore any items that have our tags
|
continue; // ignore any items that have our tags
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,15 +109,15 @@ public class EntityDeath implements Listener {
|
|||||||
// if creation date is enabled, add it
|
// if creation date is enabled, add it
|
||||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 1, newItem);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 1, newItem);
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 1);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 1);
|
||||||
lore.add(creationDate);
|
lore.add(creationDate);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 1);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 1);
|
||||||
container.set(toolStats.droppedBy, PersistentDataType.STRING, mobName);
|
container.set(toolStats.toolStatsKeys.getDroppedBy(), PersistentDataType.STRING, mobName);
|
||||||
Component droppedBy = toolStats.configTools.formatLore("dropped-by", "{name}", mobName);
|
Component droppedBy = toolStats.configTools.formatLore("dropped-by", "{name}", mobName);
|
||||||
lore.add(droppedBy);
|
lore.add(droppedBy);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class GenerateLoot implements Listener {
|
|||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) {
|
if (container.has(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG) || container.has(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,8 +122,8 @@ public class GenerateLoot implements Listener {
|
|||||||
// if creation date is enabled, add it
|
// if creation date is enabled, add it
|
||||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 2, newItem);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 2, newItem);
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 2);
|
||||||
lore.add(creationDate);
|
lore.add(creationDate);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -131,8 +131,8 @@ public class GenerateLoot implements Listener {
|
|||||||
// if ownership is enabled, add it
|
// if ownership is enabled, add it
|
||||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 2, newItem);
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 2, newItem);
|
||||||
if (itemOwner != null) {
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 2);
|
||||||
lore.add(itemOwner);
|
lore.add(itemOwner);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ public class GenerateLoot implements Listener {
|
|||||||
// if hash is enabled, add it
|
// if hash is enabled, add it
|
||||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
container.set(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
newItem.setItemMeta(meta);
|
newItem.setItemMeta(meta);
|
||||||
|
|||||||
@@ -69,13 +69,13 @@ public class InventoryOpen implements Listener {
|
|||||||
|
|
||||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||||
// if the token system is on and the item doesn't have stat keys
|
// if the token system is on and the item doesn't have stat keys
|
||||||
if (toolStats.itemChecker.keyCheck(container) && !container.has(toolStats.tokenType)) {
|
if (toolStats.itemChecker.keyCheck(container) && !container.has(toolStats.toolStatsKeys.getTokenType())) {
|
||||||
// add the tokens
|
// add the tokens
|
||||||
String newTokens = toolStats.itemChecker.addTokensToExisting(itemStack);
|
String newTokens = toolStats.itemChecker.addTokensToExisting(itemStack);
|
||||||
if (newTokens == null) {
|
if (newTokens == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, newTokens);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,29 +83,29 @@ public class InventoryOpen implements Listener {
|
|||||||
// generate a hash if the item doesn't have one (and enabled)
|
// generate a hash if the item doesn't have one (and enabled)
|
||||||
// if hashes are disabled and the item has one, remove it.
|
// if hashes are disabled and the item has one, remove it.
|
||||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||||
if (!container.has(toolStats.hash, PersistentDataType.STRING)) {
|
if (!container.has(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING)) {
|
||||||
UUID owner = null;
|
UUID owner = null;
|
||||||
// get the current owner if there is one.
|
// get the current owner if there is one.
|
||||||
if (container.has(toolStats.itemOwner, new UUIDDataType())) {
|
if (container.has(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType())) {
|
||||||
owner = container.get(toolStats.itemOwner, new UUIDDataType());
|
owner = container.get(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType());
|
||||||
}
|
}
|
||||||
// if there is no owner, use the player holding it
|
// if there is no owner, use the player holding it
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
owner = player.getUniqueId();
|
owner = player.getUniqueId();
|
||||||
}
|
}
|
||||||
Long timestamp = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
Long timestamp = container.get(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG);
|
||||||
if (timestamp == null) {
|
if (timestamp == null) {
|
||||||
// if there is no time created, use now
|
// if there is no time created, use now
|
||||||
timestamp = System.currentTimeMillis();
|
timestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
String hash = toolStats.hashMaker.makeHash(itemStack.getType(), owner, timestamp);
|
String hash = toolStats.hashMaker.makeHash(itemStack.getType(), owner, timestamp);
|
||||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
container.set(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING, hash);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if hashes are disabled but the item has one, remove it.
|
// if hashes are disabled but the item has one, remove it.
|
||||||
if (container.has(toolStats.hash, PersistentDataType.STRING)) {
|
if (container.has(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING)) {
|
||||||
container.remove(toolStats.hash);
|
container.remove(toolStats.toolStatsKeys.getHash());
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class PickupItem implements Listener {
|
|||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (itemStack.getType() == Material.ELYTRA) {
|
if (itemStack.getType() == Material.ELYTRA) {
|
||||||
// the elytra has the new key, set the lore to it
|
// the elytra has the new key, set the lore to it
|
||||||
if (container.has(toolStats.newElytra, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.toolStatsKeys.getElytraKey(), PersistentDataType.INTEGER)) {
|
||||||
ItemStack newElytra = addElytraOrigin(itemStack, (Player) event.getEntity());
|
ItemStack newElytra = addElytraOrigin(itemStack, (Player) event.getEntity());
|
||||||
if (newElytra != null) {
|
if (newElytra != null) {
|
||||||
item.setItemStack(newElytra);
|
item.setItemStack(newElytra);
|
||||||
@@ -105,7 +105,7 @@ public class PickupItem implements Listener {
|
|||||||
// only make the hash if it's enabled
|
// only make the hash if it's enabled
|
||||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||||
String hash = toolStats.hashMaker.makeHash(finalItem.getType(), owner.getUniqueId(), timeCreated);
|
String hash = toolStats.hashMaker.makeHash(finalItem.getType(), owner.getUniqueId(), timeCreated);
|
||||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
container.set(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the current lore the item
|
// get the current lore the item
|
||||||
@@ -116,23 +116,23 @@ public class PickupItem implements Listener {
|
|||||||
lore = new ArrayList<>();
|
lore = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 4);
|
||||||
container.remove(toolStats.newElytra);
|
container.remove(toolStats.toolStatsKeys.getElytraKey());
|
||||||
|
|
||||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 4, finalItem);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 4, finalItem);
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 4);
|
||||||
lore.add(creationDate);
|
lore.add(creationDate);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 4, finalItem);
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 4, finalItem);
|
||||||
if (itemOwner != null) {
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 4);
|
||||||
lore.add(itemOwner);
|
lore.add(itemOwner);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class PlayerFish implements Listener {
|
|||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) {
|
if (container.has(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG) || container.has(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,8 +132,8 @@ public class PlayerFish implements Listener {
|
|||||||
// if creation date is enabled, add it
|
// if creation date is enabled, add it
|
||||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 5, newItem);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 5, newItem);
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 5);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 5);
|
||||||
lore.add(creationDate);
|
lore.add(creationDate);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -141,8 +141,8 @@ public class PlayerFish implements Listener {
|
|||||||
// if ownership is enabled, add it
|
// if ownership is enabled, add it
|
||||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 5, newItem);
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 5, newItem);
|
||||||
if (itemOwner != null) {
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 5);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 5);
|
||||||
lore.add(itemOwner);
|
lore.add(itemOwner);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ public class PlayerFish implements Listener {
|
|||||||
// if hash is enabled, add it
|
// if hash is enabled, add it
|
||||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
container.set(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
newItem.setItemMeta(meta);
|
newItem.setItemMeta(meta);
|
||||||
|
|||||||
@@ -60,42 +60,42 @@ public class PlayerJoin implements Listener {
|
|||||||
|
|
||||||
if (toolStats.config.getBoolean("tokens.enabled")) {
|
if (toolStats.config.getBoolean("tokens.enabled")) {
|
||||||
// if the token system is on and the item doesn't have stat keys
|
// if the token system is on and the item doesn't have stat keys
|
||||||
if (toolStats.itemChecker.keyCheck(container) && !container.has(toolStats.tokenType)) {
|
if (toolStats.itemChecker.keyCheck(container) && !container.has(toolStats.toolStatsKeys.getTokenType())) {
|
||||||
// add the tokens
|
// add the tokens
|
||||||
String newTokens = toolStats.itemChecker.addTokensToExisting(itemStack);
|
String newTokens = toolStats.itemChecker.addTokensToExisting(itemStack);
|
||||||
if (newTokens == null) {
|
if (newTokens == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, newTokens);
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, newTokens);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate a hash if the item doesn't have one
|
// generate a hash if the item doesn't have one
|
||||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||||
if (!container.has(toolStats.hash, PersistentDataType.STRING)) {
|
if (!container.has(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING)) {
|
||||||
UUID owner = null;
|
UUID owner = null;
|
||||||
// get the current owner if there is one.
|
// get the current owner if there is one.
|
||||||
if (container.has(toolStats.itemOwner, new UUIDDataType())) {
|
if (container.has(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType())) {
|
||||||
owner = container.get(toolStats.itemOwner, new UUIDDataType());
|
owner = container.get(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType());
|
||||||
}
|
}
|
||||||
// if there is no owner, use the player holding it
|
// if there is no owner, use the player holding it
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
owner = player.getUniqueId();
|
owner = player.getUniqueId();
|
||||||
}
|
}
|
||||||
Long timestamp = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
Long timestamp = container.get(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG);
|
||||||
if (timestamp == null) {
|
if (timestamp == null) {
|
||||||
// if there is no time created, use now
|
// if there is no time created, use now
|
||||||
timestamp = System.currentTimeMillis();
|
timestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
String hash = toolStats.hashMaker.makeHash(itemStack.getType(), owner, timestamp);
|
String hash = toolStats.hashMaker.makeHash(itemStack.getType(), owner, timestamp);
|
||||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
container.set(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING, hash);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if hashes are disabled but the item has one, remove it.
|
// if hashes are disabled but the item has one, remove it.
|
||||||
if (container.has(toolStats.hash, PersistentDataType.STRING)) {
|
if (container.has(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING)) {
|
||||||
container.remove(toolStats.hash);
|
container.remove(toolStats.toolStatsKeys.getHash());
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class PrepareCraft implements Listener {
|
|||||||
}
|
}
|
||||||
// if the paper item has our PDC, cancel it
|
// if the paper item has our PDC, cancel it
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.tokenType)) {
|
if (container.has(toolStats.toolStatsKeys.getTokenType())) {
|
||||||
event.getInventory().setResult(null);
|
event.getInventory().setResult(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class VillagerTrade implements Listener {
|
|||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) {
|
if (container.has(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG) || container.has(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +150,8 @@ public class VillagerTrade implements Listener {
|
|||||||
// if creation date is enabled, add it
|
// if creation date is enabled, add it
|
||||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 3, newItem);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 3, newItem);
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 3);
|
||||||
lore.add(creationDate);
|
lore.add(creationDate);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -159,8 +159,8 @@ public class VillagerTrade implements Listener {
|
|||||||
// if ownership is enabled, add it
|
// if ownership is enabled, add it
|
||||||
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 3, newItem);
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 3, newItem);
|
||||||
if (itemOwner != null) {
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 3);
|
||||||
lore.add(itemOwner);
|
lore.add(itemOwner);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ public class VillagerTrade implements Listener {
|
|||||||
// if hash is enabled, add it
|
// if hash is enabled, add it
|
||||||
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
if (toolStats.config.getBoolean("generate-hash-for-items")) {
|
||||||
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
String hash = toolStats.hashMaker.makeHash(newItem.getType(), owner.getUniqueId(), timeCreated);
|
||||||
container.set(toolStats.hash, PersistentDataType.STRING, hash);
|
container.set(toolStats.toolStatsKeys.getHash(), PersistentDataType.STRING, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
newItem.setItemMeta(meta);
|
newItem.setItemMeta(meta);
|
||||||
|
|||||||
@@ -143,12 +143,12 @@ public class ItemChecker {
|
|||||||
*/
|
*/
|
||||||
public boolean checkTokens(PersistentDataContainer container, String targetToken) {
|
public boolean checkTokens(PersistentDataContainer container, String targetToken) {
|
||||||
// make sure the item has tokens
|
// make sure the item has tokens
|
||||||
if (!container.has(toolStats.tokenApplied, PersistentDataType.STRING)) {
|
if (!container.has(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the tokens for this item
|
// get the tokens for this item
|
||||||
String tokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokens = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -169,12 +169,12 @@ public class ItemChecker {
|
|||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (!container.has(toolStats.tokenApplied, PersistentDataType.STRING)) {
|
if (!container.has(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING)) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the tokens for this item
|
// get the tokens for this item
|
||||||
String tokensRaw = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
String tokensRaw = container.get(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING);
|
||||||
if (tokensRaw == null) {
|
if (tokensRaw == null) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
@@ -198,12 +198,12 @@ public class ItemChecker {
|
|||||||
String[] tokens = getTokens(item);
|
String[] tokens = getTokens(item);
|
||||||
// there are no tokens
|
// there are no tokens
|
||||||
if (tokens.length == 0) {
|
if (tokens.length == 0) {
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, token);
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, token);
|
||||||
} else {
|
} else {
|
||||||
// other tokens exist, so add
|
// other tokens exist, so add
|
||||||
String[] newTokens = Arrays.copyOf(tokens, tokens.length + 1);
|
String[] newTokens = Arrays.copyOf(tokens, tokens.length + 1);
|
||||||
newTokens[tokens.length] = token;
|
newTokens[tokens.length] = token;
|
||||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
container.set(toolStats.toolStatsKeys.getTokenApplied(), PersistentDataType.STRING, String.join(",", newTokens));
|
||||||
}
|
}
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
return item;
|
return item;
|
||||||
@@ -321,36 +321,48 @@ public class ItemChecker {
|
|||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
ArrayList<String> tokens = new ArrayList<>();
|
ArrayList<String> tokens = new ArrayList<>();
|
||||||
if (container.has(toolStats.playerKills)) {
|
if (container.has(toolStats.toolStatsKeys.getPlayerKills())) {
|
||||||
tokens.add("player-kills");
|
tokens.add("player-kills");
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.mobKills)) {
|
if (container.has(toolStats.toolStatsKeys.getMobKills())) {
|
||||||
tokens.add("mob-kills");
|
tokens.add("mob-kills");
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.blocksMined)) {
|
if (container.has(toolStats.toolStatsKeys.getBlocksMined())) {
|
||||||
tokens.add("blocks-mined");
|
tokens.add("blocks-mined");
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.cropsHarvested)) {
|
if (container.has(toolStats.toolStatsKeys.getCropsHarvested())) {
|
||||||
tokens.add("crops-mined");
|
tokens.add("crops-mined");
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.fishCaught)) {
|
if (container.has(toolStats.toolStatsKeys.getFishCaught())) {
|
||||||
tokens.add("fish-caught");
|
tokens.add("fish-caught");
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.sheepSheared)) {
|
if (container.has(toolStats.toolStatsKeys.getSheepSheared())) {
|
||||||
tokens.add("sheep-sheared");
|
tokens.add("sheep-sheared");
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.armorDamage)) {
|
if (container.has(toolStats.toolStatsKeys.getArmorDamage())) {
|
||||||
tokens.add("damage-taken");
|
tokens.add("damage-taken");
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.arrowsShot)) {
|
if (container.has(toolStats.toolStatsKeys.getArrowsShot())) {
|
||||||
tokens.add("arrows-shot");
|
tokens.add("arrows-shot");
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.flightTime)) {
|
if (container.has(toolStats.toolStatsKeys.getFlightTime())) {
|
||||||
tokens.add("flight-time");
|
tokens.add("flight-time");
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.damageDone)) {
|
if (container.has(toolStats.toolStatsKeys.getDamageDone())) {
|
||||||
tokens.add("damage-done");
|
tokens.add("damage-done");
|
||||||
}
|
}
|
||||||
|
if (container.has(toolStats.toolStatsKeys.getWitherKills())) {
|
||||||
|
tokens.add("wither-kills");
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.toolStatsKeys.getEnderDragonKills())) {
|
||||||
|
tokens.add("enderdragon-kills");
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.toolStatsKeys.getCriticalStrikes())) {
|
||||||
|
tokens.add("critical-strikes");
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.toolStatsKeys.getTridentThrows())) {
|
||||||
|
tokens.add("trident-throws");
|
||||||
|
}
|
||||||
if (tokens.isEmpty()) {
|
if (tokens.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -387,6 +399,6 @@ public class ItemChecker {
|
|||||||
public boolean keyCheck(PersistentDataContainer container) {
|
public boolean keyCheck(PersistentDataContainer container) {
|
||||||
return container.getKeys().stream()
|
return container.getKeys().stream()
|
||||||
.map(NamespacedKey::getKey)
|
.map(NamespacedKey::getKey)
|
||||||
.anyMatch(key -> toolStats.tokenKeys.stream().anyMatch(tokenKey -> tokenKey.getKey().equalsIgnoreCase(key)));
|
.anyMatch(key -> toolStats.toolStatsKeys.getTokenKeys().stream().anyMatch(tokenKey -> tokenKey.getKey().equalsIgnoreCase(key)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -209,7 +209,7 @@ public class TokenData {
|
|||||||
tokenMeta.lore(lore);
|
tokenMeta.lore(lore);
|
||||||
|
|
||||||
// set the PDC
|
// set the PDC
|
||||||
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, tokenType);
|
tokenData.set(toolStats.toolStatsKeys.getTokenType(), PersistentDataType.STRING, tokenType);
|
||||||
token.setItemMeta(tokenMeta);
|
token.setItemMeta(tokenMeta);
|
||||||
|
|
||||||
// set the custom model data
|
// set the custom model data
|
||||||
|
|||||||
182
src/main/java/lol/hyper/toolstats/tools/ToolStatsKeys.java
Normal file
182
src/main/java/lol/hyper/toolstats/tools/ToolStatsKeys.java
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
package lol.hyper.toolstats.tools;
|
||||||
|
|
||||||
|
import lol.hyper.toolstats.ToolStats;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ToolStatsKeys {
|
||||||
|
|
||||||
|
private final ToolStats toolStats;
|
||||||
|
private final Set<NamespacedKey> tokenKeys = new HashSet<>();
|
||||||
|
|
||||||
|
public ToolStatsKeys(ToolStats toolStats) {
|
||||||
|
this.toolStats = toolStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NamespacedKey itemOwner;
|
||||||
|
private NamespacedKey timeCreated;
|
||||||
|
private NamespacedKey playerKills;
|
||||||
|
private NamespacedKey mobKills;
|
||||||
|
private NamespacedKey blocksMined;
|
||||||
|
private NamespacedKey cropsHarvested;
|
||||||
|
private NamespacedKey fishCaught;
|
||||||
|
private NamespacedKey sheepSheared;
|
||||||
|
private NamespacedKey armorDamage;
|
||||||
|
private NamespacedKey damageDone;
|
||||||
|
private NamespacedKey newElytra;
|
||||||
|
private NamespacedKey hash;
|
||||||
|
private NamespacedKey arrowsShot;
|
||||||
|
private NamespacedKey droppedBy;
|
||||||
|
private NamespacedKey flightTime;
|
||||||
|
private NamespacedKey tokenType;
|
||||||
|
private NamespacedKey tokenApplied;
|
||||||
|
private NamespacedKey witherKills;
|
||||||
|
private NamespacedKey enderDragonKills;
|
||||||
|
private NamespacedKey criticalStrikes;
|
||||||
|
private NamespacedKey tridentThrows;
|
||||||
|
private NamespacedKey originType;
|
||||||
|
|
||||||
|
public void make() {
|
||||||
|
itemOwner = new NamespacedKey(toolStats, "owner");
|
||||||
|
timeCreated = new NamespacedKey(toolStats, "time-created");
|
||||||
|
playerKills = new NamespacedKey(toolStats, "player-kills");
|
||||||
|
mobKills = new NamespacedKey(toolStats, "mob-kills");
|
||||||
|
blocksMined = new NamespacedKey(toolStats, "generic-mined");
|
||||||
|
cropsHarvested = new NamespacedKey(toolStats, "crops-mined");
|
||||||
|
fishCaught = new NamespacedKey(toolStats, "fish-caught");
|
||||||
|
sheepSheared = new NamespacedKey(toolStats, "sheared");
|
||||||
|
armorDamage = new NamespacedKey(toolStats, "damage-taken");
|
||||||
|
damageDone = new NamespacedKey(toolStats, "damage-done");
|
||||||
|
newElytra = new NamespacedKey(toolStats, "new");
|
||||||
|
hash = new NamespacedKey(toolStats, "hash");
|
||||||
|
arrowsShot = new NamespacedKey(toolStats, "arrows-shot");
|
||||||
|
droppedBy = new NamespacedKey(toolStats, "dropped-by");
|
||||||
|
flightTime = new NamespacedKey(toolStats, "flightTime");
|
||||||
|
tokenType = new NamespacedKey(toolStats, "token-type");
|
||||||
|
tokenApplied = new NamespacedKey(toolStats, "token-applied");
|
||||||
|
witherKills = new NamespacedKey(toolStats, "wither-kills");
|
||||||
|
enderDragonKills = new NamespacedKey(toolStats, "enderdragon-kills");
|
||||||
|
criticalStrikes = new NamespacedKey(toolStats, "critical-strikes");
|
||||||
|
tridentThrows = new NamespacedKey(toolStats, "trident-throws");
|
||||||
|
originType = new NamespacedKey(toolStats, "origin");
|
||||||
|
|
||||||
|
// save which stat can be used by a reset token
|
||||||
|
tokenKeys.add(blocksMined);
|
||||||
|
tokenKeys.add(playerKills);
|
||||||
|
tokenKeys.add(mobKills);
|
||||||
|
tokenKeys.add(cropsHarvested);
|
||||||
|
tokenKeys.add(sheepSheared);
|
||||||
|
tokenKeys.add(fishCaught);
|
||||||
|
tokenKeys.add(flightTime);
|
||||||
|
tokenKeys.add(arrowsShot);
|
||||||
|
tokenKeys.add(armorDamage);
|
||||||
|
tokenKeys.add(witherKills);
|
||||||
|
tokenKeys.add(enderDragonKills);
|
||||||
|
tokenKeys.add(criticalStrikes);
|
||||||
|
tokenKeys.add(tridentThrows);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getItemOwner() {
|
||||||
|
return itemOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getTimeCreated() {
|
||||||
|
return timeCreated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getPlayerKills() {
|
||||||
|
return playerKills;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getMobKills() {
|
||||||
|
return mobKills;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getBlocksMined() {
|
||||||
|
return blocksMined;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getCropsHarvested() {
|
||||||
|
return cropsHarvested;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getFishCaught() {
|
||||||
|
return fishCaught;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getSheepSheared() {
|
||||||
|
return sheepSheared;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getArmorDamage() {
|
||||||
|
return armorDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getDamageDone() {
|
||||||
|
return damageDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getElytraKey() {
|
||||||
|
return newElytra;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getHash() {
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getArrowsShot() {
|
||||||
|
return arrowsShot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getDroppedBy() {
|
||||||
|
return droppedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getFlightTime() {
|
||||||
|
return flightTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getTokenType() {
|
||||||
|
return tokenType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getTokenApplied() {
|
||||||
|
return tokenApplied;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getWitherKills() {
|
||||||
|
return witherKills;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getEnderDragonKills() {
|
||||||
|
return enderDragonKills;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getCriticalStrikes() {
|
||||||
|
return criticalStrikes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getTridentThrows() {
|
||||||
|
return tridentThrows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores how an item was created.
|
||||||
|
* 0 = crafted.
|
||||||
|
* 1 = dropped.
|
||||||
|
* 2 = looted.
|
||||||
|
* 3 = traded.
|
||||||
|
* 4 = founded (for elytras).
|
||||||
|
* 5 = fished.
|
||||||
|
* 6 = spawned in (creative).
|
||||||
|
*/
|
||||||
|
public NamespacedKey getOriginType() {
|
||||||
|
return originType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<NamespacedKey> getTokenKeys() {
|
||||||
|
return tokenKeys;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user