mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
Compare commits
7 Commits
1.9.4
...
1e4e963fe1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e4e963fe1 | ||
|
|
298a8dd592 | ||
|
|
49a3c03f94 | ||
|
|
ecd241ac52 | ||
|
|
5a1be37339 | ||
|
|
a07782df5b | ||
|
|
31123fdfd5 |
2
pom.xml
2
pom.xml
@@ -23,7 +23,7 @@
|
||||
|
||||
<groupId>lol.hyper</groupId>
|
||||
<artifactId>toolstats</artifactId>
|
||||
<version>1.9.4</version>
|
||||
<version>1.9.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ToolStats</name>
|
||||
|
||||
@@ -367,6 +367,14 @@ public class CommandToolStats implements TabExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toolStats.configTools.checkConfig(original.getType(), "damage-done")) {
|
||||
if (container.has(toolStats.damageDone, PersistentDataType.DOUBLE)) {
|
||||
Double damage = container.get(toolStats.damageDone, PersistentDataType.DOUBLE);
|
||||
if (damage != null) {
|
||||
lore.add(toolStats.configTools.formatLore("damage-done", "{damage}", toolStats.numberFormat.formatDouble(damage)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toolStats.config.getBoolean("enabled.arrows-shot")) {
|
||||
if (container.has(toolStats.arrowsShot, PersistentDataType.INTEGER)) {
|
||||
Integer arrows = container.get(toolStats.arrowsShot, PersistentDataType.INTEGER);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PlayerMove implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onCraft(PlayerMoveEvent event) {
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
// player starts to fly
|
||||
if (player.isGliding()) {
|
||||
|
||||
@@ -27,10 +27,7 @@ import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemChecker {
|
||||
|
||||
@@ -343,6 +340,26 @@ public class ItemChecker {
|
||||
return String.join(",", tokens);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a given token from a list of tokens.
|
||||
*
|
||||
* @param appliedTokens The tokens on the item.
|
||||
* @param toRemove The token to remove.
|
||||
* @return The list of tokens.
|
||||
*/
|
||||
public List<String> removeToken(String appliedTokens, String toRemove) {
|
||||
// remove the tokens if they exist
|
||||
List<String> tokenList = new ArrayList<>(Arrays.asList(appliedTokens.split(",")));
|
||||
tokenList.remove(toRemove);
|
||||
|
||||
if (tokenList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return tokenList;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a given container has our keys for stats.
|
||||
*
|
||||
|
||||
@@ -252,6 +252,21 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.cropsHarvested);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "crops-mined");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
String oldCropsMinedFormatted = toolStats.numberFormat.formatInt(cropsMined);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("crops-harvested", "{crops}", oldCropsMinedFormatted);
|
||||
@@ -335,6 +350,21 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.blocksMined);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "blocks-mined");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
String oldBlocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("blocks-mined", "{blocks}", oldBlocksMinedFormatted);
|
||||
@@ -419,6 +449,21 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.playerKills);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "player-kills");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
String oldPlayerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("player-kills", "{kills}", oldPlayerKillsFormatted);
|
||||
@@ -502,6 +547,21 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.mobKills);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "mob-kills");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
String oldMobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("mob-kills", "{kills}", oldMobKillsFormatted);
|
||||
@@ -593,6 +653,21 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.armorDamage);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "damage-taken");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
String oldDamageTakenFormatted = toolStats.numberFormat.formatDouble(armorDamage);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("damage-taken", "{damage}", oldDamageTakenFormatted);
|
||||
@@ -684,6 +759,21 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.damageDone);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "damage-done");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
String oldDamageDoneFormatted = toolStats.numberFormat.formatDouble(damageDone);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("damage-done", "{damage}", oldDamageDoneFormatted);
|
||||
@@ -767,12 +857,28 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.flightTime);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "flight-time");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
// if the old format is in the config, check to see if the old format is on the elytra
|
||||
if (toolStats.config.getString("messages.flight-time-old") != null) {
|
||||
String oldFormatFormatted = toolStats.numberFormat.formatDouble((double) flightTime / 1000);
|
||||
Component oldFormat = toolStats.configTools.formatLore("flight-time-old", "{time}", oldFormatFormatted);
|
||||
meta.lore(removeLore(meta.lore(), oldFormat));
|
||||
List<Component> newLore = removeLore(meta.lore(), oldFormat);
|
||||
meta.lore(newLore);
|
||||
}
|
||||
|
||||
Map<String, String> oldFlightTimeFormatted = toolStats.numberFormat.formatTime(flightTime);
|
||||
@@ -827,9 +933,11 @@ public class ItemLore {
|
||||
Map<String, String> newFlightFormatted = toolStats.numberFormat.formatTime(flightTime + duration);
|
||||
// if the old format is in the config, check to see if the old format is on the elytra
|
||||
if (toolStats.config.getString("messages.flight-time-old") != null) {
|
||||
String oldFormatFormatted = toolStats.numberFormat.formatDouble((double) flightTime / 1000);
|
||||
Component oldFormat = toolStats.configTools.formatLore("flight-time-old", "{time}", oldFormatFormatted);
|
||||
meta.lore(removeLore(meta.lore(), oldFormat));
|
||||
if (meta.hasLore()) {
|
||||
String oldFormatFormatted = toolStats.numberFormat.formatDouble((double) flightTime / 1000);
|
||||
Component oldFormat = toolStats.configTools.formatLore("flight-time-old", "{time}", oldFormatFormatted);
|
||||
meta.lore(removeLore(meta.lore(), oldFormat));
|
||||
}
|
||||
}
|
||||
Component oldLine = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", oldFlightFormatted);
|
||||
Component newLine = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", newFlightFormatted);
|
||||
@@ -865,6 +973,21 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.sheepSheared);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "sheep-sheared");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
String oldSheepShearedFormatted = toolStats.numberFormat.formatDouble(sheepSheared);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("sheep-sheared", "{sheep}", oldSheepShearedFormatted);
|
||||
@@ -948,6 +1071,21 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.arrowsShot);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "arrows-shot");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
String oldArrowsShotFormatted = toolStats.numberFormat.formatDouble(arrowsShot);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("arrows-shot", "{arrows}", oldArrowsShotFormatted);
|
||||
@@ -1033,6 +1171,21 @@ public class ItemLore {
|
||||
return null;
|
||||
}
|
||||
container.remove(toolStats.fishCaught);
|
||||
// remove the applied token if this stat is disabled
|
||||
if (container.has(toolStats.tokenApplied)) {
|
||||
String appliedTokens = container.get(toolStats.tokenApplied, PersistentDataType.STRING);
|
||||
if (appliedTokens != null) {
|
||||
// remove the token from the list
|
||||
// if the list is empty, remove the PDC
|
||||
// otherwise set the PDC back with the new list
|
||||
List<String> newTokens = toolStats.itemChecker.removeToken(appliedTokens, "fish-caught");
|
||||
if (!newTokens.isEmpty()) {
|
||||
container.set(toolStats.tokenApplied, PersistentDataType.STRING, String.join(",", newTokens));
|
||||
} else {
|
||||
container.remove(toolStats.tokenApplied);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
String oldFishCaught = toolStats.numberFormat.formatDouble(fishCaught);
|
||||
Component lineToRemove = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", oldFishCaught);
|
||||
|
||||
Reference in New Issue
Block a user