#1146 List available converter, reference converters Wiki page in config.yml

This commit is contained in:
ljacqu
2017-05-21 12:28:35 +02:00
parent 5afe6bb35b
commit 1c46c92b4e
5 changed files with 58 additions and 22 deletions
@@ -1,7 +1,7 @@
package fr.xephi.authme.command.executable.authme;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.converter.Converter;
@@ -41,14 +41,10 @@ public class ConverterCommand implements ExecutableCommand {
private Factory<Converter> converterFactory;
@Override
public void executeCommand(final CommandSender sender, List<String> arguments) {
// Get the conversion job
String job = arguments.get(0);
// Determine the job type
Class<? extends Converter> converterClass = CONVERTERS.get(job.toLowerCase());
public void executeCommand(CommandSender sender, List<String> arguments) {
Class<? extends Converter> converterClass = getConverterClassFromArgs(arguments);
if (converterClass == null) {
sender.sendMessage("[AuthMe] Converter does not exist!");
sender.sendMessage("Converters: " + String.join(", ", CONVERTERS.keySet()));
return;
}
@@ -69,7 +65,13 @@ public class ConverterCommand implements ExecutableCommand {
});
// Show a status message
sender.sendMessage("[AuthMe] Successfully started " + job);
sender.sendMessage("[AuthMe] Successfully started " + arguments.get(0));
}
private static Class<? extends Converter> getConverterClassFromArgs(List<String> arguments) {
return arguments.isEmpty()
? null
: CONVERTERS.get(arguments.get(0).toLowerCase());
}
/**
@@ -78,7 +80,7 @@ public class ConverterCommand implements ExecutableCommand {
* @return map with all available converters
*/
private static Map<String, Class<? extends Converter>> getConverters() {
return ImmutableMap.<String, Class<? extends Converter>>builder()
return ImmutableSortedMap.<String, Class<? extends Converter>>naturalOrder()
.put("xauth", XAuthConverter.class)
.put("crazylogin", CrazyLoginConverter.class)
.put("rakamak", RakamakConverter.class)
@@ -89,5 +91,4 @@ public class ConverterCommand implements ExecutableCommand {
.put("loginsecurity", LoginSecurityConverter.class)
.build();
}
}