1.9.11 (spear support)

This commit is contained in:
hyperdefined
2025-12-22 19:09:14 -05:00
parent c28ee0fb8c
commit b5040a4636
7 changed files with 104 additions and 5 deletions

View File

@@ -23,7 +23,7 @@
<groupId>lol.hyper</groupId>
<artifactId>toolstats</artifactId>
<version>1.9.10</version>
<version>1.9.11</version>
<packaging>jar</packaging>
<name>ToolStats</name>
@@ -105,7 +105,7 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.10-R0.1-SNAPSHOT</version>
<version>1.21.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@@ -119,7 +119,7 @@ public final class ToolStats extends JavaPlugin {
*/
public final NamespacedKey originType = new NamespacedKey(this, "origin");
public final int CONFIG_VERSION = 13;
public final int CONFIG_VERSION = 14;
public final ComponentLogger logger = this.getComponentLogger();
public final File configFile = new File(this.getDataFolder(), "config.yml");
public boolean tokens = false;

View File

@@ -52,7 +52,7 @@ public class ItemChecker {
mineItems.add(material);
}
if (lowerCase.contains("_sword") || lowerCase.contains("_axe")) {
if (lowerCase.contains("_sword") || lowerCase.contains("_axe") || lowerCase.contains("_spear")) {
meleeItems.add(material);
}

View File

@@ -87,6 +87,7 @@ public class ConfigTools {
case "trident" -> toolStats.config.getBoolean("enabled." + configName + ".trident");
case "fishing-rod" -> toolStats.config.getBoolean("enabled." + configName + ".fishing-rod");
case "mace" -> toolStats.config.getBoolean("enabled." + configName + ".mace");
case "spear" -> toolStats.config.getBoolean("enabled." + configName + ".spear");
case "helmet", "chestplate", "leggings", "boots" ->
toolStats.config.getBoolean("enabled." + configName + ".armor");
default -> false;

View File

@@ -40,6 +40,7 @@ public class ConfigUpdater {
case 10 -> new Version11(toolStats).update(); // 10 to 11
case 11 -> new Version12(toolStats).update(); // 11 to 12
case 12 -> new Version13(toolStats).update(); // 12 to 13
case 13 -> new Version14(toolStats).update(); // 13 to 14
}
}
}

View File

@@ -0,0 +1,88 @@
/*
* 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.config.versions;
import lol.hyper.toolstats.ToolStats;
import java.io.File;
import java.io.IOException;
public class Version14 {
private final ToolStats toolStats;
/**
* Used for updating from version 13 to 14.
*
* @param toolStats ToolStats instance.
*/
public Version14(ToolStats toolStats) {
this.toolStats = toolStats;
}
/**
* Perform the config update.
*/
public void update() {
// save the old config first
try {
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-13.yml");
} catch (IOException exception) {
toolStats.logger.error("Unable to save config-13.yml!", exception);
}
toolStats.logger.info("Updating config.yml to version 14.");
toolStats.config.set("config-version", 14);
// add spear to sections to be a toggle
toolStats.config.set("enabled.crafted-by.spear", true);
toolStats.logger.info("Adding enabled.crafted-by.spear");
toolStats.config.set("enabled.crafted-on.spear", true);
toolStats.logger.info("Adding enabled.crafted-on.spear");
toolStats.config.set("enabled.looted-by.spear", true);
toolStats.logger.info("Adding enabled.looted-by.spear");
toolStats.config.set("enabled.looted-on.spear", true);
toolStats.logger.info("Adding enabled.looted-on.spear");
toolStats.config.set("enabled.damage-done.spear", true);
toolStats.logger.info("Adding enabled.damage-done.spear");
toolStats.config.set("enabled.player-kills.spear", true);
toolStats.logger.info("Adding enabled.player-kills.spear");
toolStats.config.set("enabled.mob-kills.spear", true);
toolStats.logger.info("Adding enabled.mob-kills.spear");
toolStats.config.set("enabled.spawned-in-by.spear", true);
toolStats.logger.info("Adding enabled.spawned-in-by.spear");
toolStats.config.set("enabled.spawned-in-on.spear", true);
toolStats.logger.info("Adding enabled.spawned-in-on.spear");
try {
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
} catch (IOException exception) {
toolStats.logger.error("Unable to save config.yml!", exception);
}
toolStats.loadConfig();
toolStats.logger.info("Config has been updated to version 14. A copy of version 13 has been saved as config-13.yml");
}
}

View File

@@ -150,6 +150,7 @@ enabled:
armor: true
mace: true
fishing-rod: true
spear: true
# Will show "Crafted on <date>"
crafted-on:
pickaxe: true
@@ -162,6 +163,7 @@ enabled:
armor: true
mace: true
fishing-rod: true
spear: true
# Will show "Fished by <player>"
fished-by:
pickaxe: true
@@ -195,6 +197,7 @@ enabled:
bow: true
armor: true
fishing-rod: true
spear: true
# Will show "Found on <date>"
looted-on:
pickaxe: true
@@ -206,6 +209,7 @@ enabled:
bow: true
armor: true
fishing-rod: true
spear: true
# Will show "Traded by <player>"
traded-by:
pickaxe: true
@@ -234,18 +238,21 @@ enabled:
trident: true
bow: true
mace: true
spear: true
player-kills:
sword: true
axe: true
trident: true
bow: true
mace: true
spear: true
mob-kills:
sword: true
axe: true
trident: true
bow: true
mace: true
spear: true
blocks-mined:
pickaxe: true
shovel: true
@@ -264,6 +271,7 @@ enabled:
armor: true
mace: true
fishing-rod: true
spear: true
# Will show "Spawned in on <date>"
spawned-in-on:
pickaxe: true
@@ -276,6 +284,7 @@ enabled:
armor: true
mace: true
fishing-rod: true
spear: true
fish-caught: true
sheep-sheared: true
armor-damage: true
@@ -346,4 +355,4 @@ normalize-time-creation: false
# Allows stats and origins to be tracked if the player is in creative mode.
allow-creative: false
config-version: 13
config-version: 14