mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2026-04-22 19:11:23 +00:00
Compare commits
3 Commits
11d6a5bf91
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b10ed61ae | ||
|
|
a881f60ed8 | ||
|
|
bdef9453c7 |
45
README.md
45
README.md
@@ -10,11 +10,12 @@
|
||||
<a href="https://patreon.com/hyperdefined"><img alt="patreon-singular" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/donate/patreon-singular_vector.svg"></a>
|
||||
</p>
|
||||
|
||||
ToolStats is a Paper plugin that display various stats about tools. This plugin is inspired off of [GearStats](https://www.spigotmc.org/resources/gearstats.12960/). You can either track all statistics by default, or a use a token system to add statistics to tool/armor. You can configure how each statistic is shown on the item, or disable it!
|
||||
ToolStats is a Paper plugin that displays various stats about tools. This plugin is inspired off of [GearStats](https://www.spigotmc.org/resources/gearstats.12960/). You can either track all statistics by default, or a use a token system to add statistics to tool/armor. You can configure how each statistic is shown on the item, or disable it!
|
||||
|
||||
Here is everything it tracks:
|
||||
|
||||
* Blocks mined (pickaxes, shovels, axes, hoes, shears).
|
||||
* Crops mined (hoes).
|
||||
* Crops harvested (hoes).
|
||||
* Player/mob kills (swords, axes, tridents, bows/crossbows, mace).
|
||||
* Ownership of items when crafted, looted (from chests/vaults/barrels), traded, spawned via creative, and caught from fishing.
|
||||
* Armor damage taken (shields too).
|
||||
@@ -30,24 +31,34 @@ Here is everything it tracks:
|
||||
The best part is, this data is stored on the item itself.
|
||||
|
||||
This plugin also has compatibility for:
|
||||
|
||||
* [RoseStacker](https://modrinth.com/plugin/rosestacker)
|
||||
|
||||
If item lore is ever incorrect/missing, you can run `/toolstats reset`. This command fixes the lore on whatever item you are holding.
|
||||
You can see some of the stats below as examples:
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
| Crafted Origin | Player/Mob Kills | Fish Caught |
|
||||
|---|---|---|
|
||||
|  |  |  |
|
||||
|
||||
| Sheep Sheared | Dropped By | Damage Taken |
|
||||
|---|---|---|
|
||||
|  |  |  |
|
||||
|
||||
| Mob Kills | Elytra | Looted Origin |
|
||||
|---|---|---|
|
||||
|  |  |  |
|
||||
|
||||
| Traded Origin | Spawned Origin | Raw NBT Data |
|
||||
|---|---|---|
|
||||
|  |  |  |
|
||||
|
||||
| Crops Harvested | Flight Time | Arrows Shot |
|
||||
|---|---|---|
|
||||
|  |  |  |
|
||||
|
||||
| Critical Strikes | Trident Throws | Logs Stripped |
|
||||
|---|---|---|
|
||||
|  |  |  |
|
||||
|
||||
## Documentation
|
||||
Visit the [wiki](https://docs.hyper.lol/plugins/toolstats/about/) for help.
|
||||
|
||||
@@ -20,7 +20,7 @@ dependencies {
|
||||
}
|
||||
|
||||
group = "lol.hyper"
|
||||
version = "2.0.3"
|
||||
version = "2.0.4"
|
||||
description = "ToolStats"
|
||||
java.sourceCompatibility = JavaVersion.VERSION_25
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
@@ -227,6 +228,29 @@ public class CommandToolStats implements BasicCommand {
|
||||
}
|
||||
return;
|
||||
}
|
||||
case "add": {
|
||||
if (!sender.hasPermission("toolstats.add")) {
|
||||
sender.sendMessage(Component.text("You do not have permission for this command.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage(Component.text("You must be a player for this command.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
// Make sure /toolstats add <stat> is present
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(Component.text("Invalid syntax. Usage: /toolstats add <stat>", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
//Make sure they typed in a valid stat
|
||||
String stat = args[1];
|
||||
if (!toolStats.tokenData.getTokenTypes().contains(stat)) {
|
||||
sender.sendMessage(Component.text("That is not a valid stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
addStat(stat, (Player) sender);
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
sender.sendMessage(Component.text("Invalid sub-command.", NamedTextColor.RED));
|
||||
}
|
||||
@@ -449,6 +473,169 @@ public class CommandToolStats implements BasicCommand {
|
||||
target.getInventory().addItem(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a stat to an item, setting it to zero.
|
||||
* @param stat The stat to add.
|
||||
* @param player The player running the command.
|
||||
*/
|
||||
private void addStat(String stat, Player player) {
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
ItemStack heldItem = playerInventory.getItemInMainHand();
|
||||
ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||
if (heldItemMeta == null) {
|
||||
return;
|
||||
}
|
||||
if (toolStats.itemChecker.checkTokens(heldItemMeta.getPersistentDataContainer(), stat)) {
|
||||
player.sendMessage(Component.text("This item already has this stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
if (stat.equalsIgnoreCase("remove") || stat.equalsIgnoreCase("reset")) {
|
||||
player.sendMessage(Component.text("That is not a valid stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack newItem = toolStats.itemChecker.addToken(heldItem, stat);
|
||||
switch (stat) {
|
||||
case "crops-mined": {
|
||||
if (toolStats.config.getBoolean("enabled.crops-harvested")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateCropsMined(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "blocks-mined": {
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "blocks-mined")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateBlocksMined(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "damage-taken": {
|
||||
if (toolStats.config.getBoolean("enabled.armor-damage")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateArmorDamage(newItem, 0.0, false));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "damage-done": {
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "damage-done")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateWeaponDamage(newItem, 0.0, false));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "mob-kills": {
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "mob-kills")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateMobKills(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "player-kills": {
|
||||
if (toolStats.configTools.checkConfig(newItem.getType(), "player-kills")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updatePlayerKills(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "arrows-shot": {
|
||||
if (toolStats.config.getBoolean("enabled.arrows-shot")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateArrowsShot(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sheep-sheared": {
|
||||
if (toolStats.config.getBoolean("enabled.sheep-sheared")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateSheepSheared(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "flight-time": {
|
||||
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateFlightTime(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "fish-caught": {
|
||||
if (toolStats.config.getBoolean("enabled.fish-caught")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateFishCaught(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "wither-kills": {
|
||||
if (toolStats.config.getBoolean("enabled.bosses-killed.wither")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateBossesKilled(newItem, 0, "wither"));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "enderdragon-kills": {
|
||||
if (toolStats.config.getBoolean("enabled.bosses-killed.enderdragon")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateBossesKilled(newItem, 0, "enderdragon"));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "critical-strikes": {
|
||||
if (toolStats.config.getBoolean("enabled.critical-strikes")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateCriticalStrikes(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "trident-throws": {
|
||||
if (toolStats.config.getBoolean("enabled.trident-throws")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateTridentThrows(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "logs-stripped": {
|
||||
if (toolStats.config.getBoolean("enabled.logs-stripped")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateLogsStripped(newItem, 0));
|
||||
} else {
|
||||
player.sendMessage(Component.text("This stat is disabled.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
player.sendMessage(Component.text(stat + " has been added!", NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle edit subcommand.
|
||||
*
|
||||
@@ -969,6 +1156,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -997,6 +1185,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1025,6 +1214,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1053,6 +1243,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1081,6 +1272,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1109,6 +1301,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1137,6 +1330,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1166,6 +1360,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1194,6 +1389,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1222,6 +1418,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1250,6 +1447,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1278,6 +1476,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1306,6 +1505,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1334,6 +1534,7 @@ public class CommandToolStats implements BasicCommand {
|
||||
editedItemMeta.lore(newLore);
|
||||
} else {
|
||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1347,6 +1548,8 @@ public class CommandToolStats implements BasicCommand {
|
||||
player.sendMessage(Component.text("Removed stat " + stat + " for held item!", NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public @NonNull Collection<String> suggest(@NonNull CommandSourceStack source, String[] args) {
|
||||
CommandSender sender = source.getSender();
|
||||
@@ -1371,6 +1574,9 @@ public class CommandToolStats implements BasicCommand {
|
||||
if (sender.hasPermission("toolstats.purge")) {
|
||||
suggestions.add("purge");
|
||||
}
|
||||
if (sender.hasPermission("toolstats.add")) {
|
||||
suggestions.add("add");
|
||||
}
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
@@ -1392,6 +1598,15 @@ public class CommandToolStats implements BasicCommand {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// suggest keys for add
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("add") && sender.hasPermission("toolstats.add")) {
|
||||
// yes I am lazy
|
||||
return toolStats.tokenData.getTokenTypes().stream()
|
||||
.filter(s -> !s.equals("remove") && !s.equals("reset"))
|
||||
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// suggest keys for remove
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("remove") && sender.hasPermission("toolstats.remove")) {
|
||||
// yes I am lazy
|
||||
|
||||
@@ -69,10 +69,6 @@ public class RoseStacker {
|
||||
difference = before;
|
||||
}
|
||||
|
||||
toolStats.logger.info("before: {}", before);
|
||||
toolStats.logger.info("after: {}", after);
|
||||
toolStats.logger.info("difference: {}", difference);
|
||||
|
||||
callback.accept(difference);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ permissions:
|
||||
toolstats.remove:
|
||||
description: Allows the usage of /toolstats remove.
|
||||
default: op
|
||||
toolstats.add:
|
||||
description: Allows the usage of /toolstats add.
|
||||
default: op
|
||||
|
||||
dependencies:
|
||||
server:
|
||||
|
||||
Reference in New Issue
Block a user