diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/commands/LineSubCommand.java b/src/main/java/eu/decentsoftware/holograms/plugin/commands/LineSubCommand.java index cbafa5d7..5eb3c243 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/commands/LineSubCommand.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/commands/LineSubCommand.java @@ -83,7 +83,6 @@ public TabCompleteHandler getTabCompleteHandler() { usage = "/dh line add [content]", description = "Add a line to Hologram.", aliases = {"append"}, - playerOnly = true, minArgs = 2 ) static class LineAddSub extends DecentCommand { diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/ConvertorType.java b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/ConvertorType.java index 0635e6ce..80a66acf 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/ConvertorType.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/ConvertorType.java @@ -9,20 +9,21 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Locale; @Getter public enum ConvertorType { CMI(true, "CMI"), FUTURE_HOLOGRAMS(true, "FutureHolograms", "fh", "fholograms"), GHOLO(false, "GHolo", "gh"), - HOLOGRAPHIC_DISPLAYS(false, "HolographicDisplays", "HD", "hd"), + HOLOGRAPHIC_DISPLAYS(false, "HolographicDisplays", "hd"), HOLOGRAMS(true, "Holograms"), ; @Nullable public static ConvertorType fromString(String alias) { for (ConvertorType convertorType : ConvertorType.values()) { - if (convertorType.getName().equalsIgnoreCase(alias) || convertorType.getAliases().contains(alias)) { + if (convertorType.getName().equalsIgnoreCase(alias) || convertorType.getAliases().contains(alias.toLowerCase(Locale.ROOT))) { return convertorType; } } diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/CMIConverter.java b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/CMIConverter.java index d54744e6..43ab5e3a 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/CMIConverter.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/CMIConverter.java @@ -23,7 +23,7 @@ public class CMIConverter implements IConvertor { @Override public ConvertorResult convert() { - return convert(new File("plugins/CMI/holograms.yml")); + return convert(new File(PLUGIN.getDataFolder().getParent() + "/CMI/", "holograms.yml")); } @Override diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/FutureHologramsConverter.java b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/FutureHologramsConverter.java index 92898b37..2b22e03a 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/FutureHologramsConverter.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/FutureHologramsConverter.java @@ -21,7 +21,7 @@ public class FutureHologramsConverter implements IConvertor { @Override public ConvertorResult convert(){ - return convert(new File("plugins/FutureHolograms/holograms.yml")); + return convert(new File(PLUGIN.getDataFolder().getParent() + "/FutureHolograms/", "holograms.yml")); } @Override diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/GHoloConverter.java b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/GHoloConverter.java index eaac5968..b2759a03 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/GHoloConverter.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/GHoloConverter.java @@ -25,7 +25,7 @@ public class GHoloConverter implements IConvertor { @Override public ConvertorResult convert(){ - return convert(new File("plugins/GHolo/data/h.data")); + return convert(new File(PLUGIN.getDataFolder().getParent() + "/GHolo/data/", "h.data")); } @Override diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/HologramsConvertor.java b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/HologramsConvertor.java index ae0f12d2..5ec2e592 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/HologramsConvertor.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/HologramsConvertor.java @@ -22,7 +22,7 @@ public class HologramsConvertor implements IConvertor { @Override public ConvertorResult convert() { - return convert(new File("plugins/Holograms/holograms.yml")); + return convert(new File(PLUGIN.getDataFolder().getParent() + "/Holograms/", "holograms.yml")); } @Override diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/HolographicDisplaysConvertor.java b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/HolographicDisplaysConvertor.java index fef70145..7b55c565 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/HolographicDisplaysConvertor.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/convertors/impl/HolographicDisplaysConvertor.java @@ -12,17 +12,21 @@ import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; +import java.util.ArrayList; import java.util.List; import java.util.logging.Level; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; public class HolographicDisplaysConvertor implements IConvertor { private static final DecentHolograms PLUGIN = DecentHologramsAPI.get(); + private static final Pattern PAPI_PATTERN = Pattern.compile("\\{papi: (.+)}"); @Override public ConvertorResult convert() { - return convert(new File("plugins/HolographicDisplays/database.yml")); + return convert(new File(PLUGIN.getDataFolder().getParent() + "/HolographicDisplays/", "database.yml")); } @Override @@ -50,8 +54,26 @@ public ConvertorResult convert(final File file) { } @Override - public List prepareLines(List lines){ - return lines.stream().map(line -> { + public List prepareLines(List lines) { + List parsed = new ArrayList<>(lines.size()); + // Go through each line and convert any {papi: } pattern to %% + for(String line : lines) { + String parsedLine = line; + Matcher matcher = PAPI_PATTERN.matcher(line); + if(matcher.find()) { + StringBuffer buffer = new StringBuffer(); + do { + matcher.appendReplacement(buffer, "%" + matcher.group(1) + "%"); + } while(matcher.find()); + + matcher.appendTail(buffer); + parsedLine = buffer.toString(); + } + + parsed.add(parsedLine); + } + + return parsed.stream().map(line -> { if (line.toUpperCase().startsWith("ICON:")) { return "#" + line; }