mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2026-03-10 18:32:01 +00:00
Compare commits
7 Commits
7e9a62a8f1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b484b772cb | ||
|
|
d56eda6512 | ||
|
|
c7a784920d | ||
|
|
e029c1af3b | ||
|
|
a0282e67c1 | ||
|
|
bb33f4031a | ||
|
|
91331965f1 |
2
pom.xml
2
pom.xml
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<groupId>lol.hyper</groupId>
|
<groupId>lol.hyper</groupId>
|
||||||
<artifactId>toolstats</artifactId>
|
<artifactId>toolstats</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>ToolStats</name>
|
<name>ToolStats</name>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import java.io.File;
|
|||||||
|
|
||||||
public final class ToolStats extends JavaPlugin {
|
public final class ToolStats extends JavaPlugin {
|
||||||
|
|
||||||
public final int CONFIG_VERSION = 15;
|
public final int CONFIG_VERSION = 16;
|
||||||
public final ComponentLogger logger = this.getComponentLogger();
|
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;
|
||||||
|
|||||||
@@ -450,6 +450,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
* @param player The player using the command.
|
* @param player The player using the command.
|
||||||
*/
|
*/
|
||||||
private void handleEdit(String stat, Object userValue, Player player) {
|
private void handleEdit(String stat, Object userValue, Player player) {
|
||||||
|
boolean updated = false;
|
||||||
ItemStack editedItem = player.getInventory().getItemInMainHand().clone();
|
ItemStack editedItem = player.getInventory().getItemInMainHand().clone();
|
||||||
if (!toolStats.itemChecker.isValidItem(editedItem.getType())) {
|
if (!toolStats.itemChecker.isValidItem(editedItem.getType())) {
|
||||||
player.sendMessage(Component.text("This is not a valid item.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This is not a valid item.", NamedTextColor.RED));
|
||||||
@@ -482,6 +483,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateCropsMined(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updateCropsMined(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -511,6 +513,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateBlocksMined(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updateBlocksMined(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -540,6 +543,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
double difference = value - statValue;
|
double difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateArmorDamage(editedItem, difference, false);
|
editedItemMeta = toolStats.itemLore.updateArmorDamage(editedItem, difference, false);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -569,6 +573,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
double difference = value - statValue;
|
double difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateWeaponDamage(editedItem, difference, false);
|
editedItemMeta = toolStats.itemLore.updateWeaponDamage(editedItem, difference, false);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -598,6 +603,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateMobKills(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updateMobKills(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -627,6 +633,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updatePlayerKills(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updatePlayerKills(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -656,6 +663,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateArrowsShot(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updateArrowsShot(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -685,6 +693,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateSheepSheared(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updateSheepSheared(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -714,6 +723,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
long difference = value - statValue;
|
long difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateFlightTime(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updateFlightTime(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -743,6 +753,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateFishCaught(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updateFishCaught(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -772,6 +783,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateBossesKilled(editedItem, difference, "wither");
|
editedItemMeta = toolStats.itemLore.updateBossesKilled(editedItem, difference, "wither");
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -801,6 +813,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateBossesKilled(editedItem, difference, "enderdragon");
|
editedItemMeta = toolStats.itemLore.updateBossesKilled(editedItem, difference, "enderdragon");
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -830,6 +843,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateCriticalStrikes(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updateCriticalStrikes(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -859,6 +873,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
int difference = value - statValue;
|
int difference = value - statValue;
|
||||||
editedItemMeta = toolStats.itemLore.updateTridentThrows(editedItem, difference);
|
editedItemMeta = toolStats.itemLore.updateTridentThrows(editedItem, difference);
|
||||||
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
player.sendMessage(Component.text("This item does not have that stat.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
@@ -869,9 +884,12 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
editedItem.setItemMeta(editedItemMeta);
|
|
||||||
player.getInventory().setItemInMainHand(editedItem);
|
if (updated) {
|
||||||
player.sendMessage(Component.text("Updated stat " + stat + " for held item!", NamedTextColor.GREEN));
|
editedItem.setItemMeta(editedItemMeta);
|
||||||
|
player.getInventory().setItemInMainHand(editedItem);
|
||||||
|
player.sendMessage(Component.text("Updated stat " + stat + " for held item!", NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1114,7 +1132,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "fight-caught": {
|
case "fish-caught": {
|
||||||
if (container.has(toolStats.toolStatsKeys.getFishCaught())) {
|
if (container.has(toolStats.toolStatsKeys.getFishCaught())) {
|
||||||
Integer statValue = container.get(toolStats.toolStatsKeys.getFishCaught(), PersistentDataType.INTEGER);
|
Integer statValue = container.get(toolStats.toolStatsKeys.getFishCaught(), PersistentDataType.INTEGER);
|
||||||
if (statValue == null) {
|
if (statValue == null) {
|
||||||
@@ -1127,7 +1145,7 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
container.remove(toolStats.toolStatsKeys.getFishCaught());
|
container.remove(toolStats.toolStatsKeys.getFishCaught());
|
||||||
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "fight-caught");
|
List<String> newTokens = toolStats.itemChecker.removeToken(tokens, "fish-caught");
|
||||||
if (newTokens.isEmpty()) {
|
if (newTokens.isEmpty()) {
|
||||||
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
container.remove(toolStats.toolStatsKeys.getTokenApplied());
|
||||||
} else {
|
} else {
|
||||||
@@ -1267,7 +1285,8 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
@Override
|
@Override
|
||||||
public @NonNull Collection<String> suggest(@NonNull CommandSourceStack source, String[] args) {
|
public @NonNull Collection<String> suggest(@NonNull CommandSourceStack source, String[] args) {
|
||||||
CommandSender sender = source.getSender();
|
CommandSender sender = source.getSender();
|
||||||
if (args.length == 1) {
|
// suggest basic sub commands
|
||||||
|
if (args.length == 0) {
|
||||||
List<String> suggestions = new ArrayList<>();
|
List<String> suggestions = new ArrayList<>();
|
||||||
if (sender.hasPermission("toolstats.reload")) {
|
if (sender.hasPermission("toolstats.reload")) {
|
||||||
suggestions.add("reload");
|
suggestions.add("reload");
|
||||||
@@ -1290,12 +1309,16 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
return suggestions;
|
return suggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// suggest confirm for reset
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
// suggest confirm for purge
|
||||||
if (args.length == 2 && args[0].equalsIgnoreCase("purge") && sender.hasPermission("toolstats.purge.confirm")) {
|
if (args.length == 2 && args[0].equalsIgnoreCase("purge") && sender.hasPermission("toolstats.purge.confirm")) {
|
||||||
return Collections.singletonList("confirm");
|
return Collections.singletonList("confirm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// suggest keys for edit
|
||||||
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()
|
||||||
@@ -1303,6 +1326,8 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
|
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// suggest keys for remove
|
||||||
if (args.length == 2 && args[0].equalsIgnoreCase("remove") && sender.hasPermission("toolstats.remove")) {
|
if (args.length == 2 && args[0].equalsIgnoreCase("remove") && sender.hasPermission("toolstats.remove")) {
|
||||||
// yes I am lazy
|
// yes I am lazy
|
||||||
return toolStats.tokenData.getTokenTypes().stream()
|
return toolStats.tokenData.getTokenTypes().stream()
|
||||||
@@ -1310,6 +1335,13 @@ public class CommandToolStats implements BasicCommand {
|
|||||||
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
|
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// suggest players for givetokens
|
||||||
|
if (args.length == 2 && args[0].equalsIgnoreCase("givetokens") && sender.hasPermission("toolstats.givetokens")) {
|
||||||
|
return Bukkit.getOnlinePlayers().stream().map(Player::getName).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// suggest token types for givetokens
|
||||||
if (args.length == 3 && args[0].equalsIgnoreCase("givetokens") && sender.hasPermission("toolstats.givetokens")) {
|
if (args.length == 3 && args[0].equalsIgnoreCase("givetokens") && sender.hasPermission("toolstats.givetokens")) {
|
||||||
return toolStats.tokenData.getTokenTypes();
|
return toolStats.tokenData.getTokenTypes();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,29 @@ public class BlockDispenseEvent implements Listener {
|
|||||||
lore = new ArrayList<>();
|
lore = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// by request
|
||||||
|
if (newItem.getType() == Material.ELYTRA) {
|
||||||
|
if (!toolStats.config.getBoolean("enabled.elytra-tag")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 4, newItem);
|
||||||
|
if (creationDate != null) {
|
||||||
|
container.set(toolStats.toolStatsKeys.getTimeCreated(), PersistentDataType.LONG, timeCreated);
|
||||||
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 4);
|
||||||
|
lore.add(creationDate);
|
||||||
|
meta.lore(lore);
|
||||||
|
}
|
||||||
|
|
||||||
|
Component itemOwner = toolStats.itemLore.formatOwner(owner.getName(), 4, newItem);
|
||||||
|
if (itemOwner != null) {
|
||||||
|
container.set(toolStats.toolStatsKeys.getItemOwner(), new UUIDDataType(), owner.getUniqueId());
|
||||||
|
container.set(toolStats.toolStatsKeys.getOriginType(), PersistentDataType.INTEGER, 4);
|
||||||
|
lore.add(itemOwner);
|
||||||
|
meta.lore(lore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if creation date is enabled, add it
|
// if creation date is enabled, add it
|
||||||
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 2, newItem);
|
Component creationDate = toolStats.itemLore.formatCreationTime(timeCreated, 2, newItem);
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ConfigTools {
|
|||||||
String itemName = material.toString().toLowerCase();
|
String itemName = material.toString().toLowerCase();
|
||||||
String itemType = null;
|
String itemType = null;
|
||||||
// hardcode these
|
// hardcode these
|
||||||
if (material == Material.BOW || material == Material.CROSSBOW || material == Material.SHEARS || material == Material.TRIDENT || material == Material.FISHING_ROD) {
|
if (material == Material.BOW || material == Material.CROSSBOW || material == Material.SHEARS || material == Material.TRIDENT || material == Material.FISHING_ROD || material == Material.SHIELD) {
|
||||||
switch (material) {
|
switch (material) {
|
||||||
case CROSSBOW:
|
case CROSSBOW:
|
||||||
case BOW: {
|
case BOW: {
|
||||||
@@ -72,6 +72,10 @@ public class ConfigTools {
|
|||||||
itemType = "fishing-rod";
|
itemType = "fishing-rod";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SHIELD: {
|
||||||
|
itemType = "shield";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
itemType = itemName.substring(itemName.indexOf('_') + 1);
|
itemType = itemName.substring(itemName.indexOf('_') + 1);
|
||||||
@@ -88,6 +92,7 @@ public class ConfigTools {
|
|||||||
case "fishing-rod" -> toolStats.config.getBoolean("enabled." + configName + ".fishing-rod");
|
case "fishing-rod" -> toolStats.config.getBoolean("enabled." + configName + ".fishing-rod");
|
||||||
case "mace" -> toolStats.config.getBoolean("enabled." + configName + ".mace");
|
case "mace" -> toolStats.config.getBoolean("enabled." + configName + ".mace");
|
||||||
case "spear" -> toolStats.config.getBoolean("enabled." + configName + ".spear");
|
case "spear" -> toolStats.config.getBoolean("enabled." + configName + ".spear");
|
||||||
|
case "shield" -> toolStats.config.getBoolean("enabled." + configName + ".shield");
|
||||||
case "helmet", "chestplate", "leggings", "boots" ->
|
case "helmet", "chestplate", "leggings", "boots" ->
|
||||||
toolStats.config.getBoolean("enabled." + configName + ".armor");
|
toolStats.config.getBoolean("enabled." + configName + ".armor");
|
||||||
default -> false;
|
default -> false;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public class ConfigUpdater {
|
|||||||
case 12 -> new Version13(toolStats).update(); // 12 to 13
|
case 12 -> new Version13(toolStats).update(); // 12 to 13
|
||||||
case 13 -> new Version14(toolStats).update(); // 13 to 14
|
case 13 -> new Version14(toolStats).update(); // 13 to 14
|
||||||
case 14 -> new Version15(toolStats).update(); // 14 to 15
|
case 14 -> new Version15(toolStats).update(); // 14 to 15
|
||||||
|
case 15 -> new Version16(toolStats).update(); // 15 to 16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* 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 Version16 {
|
||||||
|
|
||||||
|
private final ToolStats toolStats;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for updating from version 15 to 16.
|
||||||
|
*
|
||||||
|
* @param toolStats ToolStats instance.
|
||||||
|
*/
|
||||||
|
public Version16(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-15.yml");
|
||||||
|
} catch (IOException exception) {
|
||||||
|
toolStats.logger.error("Unable to save config-15.yml!", exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
// we make this super verbose so that admins can see what's being added
|
||||||
|
toolStats.logger.info("Updating config.yml to version 16.");
|
||||||
|
toolStats.config.set("config-version", 16);
|
||||||
|
|
||||||
|
toolStats.logger.info("Adding enabled.crafted-on.shield to config.yml.");
|
||||||
|
toolStats.config.set("enabled.crafted-on.shield", true);
|
||||||
|
toolStats.logger.info("Adding enabled.crafted-by.shield to config.yml.");
|
||||||
|
toolStats.config.set("enabled.crafted-by.shield", true);
|
||||||
|
|
||||||
|
toolStats.logger.info("Adding enabled.traded-on.shield to config.yml.");
|
||||||
|
toolStats.config.set("enabled.traded-on.shield", true);
|
||||||
|
toolStats.logger.info("Adding enabled.traded-by.shield to config.yml.");
|
||||||
|
toolStats.config.set("enabled.traded-by.shield", true);
|
||||||
|
|
||||||
|
toolStats.logger.info("Adding enabled.looted-on.shield to config.yml.");
|
||||||
|
toolStats.config.set("enabled.looted-on.shield", true);
|
||||||
|
toolStats.logger.info("Adding enabled.looted-by.shield to config.yml.");
|
||||||
|
toolStats.config.set("enabled.looted-by.shield", true);
|
||||||
|
|
||||||
|
// save the config and reload it
|
||||||
|
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 16. A copy of version 6 has been saved as config-15.yml");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -195,6 +195,7 @@ enabled:
|
|||||||
mace: true
|
mace: true
|
||||||
fishing-rod: true
|
fishing-rod: true
|
||||||
spear: true
|
spear: true
|
||||||
|
shield: true
|
||||||
# Will show "Crafted on <date>"
|
# Will show "Crafted on <date>"
|
||||||
crafted-on:
|
crafted-on:
|
||||||
pickaxe: true
|
pickaxe: true
|
||||||
@@ -208,6 +209,7 @@ enabled:
|
|||||||
mace: true
|
mace: true
|
||||||
fishing-rod: true
|
fishing-rod: true
|
||||||
spear: true
|
spear: true
|
||||||
|
shield: true
|
||||||
# Will show "Fished by <player>"
|
# Will show "Fished by <player>"
|
||||||
fished-by:
|
fished-by:
|
||||||
pickaxe: true
|
pickaxe: true
|
||||||
@@ -242,6 +244,7 @@ enabled:
|
|||||||
armor: true
|
armor: true
|
||||||
fishing-rod: true
|
fishing-rod: true
|
||||||
spear: true
|
spear: true
|
||||||
|
shield: true
|
||||||
# Will show "Found on <date>"
|
# Will show "Found on <date>"
|
||||||
looted-on:
|
looted-on:
|
||||||
pickaxe: true
|
pickaxe: true
|
||||||
@@ -254,6 +257,7 @@ enabled:
|
|||||||
armor: true
|
armor: true
|
||||||
fishing-rod: true
|
fishing-rod: true
|
||||||
spear: true
|
spear: true
|
||||||
|
shield: true
|
||||||
# Will show "Traded by <player>"
|
# Will show "Traded by <player>"
|
||||||
traded-by:
|
traded-by:
|
||||||
pickaxe: true
|
pickaxe: true
|
||||||
@@ -265,6 +269,7 @@ enabled:
|
|||||||
bow: true
|
bow: true
|
||||||
armor: true
|
armor: true
|
||||||
fishing-rod: true
|
fishing-rod: true
|
||||||
|
shield: true
|
||||||
# Will show "Traded on <date>"
|
# Will show "Traded on <date>"
|
||||||
traded-on:
|
traded-on:
|
||||||
pickaxe: true
|
pickaxe: true
|
||||||
@@ -276,6 +281,7 @@ enabled:
|
|||||||
bow: true
|
bow: true
|
||||||
armor: true
|
armor: true
|
||||||
fishing-rod: true
|
fishing-rod: true
|
||||||
|
shield: true
|
||||||
damage-done:
|
damage-done:
|
||||||
sword: true
|
sword: true
|
||||||
axe: true
|
axe: true
|
||||||
|
|||||||
Reference in New Issue
Block a user