mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe5e55d746 | ||
|
|
0574fb61a6 | ||
|
|
433ab547cb | ||
|
|
9746789f2b | ||
|
|
fd3c3ca8ed | ||
|
|
c6dc2c3368 | ||
|
|
d11211b1c7 | ||
|
|
e8c2296bd7 | ||
|
|
d8f296a085 | ||
|
|
58dee809f3 | ||
|
|
590cf6e8b0 | ||
|
|
a7cc8671bd | ||
|
|
37a7c642d3 | ||
|
|
31acdd9527 | ||
|
|
9b0ac2d912 | ||
|
|
4ea9e1600b | ||
|
|
72b8b31779 | ||
|
|
fce135f2f8 |
10
pom.xml
10
pom.xml
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<groupId>lol.hyper</groupId>
|
<groupId>lol.hyper</groupId>
|
||||||
<artifactId>toolstats</artifactId>
|
<artifactId>toolstats</artifactId>
|
||||||
<version>1.6</version>
|
<version>1.6.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>ToolStats</name>
|
<name>ToolStats</name>
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.10.1</version>
|
<version>3.11.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${java.version}</source>
|
<source>${java.version}</source>
|
||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -127,13 +127,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
<version>4.12.0</version>
|
<version>4.13.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-platform-bukkit</artifactId>
|
<artifactId>adventure-platform-bukkit</artifactId>
|
||||||
<version>4.2.0</version>
|
<version>4.3.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
public final NamespacedKey shearsSheared = new NamespacedKey(this, "sheared");
|
public final NamespacedKey shearsSheared = new NamespacedKey(this, "sheared");
|
||||||
// stores how much damage armor has taken
|
// stores how much damage armor has taken
|
||||||
public final NamespacedKey armorDamage = new NamespacedKey(this, "damage-taken");
|
public final NamespacedKey armorDamage = new NamespacedKey(this, "damage-taken");
|
||||||
|
// stores how much damage armor has taken (as int)
|
||||||
|
public final NamespacedKey armorDamageInt = new NamespacedKey(this, "damage-taken-int");
|
||||||
// used for tracking new elytras
|
// used for tracking new elytras
|
||||||
public final NamespacedKey newElytra = new NamespacedKey(this, "new");
|
public final NamespacedKey newElytra = new NamespacedKey(this, "new");
|
||||||
|
|
||||||
|
|||||||
@@ -86,11 +86,6 @@ public class BlocksMined implements Listener {
|
|||||||
String blocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
String blocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
||||||
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{blocks}", blocksMinedFormatted, "blocks-mined");
|
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{blocks}", blocksMinedFormatted, "blocks-mined");
|
||||||
|
|
||||||
// if the list returned null, don't add it
|
|
||||||
if (newLore == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// do we add the lore based on the config?
|
// do we add the lore based on the config?
|
||||||
if (toolStats.checkConfig(playerTool, "blocks-mined")) {
|
if (toolStats.checkConfig(playerTool, "blocks-mined")) {
|
||||||
meta.setLore(newLore);
|
meta.setLore(newLore);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import org.bukkit.persistence.PersistentDataType;
|
|||||||
public class ChunkPopulate implements Listener {
|
public class ChunkPopulate implements Listener {
|
||||||
|
|
||||||
// this tags all elytras with a "new" tag
|
// this tags all elytras with a "new" tag
|
||||||
// this let's us track any new elytras player loot
|
// this lets us track any new elytras player loot
|
||||||
|
|
||||||
private final ToolStats toolStats;
|
private final ToolStats toolStats;
|
||||||
|
|
||||||
@@ -55,21 +55,22 @@ public class ChunkPopulate implements Listener {
|
|||||||
Chunk chunk = event.getChunk();
|
Chunk chunk = event.getChunk();
|
||||||
for (Entity entity : chunk.getEntities()) {
|
for (Entity entity : chunk.getEntities()) {
|
||||||
// if there is a new item frame
|
// if there is a new item frame
|
||||||
if (entity instanceof ItemFrame) {
|
if (!(entity instanceof ItemFrame)) {
|
||||||
ItemFrame itemFrame = (ItemFrame) entity;
|
return;
|
||||||
// if the item frame has an elytra
|
}
|
||||||
if (itemFrame.getItem().getType() == Material.ELYTRA) {
|
ItemFrame itemFrame = (ItemFrame) entity;
|
||||||
ItemStack elytraCopy = itemFrame.getItem();
|
// if the item frame has an elytra
|
||||||
ItemMeta meta = elytraCopy.getItemMeta();
|
if (itemFrame.getItem().getType() == Material.ELYTRA) {
|
||||||
if (meta == null) {
|
ItemStack elytraCopy = itemFrame.getItem();
|
||||||
return;
|
ItemMeta meta = elytraCopy.getItemMeta();
|
||||||
}
|
if (meta == null) {
|
||||||
// add the new tag so we know it's new
|
return;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
|
||||||
container.set(toolStats.newElytra, PersistentDataType.INTEGER, 1);
|
|
||||||
elytraCopy.setItemMeta(meta);
|
|
||||||
itemFrame.setItem(elytraCopy);
|
|
||||||
}
|
}
|
||||||
|
// add the new tag so we know it's new
|
||||||
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
container.set(toolStats.newElytra, PersistentDataType.INTEGER, 1);
|
||||||
|
elytraCopy.setItemMeta(meta);
|
||||||
|
itemFrame.setItem(elytraCopy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
|
|||||||
@@ -249,11 +249,6 @@ public class EntityDamage implements Listener {
|
|||||||
String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||||
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{kills}", playerKillsFormatted, "kills.player");
|
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{kills}", playerKillsFormatted, "kills.player");
|
||||||
|
|
||||||
// if the list returned null, don't add it
|
|
||||||
if (newLore == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// do we add the lore based on the config?
|
// do we add the lore based on the config?
|
||||||
if (toolStats.checkConfig(itemStack, "player-kills")) {
|
if (toolStats.checkConfig(itemStack, "player-kills")) {
|
||||||
meta.setLore(newLore);
|
meta.setLore(newLore);
|
||||||
@@ -289,11 +284,6 @@ public class EntityDamage implements Listener {
|
|||||||
String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||||
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{kills}", mobKillsFormatted, "kills.mob");
|
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{kills}", mobKillsFormatted, "kills.mob");
|
||||||
|
|
||||||
// if the list returned null, don't add it
|
|
||||||
if (newLore == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// do we add the lore based on the config?
|
// do we add the lore based on the config?
|
||||||
if (toolStats.checkConfig(itemStack, "mob-kills")) {
|
if (toolStats.checkConfig(itemStack, "mob-kills")) {
|
||||||
meta.setLore(newLore);
|
meta.setLore(newLore);
|
||||||
@@ -326,15 +316,11 @@ public class EntityDamage implements Listener {
|
|||||||
|
|
||||||
damageTaken = damageTaken + damage;
|
damageTaken = damageTaken + damage;
|
||||||
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken);
|
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken);
|
||||||
|
container.set(toolStats.armorDamageInt, PersistentDataType.INTEGER, damageTaken.intValue());
|
||||||
|
|
||||||
String damageTakenFormatted = toolStats.numberFormat.formatDouble(damageTaken);
|
String damageTakenFormatted = toolStats.numberFormat.formatDouble(damageTaken);
|
||||||
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{damage}", damageTakenFormatted, "damage-taken");
|
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{damage}", damageTakenFormatted, "damage-taken");
|
||||||
|
|
||||||
// if the list returned null, don't add it
|
|
||||||
if (newLore == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toolStats.config.getBoolean("enabled.armor-damage")) {
|
if (toolStats.config.getBoolean("enabled.armor-damage")) {
|
||||||
meta.setLore(newLore);
|
meta.setLore(newLore);
|
||||||
}
|
}
|
||||||
@@ -370,11 +356,6 @@ public class EntityDamage implements Listener {
|
|||||||
String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||||
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{kills}", mobKillsFormatted, "kills.mob");
|
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{kills}", mobKillsFormatted, "kills.mob");
|
||||||
|
|
||||||
// if the list returned null, don't add it
|
|
||||||
if (newLore == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// do we add the lore based on the config?
|
// do we add the lore based on the config?
|
||||||
if (toolStats.checkConfig(newTrident, "mob-kills")) {
|
if (toolStats.checkConfig(newTrident, "mob-kills")) {
|
||||||
meta.setLore(newLore);
|
meta.setLore(newLore);
|
||||||
@@ -412,11 +393,6 @@ public class EntityDamage implements Listener {
|
|||||||
String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||||
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{kills}", playerKillsFormatted, "kills.player");
|
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{kills}", playerKillsFormatted, "kills.player");
|
||||||
|
|
||||||
// if the list returned null, don't add it
|
|
||||||
if (newLore == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// do we add the lore based on the config?
|
// do we add the lore based on the config?
|
||||||
if (toolStats.checkConfig(newTrident, "player-kills")) {
|
if (toolStats.checkConfig(newTrident, "player-kills")) {
|
||||||
meta.setLore(newLore);
|
meta.setLore(newLore);
|
||||||
|
|||||||
@@ -85,11 +85,6 @@ public class EntityDeath implements Listener {
|
|||||||
|
|
||||||
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{name}", mob, "dropped-by");
|
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{name}", mob, "dropped-by");
|
||||||
|
|
||||||
// if the list returned null, don't add it
|
|
||||||
if (newLore == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
||||||
meta.setLore(newLore);
|
meta.setLore(newLore);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,11 +128,6 @@ public class PlayerFish implements Listener {
|
|||||||
String fishCaughtFormatted = toolStats.numberFormat.formatInt(fishCaught);
|
String fishCaughtFormatted = toolStats.numberFormat.formatInt(fishCaught);
|
||||||
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{fish}", fishCaughtFormatted, "fished.fish-caught");
|
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{fish}", fishCaughtFormatted, "fished.fish-caught");
|
||||||
|
|
||||||
// if the list returned null, don't add it
|
|
||||||
if (newLore == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toolStats.config.getBoolean("enabled.fish-caught")) {
|
if (toolStats.config.getBoolean("enabled.fish-caught")) {
|
||||||
meta.setLore(newLore);
|
meta.setLore(newLore);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,10 +120,6 @@ public class SheepShear implements Listener {
|
|||||||
String sheepShearedFormatted = toolStats.numberFormat.formatInt(sheepSheared);
|
String sheepShearedFormatted = toolStats.numberFormat.formatInt(sheepSheared);
|
||||||
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{sheep}", sheepShearedFormatted, "sheep-sheared");
|
List<String> newLore = toolStats.itemLore.addItemLore(meta, "{sheep}", sheepShearedFormatted, "sheep-sheared");
|
||||||
|
|
||||||
// if the list returned null, don't add it
|
|
||||||
if (newLore == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (toolStats.config.getBoolean("enabled.sheep-sheared")) {
|
if (toolStats.config.getBoolean("enabled.sheep-sheared")) {
|
||||||
meta.setLore(newLore);
|
meta.setLore(newLore);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,20 +66,21 @@ public class VillagerTrade implements Listener {
|
|||||||
if (event.getSlotType() == InventoryType.SlotType.RESULT) {
|
if (event.getSlotType() == InventoryType.SlotType.RESULT) {
|
||||||
ItemStack item = event.getCurrentItem();
|
ItemStack item = event.getCurrentItem();
|
||||||
// only check items we want
|
// only check items we want
|
||||||
if (ItemChecker.isValidItem(item.getType())) {
|
if (!ItemChecker.isValidItem(item.getType())) {
|
||||||
// if the player shift clicks, show the warning
|
return;
|
||||||
if (event.isShiftClick()) {
|
}
|
||||||
String configMessage = toolStats.config.getString("messages.shift-click-warning.trading");
|
// if the player shift clicks, show the warning
|
||||||
if (configMessage != null) {
|
if (event.isShiftClick()) {
|
||||||
event.getWhoClicked().sendMessage(ChatColor.translateAlternateColorCodes('&', configMessage));
|
String configMessage = toolStats.config.getString("messages.shift-click-warning.trading");
|
||||||
}
|
if (configMessage != null) {
|
||||||
}
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configMessage));
|
||||||
ItemStack newItem = addLore(item, player);
|
|
||||||
if (newItem != null) {
|
|
||||||
// this gets delayed since villager inventories suck for no reason
|
|
||||||
Bukkit.getScheduler().runTaskLater(toolStats, () -> event.setCurrentItem(newItem), 5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ItemStack newItem = addLore(item, player);
|
||||||
|
if (newItem != null) {
|
||||||
|
// set the new item
|
||||||
|
inventory.setItem(event.getSlot(), newItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import lol.hyper.toolstats.ToolStats;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ public class ItemLore {
|
|||||||
if (configLore == null || configLoreRaw == null) {
|
if (configLore == null || configLoreRaw == null) {
|
||||||
toolStats.logger.warning("There is no lore message for messages." + configLorePath + "!");
|
toolStats.logger.warning("There is no lore message for messages." + configLorePath + "!");
|
||||||
toolStats.logger.warning("Unable to update lore for item.");
|
toolStats.logger.warning("Unable to update lore for item.");
|
||||||
return null;
|
return itemMeta.getLore();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> newLore;
|
List<String> newLore;
|
||||||
@@ -112,13 +113,14 @@ public class ItemLore {
|
|||||||
case "TRADED": {
|
case "TRADED": {
|
||||||
dateCreated = toolStats.getLoreFromConfig("traded.traded-on", true);
|
dateCreated = toolStats.getLoreFromConfig("traded.traded-on", true);
|
||||||
itemOwner = toolStats.getLoreFromConfig("traded.traded-by", true);
|
itemOwner = toolStats.getLoreFromConfig("traded.traded-by", true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dateCreated == null || itemOwner == null) {
|
if (dateCreated == null || itemOwner == null) {
|
||||||
toolStats.logger.warning("There is no lore message for messages." + type.toLowerCase(Locale.ENGLISH) + "!");
|
toolStats.logger.warning("There is no lore message for messages." + type.toLowerCase(Locale.ENGLISH) + "!");
|
||||||
toolStats.logger.warning("Unable to update lore for item.");
|
toolStats.logger.warning("Unable to update lore for item.");
|
||||||
return null;
|
return itemMeta.getLore();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> newLore;
|
List<String> newLore;
|
||||||
|
|||||||
Reference in New Issue
Block a user