mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3766db3454 | ||
|
|
5a5e29c5e2 | ||
|
|
d188877f18 | ||
|
|
05200f075b | ||
|
|
9973d743a5 | ||
|
|
a89b9d6f6a | ||
|
|
082f529c32 | ||
|
|
05f940026f |
@@ -1,11 +1,9 @@
|
||||
<h1 align="center">ToolStats</h1>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/Minecraft-1.15--1.19-orange" alt="Minecraft versions">
|
||||
<img src="https://img.shields.io/badge/Minecraft-1.15--1.19.2-orange" alt="Minecraft versions">
|
||||
<img src="https://img.shields.io/github/v/release/hyperdefined/ToolStats" alt="GitHub release (latest by date)">
|
||||
<a href="https://github.com/hyperdefined/ToolStats/releases"><img src="https://img.shields.io/github/downloads/hyperdefined/ToolStats/total?logo=github" alt="Downloads"></a>
|
||||
<a href="https://en.cryptobadges.io/donate/1F29aNKQzci3ga5LDcHHawYzFPXvELTFoL"><img src="https://en.cryptobadges.io/badge/micro/1F29aNKQzci3ga5LDcHHawYzFPXvELTFoL" alt="Donate with Bitcoin"></a>
|
||||
<a href="https://en.cryptobadges.io/donate/0xF3b4e87E4c11f586949ca8740eD33A1e473F924c"><img src="https://en.cryptobadges.io/badge/micro/0xF3b4e87E4c11f586949ca8740eD33A1e473F924c" alt="Donate with Ethereum"></a>
|
||||
<a href="https://ko-fi.com/hyperdefined"><img src="https://img.shields.io/badge/Donate-Ko--fi-red" alt="Donate via Ko-fi"></a>
|
||||
<a href="https://www.gnu.org/licenses/gpl-3.0"><img src="https://img.shields.io/badge/License-GPLv3-blue.svg" alt="License: GPL v3"></a>
|
||||
<a href="https://wakatime.com/badge/user/992a7647-176a-477c-8086-e1abfba87ff4/project/0200f07a-f303-4103-a5f2-34b38c9c1fa4"><img src="https://wakatime.com/badge/user/992a7647-176a-477c-8086-e1abfba87ff4/project/0200f07a-f303-4103-a5f2-34b38c9c1fa4.svg" alt="wakatime"></a>
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -23,7 +23,7 @@
|
||||
|
||||
<groupId>lol.hyper</groupId>
|
||||
<artifactId>toolstats</artifactId>
|
||||
<version>1.4.3</version>
|
||||
<version>1.4.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ToolStats</name>
|
||||
|
||||
@@ -271,13 +271,16 @@ public class CommandToolStats implements TabExecutor {
|
||||
if (args.length == 1) {
|
||||
if (sender.hasPermission("toolstats.reload")) {
|
||||
return Arrays.asList("reset", "reload");
|
||||
} else {
|
||||
}
|
||||
if (sender.hasPermission("toolstats.reset")) {
|
||||
return Collections.singletonList("reset");
|
||||
}
|
||||
}
|
||||
if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
return Collections.singletonList("confirm");
|
||||
if (sender.hasPermission("toolstats.reset.confirm")) {
|
||||
return Collections.singletonList("confirm");
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -70,17 +70,18 @@ public class BlocksMined implements Listener {
|
||||
}
|
||||
// read the current stats from the item
|
||||
// if they don't exist, then start from 0
|
||||
Integer blocksMined = 0;
|
||||
Integer blocksMined = null;
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
if (container.has(toolStats.genericMined, PersistentDataType.INTEGER)) {
|
||||
blocksMined = container.get(toolStats.genericMined, PersistentDataType.INTEGER);
|
||||
}
|
||||
if (blocksMined == null) {
|
||||
return;
|
||||
} else {
|
||||
blocksMined++;
|
||||
blocksMined = 0;
|
||||
}
|
||||
|
||||
blocksMined++;
|
||||
container.set(toolStats.genericMined, PersistentDataType.INTEGER, blocksMined);
|
||||
|
||||
String configLore = toolStats.getLoreFromConfig("blocks-mined", false);
|
||||
String configLoreRaw = toolStats.getLoreFromConfig("blocks-mined", true);
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class EntityDamage implements Listener {
|
||||
|
||||
private final ToolStats toolStats;
|
||||
public final Set<UUID> trackedMobs = new HashSet<>();
|
||||
private final List<EntityDamageEvent.DamageCause> ignoredCauses = Arrays.asList(EntityDamageEvent.DamageCause.SUICIDE, EntityDamageEvent.DamageCause.VOID, EntityDamageEvent.DamageCause.CUSTOM);
|
||||
|
||||
public EntityDamage(ToolStats toolStats) {
|
||||
this.toolStats = toolStats;
|
||||
@@ -49,10 +50,18 @@ public class EntityDamage implements Listener {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
||||
|
||||
// ignore void and /kill damage
|
||||
EntityDamageEvent.DamageCause cause = event.getCause();
|
||||
if (ignoredCauses.contains(cause)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// mob is going to die
|
||||
if (livingEntity.getHealth() - event.getFinalDamage() <= 0) {
|
||||
// a player is killing something
|
||||
@@ -141,6 +150,13 @@ public class EntityDamage implements Listener {
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ignore void and /kill damage
|
||||
EntityDamageEvent.DamageCause cause = event.getCause();
|
||||
if (ignoredCauses.contains(cause)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
||||
// player is taken damage but not being killed
|
||||
if (livingEntity instanceof Player) {
|
||||
@@ -164,6 +180,13 @@ public class EntityDamage implements Listener {
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ignore void and /kill damage
|
||||
EntityDamageEvent.DamageCause cause = event.getCause();
|
||||
if (ignoredCauses.contains(cause)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
||||
// player is taken damage but not being killed
|
||||
if (livingEntity instanceof Player) {
|
||||
@@ -194,16 +217,16 @@ public class EntityDamage implements Listener {
|
||||
if (meta == null) {
|
||||
return null;
|
||||
}
|
||||
Integer playerKills = 0;
|
||||
Integer playerKills = null;
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
if (container.has(toolStats.swordPlayerKills, PersistentDataType.INTEGER)) {
|
||||
playerKills = container.get(toolStats.swordPlayerKills, PersistentDataType.INTEGER);
|
||||
}
|
||||
if (playerKills == null) {
|
||||
return null;
|
||||
} else {
|
||||
playerKills++;
|
||||
playerKills = 0;
|
||||
}
|
||||
|
||||
playerKills++;
|
||||
container.set(toolStats.swordPlayerKills, PersistentDataType.INTEGER, playerKills);
|
||||
|
||||
String playerKillsLore = toolStats.getLoreFromConfig("kills.player", false);
|
||||
@@ -257,16 +280,16 @@ public class EntityDamage implements Listener {
|
||||
if (meta == null) {
|
||||
return null;
|
||||
}
|
||||
Integer mobKills = 0;
|
||||
Integer mobKills = null;
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
if (container.has(toolStats.swordMobKills, PersistentDataType.INTEGER)) {
|
||||
mobKills = container.get(toolStats.swordMobKills, PersistentDataType.INTEGER);
|
||||
}
|
||||
if (mobKills == null) {
|
||||
return null;
|
||||
} else {
|
||||
mobKills++;
|
||||
mobKills = 0;
|
||||
}
|
||||
|
||||
mobKills++;
|
||||
container.set(toolStats.swordMobKills, PersistentDataType.INTEGER, mobKills);
|
||||
|
||||
String mobKillsLore = toolStats.getLoreFromConfig("kills.mob", false);
|
||||
@@ -319,16 +342,16 @@ public class EntityDamage implements Listener {
|
||||
if (meta == null) {
|
||||
return;
|
||||
}
|
||||
Double damageTaken = 0.0;
|
||||
Double damageTaken = null;
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
if (container.has(toolStats.armorDamage, PersistentDataType.DOUBLE)) {
|
||||
damageTaken = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
||||
}
|
||||
if (damageTaken == null) {
|
||||
return;
|
||||
} else {
|
||||
damageTaken = damageTaken + damage;
|
||||
damageTaken = 0.0;
|
||||
}
|
||||
|
||||
damageTaken = damageTaken + damage;
|
||||
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken);
|
||||
|
||||
String damageTakenLore = toolStats.getLoreFromConfig("damage-taken", false);
|
||||
|
||||
@@ -82,16 +82,16 @@ public class PlayerFish implements Listener {
|
||||
if (meta == null) {
|
||||
return;
|
||||
}
|
||||
Integer fishCaught = 0;
|
||||
Integer fishCaught = null;
|
||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||
if (container.has(toolStats.fishingRodCaught, PersistentDataType.INTEGER)) {
|
||||
fishCaught = container.get(toolStats.fishingRodCaught, PersistentDataType.INTEGER);
|
||||
}
|
||||
if (fishCaught == null) {
|
||||
return;
|
||||
} else {
|
||||
fishCaught++;
|
||||
fishCaught = 0;
|
||||
}
|
||||
|
||||
fishCaught++;
|
||||
container.set(toolStats.fishingRodCaught, PersistentDataType.INTEGER, fishCaught);
|
||||
|
||||
String fishCaughtLore = toolStats.getLoreFromConfig("fished.fish-caught", false);
|
||||
|
||||
@@ -84,10 +84,10 @@ public class SheepShear implements Listener {
|
||||
sheepSheared = container.get(toolStats.shearsSheared, PersistentDataType.INTEGER);
|
||||
}
|
||||
if (sheepSheared == null) {
|
||||
return;
|
||||
} else {
|
||||
sheepSheared++;
|
||||
sheepSheared = 0;
|
||||
}
|
||||
|
||||
sheepSheared++;
|
||||
container.set(toolStats.shearsSheared, PersistentDataType.INTEGER, sheepSheared);
|
||||
|
||||
String sheepShearedLore = toolStats.getLoreFromConfig("sheep-sheared", false);
|
||||
|
||||
@@ -78,7 +78,6 @@ public class VillagerTrade implements Listener {
|
||||
if (newItem != null) {
|
||||
// this gets delayed since villager inventories suck for no reason
|
||||
Bukkit.getScheduler().runTaskLater(toolStats, () -> event.setCurrentItem(newItem), 5);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user