Fixed /plan m import command #550

This commit is contained in:
Rsl1122 2018-04-02 09:57:19 +03:00
parent abcf2e877a
commit b1ae7c53c7

View File

@ -1,6 +1,7 @@
package com.djrapitops.plan.command.commands.manage; package com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plan.system.processing.importing.ImporterManager; import com.djrapitops.plan.system.processing.importing.ImporterManager;
import com.djrapitops.plan.system.processing.importing.importers.Importer;
import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Locale;
import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.locale.Msg;
@ -38,20 +39,33 @@ public class ManageImportCommand extends SubCommand {
return true; return true;
} }
runImport("offlineimporter"); String importArg = args[0];
if (importArg.equals("list")) {
sender.sendMessage("Importers: ");
ImporterManager.getImporters().stream()
.map(Importer::getNames)
.map(list -> list.get(0))
.forEach(name -> sender.sendMessage("- " + name));
return true; return true;
} }
private void runImport(String importer) { Importer importer = ImporterManager.getImporter(importArg);
RunnableFactory.createNew("Import", new AbsRunnable() { if (importer == null) {
sender.sendMessage("§eImporter '" + importArg + "' doesn't exist");
return true;
}
RunnableFactory.createNew("Import:" + importArg, new AbsRunnable() {
@Override @Override
public void run() { public void run() {
try { try {
ImporterManager.getImporter(importer).processImport(); importer.processImport();
} finally { } finally {
this.cancel(); cancel();
} }
} }
}).runTaskAsynchronously(); }).runTaskAsynchronously();
return true;
} }
} }