mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
227723fe10 | ||
|
|
785333e8d1 | ||
|
|
bc784b8d46 | ||
|
|
f5ddada892 |
2
pom.xml
2
pom.xml
@@ -23,7 +23,7 @@
|
||||
|
||||
<groupId>lol.hyper</groupId>
|
||||
<artifactId>toolstats</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<version>1.8.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ToolStats</name>
|
||||
|
||||
@@ -367,8 +367,8 @@ public class EntityDamage implements Listener {
|
||||
|
||||
// do we add the lore based on the config?
|
||||
if (toolStats.configTools.checkConfig(newTrident.getType(), "mob-kills")) {
|
||||
String oldMobKillsFormatted = toolStats.numberFormat.formatDouble(mobKills);
|
||||
String newMobKillsFormatted = toolStats.numberFormat.formatDouble(mobKills + 1);
|
||||
String oldMobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||
String newMobKillsFormatted = toolStats.numberFormat.formatInt(mobKills + 1);
|
||||
String oldLine = toolStats.configTools.formatLore("kills.mob", "{kills}", oldMobKillsFormatted);
|
||||
String newLine = toolStats.configTools.formatLore("kills.mob", "{kills}", newMobKillsFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
@@ -408,8 +408,8 @@ public class EntityDamage implements Listener {
|
||||
|
||||
// do we add the lore based on the config?
|
||||
if (toolStats.configTools.checkConfig(newTrident.getType(), "player-kills")) {
|
||||
String oldPlayerKillsFormatted = toolStats.numberFormat.formatDouble(playerKills);
|
||||
String newPlayerKillsFormatted = toolStats.numberFormat.formatDouble(playerKills + 1);
|
||||
String oldPlayerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||
String newPlayerKillsFormatted = toolStats.numberFormat.formatInt(playerKills + 1);
|
||||
String oldLine = toolStats.configTools.formatLore("kills.player", "{kills}", oldPlayerKillsFormatted);
|
||||
String newLine = toolStats.configTools.formatLore("kills.player", "{kills}", newPlayerKillsFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
|
||||
@@ -86,13 +86,14 @@ public class PlayerMove implements Listener {
|
||||
}
|
||||
|
||||
// get the duration of the flight
|
||||
long duration = (System.currentTimeMillis() - startTime) + flightTime;
|
||||
long duration = (System.currentTimeMillis() - startTime);
|
||||
double newDuration = flightTime + duration;
|
||||
container.set(toolStats.flightTime, PersistentDataType.LONG, flightTime + duration);
|
||||
|
||||
// do we add the lore based on the config?
|
||||
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
||||
String oldFlightFormatted = toolStats.numberFormat.formatDouble((double) flightTime / 1000);
|
||||
String newFlightFormatted = toolStats.numberFormat.formatDouble((double) (flightTime + duration) / 1000);
|
||||
String newFlightFormatted = toolStats.numberFormat.formatDouble(newDuration / 1000);
|
||||
String oldLine = toolStats.configTools.formatLore("flight-time", "{time}", oldFlightFormatted);
|
||||
String newLine = toolStats.configTools.formatLore("flight-time", "{time}", newFlightFormatted);
|
||||
if (oldLine == null || newLine == null) {
|
||||
|
||||
@@ -24,13 +24,10 @@ import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ItemLore {
|
||||
|
||||
private final ToolStats toolStats;
|
||||
public static final Pattern COLOR_CODES = Pattern.compile("[&§]([0-9a-fk-or])");
|
||||
public static final Pattern HEX_PATTERN = Pattern.compile("[&§]#([A-Fa-f0-9]{6})");
|
||||
|
||||
public ItemLore(ToolStats toolStats) {
|
||||
this.toolStats = toolStats;
|
||||
|
||||
@@ -18,15 +18,18 @@
|
||||
package lol.hyper.toolstats.tools.config;
|
||||
|
||||
import lol.hyper.toolstats.ToolStats;
|
||||
import lol.hyper.toolstats.tools.ItemLore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ConfigTools {
|
||||
|
||||
private final ToolStats toolStats;
|
||||
public static final Pattern COLOR_CODES = Pattern.compile("[&§]([0-9a-fk-or])");
|
||||
public static final Pattern CONFIG_HEX_PATTERN = Pattern.compile("[&§]#([A-Fa-f0-9]{6})");
|
||||
public static final Pattern MINECRAFT_HEX_PATTERN = Pattern.compile("§x(?:§[a-fA-F0-9]){6}|§[a-fA-F0-9]");
|
||||
|
||||
public ConfigTools(ToolStats toolStats) {
|
||||
this.toolStats = toolStats;
|
||||
@@ -123,13 +126,13 @@ public class ConfigTools {
|
||||
// set the placeholder to the value
|
||||
lore = lore.replace(placeHolder, String.valueOf(value));
|
||||
|
||||
Matcher hexMatcher = ItemLore.HEX_PATTERN.matcher(lore);
|
||||
Matcher hexMatcher = CONFIG_HEX_PATTERN.matcher(lore);
|
||||
while (hexMatcher.find()) {
|
||||
String hexCode = hexMatcher.group(1);
|
||||
lore = lore.replaceAll(hexMatcher.group(), net.md_5.bungee.api.ChatColor.of("#" + hexCode).toString());
|
||||
}
|
||||
|
||||
Matcher colorMatcher = ItemLore.COLOR_CODES.matcher(lore);
|
||||
Matcher colorMatcher = COLOR_CODES.matcher(lore);
|
||||
while (colorMatcher.find()) {
|
||||
String colorCode = colorMatcher.group(1);
|
||||
lore = lore.replaceAll("&" + colorCode, ChatColor.getByChar(colorCode).toString());
|
||||
@@ -145,8 +148,9 @@ public class ConfigTools {
|
||||
* @return The message without color codes.
|
||||
*/
|
||||
public String removeColor(String message) {
|
||||
message = ItemLore.COLOR_CODES.matcher(message).replaceAll("");
|
||||
message = ItemLore.HEX_PATTERN.matcher(message).replaceAll("");
|
||||
message = MINECRAFT_HEX_PATTERN.matcher(message).replaceAll("");
|
||||
message = COLOR_CODES.matcher(message).replaceAll("");
|
||||
message = CONFIG_HEX_PATTERN.matcher(message).replaceAll("");
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user