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>
|
||||
<artifactId>toolstats</artifactId>
|
||||
<version>1.6</version>
|
||||
<version>1.6.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ToolStats</name>
|
||||
@@ -51,7 +51,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
@@ -115,7 +115,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -127,13 +127,13 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.12.0</version>
|
||||
<version>4.13.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<version>4.3.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -55,6 +55,8 @@ public final class ToolStats extends JavaPlugin {
|
||||
public final NamespacedKey shearsSheared = new NamespacedKey(this, "sheared");
|
||||
// stores how much damage armor has 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
|
||||
public final NamespacedKey newElytra = new NamespacedKey(this, "new");
|
||||
|
||||
|
||||
@@ -86,11 +86,6 @@ public class BlocksMined implements Listener {
|
||||
String blocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
||||
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?
|
||||
if (toolStats.checkConfig(playerTool, "blocks-mined")) {
|
||||
meta.setLore(newLore);
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.bukkit.persistence.PersistentDataType;
|
||||
public class ChunkPopulate implements Listener {
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -55,21 +55,22 @@ public class ChunkPopulate implements Listener {
|
||||
Chunk chunk = event.getChunk();
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
// if there is a new item frame
|
||||
if (entity instanceof ItemFrame) {
|
||||
ItemFrame itemFrame = (ItemFrame) entity;
|
||||
// if the item frame has an elytra
|
||||
if (itemFrame.getItem().getType() == Material.ELYTRA) {
|
||||
ItemStack elytraCopy = itemFrame.getItem();
|
||||
ItemMeta meta = elytraCopy.getItemMeta();
|
||||
if (meta == null) {
|
||||
return;
|
||||
}
|
||||
// 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);
|
||||
if (!(entity instanceof ItemFrame)) {
|
||||
return;
|
||||
}
|
||||
ItemFrame itemFrame = (ItemFrame) entity;
|
||||
// if the item frame has an elytra
|
||||
if (itemFrame.getItem().getType() == Material.ELYTRA) {
|
||||
ItemStack elytraCopy = itemFrame.getItem();
|
||||
ItemMeta meta = elytraCopy.getItemMeta();
|
||||
if (meta == null) {
|
||||
return;
|
||||
}
|
||||
// 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);
|
||||
|
||||
@@ -249,11 +249,6 @@ public class EntityDamage implements Listener {
|
||||
String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||
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?
|
||||
if (toolStats.checkConfig(itemStack, "player-kills")) {
|
||||
meta.setLore(newLore);
|
||||
@@ -289,11 +284,6 @@ public class EntityDamage implements Listener {
|
||||
String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||
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?
|
||||
if (toolStats.checkConfig(itemStack, "mob-kills")) {
|
||||
meta.setLore(newLore);
|
||||
@@ -326,15 +316,11 @@ public class EntityDamage implements Listener {
|
||||
|
||||
damageTaken = damageTaken + damage;
|
||||
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken);
|
||||
container.set(toolStats.armorDamageInt, PersistentDataType.INTEGER, damageTaken.intValue());
|
||||
|
||||
String damageTakenFormatted = toolStats.numberFormat.formatDouble(damageTaken);
|
||||
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")) {
|
||||
meta.setLore(newLore);
|
||||
}
|
||||
@@ -370,11 +356,6 @@ public class EntityDamage implements Listener {
|
||||
String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||
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?
|
||||
if (toolStats.checkConfig(newTrident, "mob-kills")) {
|
||||
meta.setLore(newLore);
|
||||
@@ -412,11 +393,6 @@ public class EntityDamage implements Listener {
|
||||
String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||
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?
|
||||
if (toolStats.checkConfig(newTrident, "player-kills")) {
|
||||
meta.setLore(newLore);
|
||||
|
||||
@@ -85,11 +85,6 @@ public class EntityDeath implements Listener {
|
||||
|
||||
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")) {
|
||||
meta.setLore(newLore);
|
||||
}
|
||||
|
||||
@@ -128,11 +128,6 @@ public class PlayerFish implements Listener {
|
||||
String fishCaughtFormatted = toolStats.numberFormat.formatInt(fishCaught);
|
||||
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")) {
|
||||
meta.setLore(newLore);
|
||||
}
|
||||
|
||||
@@ -120,10 +120,6 @@ public class SheepShear implements Listener {
|
||||
String sheepShearedFormatted = toolStats.numberFormat.formatInt(sheepSheared);
|
||||
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")) {
|
||||
meta.setLore(newLore);
|
||||
}
|
||||
|
||||
@@ -66,20 +66,21 @@ public class VillagerTrade implements Listener {
|
||||
if (event.getSlotType() == InventoryType.SlotType.RESULT) {
|
||||
ItemStack item = event.getCurrentItem();
|
||||
// only check items we want
|
||||
if (ItemChecker.isValidItem(item.getType())) {
|
||||
// if the player shift clicks, show the warning
|
||||
if (event.isShiftClick()) {
|
||||
String configMessage = toolStats.config.getString("messages.shift-click-warning.trading");
|
||||
if (configMessage != null) {
|
||||
event.getWhoClicked().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);
|
||||
if (!ItemChecker.isValidItem(item.getType())) {
|
||||
return;
|
||||
}
|
||||
// if the player shift clicks, show the warning
|
||||
if (event.isShiftClick()) {
|
||||
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) {
|
||||
// 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 java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -47,7 +48,7 @@ public class ItemLore {
|
||||
if (configLore == null || configLoreRaw == null) {
|
||||
toolStats.logger.warning("There is no lore message for messages." + configLorePath + "!");
|
||||
toolStats.logger.warning("Unable to update lore for item.");
|
||||
return null;
|
||||
return itemMeta.getLore();
|
||||
}
|
||||
|
||||
List<String> newLore;
|
||||
@@ -112,13 +113,14 @@ public class ItemLore {
|
||||
case "TRADED": {
|
||||
dateCreated = toolStats.getLoreFromConfig("traded.traded-on", true);
|
||||
itemOwner = toolStats.getLoreFromConfig("traded.traded-by", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dateCreated == null || itemOwner == null) {
|
||||
toolStats.logger.warning("There is no lore message for messages." + type.toLowerCase(Locale.ENGLISH) + "!");
|
||||
toolStats.logger.warning("Unable to update lore for item.");
|
||||
return null;
|
||||
return itemMeta.getLore();
|
||||
}
|
||||
|
||||
List<String> newLore;
|
||||
|
||||
Reference in New Issue
Block a user