diff --git a/README.md b/README.md index f0c7f1a..5cf8966 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Releases can be found on the [releases tab](https://github.com/APDevTeam/Movecra Development builds can be found on the [GitHub Actions tab](https://github.com/APDevTeam/Movecraft-Warfare/actions) of this repository. -Previous builds can be found on[our SpigotMC page](https://www.spigotmc.org/resources/movecraft-warfare.87359/). +Previous builds can be found on [our SpigotMC page](https://www.spigotmc.org/resources/movecraft-warfare.87359/). ## Building Run the following to build Movecraft-Warfare: diff --git a/src/main/java/net/countercraft/movecraft/warfare/commands/SiegeCommand.java b/src/main/java/net/countercraft/movecraft/warfare/commands/SiegeCommand.java index da52555..74697e1 100644 --- a/src/main/java/net/countercraft/movecraft/warfare/commands/SiegeCommand.java +++ b/src/main/java/net/countercraft/movecraft/warfare/commands/SiegeCommand.java @@ -4,7 +4,8 @@ import net.countercraft.movecraft.craft.CraftManager; import net.countercraft.movecraft.craft.type.CraftType; import net.countercraft.movecraft.repair.MovecraftRepair; -import net.countercraft.movecraft.util.TopicPaginator; +import net.countercraft.movecraft.util.ChatUtils; +import net.countercraft.movecraft.util.ComponentPaginator; import net.countercraft.movecraft.warfare.MovecraftWarfare; import net.countercraft.movecraft.warfare.config.Config; import net.countercraft.movecraft.warfare.features.siege.Siege; @@ -15,6 +16,7 @@ import net.countercraft.movecraft.warfare.features.siege.events.SiegePreStartEvent; import net.countercraft.movecraft.warfare.localisation.I18nSupport; import net.countercraft.movecraft.worldguard.MovecraftWorldGuard; +import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -249,16 +251,22 @@ private boolean listCommand(CommandSender commandSender, String[] args) { return true; } - TopicPaginator paginator = new TopicPaginator("Sieges"); + ComponentPaginator paginator = new ComponentPaginator( + Component.text("Sieges"), + pageNumber -> "/siege list " + pageNumber); for (Siege siege : siegeManager.getSieges()) { - paginator.addLine("- " + siege.getName()); + paginator.addLine(Component.text("- ").append(Component.text(siege.getName()))); } if (!paginator.isInBounds(page)) { - commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX - + I18nSupport.getInternationalisedString("Paginator - Invalid Page") + " \"" + args[1] + "\""); + commandSender.sendMessage(Component.empty() + .append(ChatUtils.commandPrefix()) + .append(net.countercraft.movecraft.localisation.I18nSupport.getInternationalisedComponent("Paginator - Invalid page")) + .append(Component.text(" \"")) + .append(Component.text(args[0])) + .append(Component.text("\""))); return true; } - for (String line : paginator.getPage(page)) + for (Component line : paginator.getPage(page)) commandSender.sendMessage(line); return true; } diff --git a/src/main/java/net/countercraft/movecraft/warfare/localisation/I18nSupport.java b/src/main/java/net/countercraft/movecraft/warfare/localisation/I18nSupport.java index fffb843..10746f7 100644 --- a/src/main/java/net/countercraft/movecraft/warfare/localisation/I18nSupport.java +++ b/src/main/java/net/countercraft/movecraft/warfare/localisation/I18nSupport.java @@ -2,16 +2,20 @@ import net.countercraft.movecraft.warfare.MovecraftWarfare; import net.countercraft.movecraft.warfare.config.Config; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import java.io.*; import java.util.Properties; import java.util.logging.Level; public class I18nSupport { - private static Properties langFile; + private static Properties languageFile; public static void init() { - langFile = new Properties(); + languageFile = new Properties(); File langDirectory = new File(MovecraftWarfare.getInstance().getDataFolder().getAbsolutePath() + "/localisation"); if (!langDirectory.exists()) { @@ -19,7 +23,6 @@ public static void init() { } InputStream stream = null; - try { stream = new FileInputStream(langDirectory.getAbsolutePath()+"/mcwlang_" + Config.Locale + ".properties"); } catch (FileNotFoundException e) { @@ -32,18 +35,28 @@ public static void init() { } try { - langFile.load(stream); + languageFile.load(stream); } catch (IOException e) { e.printStackTrace(); } } - public static String getInternationalisedString(String key) { - String ret = langFile.getProperty(key); + private static String get(String key) { + String ret = languageFile.getProperty(key); if (ret != null) { return ret; } else { return key; } } + + @Deprecated(forRemoval = true) + public static String getInternationalisedString(String key) { + return get(key); + } + + @Contract("_ -> new") + public static @NotNull TextComponent getInternationalisedComponent(String key){ + return Component.text(get(key)); + } }