Use common formatPath method

This commit is contained in:
filoghost 2020-08-14 18:39:04 +02:00
parent de5dd3b3ef
commit 94ab7624f7
2 changed files with 3 additions and 7 deletions

View File

@ -49,7 +49,7 @@ public class ConfigErrors {
return "value of type \"" + value.getClass() + "\" couldn't be converted by \"" + converter.getClass() + "\"";
}
private static String formatPath(Path rootDataFolder, Path path) {
public static String formatPath(Path rootDataFolder, Path path) {
if (path.startsWith(rootDataFolder)) {
// Remove root data folder prefix
return path.subpath(rootDataFolder.getNameCount(), path.getNameCount()).toString();

View File

@ -8,6 +8,7 @@ package me.filoghost.chestcommands.logging;
import me.filoghost.chestcommands.ChestCommands;
import me.filoghost.chestcommands.parsing.icon.AttributeType;
import me.filoghost.chestcommands.parsing.icon.IconSettings;
import me.filoghost.commons.config.ConfigErrors;
import org.bukkit.ChatColor;
import java.nio.file.Path;
@ -213,12 +214,7 @@ public class Errors {
}
private static String formatPath(Path path) {
if (path.startsWith(ChestCommands.getDataFolderPath())) {
// Remove "/plugins/ChestCommands" prefix
return path.subpath(ChestCommands.getDataFolderPath().getNameCount(), path.getNameCount()).toString();
} else {
return path.toString();
}
return ConfigErrors.formatPath(ChestCommands.getDataFolderPath(), path);
}
}