rename things

This commit is contained in:
hyperdefined
2025-01-26 14:43:47 -05:00
parent 73e472af3a
commit f7697bccfa
13 changed files with 63 additions and 63 deletions

View File

@@ -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<NamespacedKey> 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);

View File

@@ -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)));
}

View File

@@ -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;
}

View File

@@ -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<Component> lore;

View File

@@ -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")) {

View File

@@ -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")) {

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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")) {

View File

@@ -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;
}

View File

@@ -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")) {

View File

@@ -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);