Help message updater: specify the name of the updated file
This commit is contained in:
+3
-2
@@ -7,6 +7,7 @@ import fr.xephi.authme.service.HelpTranslationGenerator;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,8 +25,8 @@ public class UpdateHelpMessagesCommand implements ExecutableCommand {
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
try {
|
||||
helpTranslationGenerator.updateHelpFile();
|
||||
sender.sendMessage("Successfully updated the help file");
|
||||
File updatedFile = helpTranslationGenerator.updateHelpFile();
|
||||
sender.sendMessage("Successfully updated the help file '" + updatedFile.getName() + "'");
|
||||
helpMessagesService.reloadMessagesFile();
|
||||
} catch (IOException e) {
|
||||
sender.sendMessage("Could not update help file: " + e.getMessage());
|
||||
|
||||
@@ -44,15 +44,17 @@ public class HelpTranslationGenerator {
|
||||
/**
|
||||
* Updates the help file to contain entries for all commands.
|
||||
*
|
||||
* @return the help file that has been updated
|
||||
* @throws IOException if the help file cannot be written to
|
||||
*/
|
||||
public void updateHelpFile() throws IOException {
|
||||
public File updateHelpFile() throws IOException {
|
||||
String languageCode = settings.getProperty(PluginSettings.MESSAGES_LANGUAGE);
|
||||
File helpFile = new File(dataFolder, "messages/help_" + languageCode + ".yml");
|
||||
Map<String, Object> helpEntries = generateHelpMessageEntries();
|
||||
|
||||
String helpEntriesYaml = exportToYaml(helpEntries);
|
||||
Files.write(helpFile.toPath(), helpEntriesYaml.getBytes(), StandardOpenOption.TRUNCATE_EXISTING);
|
||||
return helpFile;
|
||||
}
|
||||
|
||||
private static String exportToYaml(Map<String, Object> helpEntries) {
|
||||
|
||||
Reference in New Issue
Block a user