Skip to content

Commit b5040a4

Browse files
committed
1.9.11 (spear support)
1 parent c28ee0f commit b5040a4

File tree

7 files changed

+104
-5
lines changed

7 files changed

+104
-5
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<groupId>lol.hyper</groupId>
2525
<artifactId>toolstats</artifactId>
26-
<version>1.9.10</version>
26+
<version>1.9.11</version>
2727
<packaging>jar</packaging>
2828

2929
<name>ToolStats</name>
@@ -105,7 +105,7 @@
105105
<dependency>
106106
<groupId>io.papermc.paper</groupId>
107107
<artifactId>paper-api</artifactId>
108-
<version>1.21.10-R0.1-SNAPSHOT</version>
108+
<version>1.21.11-R0.1-SNAPSHOT</version>
109109
<scope>provided</scope>
110110
</dependency>
111111
<dependency>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public final class ToolStats extends JavaPlugin {
119119
*/
120120
public final NamespacedKey originType = new NamespacedKey(this, "origin");
121121

122-
public final int CONFIG_VERSION = 13;
122+
public final int CONFIG_VERSION = 14;
123123
public final ComponentLogger logger = this.getComponentLogger();
124124
public final File configFile = new File(this.getDataFolder(), "config.yml");
125125
public boolean tokens = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void setup() {
5252
mineItems.add(material);
5353
}
5454

55-
if (lowerCase.contains("_sword") || lowerCase.contains("_axe")) {
55+
if (lowerCase.contains("_sword") || lowerCase.contains("_axe") || lowerCase.contains("_spear")) {
5656
meleeItems.add(material);
5757
}
5858

src/main/java/lol/hyper/toolstats/tools/config/ConfigTools.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public boolean checkConfig(Material material, String configName) {
8787
case "trident" -> toolStats.config.getBoolean("enabled." + configName + ".trident");
8888
case "fishing-rod" -> toolStats.config.getBoolean("enabled." + configName + ".fishing-rod");
8989
case "mace" -> toolStats.config.getBoolean("enabled." + configName + ".mace");
90+
case "spear" -> toolStats.config.getBoolean("enabled." + configName + ".spear");
9091
case "helmet", "chestplate", "leggings", "boots" ->
9192
toolStats.config.getBoolean("enabled." + configName + ".armor");
9293
default -> false;

src/main/java/lol/hyper/toolstats/tools/config/ConfigUpdater.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public void updateConfig() {
4040
case 10 -> new Version11(toolStats).update(); // 10 to 11
4141
case 11 -> new Version12(toolStats).update(); // 11 to 12
4242
case 12 -> new Version13(toolStats).update(); // 12 to 13
43+
case 13 -> new Version14(toolStats).update(); // 13 to 14
4344
}
4445
}
4546
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* This file is part of ToolStats.
3+
*
4+
* ToolStats is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* ToolStats is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with ToolStats. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package lol.hyper.toolstats.tools.config.versions;
19+
20+
import lol.hyper.toolstats.ToolStats;
21+
22+
import java.io.File;
23+
import java.io.IOException;
24+
25+
public class Version14 {
26+
27+
private final ToolStats toolStats;
28+
29+
/**
30+
* Used for updating from version 13 to 14.
31+
*
32+
* @param toolStats ToolStats instance.
33+
*/
34+
public Version14(ToolStats toolStats) {
35+
this.toolStats = toolStats;
36+
}
37+
38+
/**
39+
* Perform the config update.
40+
*/
41+
public void update() {
42+
// save the old config first
43+
try {
44+
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config-13.yml");
45+
} catch (IOException exception) {
46+
toolStats.logger.error("Unable to save config-13.yml!", exception);
47+
}
48+
49+
toolStats.logger.info("Updating config.yml to version 14.");
50+
toolStats.config.set("config-version", 14);
51+
52+
// add spear to sections to be a toggle
53+
toolStats.config.set("enabled.crafted-by.spear", true);
54+
toolStats.logger.info("Adding enabled.crafted-by.spear");
55+
56+
toolStats.config.set("enabled.crafted-on.spear", true);
57+
toolStats.logger.info("Adding enabled.crafted-on.spear");
58+
59+
toolStats.config.set("enabled.looted-by.spear", true);
60+
toolStats.logger.info("Adding enabled.looted-by.spear");
61+
62+
toolStats.config.set("enabled.looted-on.spear", true);
63+
toolStats.logger.info("Adding enabled.looted-on.spear");
64+
65+
toolStats.config.set("enabled.damage-done.spear", true);
66+
toolStats.logger.info("Adding enabled.damage-done.spear");
67+
68+
toolStats.config.set("enabled.player-kills.spear", true);
69+
toolStats.logger.info("Adding enabled.player-kills.spear");
70+
71+
toolStats.config.set("enabled.mob-kills.spear", true);
72+
toolStats.logger.info("Adding enabled.mob-kills.spear");
73+
74+
toolStats.config.set("enabled.spawned-in-by.spear", true);
75+
toolStats.logger.info("Adding enabled.spawned-in-by.spear");
76+
77+
toolStats.config.set("enabled.spawned-in-on.spear", true);
78+
toolStats.logger.info("Adding enabled.spawned-in-on.spear");
79+
80+
try {
81+
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
82+
} catch (IOException exception) {
83+
toolStats.logger.error("Unable to save config.yml!", exception);
84+
}
85+
toolStats.loadConfig();
86+
toolStats.logger.info("Config has been updated to version 14. A copy of version 13 has been saved as config-13.yml");
87+
}
88+
}

src/main/resources/config.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ enabled:
150150
armor: true
151151
mace: true
152152
fishing-rod: true
153+
spear: true
153154
# Will show "Crafted on <date>"
154155
crafted-on:
155156
pickaxe: true
@@ -162,6 +163,7 @@ enabled:
162163
armor: true
163164
mace: true
164165
fishing-rod: true
166+
spear: true
165167
# Will show "Fished by <player>"
166168
fished-by:
167169
pickaxe: true
@@ -195,6 +197,7 @@ enabled:
195197
bow: true
196198
armor: true
197199
fishing-rod: true
200+
spear: true
198201
# Will show "Found on <date>"
199202
looted-on:
200203
pickaxe: true
@@ -206,6 +209,7 @@ enabled:
206209
bow: true
207210
armor: true
208211
fishing-rod: true
212+
spear: true
209213
# Will show "Traded by <player>"
210214
traded-by:
211215
pickaxe: true
@@ -234,18 +238,21 @@ enabled:
234238
trident: true
235239
bow: true
236240
mace: true
241+
spear: true
237242
player-kills:
238243
sword: true
239244
axe: true
240245
trident: true
241246
bow: true
242247
mace: true
248+
spear: true
243249
mob-kills:
244250
sword: true
245251
axe: true
246252
trident: true
247253
bow: true
248254
mace: true
255+
spear: true
249256
blocks-mined:
250257
pickaxe: true
251258
shovel: true
@@ -264,6 +271,7 @@ enabled:
264271
armor: true
265272
mace: true
266273
fishing-rod: true
274+
spear: true
267275
# Will show "Spawned in on <date>"
268276
spawned-in-on:
269277
pickaxe: true
@@ -276,6 +284,7 @@ enabled:
276284
armor: true
277285
mace: true
278286
fishing-rod: true
287+
spear: true
279288
fish-caught: true
280289
sheep-sheared: true
281290
armor-damage: true
@@ -346,4 +355,4 @@ normalize-time-creation: false
346355
# Allows stats and origins to be tracked if the player is in creative mode.
347356
allow-creative: false
348357

349-
config-version: 13
358+
config-version: 14

0 commit comments

Comments
 (0)