Skip to content

Commit c754024

Browse files
committed
update things
1 parent 613957f commit c754024

File tree

15 files changed

+59
-80
lines changed

15 files changed

+59
-80
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<dependency>
112112
<groupId>com.github.hyperdefined</groupId>
113113
<artifactId>hyperlib</artifactId>
114-
<version>1.0.8</version>
114+
<version>1.0.9</version>
115115
<scope>compile</scope>
116116
</dependency>
117117
</dependencies>

src/main/java/lol/hyper/toolstats/ToolStats.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import lol.hyper.toolstats.tools.*;
2727
import lol.hyper.toolstats.tools.config.ConfigTools;
2828
import lol.hyper.toolstats.tools.config.ConfigUpdater;
29+
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
2930
import org.bukkit.Bukkit;
3031
import org.bukkit.NamespacedKey;
3132
import org.bukkit.configuration.file.YamlConfiguration;
@@ -35,7 +36,6 @@
3536
import java.io.File;
3637
import java.util.HashSet;
3738
import java.util.Set;
38-
import java.util.logging.Logger;
3939

4040
public final class ToolStats extends JavaPlugin {
4141

@@ -120,7 +120,7 @@ public final class ToolStats extends JavaPlugin {
120120
public final NamespacedKey originType = new NamespacedKey(this, "origin");
121121

122122
public final int CONFIG_VERSION = 13;
123-
public final Logger logger = this.getLogger();
123+
public final ComponentLogger logger = this.getComponentLogger();
124124
public final File configFile = new File(this.getDataFolder(), "config.yml");
125125
public boolean tokens = false;
126126
public final Set<NamespacedKey> tokenKeys = new HashSet<>();
@@ -244,7 +244,7 @@ public void onEnable() {
244244
public void loadConfig() {
245245
config = YamlConfiguration.loadConfiguration(configFile);
246246
if (config.getInt("config-version") != CONFIG_VERSION) {
247-
logger.warning("Your config file is outdated! We will try to update it, but you should regenerate it!");
247+
logger.warn("Your config file is outdated! We will try to update it, but you should regenerate it!");
248248
ConfigUpdater configUpdater = new ConfigUpdater(this);
249249
configUpdater.updateConfig();
250250
}

src/main/java/lol/hyper/toolstats/events/CraftItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private ItemStack addCraftOrigin(ItemStack itemStack, Player owner) {
116116
ItemStack newItem = itemStack.clone();
117117
ItemMeta meta = newItem.getItemMeta();
118118
if (meta == null) {
119-
toolStats.logger.warning(itemStack + " does NOT have any meta! Unable to update stats.");
119+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", itemStack);
120120
return null;
121121
}
122122
// get the current time

src/main/java/lol/hyper/toolstats/events/CreativeEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private ItemStack addCreativeOrigin(ItemStack itemStack, Player owner) {
8383
ItemStack newSpawnedItem = itemStack.clone();
8484
ItemMeta meta = newSpawnedItem.getItemMeta();
8585
if (meta == null) {
86-
toolStats.logger.warning(itemStack + " does NOT have any meta! Unable to update stats.");
86+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", itemStack);
8787
return null;
8888
}
8989
// get the current time

src/main/java/lol/hyper/toolstats/events/PlayerMove.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package lol.hyper.toolstats.events;
1919

2020
import lol.hyper.toolstats.ToolStats;
21-
import org.bukkit.Material;
2221
import org.bukkit.entity.Player;
2322
import org.bukkit.event.EventHandler;
2423
import org.bukkit.event.EventPriority;

src/main/java/lol/hyper/toolstats/events/VillagerTrade.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private ItemStack addTradeOrigin(ItemStack oldItem, Player owner) {
123123
ItemStack newItem = oldItem.clone();
124124
ItemMeta meta = newItem.getItemMeta();
125125
if (meta == null) {
126-
toolStats.logger.warning(newItem + " does NOT have any meta! Unable to update stats.");
126+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", newItem);
127127
return null;
128128
}
129129
long timeCreated = System.currentTimeMillis();

src/main/java/lol/hyper/toolstats/tools/HashMaker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public String makeHash(Material itemType, UUID player, long timestamp) {
5151

5252
return hexString.toString();
5353
} catch (NoSuchAlgorithmException exception) {
54-
toolStats.logger.warning("Unable to generate hash for " + player + "!");
55-
toolStats.logger.warning("Generating a random UUID instead.");
56-
exception.printStackTrace();
54+
toolStats.logger.error("Unable to generate hash", exception);
55+
toolStats.logger.warn("Unable to generate hash for {}!", player);
56+
toolStats.logger.warn("Generating a random UUID instead.");
5757
return java.util.UUID.randomUUID().toString();
5858
}
5959
}

src/main/java/lol/hyper/toolstats/tools/ItemChecker.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package lol.hyper.toolstats.tools;
1919

20-
import io.papermc.paper.datacomponent.DataComponentType;
2120
import io.papermc.paper.datacomponent.DataComponentTypes;
2221
import lol.hyper.toolstats.ToolStats;
2322
import org.bukkit.Material;

src/main/java/lol/hyper/toolstats/tools/ItemLore.java

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,6 @@ public List<Component> updateItemLore(ItemMeta itemMeta, Component oldLine, Comp
7070
return itemLore;
7171
}
7272

73-
/**
74-
* Add lore to a given item.
75-
*
76-
* @param itemMeta The item's meta.
77-
* @param newLine The new line to add to the lore.
78-
* @return The new item's lore.
79-
*/
80-
public List<Component> addItemLore(ItemMeta itemMeta, Component newLine) {
81-
List<Component> itemLore;
82-
if (itemMeta.hasLore()) {
83-
itemLore = itemMeta.lore();
84-
itemLore.add(newLine);
85-
} else {
86-
itemLore = new ArrayList<>();
87-
itemLore.add(newLine);
88-
}
89-
return itemLore;
90-
}
91-
9273
/**
9374
* Remove a given lore from an item.
9475
*
@@ -114,7 +95,7 @@ public ItemMeta updateCropsMined(ItemStack playerTool, int add) {
11495
ItemStack clone = playerTool.clone();
11596
ItemMeta meta = clone.getItemMeta();
11697
if (meta == null) {
117-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
98+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
11899
return null;
119100
}
120101
// read the current stats from the item
@@ -188,7 +169,7 @@ public ItemMeta updateCropsMined(ItemStack playerTool, int add) {
188169

189170
if (cropsMined == null) {
190171
cropsMined = 0;
191-
toolStats.logger.warning(clone + " does not have valid crops-mined set! Resting to zero. This should NEVER happen.");
172+
toolStats.logger.warn("{} does not have valid crops-mined set! Resting to zero. This should NEVER happen.", clone);
192173
}
193174

194175
container.set(toolStats.cropsHarvested, PersistentDataType.INTEGER, cropsMined + add);
@@ -213,7 +194,7 @@ public ItemMeta updateBlocksMined(ItemStack playerTool, int add) {
213194
ItemStack clone = playerTool.clone();
214195
ItemMeta meta = clone.getItemMeta();
215196
if (meta == null) {
216-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
197+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
217198
return null;
218199
}
219200

@@ -287,7 +268,7 @@ public ItemMeta updateBlocksMined(ItemStack playerTool, int add) {
287268

288269
if (blocksMined == null) {
289270
blocksMined = 0;
290-
toolStats.logger.warning(clone + " does not have valid generic-mined set! Resting to zero. This should NEVER happen.");
271+
toolStats.logger.warn("{} does not have valid generic-mined set! Resting to zero. This should NEVER happen.", clone);
291272
}
292273

293274
container.set(toolStats.blocksMined, PersistentDataType.INTEGER, blocksMined + add);
@@ -312,7 +293,7 @@ public ItemMeta updatePlayerKills(ItemStack playerWeapon, int add) {
312293
ItemStack clone = playerWeapon.clone();
313294
ItemMeta meta = clone.getItemMeta();
314295
if (meta == null) {
315-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
296+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
316297
return null;
317298
}
318299

@@ -385,7 +366,7 @@ public ItemMeta updatePlayerKills(ItemStack playerWeapon, int add) {
385366

386367
if (playerKills == null) {
387368
playerKills = 0;
388-
toolStats.logger.warning(clone + " does not have valid player-kills set! Resting to zero. This should NEVER happen.");
369+
toolStats.logger.warn("{} does not have valid player-kills set! Resting to zero. This should NEVER happen.", clone);
389370
}
390371

391372
container.set(toolStats.playerKills, PersistentDataType.INTEGER, playerKills + add);
@@ -410,7 +391,7 @@ public ItemMeta updateMobKills(ItemStack playerWeapon, int add) {
410391
ItemStack clone = playerWeapon.clone();
411392
ItemMeta meta = clone.getItemMeta();
412393
if (meta == null) {
413-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
394+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
414395
return null;
415396
}
416397

@@ -483,7 +464,7 @@ public ItemMeta updateMobKills(ItemStack playerWeapon, int add) {
483464

484465
if (mobKills == null) {
485466
mobKills = 0;
486-
toolStats.logger.warning(clone + " does not have valid mob-kills set! Resting to zero. This should NEVER happen.");
467+
toolStats.logger.warn("{} does not have valid mob-kills set! Resting to zero. This should NEVER happen.", clone);
487468
}
488469

489470
container.set(toolStats.mobKills, PersistentDataType.INTEGER, mobKills + add);
@@ -516,7 +497,7 @@ public ItemMeta updateArmorDamage(ItemStack armorPiece, double damage, boolean b
516497
ItemStack clone = armorPiece.clone();
517498
ItemMeta meta = clone.getItemMeta();
518499
if (meta == null) {
519-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
500+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
520501
return null;
521502
}
522503

@@ -589,7 +570,7 @@ public ItemMeta updateArmorDamage(ItemStack armorPiece, double damage, boolean b
589570

590571
if (damageTaken == null) {
591572
damageTaken = 0.0;
592-
toolStats.logger.warning(clone + " does not have valid damage-taken set! Resting to zero. This should NEVER happen.");
573+
toolStats.logger.warn("{} does not have valid damage-taken set! Resting to zero. This should NEVER happen.", clone);
593574
}
594575

595576
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken + damage);
@@ -622,7 +603,7 @@ public ItemMeta updateWeaponDamage(ItemStack weapon, double damage, boolean bypa
622603
ItemStack clone = weapon.clone();
623604
ItemMeta meta = clone.getItemMeta();
624605
if (meta == null) {
625-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
606+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
626607
return null;
627608
}
628609

@@ -695,7 +676,7 @@ public ItemMeta updateWeaponDamage(ItemStack weapon, double damage, boolean bypa
695676

696677
if (damageDone == null) {
697678
damageDone = 0.0;
698-
toolStats.logger.warning(clone + " does not have valid damage-done set! Resting to zero. This should NEVER happen.");
679+
toolStats.logger.warn("{} does not have valid damage-done set! Resting to zero. This should NEVER happen.", clone);
699680
}
700681

701682
container.set(toolStats.damageDone, PersistentDataType.DOUBLE, damageDone + damage);
@@ -720,7 +701,7 @@ public ItemMeta updateFlightTime(ItemStack elytra, long duration) {
720701
ItemStack clone = elytra.clone();
721702
ItemMeta meta = clone.getItemMeta();
722703
if (meta == null) {
723-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
704+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
724705
return null;
725706
}
726707

@@ -803,7 +784,7 @@ public ItemMeta updateFlightTime(ItemStack elytra, long duration) {
803784

804785
if (flightTime == null) {
805786
flightTime = 0L;
806-
toolStats.logger.warning(flightTime + " does not have valid flight-time set! Resting to zero. This should NEVER happen.");
787+
toolStats.logger.warn("{} does not have valid flight-time set! Resting to zero. This should NEVER happen.", flightTime);
807788
}
808789

809790
container.set(toolStats.flightTime, PersistentDataType.LONG, flightTime + duration);
@@ -836,7 +817,7 @@ public ItemMeta updateSheepSheared(ItemStack shears, int add) {
836817
ItemStack clone = shears.clone();
837818
ItemMeta meta = clone.getItemMeta();
838819
if (meta == null) {
839-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
820+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
840821
return null;
841822
}
842823

@@ -909,7 +890,7 @@ public ItemMeta updateSheepSheared(ItemStack shears, int add) {
909890

910891
if (sheepSheared == null) {
911892
sheepSheared = 0;
912-
toolStats.logger.warning(clone + " does not have valid sheared set! Resting to zero. This should NEVER happen.");
893+
toolStats.logger.warn("{} does not have valid sheared set! Resting to zero. This should NEVER happen.", clone);
913894
}
914895

915896
container.set(toolStats.sheepSheared, PersistentDataType.INTEGER, sheepSheared + add);
@@ -934,7 +915,7 @@ public ItemMeta updateArrowsShot(ItemStack bow, int add) {
934915
ItemStack clone = bow.clone();
935916
ItemMeta meta = clone.getItemMeta();
936917
if (meta == null) {
937-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
918+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
938919
return null;
939920
}
940921

@@ -1009,7 +990,7 @@ public ItemMeta updateArrowsShot(ItemStack bow, int add) {
1009990

1010991
if (arrowsShot == null) {
1011992
arrowsShot = 0;
1012-
toolStats.logger.warning(arrowsShot + " does not have valid arrows-shot set! Resting to zero. This should NEVER happen.");
993+
toolStats.logger.warn("{} does not have valid arrows-shot set! Resting to zero. This should NEVER happen.", arrowsShot);
1013994
}
1014995

1015996
container.set(toolStats.arrowsShot, PersistentDataType.INTEGER, arrowsShot + add);
@@ -1034,7 +1015,7 @@ public ItemMeta updateFishCaught(ItemStack fishingRod, int add) {
10341015
ItemStack clone = fishingRod.clone();
10351016
ItemMeta meta = clone.getItemMeta();
10361017
if (meta == null) {
1037-
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
1018+
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
10381019
return null;
10391020
}
10401021

@@ -1107,7 +1088,7 @@ public ItemMeta updateFishCaught(ItemStack fishingRod, int add) {
11071088

11081089
if (fishCaught == null) {
11091090
fishCaught = 0;
1110-
toolStats.logger.warning(clone + " does not have valid fish-caught set! Resting to zero. This should NEVER happen.");
1091+
toolStats.logger.warn("{} does not have valid fish-caught set! Resting to zero. This should NEVER happen.", clone);
11111092
}
11121093

11131094
container.set(toolStats.fishCaught, PersistentDataType.INTEGER, fishCaught + add);

src/main/java/lol/hyper/toolstats/tools/NumberFormat.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,35 @@ public NumberFormat(ToolStats toolStats) {
5353
// if these config values are missing, use the default ones
5454
if (dateFormat == null) {
5555
dateFormat = "M/dd/yyyy";
56-
toolStats.logger.warning("date-format is missing! Using default American English format.");
56+
toolStats.logger.warn("date-format is missing! Using default American English format.");
5757
}
5858

5959
if (decimalSeparator == null) {
6060
decimalSeparator = ".";
61-
toolStats.logger.warning("number-formats.decimal-separator is missing! Using default \".\" instead.");
61+
toolStats.logger.warn("number-formats.decimal-separator is missing! Using default \".\" instead.");
6262
}
6363

6464
if (commaSeparator == null) {
6565
commaSeparator = ",";
66-
toolStats.logger.warning("number-formats.comma-separator is missing! Using default \",\" instead.");
66+
toolStats.logger.warn("number-formats.comma-separator is missing! Using default \",\" instead.");
6767
}
6868

6969
if (commaFormat == null) {
7070
commaFormat = "#,###";
71-
toolStats.logger.warning("number-formats.comma-format is missing! Using default #,### instead.");
71+
toolStats.logger.warn("number-formats.comma-format is missing! Using default #,### instead.");
7272
}
7373

7474
if (decimalFormat == null) {
7575
decimalFormat = "#,##0.00";
76-
toolStats.logger.warning("number-formats.comma-separator is missing! Using default #,###.00 instead.");
76+
toolStats.logger.warn("number-formats.comma-separator is missing! Using default #,###.00 instead.");
7777
}
7878

7979
// test the date format
8080
try {
8181
DATE_FORMAT = new SimpleDateFormat(dateFormat, Locale.getDefault());
8282
} catch (NullPointerException | IllegalArgumentException exception) {
83-
toolStats.logger.warning("date-format is NOT a valid format! Using default American English format.");
84-
exception.printStackTrace();
83+
toolStats.logger.error("Invalid format or missing format", exception);
84+
toolStats.logger.warn("date-format is NOT a valid format! Using default American English format.");
8585
DATE_FORMAT = new SimpleDateFormat("M/dd/yyyy", Locale.ENGLISH);
8686
}
8787

@@ -95,17 +95,17 @@ public NumberFormat(ToolStats toolStats) {
9595
try {
9696
COMMA_FORMAT = new DecimalFormat(commaFormat, formatSymbols);
9797
} catch (NullPointerException | IllegalArgumentException exception) {
98-
toolStats.logger.warning("number-formats.comma-format is NOT a valid format! Using default #,### instead.");
99-
exception.printStackTrace();
98+
toolStats.logger.error("Invalid comma or missing format", exception);
99+
toolStats.logger.warn("number-formats.comma-format is NOT a valid format! Using default #,### instead.");
100100
COMMA_FORMAT = new DecimalFormat("#,###", formatSymbols);
101101
}
102102

103103
// test the decimal format
104104
try {
105105
DECIMAL_FORMAT = new DecimalFormat(decimalFormat, formatSymbols);
106106
} catch (NullPointerException | IllegalArgumentException exception) {
107-
toolStats.logger.warning("number-formats.decimal-format is NOT a valid format! Using default #,###.00 instead.");
108-
exception.printStackTrace();
107+
toolStats.logger.error("Invalid decimal or missing format", exception);
108+
toolStats.logger.warn("number-formats.decimal-format is NOT a valid format! Using default #,###.00 instead.");
109109
DECIMAL_FORMAT = new DecimalFormat("#,###.00", formatSymbols);
110110
}
111111
}

0 commit comments

Comments
 (0)