diff --git a/src/main/java/lol/hyper/toolstats/ToolStats.java b/src/main/java/lol/hyper/toolstats/ToolStats.java index 018eea4..b21c3f9 100644 --- a/src/main/java/lol/hyper/toolstats/ToolStats.java +++ b/src/main/java/lol/hyper/toolstats/ToolStats.java @@ -43,7 +43,7 @@ public final class ToolStats extends JavaPlugin { /** * Stores who created an item. */ - public final NamespacedKey genericOwner = new NamespacedKey(this, "owner"); + public final NamespacedKey itemOwner = new NamespacedKey(this, "owner"); /** * Stores when the item was created. */ @@ -51,15 +51,15 @@ public final class ToolStats extends JavaPlugin { /** * Stores how many player kills. */ - public final NamespacedKey swordPlayerKills = new NamespacedKey(this, "player-kills"); + public final NamespacedKey playerKills = new NamespacedKey(this, "player-kills"); /** * Stores how many mob kills. */ - public final NamespacedKey swordMobKills = new NamespacedKey(this, "mob-kills"); + public final NamespacedKey mobKills = new NamespacedKey(this, "mob-kills"); /** * Stores how many blocks were mined. */ - public final NamespacedKey genericMined = new NamespacedKey(this, "generic-mined"); + public final NamespacedKey blocksMined = new NamespacedKey(this, "generic-mined"); /** * Stores how many crops were harvested. */ @@ -67,11 +67,11 @@ public final class ToolStats extends JavaPlugin { /** * Stores how many fish were caught. */ - public final NamespacedKey fishingRodCaught = new NamespacedKey(this, "fish-caught"); + public final NamespacedKey fishCaught = new NamespacedKey(this, "fish-caught"); /** * Stores how many sheep were sheared. */ - public final NamespacedKey shearsSheared = new NamespacedKey(this, "sheared"); + public final NamespacedKey sheepSheared = new NamespacedKey(this, "sheared"); /** * Stores how much damage an armor piece has taken. */ @@ -118,7 +118,7 @@ public final class ToolStats extends JavaPlugin { public boolean tokens = false; public Set tokenKeys = new HashSet<>(); - public BlocksMined blocksMined; + public BlockBreak blockBreak; public ChunkPopulate chunkPopulate; public CraftItem craftItem; public EntityDeath entityDeath; @@ -165,7 +165,7 @@ public final class ToolStats extends JavaPlugin { } } hashMaker = new HashMaker(this); - blocksMined = new BlocksMined(this); + blockBreak = new BlockBreak(this); craftItem = new CraftItem(this); chunkPopulate = new ChunkPopulate(this); entityDeath = new EntityDeath(this); @@ -190,17 +190,17 @@ public final class ToolStats extends JavaPlugin { grindstoneEvent = new GrindstoneEvent(this); // save which stat can be used by a reset token - tokenKeys.add(genericMined); - tokenKeys.add(swordPlayerKills); - tokenKeys.add(swordMobKills); + tokenKeys.add(blocksMined); + tokenKeys.add(playerKills); + tokenKeys.add(mobKills); tokenKeys.add(cropsHarvested); - tokenKeys.add(shearsSheared); - tokenKeys.add(fishingRodCaught); + tokenKeys.add(sheepSheared); + tokenKeys.add(fishCaught); tokenKeys.add(flightTime); tokenKeys.add(arrowsShot); tokenKeys.add(armorDamage); - Bukkit.getServer().getPluginManager().registerEvents(blocksMined, this); + Bukkit.getServer().getPluginManager().registerEvents(blockBreak, this); Bukkit.getServer().getPluginManager().registerEvents(chunkPopulate, this); Bukkit.getServer().getPluginManager().registerEvents(craftItem, this); Bukkit.getServer().getPluginManager().registerEvents(entityDeath, this); diff --git a/src/main/java/lol/hyper/toolstats/commands/CommandToolStats.java b/src/main/java/lol/hyper/toolstats/commands/CommandToolStats.java index c031575..f913d5a 100644 --- a/src/main/java/lol/hyper/toolstats/commands/CommandToolStats.java +++ b/src/main/java/lol/hyper/toolstats/commands/CommandToolStats.java @@ -227,8 +227,8 @@ public class CommandToolStats implements TabExecutor { } if (toolStats.configTools.checkConfig(original.getType(), "created-by")) { - if (container.has(toolStats.genericOwner, new UUIDDataType())) { - UUID owner = container.get(toolStats.genericOwner, new UUIDDataType()); + if (container.has(toolStats.itemOwner, new UUIDDataType())) { + UUID owner = container.get(toolStats.itemOwner, new UUIDDataType()); String ownerName = null; // if we can read the current owner if (owner != null) { @@ -241,7 +241,7 @@ public class CommandToolStats implements TabExecutor { if (ownerName == null) { player.sendMessage(Component.text("The owner of this item is null. Setting to " + player.getName() + ".", NamedTextColor.RED)); ownerName = player.getName(); - container.set(toolStats.genericOwner, new UUIDDataType(), player.getUniqueId()); + container.set(toolStats.itemOwner, new UUIDDataType(), player.getUniqueId()); } // show how the item was created based on the previous lore @@ -309,16 +309,16 @@ public class CommandToolStats implements TabExecutor { } } if (toolStats.configTools.checkConfig(original.getType(), "player-kills")) { - if (container.has(toolStats.swordPlayerKills, PersistentDataType.INTEGER)) { - Integer kills = container.get(toolStats.swordPlayerKills, PersistentDataType.INTEGER); + if (container.has(toolStats.playerKills, PersistentDataType.INTEGER)) { + Integer kills = container.get(toolStats.playerKills, PersistentDataType.INTEGER); if (kills != null) { lore.add(toolStats.configTools.formatLore("kills.player", "{kills}", toolStats.numberFormat.formatInt(kills))); } } } if (toolStats.configTools.checkConfig(original.getType(), "mob-kills")) { - if (container.has(toolStats.swordMobKills, PersistentDataType.INTEGER)) { - Integer kills = container.get(toolStats.swordMobKills, PersistentDataType.INTEGER); + if (container.has(toolStats.mobKills, PersistentDataType.INTEGER)) { + Integer kills = container.get(toolStats.mobKills, PersistentDataType.INTEGER); if (kills != null) { lore.add(toolStats.configTools.formatLore("kills.mob", "{kills}", toolStats.numberFormat.formatInt(kills))); } @@ -333,24 +333,24 @@ public class CommandToolStats implements TabExecutor { } } } - if (container.has(toolStats.genericMined, PersistentDataType.INTEGER)) { - Integer blocksMined = container.get(toolStats.genericMined, PersistentDataType.INTEGER); + if (container.has(toolStats.blocksMined, PersistentDataType.INTEGER)) { + Integer blocksMined = container.get(toolStats.blocksMined, PersistentDataType.INTEGER); if (blocksMined != null) { lore.add(toolStats.configTools.formatLore("blocks-mined", "{blocks}", toolStats.numberFormat.formatInt(blocksMined))); } } } if (toolStats.config.getBoolean("enabled.fish-caught")) { - if (container.has(toolStats.fishingRodCaught, PersistentDataType.INTEGER)) { - Integer fish = container.get(toolStats.fishingRodCaught, PersistentDataType.INTEGER); + if (container.has(toolStats.fishCaught, PersistentDataType.INTEGER)) { + Integer fish = container.get(toolStats.fishCaught, PersistentDataType.INTEGER); if (fish != null) { lore.add(toolStats.configTools.formatLore("fished.fish-caught", "{fish}", toolStats.numberFormat.formatInt(fish))); } } } if (toolStats.config.getBoolean("enabled.sheep-sheared")) { - if (container.has(toolStats.shearsSheared, PersistentDataType.INTEGER)) { - Integer sheep = container.get(toolStats.shearsSheared, PersistentDataType.INTEGER); + if (container.has(toolStats.sheepSheared, PersistentDataType.INTEGER)) { + Integer sheep = container.get(toolStats.sheepSheared, PersistentDataType.INTEGER); if (sheep != null) { lore.add(toolStats.configTools.formatLore("sheep-sheared", "{sheep}", toolStats.numberFormat.formatInt(sheep))); } diff --git a/src/main/java/lol/hyper/toolstats/events/BlocksMined.java b/src/main/java/lol/hyper/toolstats/events/BlockBreak.java similarity index 97% rename from src/main/java/lol/hyper/toolstats/events/BlocksMined.java rename to src/main/java/lol/hyper/toolstats/events/BlockBreak.java index 3b6656e..091d286 100644 --- a/src/main/java/lol/hyper/toolstats/events/BlocksMined.java +++ b/src/main/java/lol/hyper/toolstats/events/BlockBreak.java @@ -34,11 +34,11 @@ import org.bukkit.inventory.meta.ItemMeta; import java.util.Locale; -public class BlocksMined implements Listener { +public class BlockBreak implements Listener { private final ToolStats toolStats; - public BlocksMined(ToolStats toolStats) { + public BlockBreak(ToolStats toolStats) { this.toolStats = toolStats; } diff --git a/src/main/java/lol/hyper/toolstats/events/CraftItem.java b/src/main/java/lol/hyper/toolstats/events/CraftItem.java index 0fc03a0..9756ae6 100644 --- a/src/main/java/lol/hyper/toolstats/events/CraftItem.java +++ b/src/main/java/lol/hyper/toolstats/events/CraftItem.java @@ -126,7 +126,7 @@ public class CraftItem implements Listener { // if the item already has the tag // this is to prevent duplicate tags - if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.genericOwner, PersistentDataType.LONG)) { + if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) { return null; } @@ -137,7 +137,7 @@ public class CraftItem implements Listener { } container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated); - container.set(toolStats.genericOwner, new UUIDDataType(), owner.getUniqueId()); + container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId()); container.set(toolStats.originType, PersistentDataType.INTEGER, 0); List lore; diff --git a/src/main/java/lol/hyper/toolstats/events/CreativeEvent.java b/src/main/java/lol/hyper/toolstats/events/CreativeEvent.java index 2f48f46..a2c380d 100644 --- a/src/main/java/lol/hyper/toolstats/events/CreativeEvent.java +++ b/src/main/java/lol/hyper/toolstats/events/CreativeEvent.java @@ -100,7 +100,7 @@ public class CreativeEvent implements Listener { } container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated); - container.set(toolStats.genericOwner, new UUIDDataType(), owner.getUniqueId()); + container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId()); container.set(toolStats.originType, PersistentDataType.INTEGER, 6); if (toolStats.configTools.checkConfig(newSpawnedItem.getType(), "spawned-in")) { diff --git a/src/main/java/lol/hyper/toolstats/events/GenerateLoot.java b/src/main/java/lol/hyper/toolstats/events/GenerateLoot.java index aeed7f9..ddea209 100644 --- a/src/main/java/lol/hyper/toolstats/events/GenerateLoot.java +++ b/src/main/java/lol/hyper/toolstats/events/GenerateLoot.java @@ -102,7 +102,7 @@ public class GenerateLoot implements Listener { Date finalDate = new Date(timeCreated); PersistentDataContainer container = meta.getPersistentDataContainer(); - if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.genericOwner, PersistentDataType.LONG)) { + if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) { return null; } @@ -113,7 +113,7 @@ public class GenerateLoot implements Listener { } container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated); - container.set(toolStats.genericOwner, new UUIDDataType(), owner.getUniqueId()); + container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId()); container.set(toolStats.originType, PersistentDataType.INTEGER, 2); if (toolStats.configTools.checkConfig(newItem.getType(), "looted-tag")) { diff --git a/src/main/java/lol/hyper/toolstats/events/GrindstoneEvent.java b/src/main/java/lol/hyper/toolstats/events/GrindstoneEvent.java index 38730ad..bc0c0e1 100644 --- a/src/main/java/lol/hyper/toolstats/events/GrindstoneEvent.java +++ b/src/main/java/lol/hyper/toolstats/events/GrindstoneEvent.java @@ -108,17 +108,17 @@ public class GrindstoneEvent implements Listener { for (String token : tokens) { switch (appliedTokens) { case "player-kills": { - container.set(toolStats.swordPlayerKills, PersistentDataType.INTEGER, 0); + container.set(toolStats.playerKills, PersistentDataType.INTEGER, 0); finalMeta = toolStats.itemLore.updatePlayerKills(inputItem, 0); break; } case "mob-kills": { - container.set(toolStats.swordMobKills, PersistentDataType.INTEGER, 0); + container.set(toolStats.mobKills, PersistentDataType.INTEGER, 0); finalMeta = toolStats.itemLore.updateMobKills(inputItem, 0); break; } case "blocks-mined": { - container.set(toolStats.genericMined, PersistentDataType.INTEGER, 0); + container.set(toolStats.blocksMined, PersistentDataType.INTEGER, 0); finalMeta = toolStats.itemLore.updateBlocksMined(inputItem, 0); break; } @@ -128,12 +128,12 @@ public class GrindstoneEvent implements Listener { break; } case "fish-caught": { - container.set(toolStats.fishingRodCaught, PersistentDataType.INTEGER, 0); + container.set(toolStats.fishCaught, PersistentDataType.INTEGER, 0); finalMeta = toolStats.itemLore.updateFishCaught(inputItem, 0); break; } case "sheep-sheared": { - container.set(toolStats.shearsSheared, PersistentDataType.INTEGER, 0); + container.set(toolStats.sheepSheared, PersistentDataType.INTEGER, 0); finalMeta = toolStats.itemLore.updateSheepSheared(inputItem, 0); break; } diff --git a/src/main/java/lol/hyper/toolstats/events/InventoryOpen.java b/src/main/java/lol/hyper/toolstats/events/InventoryOpen.java index fc741c8..ae6ff3b 100644 --- a/src/main/java/lol/hyper/toolstats/events/InventoryOpen.java +++ b/src/main/java/lol/hyper/toolstats/events/InventoryOpen.java @@ -66,10 +66,10 @@ public class InventoryOpen implements Listener { if (toolStats.config.getBoolean("generate-hash-for-items")) { if (!container.has(toolStats.hash, PersistentDataType.STRING)) { // make sure the item has an owner - if (!container.has(toolStats.genericOwner, new UUIDDataType())) { + if (!container.has(toolStats.itemOwner, new UUIDDataType())) { continue; } - UUID owner = container.get(toolStats.genericOwner, new UUIDDataType()); + UUID owner = container.get(toolStats.itemOwner, new UUIDDataType()); if (owner == null) { continue; } diff --git a/src/main/java/lol/hyper/toolstats/events/PickupItem.java b/src/main/java/lol/hyper/toolstats/events/PickupItem.java index 0321adf..a252c9a 100644 --- a/src/main/java/lol/hyper/toolstats/events/PickupItem.java +++ b/src/main/java/lol/hyper/toolstats/events/PickupItem.java @@ -97,7 +97,7 @@ public class PickupItem implements Listener { } container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated); - container.set(toolStats.genericOwner, new UUIDDataType(), owner.getUniqueId()); + container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId()); container.set(toolStats.originType, PersistentDataType.INTEGER, 4); container.remove(toolStats.newElytra); diff --git a/src/main/java/lol/hyper/toolstats/events/PlayerFish.java b/src/main/java/lol/hyper/toolstats/events/PlayerFish.java index cf5d3fc..a931c6e 100644 --- a/src/main/java/lol/hyper/toolstats/events/PlayerFish.java +++ b/src/main/java/lol/hyper/toolstats/events/PlayerFish.java @@ -111,7 +111,7 @@ public class PlayerFish implements Listener { Date finalDate = new Date(timeCreated); PersistentDataContainer container = meta.getPersistentDataContainer(); - if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.genericOwner, PersistentDataType.LONG)) { + if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) { return null; } @@ -119,7 +119,7 @@ public class PlayerFish implements Listener { container.set(toolStats.hash, PersistentDataType.STRING, hash); container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated); - container.set(toolStats.genericOwner, new UUIDDataType(), owner.getUniqueId()); + container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId()); container.set(toolStats.originType, PersistentDataType.INTEGER, 5); if (toolStats.configTools.checkConfig(newItem.getType(), "fished-tag")) { diff --git a/src/main/java/lol/hyper/toolstats/events/PlayerJoin.java b/src/main/java/lol/hyper/toolstats/events/PlayerJoin.java index 447cba4..70ecaeb 100644 --- a/src/main/java/lol/hyper/toolstats/events/PlayerJoin.java +++ b/src/main/java/lol/hyper/toolstats/events/PlayerJoin.java @@ -61,10 +61,10 @@ public class PlayerJoin implements Listener { // generate a hash if the item doesn't have one if (!container.has(toolStats.hash, PersistentDataType.STRING)) { // make sure the item has an owner - if (!container.has(toolStats.genericOwner, new UUIDDataType())) { + if (!container.has(toolStats.itemOwner, new UUIDDataType())) { continue; } - UUID owner = container.get(toolStats.genericOwner, new UUIDDataType()); + UUID owner = container.get(toolStats.itemOwner, new UUIDDataType()); if (owner == null) { continue; } diff --git a/src/main/java/lol/hyper/toolstats/events/VillagerTrade.java b/src/main/java/lol/hyper/toolstats/events/VillagerTrade.java index 0974b38..15c9237 100644 --- a/src/main/java/lol/hyper/toolstats/events/VillagerTrade.java +++ b/src/main/java/lol/hyper/toolstats/events/VillagerTrade.java @@ -129,7 +129,7 @@ public class VillagerTrade implements Listener { Date finalDate = new Date(timeCreated); PersistentDataContainer container = meta.getPersistentDataContainer(); - if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.genericOwner, PersistentDataType.LONG)) { + if (container.has(toolStats.timeCreated, PersistentDataType.LONG) || container.has(toolStats.itemOwner, PersistentDataType.LONG)) { return null; } @@ -140,7 +140,7 @@ public class VillagerTrade implements Listener { } container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated); - container.set(toolStats.genericOwner, new UUIDDataType(), owner.getUniqueId()); + container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId()); container.set(toolStats.originType, PersistentDataType.INTEGER, 3); if (toolStats.configTools.checkConfig(newItem.getType(), "traded-tag")) { diff --git a/src/main/java/lol/hyper/toolstats/tools/ItemLore.java b/src/main/java/lol/hyper/toolstats/tools/ItemLore.java index 9f9508d..65fa58d 100644 --- a/src/main/java/lol/hyper/toolstats/tools/ItemLore.java +++ b/src/main/java/lol/hyper/toolstats/tools/ItemLore.java @@ -293,8 +293,8 @@ public class ItemLore { // read the current stats from the item // if they don't exist, then start from 0 Integer blocksMined = 0; - if (container.has(toolStats.genericMined, PersistentDataType.INTEGER)) { - blocksMined = container.get(toolStats.genericMined, PersistentDataType.INTEGER); + if (container.has(toolStats.blocksMined, PersistentDataType.INTEGER)) { + blocksMined = container.get(toolStats.blocksMined, PersistentDataType.INTEGER); } if (blocksMined == null) { @@ -302,7 +302,7 @@ public class ItemLore { toolStats.logger.warning(clone + " does not have valid generic-mined set! Resting to zero. This should NEVER happen."); } - container.set(toolStats.genericMined, PersistentDataType.INTEGER, blocksMined + add); + container.set(toolStats.blocksMined, PersistentDataType.INTEGER, blocksMined + add); // do we add the lore based on the config? if (toolStats.configTools.checkConfig(clone.getType(), "blocks-mined")) { @@ -344,8 +344,8 @@ public class ItemLore { } Integer playerKills = 0; - if (container.has(toolStats.swordPlayerKills, PersistentDataType.INTEGER)) { - playerKills = container.get(toolStats.swordPlayerKills, PersistentDataType.INTEGER); + if (container.has(toolStats.playerKills, PersistentDataType.INTEGER)) { + playerKills = container.get(toolStats.playerKills, PersistentDataType.INTEGER); } if (playerKills == null) { @@ -353,7 +353,7 @@ public class ItemLore { toolStats.logger.warning(clone + " does not have valid player-kills set! Resting to zero. This should NEVER happen."); } - container.set(toolStats.swordPlayerKills, PersistentDataType.INTEGER, playerKills + add); + container.set(toolStats.playerKills, PersistentDataType.INTEGER, playerKills + add); // do we add the lore based on the config? if (toolStats.configTools.checkConfig(clone.getType(), "player-kills")) { @@ -395,8 +395,8 @@ public class ItemLore { } Integer mobKills = 0; - if (container.has(toolStats.swordMobKills, PersistentDataType.INTEGER)) { - mobKills = container.get(toolStats.swordMobKills, PersistentDataType.INTEGER); + if (container.has(toolStats.mobKills, PersistentDataType.INTEGER)) { + mobKills = container.get(toolStats.mobKills, PersistentDataType.INTEGER); } if (mobKills == null) { @@ -404,7 +404,7 @@ public class ItemLore { toolStats.logger.warning(clone + " does not have valid mob-kills set! Resting to zero. This should NEVER happen."); } - container.set(toolStats.swordMobKills, PersistentDataType.INTEGER, mobKills + add); + container.set(toolStats.mobKills, PersistentDataType.INTEGER, mobKills + add); // do we add the lore based on the config? if (toolStats.configTools.checkConfig(clone.getType(), "mob-kills")) { @@ -553,8 +553,8 @@ public class ItemLore { } Integer sheepSheared = 0; - if (container.has(toolStats.shearsSheared, PersistentDataType.INTEGER)) { - sheepSheared = container.get(toolStats.shearsSheared, PersistentDataType.INTEGER); + if (container.has(toolStats.sheepSheared, PersistentDataType.INTEGER)) { + sheepSheared = container.get(toolStats.sheepSheared, PersistentDataType.INTEGER); } if (sheepSheared == null) { @@ -562,7 +562,7 @@ public class ItemLore { toolStats.logger.warning(clone + " does not have valid sheared set! Resting to zero. This should NEVER happen."); } - container.set(toolStats.shearsSheared, PersistentDataType.INTEGER, sheepSheared + add); + container.set(toolStats.sheepSheared, PersistentDataType.INTEGER, sheepSheared + add); if (toolStats.config.getBoolean("enabled.sheep-sheared")) { String oldSheepFormatted = toolStats.numberFormat.formatInt(sheepSheared); @@ -656,8 +656,8 @@ public class ItemLore { } Integer fishCaught = 0; - if (container.has(toolStats.fishingRodCaught, PersistentDataType.INTEGER)) { - fishCaught = container.get(toolStats.fishingRodCaught, PersistentDataType.INTEGER); + if (container.has(toolStats.fishCaught, PersistentDataType.INTEGER)) { + fishCaught = container.get(toolStats.fishCaught, PersistentDataType.INTEGER); } if (fishCaught == null) { @@ -665,7 +665,7 @@ public class ItemLore { toolStats.logger.warning(clone + " does not have valid fish-caught set! Resting to zero. This should NEVER happen."); } - container.set(toolStats.fishingRodCaught, PersistentDataType.INTEGER, fishCaught + add); + container.set(toolStats.fishCaught, PersistentDataType.INTEGER, fishCaught + add); if (toolStats.config.getBoolean("enabled.fish-caught")) { String oldFishFormatted = toolStats.numberFormat.formatInt(fishCaught);