mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
update things
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -111,7 +111,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.hyperdefined</groupId>
|
<groupId>com.github.hyperdefined</groupId>
|
||||||
<artifactId>hyperlib</artifactId>
|
<artifactId>hyperlib</artifactId>
|
||||||
<version>1.0.8</version>
|
<version>1.0.9</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import lol.hyper.toolstats.events.*;
|
|||||||
import lol.hyper.toolstats.tools.*;
|
import lol.hyper.toolstats.tools.*;
|
||||||
import lol.hyper.toolstats.tools.config.ConfigTools;
|
import lol.hyper.toolstats.tools.config.ConfigTools;
|
||||||
import lol.hyper.toolstats.tools.config.ConfigUpdater;
|
import lol.hyper.toolstats.tools.config.ConfigUpdater;
|
||||||
|
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@@ -35,7 +36,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public final class ToolStats extends JavaPlugin {
|
public final class ToolStats extends JavaPlugin {
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
public final NamespacedKey originType = new NamespacedKey(this, "origin");
|
public final NamespacedKey originType = new NamespacedKey(this, "origin");
|
||||||
|
|
||||||
public final int CONFIG_VERSION = 13;
|
public final int CONFIG_VERSION = 13;
|
||||||
public final Logger logger = this.getLogger();
|
public final ComponentLogger logger = this.getComponentLogger();
|
||||||
public final File configFile = new File(this.getDataFolder(), "config.yml");
|
public final File configFile = new File(this.getDataFolder(), "config.yml");
|
||||||
public boolean tokens = false;
|
public boolean tokens = false;
|
||||||
public final Set<NamespacedKey> tokenKeys = new HashSet<>();
|
public final Set<NamespacedKey> tokenKeys = new HashSet<>();
|
||||||
@@ -244,7 +244,7 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
if (config.getInt("config-version") != CONFIG_VERSION) {
|
if (config.getInt("config-version") != CONFIG_VERSION) {
|
||||||
logger.warning("Your config file is outdated! We will try to update it, but you should regenerate it!");
|
logger.warn("Your config file is outdated! We will try to update it, but you should regenerate it!");
|
||||||
ConfigUpdater configUpdater = new ConfigUpdater(this);
|
ConfigUpdater configUpdater = new ConfigUpdater(this);
|
||||||
configUpdater.updateConfig();
|
configUpdater.updateConfig();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class CraftItem implements Listener {
|
|||||||
ItemStack newItem = itemStack.clone();
|
ItemStack newItem = itemStack.clone();
|
||||||
ItemMeta meta = newItem.getItemMeta();
|
ItemMeta meta = newItem.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(itemStack + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", itemStack);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// get the current time
|
// get the current time
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class CreativeEvent implements Listener {
|
|||||||
ItemStack newSpawnedItem = itemStack.clone();
|
ItemStack newSpawnedItem = itemStack.clone();
|
||||||
ItemMeta meta = newSpawnedItem.getItemMeta();
|
ItemMeta meta = newSpawnedItem.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(itemStack + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", itemStack);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// get the current time
|
// get the current time
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package lol.hyper.toolstats.events;
|
package lol.hyper.toolstats.events;
|
||||||
|
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public class VillagerTrade implements Listener {
|
|||||||
ItemStack newItem = oldItem.clone();
|
ItemStack newItem = oldItem.clone();
|
||||||
ItemMeta meta = newItem.getItemMeta();
|
ItemMeta meta = newItem.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(newItem + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", newItem);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
long timeCreated = System.currentTimeMillis();
|
long timeCreated = System.currentTimeMillis();
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ public class HashMaker {
|
|||||||
|
|
||||||
return hexString.toString();
|
return hexString.toString();
|
||||||
} catch (NoSuchAlgorithmException exception) {
|
} catch (NoSuchAlgorithmException exception) {
|
||||||
toolStats.logger.warning("Unable to generate hash for " + player + "!");
|
toolStats.logger.error("Unable to generate hash", exception);
|
||||||
toolStats.logger.warning("Generating a random UUID instead.");
|
toolStats.logger.warn("Unable to generate hash for {}!", player);
|
||||||
exception.printStackTrace();
|
toolStats.logger.warn("Generating a random UUID instead.");
|
||||||
return java.util.UUID.randomUUID().toString();
|
return java.util.UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.tools;
|
package lol.hyper.toolstats.tools;
|
||||||
|
|
||||||
import io.papermc.paper.datacomponent.DataComponentType;
|
|
||||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|||||||
@@ -70,25 +70,6 @@ public class ItemLore {
|
|||||||
return itemLore;
|
return itemLore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add lore to a given item.
|
|
||||||
*
|
|
||||||
* @param itemMeta The item's meta.
|
|
||||||
* @param newLine The new line to add to the lore.
|
|
||||||
* @return The new item's lore.
|
|
||||||
*/
|
|
||||||
public List<Component> addItemLore(ItemMeta itemMeta, Component newLine) {
|
|
||||||
List<Component> itemLore;
|
|
||||||
if (itemMeta.hasLore()) {
|
|
||||||
itemLore = itemMeta.lore();
|
|
||||||
itemLore.add(newLine);
|
|
||||||
} else {
|
|
||||||
itemLore = new ArrayList<>();
|
|
||||||
itemLore.add(newLine);
|
|
||||||
}
|
|
||||||
return itemLore;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a given lore from an item.
|
* Remove a given lore from an item.
|
||||||
*
|
*
|
||||||
@@ -114,7 +95,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = playerTool.clone();
|
ItemStack clone = playerTool.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// read the current stats from the item
|
// read the current stats from the item
|
||||||
@@ -188,7 +169,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (cropsMined == null) {
|
if (cropsMined == null) {
|
||||||
cropsMined = 0;
|
cropsMined = 0;
|
||||||
toolStats.logger.warning(clone + " does not have valid crops-mined set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid crops-mined set! Resting to zero. This should NEVER happen.", clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.cropsHarvested, PersistentDataType.INTEGER, cropsMined + add);
|
container.set(toolStats.cropsHarvested, PersistentDataType.INTEGER, cropsMined + add);
|
||||||
@@ -213,7 +194,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = playerTool.clone();
|
ItemStack clone = playerTool.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +268,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (blocksMined == null) {
|
if (blocksMined == null) {
|
||||||
blocksMined = 0;
|
blocksMined = 0;
|
||||||
toolStats.logger.warning(clone + " does not have valid generic-mined set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid generic-mined set! Resting to zero. This should NEVER happen.", clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.blocksMined, PersistentDataType.INTEGER, blocksMined + add);
|
container.set(toolStats.blocksMined, PersistentDataType.INTEGER, blocksMined + add);
|
||||||
@@ -312,7 +293,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = playerWeapon.clone();
|
ItemStack clone = playerWeapon.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +366,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (playerKills == null) {
|
if (playerKills == null) {
|
||||||
playerKills = 0;
|
playerKills = 0;
|
||||||
toolStats.logger.warning(clone + " does not have valid player-kills set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid player-kills set! Resting to zero. This should NEVER happen.", clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.playerKills, PersistentDataType.INTEGER, playerKills + add);
|
container.set(toolStats.playerKills, PersistentDataType.INTEGER, playerKills + add);
|
||||||
@@ -410,7 +391,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = playerWeapon.clone();
|
ItemStack clone = playerWeapon.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,7 +464,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (mobKills == null) {
|
if (mobKills == null) {
|
||||||
mobKills = 0;
|
mobKills = 0;
|
||||||
toolStats.logger.warning(clone + " does not have valid mob-kills set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid mob-kills set! Resting to zero. This should NEVER happen.", clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.mobKills, PersistentDataType.INTEGER, mobKills + add);
|
container.set(toolStats.mobKills, PersistentDataType.INTEGER, mobKills + add);
|
||||||
@@ -516,7 +497,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = armorPiece.clone();
|
ItemStack clone = armorPiece.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +570,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (damageTaken == null) {
|
if (damageTaken == null) {
|
||||||
damageTaken = 0.0;
|
damageTaken = 0.0;
|
||||||
toolStats.logger.warning(clone + " does not have valid damage-taken set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid damage-taken set! Resting to zero. This should NEVER happen.", clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken + damage);
|
container.set(toolStats.armorDamage, PersistentDataType.DOUBLE, damageTaken + damage);
|
||||||
@@ -622,7 +603,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = weapon.clone();
|
ItemStack clone = weapon.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,7 +676,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (damageDone == null) {
|
if (damageDone == null) {
|
||||||
damageDone = 0.0;
|
damageDone = 0.0;
|
||||||
toolStats.logger.warning(clone + " does not have valid damage-done set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid damage-done set! Resting to zero. This should NEVER happen.", clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.damageDone, PersistentDataType.DOUBLE, damageDone + damage);
|
container.set(toolStats.damageDone, PersistentDataType.DOUBLE, damageDone + damage);
|
||||||
@@ -720,7 +701,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = elytra.clone();
|
ItemStack clone = elytra.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,7 +784,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (flightTime == null) {
|
if (flightTime == null) {
|
||||||
flightTime = 0L;
|
flightTime = 0L;
|
||||||
toolStats.logger.warning(flightTime + " does not have valid flight-time set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid flight-time set! Resting to zero. This should NEVER happen.", flightTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.flightTime, PersistentDataType.LONG, flightTime + duration);
|
container.set(toolStats.flightTime, PersistentDataType.LONG, flightTime + duration);
|
||||||
@@ -836,7 +817,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = shears.clone();
|
ItemStack clone = shears.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -909,7 +890,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (sheepSheared == null) {
|
if (sheepSheared == null) {
|
||||||
sheepSheared = 0;
|
sheepSheared = 0;
|
||||||
toolStats.logger.warning(clone + " does not have valid sheared set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid sheared set! Resting to zero. This should NEVER happen.", clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.sheepSheared, PersistentDataType.INTEGER, sheepSheared + add);
|
container.set(toolStats.sheepSheared, PersistentDataType.INTEGER, sheepSheared + add);
|
||||||
@@ -934,7 +915,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = bow.clone();
|
ItemStack clone = bow.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1009,7 +990,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (arrowsShot == null) {
|
if (arrowsShot == null) {
|
||||||
arrowsShot = 0;
|
arrowsShot = 0;
|
||||||
toolStats.logger.warning(arrowsShot + " does not have valid arrows-shot set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid arrows-shot set! Resting to zero. This should NEVER happen.", arrowsShot);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.arrowsShot, PersistentDataType.INTEGER, arrowsShot + add);
|
container.set(toolStats.arrowsShot, PersistentDataType.INTEGER, arrowsShot + add);
|
||||||
@@ -1034,7 +1015,7 @@ public class ItemLore {
|
|||||||
ItemStack clone = fishingRod.clone();
|
ItemStack clone = fishingRod.clone();
|
||||||
ItemMeta meta = clone.getItemMeta();
|
ItemMeta meta = clone.getItemMeta();
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
toolStats.logger.warning(clone + " does NOT have any meta! Unable to update stats.");
|
toolStats.logger.warn("{} does NOT have any meta! Unable to update stats.", clone);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1107,7 +1088,7 @@ public class ItemLore {
|
|||||||
|
|
||||||
if (fishCaught == null) {
|
if (fishCaught == null) {
|
||||||
fishCaught = 0;
|
fishCaught = 0;
|
||||||
toolStats.logger.warning(clone + " does not have valid fish-caught set! Resting to zero. This should NEVER happen.");
|
toolStats.logger.warn("{} does not have valid fish-caught set! Resting to zero. This should NEVER happen.", clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.set(toolStats.fishCaught, PersistentDataType.INTEGER, fishCaught + add);
|
container.set(toolStats.fishCaught, PersistentDataType.INTEGER, fishCaught + add);
|
||||||
|
|||||||
@@ -53,35 +53,35 @@ public class NumberFormat {
|
|||||||
// if these config values are missing, use the default ones
|
// if these config values are missing, use the default ones
|
||||||
if (dateFormat == null) {
|
if (dateFormat == null) {
|
||||||
dateFormat = "M/dd/yyyy";
|
dateFormat = "M/dd/yyyy";
|
||||||
toolStats.logger.warning("date-format is missing! Using default American English format.");
|
toolStats.logger.warn("date-format is missing! Using default American English format.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decimalSeparator == null) {
|
if (decimalSeparator == null) {
|
||||||
decimalSeparator = ".";
|
decimalSeparator = ".";
|
||||||
toolStats.logger.warning("number-formats.decimal-separator is missing! Using default \".\" instead.");
|
toolStats.logger.warn("number-formats.decimal-separator is missing! Using default \".\" instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commaSeparator == null) {
|
if (commaSeparator == null) {
|
||||||
commaSeparator = ",";
|
commaSeparator = ",";
|
||||||
toolStats.logger.warning("number-formats.comma-separator is missing! Using default \",\" instead.");
|
toolStats.logger.warn("number-formats.comma-separator is missing! Using default \",\" instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commaFormat == null) {
|
if (commaFormat == null) {
|
||||||
commaFormat = "#,###";
|
commaFormat = "#,###";
|
||||||
toolStats.logger.warning("number-formats.comma-format is missing! Using default #,### instead.");
|
toolStats.logger.warn("number-formats.comma-format is missing! Using default #,### instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decimalFormat == null) {
|
if (decimalFormat == null) {
|
||||||
decimalFormat = "#,##0.00";
|
decimalFormat = "#,##0.00";
|
||||||
toolStats.logger.warning("number-formats.comma-separator is missing! Using default #,###.00 instead.");
|
toolStats.logger.warn("number-formats.comma-separator is missing! Using default #,###.00 instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the date format
|
// test the date format
|
||||||
try {
|
try {
|
||||||
DATE_FORMAT = new SimpleDateFormat(dateFormat, Locale.getDefault());
|
DATE_FORMAT = new SimpleDateFormat(dateFormat, Locale.getDefault());
|
||||||
} catch (NullPointerException | IllegalArgumentException exception) {
|
} catch (NullPointerException | IllegalArgumentException exception) {
|
||||||
toolStats.logger.warning("date-format is NOT a valid format! Using default American English format.");
|
toolStats.logger.error("Invalid format or missing format", exception);
|
||||||
exception.printStackTrace();
|
toolStats.logger.warn("date-format is NOT a valid format! Using default American English format.");
|
||||||
DATE_FORMAT = new SimpleDateFormat("M/dd/yyyy", Locale.ENGLISH);
|
DATE_FORMAT = new SimpleDateFormat("M/dd/yyyy", Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,8 +95,8 @@ public class NumberFormat {
|
|||||||
try {
|
try {
|
||||||
COMMA_FORMAT = new DecimalFormat(commaFormat, formatSymbols);
|
COMMA_FORMAT = new DecimalFormat(commaFormat, formatSymbols);
|
||||||
} catch (NullPointerException | IllegalArgumentException exception) {
|
} catch (NullPointerException | IllegalArgumentException exception) {
|
||||||
toolStats.logger.warning("number-formats.comma-format is NOT a valid format! Using default #,### instead.");
|
toolStats.logger.error("Invalid comma or missing format", exception);
|
||||||
exception.printStackTrace();
|
toolStats.logger.warn("number-formats.comma-format is NOT a valid format! Using default #,### instead.");
|
||||||
COMMA_FORMAT = new DecimalFormat("#,###", formatSymbols);
|
COMMA_FORMAT = new DecimalFormat("#,###", formatSymbols);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,8 +104,8 @@ public class NumberFormat {
|
|||||||
try {
|
try {
|
||||||
DECIMAL_FORMAT = new DecimalFormat(decimalFormat, formatSymbols);
|
DECIMAL_FORMAT = new DecimalFormat(decimalFormat, formatSymbols);
|
||||||
} catch (NullPointerException | IllegalArgumentException exception) {
|
} catch (NullPointerException | IllegalArgumentException exception) {
|
||||||
toolStats.logger.warning("number-formats.decimal-format is NOT a valid format! Using default #,###.00 instead.");
|
toolStats.logger.error("Invalid decimal or missing format", exception);
|
||||||
exception.printStackTrace();
|
toolStats.logger.warn("number-formats.decimal-format is NOT a valid format! Using default #,###.00 instead.");
|
||||||
DECIMAL_FORMAT = new DecimalFormat("#,###.00", formatSymbols);
|
DECIMAL_FORMAT = new DecimalFormat("#,###.00", formatSymbols);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,14 +154,14 @@ public class TokenData {
|
|||||||
|
|
||||||
String materialFromConfig = tokenConfig.getString("material");
|
String materialFromConfig = tokenConfig.getString("material");
|
||||||
if (materialFromConfig == null) {
|
if (materialFromConfig == null) {
|
||||||
toolStats.logger.warning("Could not find material config for token " + tokenType);
|
toolStats.logger.warn("Could not find material config for token {}", tokenType);
|
||||||
toolStats.logger.warning("Using PAPER as default.");
|
toolStats.logger.warn("Using PAPER as default.");
|
||||||
materialFromConfig = "PAPER";
|
materialFromConfig = "PAPER";
|
||||||
}
|
}
|
||||||
Material material = Material.getMaterial(materialFromConfig);
|
Material material = Material.getMaterial(materialFromConfig);
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
toolStats.logger.warning("Material " + materialFromConfig + " is not a valid Minecraft material.");
|
toolStats.logger.warn("Material {} is not a valid Minecraft material.", materialFromConfig);
|
||||||
toolStats.logger.warning("Using PAPER as default.");
|
toolStats.logger.warn("Using PAPER as default.");
|
||||||
material = Material.PAPER;
|
material = Material.PAPER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,9 +185,9 @@ public class TokenData {
|
|||||||
String type = tokenConfig.getString("custom-model-data.type");
|
String type = tokenConfig.getString("custom-model-data.type");
|
||||||
Object value = tokenConfig.get("custom-model-data.value");
|
Object value = tokenConfig.get("custom-model-data.value");
|
||||||
if (type == null || value == null) {
|
if (type == null || value == null) {
|
||||||
toolStats.logger.info("Could not find custom model data for token " + tokenType);
|
toolStats.logger.info("Could not find custom model data for token {}", tokenType);
|
||||||
toolStats.logger.info("Type: " + type);
|
toolStats.logger.info("Type: {}", type);
|
||||||
toolStats.logger.info("Value: " + value);
|
toolStats.logger.info("Value: {}", value);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
CustomModelData data = setData(type, value);
|
CustomModelData data = setData(type, value);
|
||||||
@@ -208,7 +208,7 @@ public class TokenData {
|
|||||||
try {
|
try {
|
||||||
f = Float.parseFloat(data.toString());
|
f = Float.parseFloat(data.toString());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
toolStats.logger.info(data + " is not a valid float!");
|
toolStats.logger.info("{} is not a valid float!", data);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CustomModelData.customModelData().addFloat(f).build();
|
return CustomModelData.customModelData().addFloat(f).build();
|
||||||
@@ -217,7 +217,7 @@ public class TokenData {
|
|||||||
return CustomModelData.customModelData().addString(data.toString()).build();
|
return CustomModelData.customModelData().addString(data.toString()).build();
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
toolStats.logger.info(data + " is not a valid data type!");
|
toolStats.logger.info("{} is not a valid data type!", data);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class ConfigTools {
|
|||||||
*/
|
*/
|
||||||
public boolean checkConfig(Material material, String configName) {
|
public boolean checkConfig(Material material, String configName) {
|
||||||
if (toolStats.config.getConfigurationSection("enabled." + configName) == null) {
|
if (toolStats.config.getConfigurationSection("enabled." + configName) == null) {
|
||||||
toolStats.logger.warning("Missing config section for enabled" + configName);
|
toolStats.logger.warn("Missing config section for enabled{}", configName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ public class ConfigTools {
|
|||||||
public Component formatLore(String configName, String placeHolder, Object value) {
|
public Component formatLore(String configName, String placeHolder, Object value) {
|
||||||
String lore = toolStats.config.getString("messages." + configName);
|
String lore = toolStats.config.getString("messages." + configName);
|
||||||
if (lore == null) {
|
if (lore == null) {
|
||||||
toolStats.logger.warning("Unable to find config message for: messages." + configName);
|
toolStats.logger.warn("Unable to find config message for: messages.{}", configName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ public class ConfigTools {
|
|||||||
public Component formatLoreMultiplePlaceholders(String configName, Map<String, String> placeHoldersValues) {
|
public Component formatLoreMultiplePlaceholders(String configName, Map<String, String> placeHoldersValues) {
|
||||||
String lore = toolStats.config.getString("messages." + configName);
|
String lore = toolStats.config.getString("messages." + configName);
|
||||||
if (lore == null) {
|
if (lore == null) {
|
||||||
toolStats.logger.warning("Unable to find config message for: messages." + configName);
|
toolStats.logger.warn("Unable to find config message for: messages.{}", configName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class Version12 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void transfer(String oldSection, String newSection) {
|
private void transfer(String oldSection, String newSection) {
|
||||||
toolStats.logger.info("Moving " + oldSection + " to " + newSection);
|
toolStats.logger.info("Moving {} to {}", oldSection, newSection);
|
||||||
ConfigurationSection old = toolStats.config.getConfigurationSection(oldSection);
|
ConfigurationSection old = toolStats.config.getConfigurationSection(oldSection);
|
||||||
toolStats.config.set(newSection, old);
|
toolStats.config.set(newSection, old);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ public class Version13 {
|
|||||||
toolStats.config.set("config-version", 13);
|
toolStats.config.set("config-version", 13);
|
||||||
|
|
||||||
for (String key : toolStats.config.getConfigurationSection("tokens.data").getKeys(false)) {
|
for (String key : toolStats.config.getConfigurationSection("tokens.data").getKeys(false)) {
|
||||||
toolStats.logger.info("Adding tokens.data." + key + ".material");
|
toolStats.logger.info("Adding tokens.data.{}.material", key);
|
||||||
toolStats.config.set("tokens.data." + key + ".material", "PAPER");
|
toolStats.config.set("tokens.data." + key + ".material", "PAPER");
|
||||||
toolStats.logger.info("Adding tokens.data." + key + ".custom-model-data.enabled");
|
toolStats.logger.info("Adding tokens.data.{}.custom-model-data.enabled", key);
|
||||||
toolStats.config.set("tokens.data." + key + ".custom-model-data.enabled", false);
|
toolStats.config.set("tokens.data." + key + ".custom-model-data.enabled", false);
|
||||||
toolStats.logger.info("Adding tokens.data." + key + ".custom-model-data.type");
|
toolStats.logger.info("Adding tokens.data.{}.custom-model-data.type", key);
|
||||||
toolStats.config.set("tokens.data." + key + ".custom-model-data.type", "float");
|
toolStats.config.set("tokens.data." + key + ".custom-model-data.type", "float");
|
||||||
toolStats.logger.info("Adding tokens.data." + key + ".custom-model-data.value");
|
toolStats.logger.info("Adding tokens.data.{}.custom-model-data.value", key);
|
||||||
toolStats.config.set("tokens.data." + key + ".custom-model-data.value", 1001);
|
toolStats.config.set("tokens.data." + key + ".custom-model-data.value", 1001);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class Version9 {
|
|||||||
* @param lore The lore of the item.
|
* @param lore The lore of the item.
|
||||||
*/
|
*/
|
||||||
private void addToken(String tokenType, String title, String lore) {
|
private void addToken(String tokenType, String title, String lore) {
|
||||||
toolStats.logger.info("Adding token type configuration for " + tokenType);
|
toolStats.logger.info("Adding token type configuration for {}", tokenType);
|
||||||
toolStats.config.set("tokens.data." + tokenType + ".title", title);
|
toolStats.config.set("tokens.data." + tokenType + ".title", title);
|
||||||
List<String> loreList = new ArrayList<>();
|
List<String> loreList = new ArrayList<>();
|
||||||
loreList.add(lore);
|
loreList.add(lore);
|
||||||
|
|||||||
Reference in New Issue
Block a user