Compare commits
13 Commits
1.9.7
...
e38ffdef07
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e38ffdef07 | ||
|
|
c7540244bc | ||
|
|
613957fadf | ||
|
|
e48be6ba20 | ||
|
|
c0d79fd740 | ||
|
|
b056972d30 | ||
|
|
525df4bcf6 | ||
|
|
86cbdd58ff | ||
|
|
27a89fd67c | ||
|
|
70ed50ce9e | ||
|
|
84c1f8313a | ||
|
|
f7ec488396 | ||
|
|
df014fd888 |
32
README.md
@@ -4,7 +4,7 @@
|
|||||||
<a href="https://modrinth.com/plugin/ToolStats"><img alt="modrinth" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/available/modrinth_vector.svg"></a>
|
<a href="https://modrinth.com/plugin/ToolStats"><img alt="modrinth" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/available/modrinth_vector.svg"></a>
|
||||||
<a href="https://hangar.papermc.io/hyperdefined/ToolStats"><img alt="hangar" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/available/hangar_vector.svg"></a>
|
<a href="https://hangar.papermc.io/hyperdefined/ToolStats"><img alt="hangar" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/available/hangar_vector.svg"></a>
|
||||||
<a href="https://papermc.io"><img alt="paper" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/supported/paper_vector.svg"></a>
|
<a href="https://papermc.io"><img alt="paper" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/supported/paper_vector.svg"></a>
|
||||||
<a href="https://github.com/hyperdefined/ToolStats/wiki"><img alt="ghpages" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/documentation/ghpages_vector.svg"></a>
|
<a href="https://docs.hyper.lol/plugins/toolstats/about/"><img alt="ghpages" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/documentation/ghpages_vector.svg"></a>
|
||||||
<a href="https://discord.gg/rJuQXVcJz8"><img alt="discord-singular" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/social/discord-singular_vector.svg"></a>
|
<a href="https://discord.gg/rJuQXVcJz8"><img alt="discord-singular" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/social/discord-singular_vector.svg"></a>
|
||||||
<a href="https://buymeacoffee.com/hyperdefined"><img alt="buymeacoffee-singular" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/donate/buymeacoffee-singular_vector.svg"></a>
|
<a href="https://buymeacoffee.com/hyperdefined"><img alt="buymeacoffee-singular" height="40" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/donate/buymeacoffee-singular_vector.svg"></a>
|
||||||
</p>
|
</p>
|
||||||
@@ -27,23 +27,23 @@ The best part is, this data is stored on the item itself.
|
|||||||
|
|
||||||
If item lore is ever incorrect/missing, you can run `/toolstats reset`. This command fixes the lore on whatever item you are holding.
|
If item lore is ever incorrect/missing, you can run `/toolstats reset`. This command fixes the lore on whatever item you are holding.
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
Visit the [wiki](https://github.com/hyperdefined/ToolStats/wiki) for help.
|
Visit the [wiki](https://docs.hyper.lol/plugins/toolstats/about/) for help.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
This plugin is released under GNU General Public License v3. See [LICENSE](https://github.com/hyperdefined/ToolStats/blob/master/LICENSE).
|
This plugin is released under GNU General Public License v3. See [LICENSE](https://github.com/hyperdefined/ToolStats/blob/master/LICENSE).
|
||||||
|
Before Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
BIN
images/image.png
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 15 KiB |
30
pom.xml
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<groupId>lol.hyper</groupId>
|
<groupId>lol.hyper</groupId>
|
||||||
<artifactId>toolstats</artifactId>
|
<artifactId>toolstats</artifactId>
|
||||||
<version>1.9.7</version>
|
<version>1.9.9</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>ToolStats</name>
|
<name>ToolStats</name>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
<version>3.4.1</version>
|
<version>3.5.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>auto-clean</id>
|
<id>auto-clean</id>
|
||||||
@@ -64,12 +64,8 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.bstats</pattern>
|
<pattern>lol.hyper.hyperlib</pattern>
|
||||||
<shadedPattern>lol.hyper.toolstats.bstats</shadedPattern>
|
<shadedPattern>lol.hyper.toolstats.hyperlib</shadedPattern>
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>lol.hyper.githubreleaseapi</pattern>
|
|
||||||
<shadedPattern>lol.hyper.toolstats.updater</shadedPattern>
|
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -99,25 +95,23 @@
|
|||||||
<id>papermc</id>
|
<id>papermc</id>
|
||||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.21.5-R0.1-SNAPSHOT</version>
|
<version>1.21.8-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>com.github.hyperdefined</groupId>
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
<artifactId>hyperlib</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>1.0.9</version>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>lol.hyper</groupId>
|
|
||||||
<artifactId>github-release-api</artifactId>
|
|
||||||
<version>1.0.5</version>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -17,15 +17,16 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats;
|
package lol.hyper.toolstats;
|
||||||
|
|
||||||
import lol.hyper.githubreleaseapi.GitHubRelease;
|
import lol.hyper.hyperlib.HyperLib;
|
||||||
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
|
import lol.hyper.hyperlib.bstats.HyperStats;
|
||||||
import lol.hyper.githubreleaseapi.ReleaseNotFoundException;
|
import lol.hyper.hyperlib.releases.HyperUpdater;
|
||||||
|
import lol.hyper.hyperlib.utils.TextUtils;
|
||||||
import lol.hyper.toolstats.commands.CommandToolStats;
|
import lol.hyper.toolstats.commands.CommandToolStats;
|
||||||
import lol.hyper.toolstats.events.*;
|
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 org.bstats.bukkit.Metrics;
|
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;
|
||||||
@@ -33,10 +34,8 @@ import org.bukkit.inventory.ShapedRecipe;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
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 {
|
||||||
|
|
||||||
@@ -121,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<>();
|
||||||
@@ -152,9 +151,19 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
public TokenData tokenData;
|
public TokenData tokenData;
|
||||||
public AnvilEvent anvilEvent;
|
public AnvilEvent anvilEvent;
|
||||||
public PrepareCraft prepareCraft;
|
public PrepareCraft prepareCraft;
|
||||||
|
public HyperLib hyperLib;
|
||||||
|
public TextUtils textUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
hyperLib = new HyperLib(this);
|
||||||
|
hyperLib.setup();
|
||||||
|
|
||||||
|
HyperStats stats = new HyperStats(hyperLib, 14110);
|
||||||
|
stats.setup();
|
||||||
|
|
||||||
|
textUtils = new TextUtils(hyperLib);
|
||||||
|
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
this.saveResource("config.yml", true);
|
this.saveResource("config.yml", true);
|
||||||
logger.info("Copying default config!");
|
logger.info("Copying default config!");
|
||||||
@@ -225,14 +234,17 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
|
|
||||||
this.getCommand("toolstats").setExecutor(commandToolStats);
|
this.getCommand("toolstats").setExecutor(commandToolStats);
|
||||||
|
|
||||||
new Metrics(this, 14110);
|
HyperUpdater updater = new HyperUpdater(hyperLib);
|
||||||
Bukkit.getAsyncScheduler().runNow(this, scheduledTask -> checkForUpdates());
|
updater.setGitHub("hyperdefined", "ToolStats");
|
||||||
|
updater.setModrinth("oBZj9E15");
|
||||||
|
updater.setHangar("ToolStats", "paper");
|
||||||
|
updater.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
@@ -247,29 +259,4 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
|
|
||||||
numberFormat = new NumberFormat(this);
|
numberFormat = new NumberFormat(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkForUpdates() {
|
|
||||||
GitHubReleaseAPI api;
|
|
||||||
try {
|
|
||||||
api = new GitHubReleaseAPI("ToolStats", "hyperdefined");
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.warning("Unable to check updates!");
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GitHubRelease current;
|
|
||||||
try {
|
|
||||||
current = api.getReleaseByTag(this.getPluginMeta().getVersion());
|
|
||||||
} catch (ReleaseNotFoundException e) {
|
|
||||||
logger.warning("You are running a version that does not exist on GitHub. If you are in a dev environment, you can ignore this. Otherwise, this is a bug!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GitHubRelease latest = api.getLatestVersion();
|
|
||||||
int buildsBehind = api.getBuildsBehind(current);
|
|
||||||
if (buildsBehind == 0) {
|
|
||||||
logger.info("You are running the latest version.");
|
|
||||||
} else {
|
|
||||||
logger.warning("A new version is available (" + latest.getTagVersion() + ")! You are running version " + current.getTagVersion() + ". You are " + buildsBehind + " version(s) behind.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,11 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.commands;
|
package lol.hyper.toolstats.commands;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -155,6 +154,37 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
sender.sendMessage(Component.text("Type /toolstats reset confirm to confirm this.", NamedTextColor.GREEN));
|
sender.sendMessage(Component.text("Type /toolstats reset confirm to confirm this.", NamedTextColor.GREEN));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case "purge": {
|
||||||
|
if (!sender.hasPermission("toolstats.purge")) {
|
||||||
|
sender.sendMessage(Component.text("You do not have permission for this command.", NamedTextColor.RED));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
sender.sendMessage(Component.text("You must be a player for this command.", NamedTextColor.RED));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length == 2 && args[1].equalsIgnoreCase("confirm")) {
|
||||||
|
if (!sender.hasPermission("toolstats.purge.confirm")) {
|
||||||
|
sender.sendMessage(Component.text("You do not have permission for this command.", NamedTextColor.RED));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
|
if (!toolStats.itemChecker.isValidItem(heldItem.getType())) {
|
||||||
|
sender.sendMessage(Component.text("You must hold a valid item.", NamedTextColor.RED));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ItemStack purgedItem = toolStats.itemLore.removeAll(heldItem, true);
|
||||||
|
player.getInventory().setItemInMainHand(purgedItem);
|
||||||
|
sender.sendMessage(Component.text("The item was purged!", NamedTextColor.GREEN));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
sender.sendMessage(Component.text("This will purge ALL ToolStats data from this item.", NamedTextColor.GREEN));
|
||||||
|
sender.sendMessage(Component.text("This includes all stats, ownership, and creation time.", NamedTextColor.GREEN));
|
||||||
|
sender.sendMessage(Component.text("THIS CANNOT BE UNDONE!", NamedTextColor.GREEN));
|
||||||
|
sender.sendMessage(Component.text("Type /toolstats purge confirm to confirm this.", NamedTextColor.GREEN));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case "givetokens": {
|
case "givetokens": {
|
||||||
if (!sender.hasPermission("toolstats.givetokens")) {
|
if (!sender.hasPermission("toolstats.givetokens")) {
|
||||||
sender.sendMessage(Component.text("You do not have permission for this command.", NamedTextColor.RED));
|
sender.sendMessage(Component.text("You do not have permission for this command.", NamedTextColor.RED));
|
||||||
@@ -233,38 +263,6 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
origin = -1;
|
origin = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// hard code elytras
|
|
||||||
if (finalItem.getType() == Material.ELYTRA) {
|
|
||||||
Long flightTime = null;
|
|
||||||
Long timeCreated = null;
|
|
||||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG)) {
|
|
||||||
timeCreated = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.flightTime, PersistentDataType.LONG)) {
|
|
||||||
flightTime = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flightTime != null) {
|
|
||||||
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
|
||||||
Map<String, String> flightTimeFormatted = toolStats.numberFormat.formatTime(flightTime);
|
|
||||||
Component line = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", flightTimeFormatted);
|
|
||||||
lore.add(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeCreated != null) {
|
|
||||||
Component timeCreatedLine = toolStats.configTools.formatLore("looted.found-by", "{player}", player.getName());
|
|
||||||
Component playerOwnerLine = toolStats.configTools.formatLore("looted.found-on", "{date}", toolStats.numberFormat.formatDate(new Date(timeCreated)));
|
|
||||||
lore.add(timeCreatedLine);
|
|
||||||
lore.add(playerOwnerLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
finalMeta.lore(lore);
|
|
||||||
finalItem.setItemMeta(finalMeta);
|
|
||||||
int slot = player.getInventory().getHeldItemSlot();
|
|
||||||
player.getInventory().setItem(slot, finalItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (container.has(toolStats.droppedBy, PersistentDataType.STRING)) {
|
if (container.has(toolStats.droppedBy, PersistentDataType.STRING)) {
|
||||||
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
||||||
if (container.has(toolStats.droppedBy)) {
|
if (container.has(toolStats.droppedBy)) {
|
||||||
@@ -293,82 +291,30 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
container.set(toolStats.itemOwner, new UUIDDataType(), player.getUniqueId());
|
container.set(toolStats.itemOwner, new UUIDDataType(), player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// show how the item was created based on the previous lore
|
// add the ownership lore
|
||||||
switch (origin) {
|
Component ownerLore = toolStats.itemLore.formatOwner(ownerName, origin, original);
|
||||||
case 0: {
|
if (ownerLore != null) {
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "crafted-by")) {
|
lore.add(ownerLore);
|
||||||
lore.add(toolStats.configTools.formatLore("crafted.crafted-by", "{player}", ownerName));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: {
|
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "looted-by")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("looted.looted-by", "{player}", ownerName));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3: {
|
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "traded-by")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("traded.traded-by", "{player}", ownerName));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 5: {
|
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "fished-by")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("fished.caught-by", "{player}", ownerName));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 6: {
|
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "spawned-in-by")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("spawned-in.spawned-by", "{player}", ownerName));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (container.has(toolStats.timeCreated, PersistentDataType.LONG)) {
|
if (container.has(toolStats.timeCreated, PersistentDataType.LONG)) {
|
||||||
Long time = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
Long time = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
||||||
if (time != null) {
|
if (time != null) {
|
||||||
String date = toolStats.numberFormat.formatDate(new Date(time));
|
// add the creation time lore
|
||||||
// show how when the item was created based on the previous lore
|
Component creationTimeLore = toolStats.itemLore.formatCreationTime(time, origin, original);
|
||||||
switch (origin) {
|
if (creationTimeLore != null) {
|
||||||
case 0: {
|
lore.add(creationTimeLore);
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "crafted-on")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("crafted.crafted-on", "{date}", date));
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 1: {
|
|
||||||
if (toolStats.config.getBoolean("enabled.dropped-on")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("dropped-on", "{date}", date));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: {
|
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "looted-on")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("looted.looted-on", "{date}", date));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3: {
|
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "traded-on")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("traded.traded-on", "{date}", date));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 5: {
|
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "fished-on")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("fished.caught-on", "{date}", date));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 6: {
|
|
||||||
if (toolStats.configTools.checkConfig(original.getType(), "spawned-in-on")) {
|
|
||||||
lore.add(toolStats.configTools.formatLore("spawned-in.spawned-on", "{date}", date));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if (toolStats.config.getBoolean("enabled.flight-time")) {
|
||||||
|
if (container.has(toolStats.flightTime, PersistentDataType.LONG)) {
|
||||||
|
Long flightTime = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
||||||
|
if (flightTime != null) {
|
||||||
|
Map<String, String> flightTimeFormatted = toolStats.numberFormat.formatTime(flightTime);
|
||||||
|
Component line = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", flightTimeFormatted);
|
||||||
|
lore.add(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1076,12 +1022,18 @@ public class CommandToolStats implements TabExecutor {
|
|||||||
if (sender.hasPermission("toolstats.remove")) {
|
if (sender.hasPermission("toolstats.remove")) {
|
||||||
suggestions.add("remove");
|
suggestions.add("remove");
|
||||||
}
|
}
|
||||||
|
if (sender.hasPermission("toolstats.purge")) {
|
||||||
|
suggestions.add("purge");
|
||||||
|
}
|
||||||
return suggestions.isEmpty() ? null : suggestions;
|
return suggestions.isEmpty() ? null : suggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 2 && args[0].equalsIgnoreCase("reset") && sender.hasPermission("toolstats.reset.confirm")) {
|
if (args.length == 2 && args[0].equalsIgnoreCase("reset") && sender.hasPermission("toolstats.reset.confirm")) {
|
||||||
return Collections.singletonList("confirm");
|
return Collections.singletonList("confirm");
|
||||||
}
|
}
|
||||||
|
if (args.length == 2 && args[0].equalsIgnoreCase("purge") && sender.hasPermission("toolstats.purge.confirm")) {
|
||||||
|
return Collections.singletonList("confirm");
|
||||||
|
}
|
||||||
if (args.length == 2 && args[0].equalsIgnoreCase("edit") && sender.hasPermission("toolstats.edit")) {
|
if (args.length == 2 && args[0].equalsIgnoreCase("edit") && sender.hasPermission("toolstats.edit")) {
|
||||||
// yes I am lazy
|
// yes I am lazy
|
||||||
return toolStats.tokenData.getTokenTypes().stream()
|
return toolStats.tokenData.getTokenTypes().stream()
|
||||||
|
|||||||
@@ -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 net.kyori.adventure.text.Component;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@@ -90,7 +89,9 @@ public class AnvilEvent implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tokenType.equalsIgnoreCase("remove")) {
|
if (tokenType.equalsIgnoreCase("remove")) {
|
||||||
remove(event, clone);
|
ItemStack removedStats = toolStats.itemLore.removeAll(clone, false);
|
||||||
|
event.setResult(removedStats);
|
||||||
|
event.getView().setRepairCost(toolStats.itemChecker.getCost("remove"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +123,15 @@ public class AnvilEvent implements Listener {
|
|||||||
addToken(event, tokenType, "mob-kills", clone);
|
addToken(event, tokenType, "mob-kills", clone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (tokenType.equalsIgnoreCase("damage-done")) {
|
||||||
|
addToken(event, tokenType, "damage-done", clone);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (toolStats.itemChecker.canGlide(clone)) {
|
||||||
|
addToken(event, tokenType, "flight-time", clone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (toolStats.itemChecker.isArmor(firstSlotMaterial)) {
|
if (toolStats.itemChecker.isArmor(firstSlotMaterial)) {
|
||||||
@@ -163,10 +172,6 @@ public class AnvilEvent implements Listener {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (firstSlotMaterial == Material.ELYTRA) {
|
|
||||||
addToken(event, tokenType, "flight-time", clone);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (firstSlotMaterial == Material.FISHING_ROD) {
|
if (firstSlotMaterial == Material.FISHING_ROD) {
|
||||||
addToken(event, tokenType, "fish-caught", clone);
|
addToken(event, tokenType, "fish-caught", clone);
|
||||||
}
|
}
|
||||||
@@ -390,155 +395,4 @@ public class AnvilEvent implements Listener {
|
|||||||
event.setResult(finalItem);
|
event.setResult(finalItem);
|
||||||
event.getView().setRepairCost(toolStats.itemChecker.getCost("reset"));
|
event.getView().setRepairCost(toolStats.itemChecker.getCost("reset"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove all stats from an item.
|
|
||||||
*
|
|
||||||
* @param event The PrepareAnvilEvent event.
|
|
||||||
* @param inputItem The input item to remove stats from.
|
|
||||||
*/
|
|
||||||
private void remove(PrepareAnvilEvent event, ItemStack inputItem) {
|
|
||||||
ItemStack finalItem = inputItem.clone();
|
|
||||||
ItemMeta meta = finalItem.getItemMeta();
|
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
|
||||||
|
|
||||||
// remove the applied tokens
|
|
||||||
if (container.has(toolStats.tokenApplied)) {
|
|
||||||
container.remove(toolStats.tokenApplied);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (container.has(toolStats.playerKills)) {
|
|
||||||
Integer playerKills = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
|
||||||
if (playerKills == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.playerKills);
|
|
||||||
|
|
||||||
String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("kills.player", "{kills}", playerKillsFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.mobKills)) {
|
|
||||||
Integer mobKills = container.get(toolStats.mobKills, PersistentDataType.INTEGER);
|
|
||||||
if (mobKills == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.mobKills);
|
|
||||||
|
|
||||||
String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("kills.mob", "{kills}", mobKillsFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.blocksMined)) {
|
|
||||||
Integer blocksMined = container.get(toolStats.blocksMined, PersistentDataType.INTEGER);
|
|
||||||
if (blocksMined == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.blocksMined);
|
|
||||||
|
|
||||||
String blocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("blocks-mined", "{blocks}", blocksMinedFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.cropsHarvested)) {
|
|
||||||
Integer cropsHarvested = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
|
||||||
if (cropsHarvested == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.cropsHarvested);
|
|
||||||
|
|
||||||
String cropsHarvestedFormatted = toolStats.numberFormat.formatInt(cropsHarvested);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("crops-harvested", "{crops}", cropsHarvestedFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.fishCaught)) {
|
|
||||||
Integer fishCaught = container.get(toolStats.fishCaught, PersistentDataType.INTEGER);
|
|
||||||
if (fishCaught == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.fishCaught);
|
|
||||||
|
|
||||||
String fishCaughtFormatted = toolStats.numberFormat.formatInt(fishCaught);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", fishCaughtFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.sheepSheared)) {
|
|
||||||
Integer sheepSheared = container.get(toolStats.sheepSheared, PersistentDataType.INTEGER);
|
|
||||||
if (sheepSheared == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.sheepSheared);
|
|
||||||
|
|
||||||
String sheepShearedFormatted = toolStats.numberFormat.formatInt(sheepSheared);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("sheep.sheared", "{sheep}", sheepShearedFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.armorDamage)) {
|
|
||||||
Double armorDamage = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
|
||||||
if (armorDamage == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.armorDamage);
|
|
||||||
|
|
||||||
String armorDamageFormatted = toolStats.numberFormat.formatDouble(armorDamage);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("damage-taken", "{damage}", armorDamageFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.damageDone)) {
|
|
||||||
Double damageDone = container.get(toolStats.damageDone, PersistentDataType.DOUBLE);
|
|
||||||
if (damageDone == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.damageDone);
|
|
||||||
|
|
||||||
String damageDoneFormatted = toolStats.numberFormat.formatDouble(damageDone);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("damage-done", "{damage}", damageDoneFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.arrowsShot)) {
|
|
||||||
Integer arrowsShot = container.get(toolStats.arrowsShot, PersistentDataType.INTEGER);
|
|
||||||
if (arrowsShot == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.arrowsShot);
|
|
||||||
|
|
||||||
String arrowsShotFormatted = toolStats.numberFormat.formatInt(arrowsShot);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("arrows-shot", "{arrows}", arrowsShotFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
if (container.has(toolStats.flightTime)) {
|
|
||||||
Long flightTime = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
|
||||||
if (flightTime == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.remove(toolStats.flightTime);
|
|
||||||
|
|
||||||
String flightTimeFormatted = toolStats.numberFormat.formatDouble(flightTime);
|
|
||||||
Component lineToRemove = toolStats.configTools.formatLore("flight-time", "{time}", flightTimeFormatted);
|
|
||||||
meta.lore(toolStats.itemLore.removeLore(meta.lore(), lineToRemove));
|
|
||||||
finalItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setResult(finalItem);
|
|
||||||
event.getView().setRepairCost(toolStats.itemChecker.getCost("remove"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.events;
|
package lol.hyper.toolstats.events;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -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
|
||||||
@@ -125,8 +125,6 @@ public class CraftItem implements Listener {
|
|||||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||||
timeCreated = finalDate.getTime();
|
timeCreated = finalDate.getTime();
|
||||||
} else {
|
|
||||||
finalDate = new Date(timeCreated);
|
|
||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
@@ -145,29 +143,20 @@ public class CraftItem implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if creation date is enabled, add it
|
// if creation date is enabled, add it
|
||||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "crafted-on")) {
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 0, newItem);
|
||||||
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
||||||
|
lore.add(creationDate);
|
||||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
|
||||||
Component newLine = toolStats.configTools.formatLore("crafted.crafted-on", "{date}", date);
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if creation owner is enabled, add it
|
// if ownership is enabled, add it
|
||||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "crafted-by")) {
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 0, newItem);
|
||||||
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 0);
|
||||||
|
lore.add(itemOwner);
|
||||||
Component newLine = toolStats.configTools.formatLore("crafted.crafted-by", "{player}", owner.getName());
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.events;
|
package lol.hyper.toolstats.events;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -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
|
||||||
@@ -92,8 +92,6 @@ public class CreativeEvent implements Listener {
|
|||||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||||
timeCreated = finalDate.getTime();
|
timeCreated = finalDate.getTime();
|
||||||
} else {
|
|
||||||
finalDate = new Date(timeCreated);
|
|
||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
@@ -111,28 +109,21 @@ public class CreativeEvent implements Listener {
|
|||||||
lore = new ArrayList<>();
|
lore = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "spawned-in-on")) {
|
// if creation date is enabled, add it
|
||||||
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 6, newSpawnedItem);
|
||||||
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
||||||
|
lore.add(creationDate);
|
||||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
|
||||||
Component newLine = toolStats.configTools.formatLore("spawned-in.spawned-on", "{date}", date);
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.configTools.checkConfig(itemStack.getType(), "spawned-in-by")) {
|
// if ownership is enabled, add it
|
||||||
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 6, newSpawnedItem);
|
||||||
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 6);
|
||||||
|
lore.add(itemOwner);
|
||||||
Component newLine = toolStats.configTools.formatLore("spawned-in.spawned-by", "{player}", owner.getName());
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,8 +91,6 @@ public class EntityDeath implements Listener {
|
|||||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||||
timeCreated = finalDate.getTime();
|
timeCreated = finalDate.getTime();
|
||||||
} else {
|
|
||||||
finalDate = new Date(timeCreated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
@@ -108,12 +106,13 @@ public class EntityDeath implements Listener {
|
|||||||
lore = new ArrayList<>();
|
lore = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.config.getBoolean("enabled.dropped-on")) {
|
// if creation date is enabled, add it
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 1);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 1, newItem);
|
||||||
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 1);
|
||||||
Component droppedOn = toolStats.configTools.formatLore("dropped-on", "{date}", date);
|
lore.add(creationDate);
|
||||||
lore.add(droppedOn);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
if (toolStats.config.getBoolean("enabled.dropped-by")) {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.events;
|
package lol.hyper.toolstats.events;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -104,8 +104,6 @@ public class GenerateLoot implements Listener {
|
|||||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||||
timeCreated = finalDate.getTime();
|
timeCreated = finalDate.getTime();
|
||||||
} else {
|
|
||||||
finalDate = new Date(timeCreated);
|
|
||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
@@ -121,28 +119,21 @@ public class GenerateLoot implements Listener {
|
|||||||
lore = new ArrayList<>();
|
lore = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.configTools.checkConfig(newItem.getType(), "looted-on")) {
|
// if creation date is enabled, add it
|
||||||
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 2, newItem);
|
||||||
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
||||||
|
lore.add(creationDate);
|
||||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
|
||||||
Component newLine = toolStats.configTools.formatLore("looted.looted-on", "{date}", date);
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.configTools.checkConfig(newItem.getType(), "looted-by")) {
|
// if ownership is enabled, add it
|
||||||
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 2, newItem);
|
||||||
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 2);
|
||||||
|
lore.add(itemOwner);
|
||||||
Component newLine = toolStats.configTools.formatLore("looted.looted-by", "{player}", owner.getName());
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.events;
|
package lol.hyper.toolstats.events;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.events;
|
package lol.hyper.toolstats.events;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -95,8 +95,6 @@ public class PickupItem implements Listener {
|
|||||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||||
timeCreated = finalDate.getTime();
|
timeCreated = finalDate.getTime();
|
||||||
} else {
|
|
||||||
finalDate = new Date(timeCreated);
|
|
||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
@@ -123,12 +121,22 @@ public class PickupItem implements Listener {
|
|||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
||||||
container.remove(toolStats.newElytra);
|
container.remove(toolStats.newElytra);
|
||||||
|
|
||||||
String formattedDate = toolStats.numberFormat.formatDate(finalDate);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 4, finalItem);
|
||||||
Component dateCreatedLore = toolStats.configTools.formatLore("looted.found-on", "{date}", formattedDate);
|
if (creationDate != null) {
|
||||||
Component itemOwnerLore = toolStats.configTools.formatLore("looted.found-by", "{player}", owner.getName());
|
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||||
lore.add(dateCreatedLore);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
||||||
lore.add(itemOwnerLore);
|
lore.add(creationDate);
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
|
}
|
||||||
|
|
||||||
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 4, finalItem);
|
||||||
|
if (itemOwner != null) {
|
||||||
|
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||||
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 4);
|
||||||
|
lore.add(itemOwner);
|
||||||
|
meta.lore(lore);
|
||||||
|
}
|
||||||
|
|
||||||
finalItem.setItemMeta(meta);
|
finalItem.setItemMeta(meta);
|
||||||
return finalItem;
|
return finalItem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.events;
|
package lol.hyper.toolstats.events;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -114,8 +114,6 @@ public class PlayerFish implements Listener {
|
|||||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||||
timeCreated = finalDate.getTime();
|
timeCreated = finalDate.getTime();
|
||||||
} else {
|
|
||||||
finalDate = new Date(timeCreated);
|
|
||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
@@ -131,28 +129,21 @@ public class PlayerFish implements Listener {
|
|||||||
lore = new ArrayList<>();
|
lore = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.configTools.checkConfig(newItem.getType(), "fished-on")) {
|
// if creation date is enabled, add it
|
||||||
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 5, newItem);
|
||||||
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 5);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 5);
|
||||||
|
lore.add(creationDate);
|
||||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
|
||||||
Component newLine = toolStats.configTools.formatLore("fished.caught-on", "{date}", date);
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.configTools.checkConfig(newItem.getType(), "fished-by")) {
|
// if ownership is enabled, add it
|
||||||
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 5, newItem);
|
||||||
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 5);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 5);
|
||||||
|
lore.add(itemOwner);
|
||||||
Component newLine = toolStats.configTools.formatLore("fished.caught-by", "{player}", owner.getName());
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.events;
|
package lol.hyper.toolstats.events;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -53,15 +52,23 @@ public class PlayerMove implements Listener {
|
|||||||
// player is not flying
|
// player is not flying
|
||||||
if (playerStartFlight.containsKey(player)) {
|
if (playerStartFlight.containsKey(player)) {
|
||||||
PlayerInventory inventory = player.getInventory();
|
PlayerInventory inventory = player.getInventory();
|
||||||
ItemStack chest = inventory.getChestplate();
|
// copy their current armor
|
||||||
// make sure the player is wearing an elytra
|
ItemStack[] armor = inventory.getArmorContents().clone();
|
||||||
if (chest != null && chest.getType() == Material.ELYTRA) {
|
for (ItemStack armorPiece : armor) {
|
||||||
|
// skip missing slots
|
||||||
|
if (armorPiece == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// if the armor piece can glide, track the flight time
|
||||||
|
if (toolStats.itemChecker.canGlide(armorPiece)) {
|
||||||
long duration = (System.currentTimeMillis() - playerStartFlight.get(player));
|
long duration = (System.currentTimeMillis() - playerStartFlight.get(player));
|
||||||
ItemMeta newItem = toolStats.itemLore.updateFlightTime(chest, duration);
|
ItemMeta newMeta = toolStats.itemLore.updateFlightTime(armorPiece, duration);
|
||||||
if (newItem != null) {
|
if (newMeta != null) {
|
||||||
inventory.getChestplate().setItemMeta(newItem);
|
armorPiece.setItemMeta(newMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
inventory.setArmorContents(armor);
|
||||||
playerStartFlight.remove(player);
|
playerStartFlight.remove(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.events;
|
package lol.hyper.toolstats.events;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import lol.hyper.toolstats.tools.UUIDDataType;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -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();
|
||||||
@@ -131,8 +131,6 @@ public class VillagerTrade implements Listener {
|
|||||||
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
if (toolStats.config.getBoolean("normalize-time-creation")) {
|
||||||
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
finalDate = toolStats.numberFormat.normalizeTime(timeCreated);
|
||||||
timeCreated = finalDate.getTime();
|
timeCreated = finalDate.getTime();
|
||||||
} else {
|
|
||||||
finalDate = new Date(timeCreated);
|
|
||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
@@ -148,28 +146,22 @@ public class VillagerTrade implements Listener {
|
|||||||
lore = new ArrayList<>();
|
lore = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.configTools.checkConfig(newItem.getType(), "traded-on")) {
|
|
||||||
|
// if creation date is enabled, add it
|
||||||
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 3, newItem);
|
||||||
|
if (creationDate != null) {
|
||||||
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
container.set(toolStats.timeCreated, PersistentDataType.LONG, timeCreated);
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
|
||||||
|
lore.add(creationDate);
|
||||||
String date = toolStats.numberFormat.formatDate(finalDate);
|
|
||||||
Component newLine = toolStats.configTools.formatLore("traded.traded-on", "{date}", date);
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStats.configTools.checkConfig(newItem.getType(), "traded-by")) {
|
// if ownership is enabled, add it
|
||||||
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 3, newItem);
|
||||||
|
if (itemOwner != null) {
|
||||||
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
container.set(toolStats.itemOwner, new UUIDDataType(), owner.getUniqueId());
|
||||||
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
|
container.set(toolStats.originType, PersistentDataType.INTEGER, 3);
|
||||||
|
lore.add(itemOwner);
|
||||||
Component newLine = toolStats.configTools.formatLore("traded.traded-by", "{player}", owner.getName());
|
|
||||||
if (newLine == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
lore.add(newLine);
|
|
||||||
meta.lore(lore);
|
meta.lore(lore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,6 +17,7 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.tools;
|
package lol.hyper.toolstats.tools;
|
||||||
|
|
||||||
|
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
@@ -116,6 +117,22 @@ public class ItemChecker {
|
|||||||
return mineItems.contains(itemType);
|
return mineItems.contains(itemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In newer versions of Minecraft, you can make items glide, which works
|
||||||
|
* like an Elytra.
|
||||||
|
*
|
||||||
|
* @param itemStack The item to check.
|
||||||
|
* @return True/false if the item can glide like an Elytra.
|
||||||
|
*/
|
||||||
|
public boolean canGlide(ItemStack itemStack) {
|
||||||
|
// if it's an elytra, we are good
|
||||||
|
if (itemStack.getType() == Material.ELYTRA) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// otherwise if it has the GLIDER data
|
||||||
|
return itemStack.hasData(DataComponentTypes.GLIDER);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check a given item for a target token.
|
* Check a given item for a target token.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -17,17 +17,17 @@
|
|||||||
|
|
||||||
package lol.hyper.toolstats.tools;
|
package lol.hyper.toolstats.tools;
|
||||||
|
|
||||||
|
import lol.hyper.hyperlib.datatypes.UUIDDataType;
|
||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ItemLore {
|
public class ItemLore {
|
||||||
|
|
||||||
@@ -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.
|
||||||
*
|
*
|
||||||
@@ -97,6 +78,9 @@ public class ItemLore {
|
|||||||
* @return The lore with the line removed.
|
* @return The lore with the line removed.
|
||||||
*/
|
*/
|
||||||
public List<Component> removeLore(List<Component> inputLore, Component toRemove) {
|
public List<Component> removeLore(List<Component> inputLore, Component toRemove) {
|
||||||
|
if (inputLore == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
List<Component> newLore = new ArrayList<>(inputLore);
|
List<Component> newLore = new ArrayList<>(inputLore);
|
||||||
newLore.removeIf(line -> PlainTextComponentSerializer.plainText().serialize(line).equals(PlainTextComponentSerializer.plainText().serialize(toRemove)));
|
newLore.removeIf(line -> PlainTextComponentSerializer.plainText().serialize(line).equals(PlainTextComponentSerializer.plainText().serialize(toRemove)));
|
||||||
return newLore;
|
return newLore;
|
||||||
@@ -111,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
|
||||||
@@ -185,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);
|
||||||
@@ -196,7 +180,7 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@@ -210,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,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);
|
||||||
@@ -295,7 +279,7 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@@ -309,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,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);
|
||||||
@@ -393,7 +377,7 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@@ -407,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,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);
|
||||||
@@ -491,7 +475,7 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@@ -513,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,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);
|
||||||
@@ -597,7 +581,7 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@@ -619,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -692,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);
|
||||||
@@ -703,7 +687,7 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@@ -717,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -800,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);
|
||||||
@@ -819,7 +803,7 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@@ -833,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -906,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);
|
||||||
@@ -917,7 +901,7 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@@ -931,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1006,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);
|
||||||
@@ -1017,7 +1001,7 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
@@ -1031,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1104,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);
|
||||||
@@ -1115,8 +1099,269 @@ public class ItemLore {
|
|||||||
if (oldLine == null || newLine == null) {
|
if (oldLine == null || newLine == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Component> newLore = toolStats.itemLore.updateItemLore(meta, oldLine, newLine);
|
List<Component> newLore = updateItemLore(meta, oldLine, newLine);
|
||||||
meta.lore(newLore);
|
meta.lore(newLore);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the item owner lore.
|
||||||
|
*
|
||||||
|
* @param playerName The player's name who owns the items.
|
||||||
|
* @param origin The origin type.
|
||||||
|
* @param item The item.
|
||||||
|
* @return A component with the lore.
|
||||||
|
*/
|
||||||
|
public Component formatOwner(String playerName, int origin, ItemStack item) {
|
||||||
|
switch (origin) {
|
||||||
|
case 0: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "crafted-by")) {
|
||||||
|
return toolStats.configTools.formatLore("crafted.crafted-by", "{player}", playerName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "looted-by")) {
|
||||||
|
return toolStats.configTools.formatLore("looted.looted-by", "{player}", playerName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "traded-by")) {
|
||||||
|
return toolStats.configTools.formatLore("traded.traded-by", "{player}", playerName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: {
|
||||||
|
if (toolStats.config.getBoolean("enabled.elytra-tag")) {
|
||||||
|
return toolStats.configTools.formatLore("looted.found-by", "{player}", playerName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "fished-by")) {
|
||||||
|
return toolStats.configTools.formatLore("fished.caught-by", "{player}", playerName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 6: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "spawned-in-by")) {
|
||||||
|
return toolStats.configTools.formatLore("spawned-in.spawned-by", "{player}", playerName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the item creation time.
|
||||||
|
*
|
||||||
|
* @param creationDate When the item was created.
|
||||||
|
* @param origin The origin type.
|
||||||
|
* @param item The item.
|
||||||
|
* @return A component with the lore.
|
||||||
|
*/
|
||||||
|
public Component formatCreationTime(long creationDate, int origin, ItemStack item) {
|
||||||
|
String date = toolStats.numberFormat.formatDate(new Date(creationDate));
|
||||||
|
switch (origin) {
|
||||||
|
case 0: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "crafted-on")) {
|
||||||
|
return toolStats.configTools.formatLore("crafted.crafted-on", "{date}", date);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
if (toolStats.config.getBoolean("enabled.dropped-on")) {
|
||||||
|
return toolStats.configTools.formatLore("dropped-on", "{date}", date);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "looted-on")) {
|
||||||
|
return toolStats.configTools.formatLore("looted.looted-on", "{date}", date);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "traded-on")) {
|
||||||
|
return toolStats.configTools.formatLore("traded.traded-on", "{date}", date);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: {
|
||||||
|
if (toolStats.config.getBoolean("enabled.elytra-tag")) {
|
||||||
|
return toolStats.configTools.formatLore("looted.found-on", "{date}", date);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "fished-on")) {
|
||||||
|
return toolStats.configTools.formatLore("fished.caught-on", "{date}", date);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 6: {
|
||||||
|
if (toolStats.configTools.checkConfig(item.getType(), "spawned-in-on")) {
|
||||||
|
return toolStats.configTools.formatLore("spawned-in.spawned-on", "{date}", date);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all stats, ownership, and creation time from an item.
|
||||||
|
*
|
||||||
|
* @param inputItem The input item to remove stats from.
|
||||||
|
* @param removeMeta Remove ownership and creation time?
|
||||||
|
*/
|
||||||
|
public ItemStack removeAll(ItemStack inputItem, boolean removeMeta) {
|
||||||
|
ItemStack finalItem = inputItem.clone();
|
||||||
|
ItemMeta meta = finalItem.getItemMeta();
|
||||||
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
|
// remove the applied tokens
|
||||||
|
if (container.has(toolStats.tokenApplied)) {
|
||||||
|
container.remove(toolStats.tokenApplied);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (container.has(toolStats.playerKills)) {
|
||||||
|
Integer playerKills = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
||||||
|
if (playerKills != null) {
|
||||||
|
container.remove(toolStats.playerKills);
|
||||||
|
|
||||||
|
String playerKillsFormatted = toolStats.numberFormat.formatInt(playerKills);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLore("kills.player", "{kills}", playerKillsFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.mobKills)) {
|
||||||
|
Integer mobKills = container.get(toolStats.mobKills, PersistentDataType.INTEGER);
|
||||||
|
if (mobKills != null) {
|
||||||
|
container.remove(toolStats.mobKills);
|
||||||
|
String mobKillsFormatted = toolStats.numberFormat.formatInt(mobKills);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLore("kills.mob", "{kills}", mobKillsFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.blocksMined)) {
|
||||||
|
Integer blocksMined = container.get(toolStats.blocksMined, PersistentDataType.INTEGER);
|
||||||
|
if (blocksMined != null) {
|
||||||
|
container.remove(toolStats.blocksMined);
|
||||||
|
String blocksMinedFormatted = toolStats.numberFormat.formatInt(blocksMined);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLore("blocks-mined", "{blocks}", blocksMinedFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.cropsHarvested)) {
|
||||||
|
Integer cropsHarvested = container.get(toolStats.playerKills, PersistentDataType.INTEGER);
|
||||||
|
if (cropsHarvested != null) {
|
||||||
|
container.remove(toolStats.cropsHarvested);
|
||||||
|
String cropsHarvestedFormatted = toolStats.numberFormat.formatInt(cropsHarvested);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLore("crops-harvested", "{crops}", cropsHarvestedFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.fishCaught)) {
|
||||||
|
Integer fishCaught = container.get(toolStats.fishCaught, PersistentDataType.INTEGER);
|
||||||
|
if (fishCaught != null) {
|
||||||
|
container.remove(toolStats.fishCaught);
|
||||||
|
String fishCaughtFormatted = toolStats.numberFormat.formatInt(fishCaught);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLore("fished.fish-caught", "{fish}", fishCaughtFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.sheepSheared)) {
|
||||||
|
Integer sheepSheared = container.get(toolStats.sheepSheared, PersistentDataType.INTEGER);
|
||||||
|
if (sheepSheared != null) {
|
||||||
|
container.remove(toolStats.sheepSheared);
|
||||||
|
String sheepShearedFormatted = toolStats.numberFormat.formatInt(sheepSheared);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLore("sheep.sheared", "{sheep}", sheepShearedFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.armorDamage)) {
|
||||||
|
Double armorDamage = container.get(toolStats.armorDamage, PersistentDataType.DOUBLE);
|
||||||
|
if (armorDamage != null) {
|
||||||
|
container.remove(toolStats.armorDamage);
|
||||||
|
String armorDamageFormatted = toolStats.numberFormat.formatDouble(armorDamage);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLore("damage-taken", "{damage}", armorDamageFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.damageDone)) {
|
||||||
|
Double damageDone = container.get(toolStats.damageDone, PersistentDataType.DOUBLE);
|
||||||
|
if (damageDone != null) {
|
||||||
|
container.remove(toolStats.damageDone);
|
||||||
|
String damageDoneFormatted = toolStats.numberFormat.formatDouble(damageDone);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLore("damage-done", "{damage}", damageDoneFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.arrowsShot)) {
|
||||||
|
Integer arrowsShot = container.get(toolStats.arrowsShot, PersistentDataType.INTEGER);
|
||||||
|
if (arrowsShot != null) {
|
||||||
|
container.remove(toolStats.arrowsShot);
|
||||||
|
|
||||||
|
String arrowsShotFormatted = toolStats.numberFormat.formatInt(arrowsShot);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLore("arrows-shot", "{arrows}", arrowsShotFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.flightTime)) {
|
||||||
|
Long flightTime = container.get(toolStats.flightTime, PersistentDataType.LONG);
|
||||||
|
if (flightTime != null) {
|
||||||
|
container.remove(toolStats.flightTime);
|
||||||
|
Map<String, String> flightTimeFormatted = toolStats.numberFormat.formatTime(flightTime);
|
||||||
|
Component lineToRemove = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", flightTimeFormatted);
|
||||||
|
meta.lore(removeLore(meta.lore(), lineToRemove));
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (removeMeta) {
|
||||||
|
Integer origin = null;
|
||||||
|
if (container.has(toolStats.originType)) {
|
||||||
|
origin = container.get(toolStats.originType, PersistentDataType.INTEGER);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (container.has(toolStats.timeCreated)) {
|
||||||
|
Long timeCreated = container.get(toolStats.timeCreated, PersistentDataType.LONG);
|
||||||
|
if (timeCreated != null && origin != null) {
|
||||||
|
container.remove(toolStats.timeCreated);
|
||||||
|
Component timeCreatedLore = formatCreationTime(timeCreated, origin, finalItem);
|
||||||
|
meta.lore(removeLore(meta.lore(), timeCreatedLore));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container.has(toolStats.itemOwner)) {
|
||||||
|
UUID owner = container.get(toolStats.itemOwner, new UUIDDataType());
|
||||||
|
if (owner != null && origin != null) {
|
||||||
|
container.remove(toolStats.itemOwner);
|
||||||
|
String ownerName = Bukkit.getOfflinePlayer(owner).getName();
|
||||||
|
if (ownerName != null) {
|
||||||
|
Component ownerLore = formatOwner(ownerName, origin, finalItem);
|
||||||
|
meta.lore(removeLore(meta.lore(), ownerLore));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (origin != null) {
|
||||||
|
container.remove(toolStats.originType);
|
||||||
|
}
|
||||||
|
|
||||||
|
finalItem.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
return finalItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,8 @@ public class TokenData {
|
|||||||
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
|
PersistentDataContainer tokenData = tokenMeta.getPersistentDataContainer();
|
||||||
|
|
||||||
// set the title and lore
|
// set the title and lore
|
||||||
Component title = toolStats.configTools.format("tokens.data." + tokenType + ".title");
|
String titleFromConfig = toolStats.config.getString("tokens.data." + tokenType + ".title");
|
||||||
|
Component title = toolStats.textUtils.format(titleFromConfig);
|
||||||
List<Component> lore = toolStats.configTools.getTokenLore(tokenType);
|
List<Component> lore = toolStats.configTools.getTokenLore(tokenType);
|
||||||
tokenMeta.displayName(title);
|
tokenMeta.displayName(title);
|
||||||
tokenMeta.lore(lore);
|
tokenMeta.lore(lore);
|
||||||
@@ -184,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);
|
||||||
@@ -207,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();
|
||||||
@@ -216,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ToolStats.
|
|
||||||
*
|
|
||||||
* ToolStats is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* ToolStats is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with ToolStats. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package lol.hyper.toolstats.tools;
|
|
||||||
|
|
||||||
import org.bukkit.persistence.PersistentDataAdapterContext;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class UUIDDataType implements PersistentDataType<byte[], UUID> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Class<byte[]> getPrimitiveType() {
|
|
||||||
return byte[].class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Class<UUID> getComplexType() {
|
|
||||||
return UUID.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte @NotNull [] toPrimitive(UUID complex, @NotNull PersistentDataAdapterContext context) {
|
|
||||||
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
|
|
||||||
bb.putLong(complex.getMostSignificantBits());
|
|
||||||
bb.putLong(complex.getLeastSignificantBits());
|
|
||||||
return bb.array();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull UUID fromPrimitive(byte @NotNull [] primitive, @NotNull PersistentDataAdapterContext context) {
|
|
||||||
ByteBuffer bb = ByteBuffer.wrap(primitive);
|
|
||||||
long firstLong = bb.getLong();
|
|
||||||
long secondLong = bb.getLong();
|
|
||||||
return new UUID(firstLong, secondLong);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,8 +20,6 @@ package lol.hyper.toolstats.tools.config;
|
|||||||
import lol.hyper.toolstats.ToolStats;
|
import lol.hyper.toolstats.ToolStats;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -34,8 +32,6 @@ import java.util.regex.Pattern;
|
|||||||
public class ConfigTools {
|
public class ConfigTools {
|
||||||
|
|
||||||
private final ToolStats toolStats;
|
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 ConfigTools(ToolStats toolStats) {
|
public ConfigTools(ToolStats toolStats) {
|
||||||
this.toolStats = toolStats;
|
this.toolStats = toolStats;
|
||||||
@@ -50,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,16 +121,7 @@ public class ConfigTools {
|
|||||||
lore = lore.replace(placeHolder, String.valueOf(value));
|
lore = lore.replace(placeHolder, String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we match the old color codes, then format them as so
|
component = toolStats.textUtils.format(lore);
|
||||||
Matcher hexMatcher = CONFIG_HEX_PATTERN.matcher(lore);
|
|
||||||
Matcher colorMatcher = COLOR_CODES.matcher(lore);
|
|
||||||
if (hexMatcher.find() || colorMatcher.find()) {
|
|
||||||
component = LegacyComponentSerializer.legacyAmpersand().deserialize(lore);
|
|
||||||
} else {
|
|
||||||
// otherwise format them normally
|
|
||||||
component = MiniMessage.miniMessage().deserialize(lore);
|
|
||||||
}
|
|
||||||
|
|
||||||
return component.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE);
|
return component.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,49 +170,7 @@ public class ConfigTools {
|
|||||||
Component component;
|
Component component;
|
||||||
// Clean output text
|
// Clean output text
|
||||||
String outputText = result.toString().replaceAll("\\s+", " ").trim();
|
String outputText = result.toString().replaceAll("\\s+", " ").trim();
|
||||||
|
component = toolStats.textUtils.format(outputText);
|
||||||
// if we match the old color codes, then format them as so
|
|
||||||
Matcher hexMatcher = CONFIG_HEX_PATTERN.matcher(outputText);
|
|
||||||
Matcher colorMatcher = COLOR_CODES.matcher(outputText);
|
|
||||||
if (hexMatcher.find() || colorMatcher.find()) {
|
|
||||||
component = LegacyComponentSerializer.legacyAmpersand().deserialize(outputText);
|
|
||||||
} else {
|
|
||||||
// otherwise format them normally
|
|
||||||
component = MiniMessage.miniMessage().deserialize(outputText);
|
|
||||||
}
|
|
||||||
|
|
||||||
return component.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format a string from the config.
|
|
||||||
*
|
|
||||||
* @param configName The config to format.
|
|
||||||
* @return Formatted string, null if the configName doesn't exist.
|
|
||||||
*/
|
|
||||||
public Component format(String configName) {
|
|
||||||
String message = toolStats.config.getString(configName);
|
|
||||||
if (message == null) {
|
|
||||||
toolStats.logger.warning("Unable to find config message for: " + configName);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the config message is empty, don't send it
|
|
||||||
if (message.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the final component for this lore
|
|
||||||
Component component;
|
|
||||||
// if we match the old color codes, then format them as so
|
|
||||||
Matcher hexMatcher = CONFIG_HEX_PATTERN.matcher(message);
|
|
||||||
Matcher colorMatcher = COLOR_CODES.matcher(message);
|
|
||||||
if (hexMatcher.find() || colorMatcher.find()) {
|
|
||||||
component = LegacyComponentSerializer.legacyAmpersand().deserialize(message);
|
|
||||||
} else {
|
|
||||||
// otherwise format them normally
|
|
||||||
component = MiniMessage.miniMessage().deserialize(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return component.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE);
|
return component.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE);
|
||||||
}
|
}
|
||||||
@@ -251,16 +196,7 @@ public class ConfigTools {
|
|||||||
line = line.replace("{levels}", String.valueOf(levels));
|
line = line.replace("{levels}", String.valueOf(levels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component component;
|
Component component = toolStats.textUtils.format(line);
|
||||||
// if we match the old color codes, then format them as so
|
|
||||||
Matcher hexMatcher = CONFIG_HEX_PATTERN.matcher(line);
|
|
||||||
Matcher colorMatcher = COLOR_CODES.matcher(line);
|
|
||||||
if (hexMatcher.find() || colorMatcher.find()) {
|
|
||||||
component = LegacyComponentSerializer.legacyAmpersand().deserialize(line);
|
|
||||||
} else {
|
|
||||||
// otherwise format them normally
|
|
||||||
component = MiniMessage.miniMessage().deserialize(line);
|
|
||||||
}
|
|
||||||
component = component.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE);
|
component = component.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE);
|
||||||
finalLore.add(component);
|
finalLore.add(component);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ public class Version10 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-9.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-9.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config-9.yml!");
|
toolStats.logger.error("Unable to save config-9.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we make this super verbose so that admins can see what's being added
|
// we make this super verbose so that admins can see what's being added
|
||||||
@@ -72,8 +71,7 @@ public class Version10 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config.yml!");
|
toolStats.logger.error("Unable to save config.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
toolStats.loadConfig();
|
toolStats.loadConfig();
|
||||||
toolStats.logger.info("Config has been updated to version 10. A copy of version 9 has been saved as config-9.yml");
|
toolStats.logger.info("Config has been updated to version 10. A copy of version 9 has been saved as config-9.yml");
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ public class Version11 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-10.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-10.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config-10.yml!");
|
toolStats.logger.error("Unable to save config-10.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we make this super verbose so that admins can see what's being added
|
// we make this super verbose so that admins can see what's being added
|
||||||
@@ -95,8 +94,7 @@ public class Version11 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config.yml!");
|
toolStats.logger.error("Unable to save config.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
toolStats.loadConfig();
|
toolStats.loadConfig();
|
||||||
toolStats.logger.info("Config has been updated to version 11. A copy of version 10 has been saved as config-10.yml");
|
toolStats.logger.info("Config has been updated to version 11. A copy of version 10 has been saved as config-10.yml");
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ public class Version12 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-11.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-11.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config-11.yml!");
|
toolStats.logger.error("Unable to save config-11.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toolStats.logger.info("Updating config.yml to version 12.");
|
toolStats.logger.info("Updating config.yml to version 12.");
|
||||||
@@ -102,15 +101,14 @@ public class Version12 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config.yml!");
|
toolStats.logger.error("Unable to save config.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
toolStats.loadConfig();
|
toolStats.loadConfig();
|
||||||
toolStats.logger.info("Config has been updated to version 12. A copy of version 11 has been saved as config-11.yml");
|
toolStats.logger.info("Config has been updated to version 12. A copy of version 11 has been saved as config-11.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,21 +43,20 @@ public class Version13 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-12.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-12.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config-12.yml!");
|
toolStats.logger.error("Unable to save config-12.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toolStats.logger.info("Updating config.yml to version 13.");
|
toolStats.logger.info("Updating config.yml to version 13.");
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,8 +64,7 @@ public class Version13 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config.yml!");
|
toolStats.logger.error("Unable to save config.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
toolStats.loadConfig();
|
toolStats.loadConfig();
|
||||||
toolStats.logger.info("Config has been updated to version 13. A copy of version 12 has been saved as config-12.yml");
|
toolStats.logger.info("Config has been updated to version 13. A copy of version 12 has been saved as config-12.yml");
|
||||||
|
|||||||
@@ -46,8 +46,7 @@ public class Version6 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-5.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-5.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config-5.yml!");
|
toolStats.logger.error("Unable to save config-5.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we make this super verbose so that admins can see what's being added
|
// we make this super verbose so that admins can see what's being added
|
||||||
@@ -107,8 +106,7 @@ public class Version6 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config.yml!");
|
toolStats.logger.error("Unable to save config.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
toolStats.loadConfig();
|
toolStats.loadConfig();
|
||||||
toolStats.logger.info("Config has been updated to version 6. A copy of version 5 has been saved as config-5.yml");
|
toolStats.logger.info("Config has been updated to version 6. A copy of version 5 has been saved as config-5.yml");
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ public class Version7 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-6.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-6.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config-6.yml!");
|
toolStats.logger.error("Unable to save config-6.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we make this super verbose so that admins can see what's being added
|
// we make this super verbose so that admins can see what's being added
|
||||||
@@ -61,8 +60,7 @@ public class Version7 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config.yml!");
|
toolStats.logger.error("Unable to save config.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
toolStats.loadConfig();
|
toolStats.loadConfig();
|
||||||
toolStats.logger.info("Config has been updated to version 7. A copy of version 6 has been saved as config-6.yml");
|
toolStats.logger.info("Config has been updated to version 7. A copy of version 6 has been saved as config-6.yml");
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ public class Version8 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-7.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-7.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config-7.yml!");
|
toolStats.logger.error("Unable to save config-7.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we make this super verbose so that admins can see what's being added
|
// we make this super verbose so that admins can see what's being added
|
||||||
@@ -78,8 +77,7 @@ public class Version8 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config.yml!");
|
toolStats.logger.error("Unable to save config.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
toolStats.loadConfig();
|
toolStats.loadConfig();
|
||||||
toolStats.logger.info("Config has been updated to version 8. A copy of version 7 has been saved as config-7.yml");
|
toolStats.logger.info("Config has been updated to version 8. A copy of version 7 has been saved as config-7.yml");
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ public class Version9 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-8.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-8.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config-8.yml!");
|
toolStats.logger.error("Unable to save config-8.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toolStats.logger.info("Updating config.yml to version 9.");
|
toolStats.logger.info("Updating config.yml to version 9.");
|
||||||
@@ -78,8 +77,7 @@ public class Version9 {
|
|||||||
try {
|
try {
|
||||||
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
toolStats.logger.severe("Unable to save config.yml!");
|
toolStats.logger.error("Unable to save config.yml!", exception);
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
}
|
||||||
toolStats.loadConfig();
|
toolStats.loadConfig();
|
||||||
toolStats.logger.info("Config has been updated to version 9. A copy of version 8 has been saved as config-8.yml");
|
toolStats.logger.info("Config has been updated to version 9. A copy of version 8 has been saved as config-8.yml");
|
||||||
@@ -93,7 +91,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);
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ permissions:
|
|||||||
toolstats.reset.confirm:
|
toolstats.reset.confirm:
|
||||||
description: Allows the usage of /toolstats reset confirm.
|
description: Allows the usage of /toolstats reset confirm.
|
||||||
default: true
|
default: true
|
||||||
|
toolstats.purge:
|
||||||
|
description: Allows the usage of /toolstats purge.
|
||||||
|
default: true
|
||||||
|
toolstats.purge.confirm:
|
||||||
|
description: Allows the usage of /toolstats purge confirm.
|
||||||
|
default: true
|
||||||
toolstats.givetokens:
|
toolstats.givetokens:
|
||||||
description: Allows the usage of /toolstats givetoken.
|
description: Allows the usage of /toolstats givetoken.
|
||||||
default: op
|
default: op
|
||||||
|
|||||||