Skip to content

Commit d56eda6

Browse files
committed
added more missing config values
1 parent c7a7849 commit d56eda6

3 files changed

Lines changed: 82 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public void updateConfig() {
4242
case 12 -> new Version13(toolStats).update(); // 12 to 13
4343
case 13 -> new Version14(toolStats).update(); // 13 to 14
4444
case 14 -> new Version15(toolStats).update(); // 14 to 15
45+
case 15 -> new Version16(toolStats).update(); // 15 to 16
4546
}
4647
}
4748
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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 Version16 {
26+
27+
private final ToolStats toolStats;
28+
29+
/**
30+
* Used for updating from version 15 to 16.
31+
*
32+
* @param toolStats ToolStats instance.
33+
*/
34+
public Version16(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-15.yml");
45+
} catch (IOException exception) {
46+
toolStats.logger.error("Unable to save config-15.yml!", exception);
47+
}
48+
49+
// we make this super verbose so that admins can see what's being added
50+
toolStats.logger.info("Updating config.yml to version 16.");
51+
toolStats.config.set("config-version", 16);
52+
53+
toolStats.logger.info("Adding enabled.crafted-on.shield to config.yml.");
54+
toolStats.config.set("enabled.crafted-on.shield", true);
55+
toolStats.logger.info("Adding enabled.crafted-by.shield to config.yml.");
56+
toolStats.config.set("enabled.crafted-by.shield", true);
57+
58+
toolStats.logger.info("Adding enabled.traded-on.shield to config.yml.");
59+
toolStats.config.set("enabled.traded-on.shield", true);
60+
toolStats.logger.info("Adding enabled.traded-by.shield to config.yml.");
61+
toolStats.config.set("enabled.traded-by.shield", true);
62+
63+
toolStats.logger.info("Adding enabled.looted-on.shield to config.yml.");
64+
toolStats.config.set("enabled.looted-on.shield", true);
65+
toolStats.logger.info("Adding enabled.looted-by.shield to config.yml.");
66+
toolStats.config.set("enabled.looted-by.shield", true);
67+
68+
// save the config and reload it
69+
try {
70+
toolStats.config.save("plugins" + File.separator + "ToolStats" + File.separator + "config.yml");
71+
} catch (IOException exception) {
72+
toolStats.logger.error("Unable to save config.yml!", exception);
73+
}
74+
toolStats.loadConfig();
75+
toolStats.logger.info("Config has been updated to version 16. A copy of version 6 has been saved as config-15.yml");
76+
}
77+
}

src/main/resources/config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ enabled:
195195
mace: true
196196
fishing-rod: true
197197
spear: true
198+
shield: true
198199
# Will show "Crafted on <date>"
199200
crafted-on:
200201
pickaxe: true
@@ -208,6 +209,7 @@ enabled:
208209
mace: true
209210
fishing-rod: true
210211
spear: true
212+
shield: true
211213
# Will show "Fished by <player>"
212214
fished-by:
213215
pickaxe: true
@@ -243,7 +245,6 @@ enabled:
243245
fishing-rod: true
244246
spear: true
245247
shield: true
246-
elytra: true
247248
# Will show "Found on <date>"
248249
looted-on:
249250
pickaxe: true
@@ -257,7 +258,6 @@ enabled:
257258
fishing-rod: true
258259
spear: true
259260
shield: true
260-
elytra: true
261261
# Will show "Traded by <player>"
262262
traded-by:
263263
pickaxe: true
@@ -269,6 +269,7 @@ enabled:
269269
bow: true
270270
armor: true
271271
fishing-rod: true
272+
shield: true
272273
# Will show "Traded on <date>"
273274
traded-on:
274275
pickaxe: true
@@ -280,6 +281,7 @@ enabled:
280281
bow: true
281282
armor: true
282283
fishing-rod: true
284+
shield: true
283285
damage-done:
284286
sword: true
285287
axe: true

0 commit comments

Comments
 (0)