mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05200f075b | ||
|
|
9973d743a5 | ||
|
|
a89b9d6f6a | ||
|
|
082f529c32 | ||
|
|
05f940026f | ||
|
|
59d0295b18 | ||
|
|
af908f2eb6 | ||
|
|
c86e96e200 | ||
|
|
8061293810 | ||
|
|
656e265006 | ||
|
|
507813f106 | ||
|
|
e3e1c6a690 | ||
|
|
5eebcb9ff4 |
12
pom.xml
12
pom.xml
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<groupId>lol.hyper</groupId>
|
<groupId>lol.hyper</groupId>
|
||||||
<artifactId>toolstats</artifactId>
|
<artifactId>toolstats</artifactId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>ToolStats</name>
|
<name>ToolStats</name>
|
||||||
@@ -121,14 +121,8 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>lol.hyper</groupId>
|
<groupId>lol.hyper</groupId>
|
||||||
<artifactId>github-release-api</artifactId>
|
<artifactId>github-release-api</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.4</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
@@ -139,7 +133,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-platform-bukkit</artifactId>
|
<artifactId>adventure-platform-bukkit</artifactId>
|
||||||
<version>4.1.1</version>
|
<version>4.1.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (!sender.hasPermission("toolstats.use")) {
|
if (!sender.hasPermission("toolstats.command")) {
|
||||||
audiences.sender(sender).sendMessage(Component.text("You do not have permission for this command.").color(NamedTextColor.RED));
|
audiences.sender(sender).sendMessage(Component.text("You do not have permission for this command.").color(NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,15 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "reset": {
|
case "reset": {
|
||||||
|
if (!sender.hasPermission("toolstats.reset")) {
|
||||||
|
audiences.sender(sender).sendMessage(Component.text("You do not have permission for this command.").color(NamedTextColor.RED));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (args.length == 2 && args[1].equalsIgnoreCase("confirm")) {
|
if (args.length == 2 && args[1].equalsIgnoreCase("confirm")) {
|
||||||
|
if (!sender.hasPermission("toolstats.reset.confirm")) {
|
||||||
|
audiences.sender(sender).sendMessage(Component.text("You do not have permission for this command.").color(NamedTextColor.RED));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
if (heldItem.getType() == Material.AIR) {
|
if (heldItem.getType() == Material.AIR) {
|
||||||
@@ -263,13 +271,16 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (sender.hasPermission("toolstats.reload")) {
|
if (sender.hasPermission("toolstats.reload")) {
|
||||||
return Arrays.asList("reset", "reload");
|
return Arrays.asList("reset", "reload");
|
||||||
} else {
|
}
|
||||||
|
if (sender.hasPermission("toolstats.reset")) {
|
||||||
return Collections.singletonList("reset");
|
return Collections.singletonList("reset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
if (args[0].equalsIgnoreCase("reset")) {
|
if (args[0].equalsIgnoreCase("reset")) {
|
||||||
return Collections.singletonList("confirm");
|
if (sender.hasPermission("toolstats.reset.confirm")) {
|
||||||
|
return Collections.singletonList("confirm");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -70,17 +70,18 @@ public class BlocksMined implements Listener {
|
|||||||
}
|
}
|
||||||
// read the current stats from the item
|
// read the current stats from the item
|
||||||
// if they don't exist, then start from 0
|
// if they don't exist, then start from 0
|
||||||
Integer blocksMined = 0;
|
Integer blocksMined = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.genericMined, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.genericMined, PersistentDataType.INTEGER)) {
|
||||||
blocksMined = container.get(toolStats.genericMined, PersistentDataType.INTEGER);
|
blocksMined = container.get(toolStats.genericMined, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (blocksMined == null) {
|
if (blocksMined == null) {
|
||||||
return;
|
blocksMined = 0;
|
||||||
} else {
|
|
||||||
blocksMined++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blocksMined++;
|
||||||
container.set(toolStats.genericMined, PersistentDataType.INTEGER, blocksMined);
|
container.set(toolStats.genericMined, PersistentDataType.INTEGER, blocksMined);
|
||||||
|
|
||||||
String configLore = toolStats.getLoreFromConfig("blocks-mined", false);
|
String configLore = toolStats.getLoreFromConfig("blocks-mined", false);
|
||||||
String configLoreRaw = toolStats.getLoreFromConfig("blocks-mined", true);
|
String configLoreRaw = toolStats.getLoreFromConfig("blocks-mined", true);
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,18 @@ public class EntityDamage implements Listener {
|
|||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
||||||
|
|
||||||
|
// ignore void and /kill damage
|
||||||
|
EntityDamageEvent.DamageCause cause = event.getCause();
|
||||||
|
if (cause == EntityDamageEvent.DamageCause.SUICIDE || cause == EntityDamageEvent.DamageCause.VOID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// mob is going to die
|
// mob is going to die
|
||||||
if (livingEntity.getHealth() - event.getFinalDamage() <= 0) {
|
if (livingEntity.getHealth() - event.getFinalDamage() <= 0) {
|
||||||
// a player is killing something
|
// a player is killing something
|
||||||
@@ -141,6 +149,13 @@ public class EntityDamage implements Listener {
|
|||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore void and /kill damage
|
||||||
|
EntityDamageEvent.DamageCause cause = event.getCause();
|
||||||
|
if (cause == EntityDamageEvent.DamageCause.SUICIDE || cause == EntityDamageEvent.DamageCause.VOID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
||||||
// player is taken damage but not being killed
|
// player is taken damage but not being killed
|
||||||
if (livingEntity instanceof Player) {
|
if (livingEntity instanceof Player) {
|
||||||
@@ -164,6 +179,13 @@ public class EntityDamage implements Listener {
|
|||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore void and /kill damage
|
||||||
|
EntityDamageEvent.DamageCause cause = event.getCause();
|
||||||
|
if (cause == EntityDamageEvent.DamageCause.SUICIDE || cause == EntityDamageEvent.DamageCause.VOID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
||||||
// player is taken damage but not being killed
|
// player is taken damage but not being killed
|
||||||
if (livingEntity instanceof Player) {
|
if (livingEntity instanceof Player) {
|
||||||
@@ -194,16 +216,16 @@ public class EntityDamage implements Listener {
|
|||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Integer playerKills = 0;
|
Integer playerKills = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.swordPlayerKills, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.swordPlayerKills, PersistentDataType.INTEGER)) {
|
||||||
playerKills = container.get(toolStats.swordPlayerKills, PersistentDataType.INTEGER);
|
playerKills = container.get(toolStats.swordPlayerKills, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (playerKills == null) {
|
if (playerKills == null) {
|
||||||
return null;
|
playerKills = 0;
|
||||||
} else {
|
|
||||||
playerKills++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playerKills++;
|
||||||
container.set(toolStats.swordPlayerKills, PersistentDataType.INTEGER, playerKills);
|
container.set(toolStats.swordPlayerKills, PersistentDataType.INTEGER, playerKills);
|
||||||
|
|
||||||
String playerKillsLore = toolStats.getLoreFromConfig("kills.player", false);
|
String playerKillsLore = toolStats.getLoreFromConfig("kills.player", false);
|
||||||
@@ -257,16 +279,16 @@ public class EntityDamage implements Listener {
|
|||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Integer mobKills = 0;
|
Integer mobKills = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.swordMobKills, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.swordMobKills, PersistentDataType.INTEGER)) {
|
||||||
mobKills = container.get(toolStats.swordMobKills, PersistentDataType.INTEGER);
|
mobKills = container.get(toolStats.swordMobKills, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (mobKills == null) {
|
if (mobKills == null) {
|
||||||
return null;
|
mobKills = 0;
|
||||||
} else {
|
|
||||||
mobKills++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mobKills++;
|
||||||
container.set(toolStats.swordMobKills, PersistentDataType.INTEGER, mobKills);
|
container.set(toolStats.swordMobKills, PersistentDataType.INTEGER, mobKills);
|
||||||
|
|
||||||
String mobKillsLore = toolStats.getLoreFromConfig("kills.mob", false);
|
String mobKillsLore = toolStats.getLoreFromConfig("kills.mob", false);
|
||||||
@@ -319,16 +341,16 @@ public class EntityDamage implements Listener {
|
|||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Double damageTaken = 0.0;
|
Double damageTaken = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.armorDamage, PersistentDataType.DOUBLE)) {
|
if (container.has(toolStats.armorDamage, PersistentDataType.DOUBLE)) {
|
||||||
damageTaken = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
damageTaken = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
||||||
}
|
}
|
||||||
if (damageTaken == null) {
|
if (damageTaken == null) {
|
||||||
return;
|
damageTaken = 0.0;
|
||||||
} else {
|
|
||||||
damageTaken = damageTaken + damage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
damageTaken = damageTaken + damage;
|
||||||
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken);
|
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken);
|
||||||
|
|
||||||
String damageTakenLore = toolStats.getLoreFromConfig("damage-taken", false);
|
String damageTakenLore = toolStats.getLoreFromConfig("damage-taken", false);
|
||||||
|
|||||||
@@ -65,9 +65,11 @@ public class GenerateLoot implements Listener {
|
|||||||
// if the distance is less than 1, it's the same chest
|
// if the distance is less than 1, it's the same chest
|
||||||
for (Block chest : toolStats.playerInteract.openedChests.keySet()) {
|
for (Block chest : toolStats.playerInteract.openedChests.keySet()) {
|
||||||
Location chestLocation = chest.getLocation();
|
Location chestLocation = chest.getLocation();
|
||||||
double distance = lootLocation.distance(chestLocation);
|
if (chest.getWorld() == lootLocation.getWorld()) {
|
||||||
if (distance <= 1.0) {
|
double distance = lootLocation.distance(chestLocation);
|
||||||
openedChest = chest;
|
if (distance <= 1.0) {
|
||||||
|
openedChest = chest;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ignore if the chest is not in the same location
|
// ignore if the chest is not in the same location
|
||||||
|
|||||||
@@ -82,16 +82,16 @@ public class PlayerFish implements Listener {
|
|||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer fishCaught = 0;
|
Integer fishCaught = null;
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
if (container.has(toolStats.fishingRodCaught, PersistentDataType.INTEGER)) {
|
if (container.has(toolStats.fishingRodCaught, PersistentDataType.INTEGER)) {
|
||||||
fishCaught = container.get(toolStats.fishingRodCaught, PersistentDataType.INTEGER);
|
fishCaught = container.get(toolStats.fishingRodCaught, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (fishCaught == null) {
|
if (fishCaught == null) {
|
||||||
return;
|
fishCaught = 0;
|
||||||
} else {
|
|
||||||
fishCaught++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fishCaught++;
|
||||||
container.set(toolStats.fishingRodCaught, PersistentDataType.INTEGER, fishCaught);
|
container.set(toolStats.fishingRodCaught, PersistentDataType.INTEGER, fishCaught);
|
||||||
|
|
||||||
String fishCaughtLore = toolStats.getLoreFromConfig("fished.fish-caught", false);
|
String fishCaughtLore = toolStats.getLoreFromConfig("fished.fish-caught", false);
|
||||||
|
|||||||
@@ -84,10 +84,10 @@ public class SheepShear implements Listener {
|
|||||||
sheepSheared = container.get(toolStats.shearsSheared, PersistentDataType.INTEGER);
|
sheepSheared = container.get(toolStats.shearsSheared, PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
if (sheepSheared == null) {
|
if (sheepSheared == null) {
|
||||||
return;
|
sheepSheared = 0;
|
||||||
} else {
|
|
||||||
sheepSheared++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sheepSheared++;
|
||||||
container.set(toolStats.shearsSheared, PersistentDataType.INTEGER, sheepSheared);
|
container.set(toolStats.shearsSheared, PersistentDataType.INTEGER, sheepSheared);
|
||||||
|
|
||||||
String sheepShearedLore = toolStats.getLoreFromConfig("sheep-sheared", false);
|
String sheepShearedLore = toolStats.getLoreFromConfig("sheep-sheared", false);
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ public class VillagerTrade implements Listener {
|
|||||||
if (newItem != null) {
|
if (newItem != null) {
|
||||||
// this gets delayed since villager inventories suck for no reason
|
// this gets delayed since villager inventories suck for no reason
|
||||||
Bukkit.getScheduler().runTaskLater(toolStats, () -> event.setCurrentItem(newItem), 5);
|
Bukkit.getScheduler().runTaskLater(toolStats, () -> event.setCurrentItem(newItem), 5);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,17 @@ description: Track various tool stats!
|
|||||||
commands:
|
commands:
|
||||||
toolstats:
|
toolstats:
|
||||||
usage: /toolstats
|
usage: /toolstats
|
||||||
description: Main command.
|
permission: toolstats.command
|
||||||
permission: toolstats.main
|
|
||||||
permissions:
|
permissions:
|
||||||
toolstats.main:
|
toolstats.command:
|
||||||
description: Allows the usage of /toolstats
|
description: Allows the usage of /toolstats.
|
||||||
default: true
|
default: true
|
||||||
toolstats.reload:
|
toolstats.reload:
|
||||||
description: Allows the usage of /toolstats reload
|
description: Allows the usage of /toolstats reload.
|
||||||
default: op
|
default: op
|
||||||
|
toolstats.reset:
|
||||||
|
description: Allows the usage of /toolstats reset.
|
||||||
|
default: true
|
||||||
|
toolstats.reset.confirm:
|
||||||
|
description: Allows the usage of /toolstats reset confirm.
|
||||||
|
default: true
|
||||||
Reference in New Issue
Block a user