2014-10-19 07:37:25 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Conf;
|
|
|
|
import com.massivecraft.factions.Conf.Backend;
|
2019-01-27 03:41:25 +01:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2014-10-19 07:37:25 +02:00
|
|
|
import com.massivecraft.factions.zcore.persist.json.FactionsJSON;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2014-11-06 01:36:47 +01:00
|
|
|
import org.bukkit.command.ConsoleCommandSender;
|
2014-10-19 07:37:25 +02:00
|
|
|
|
|
|
|
public class CmdConvert extends FCommand {
|
|
|
|
|
2019-09-15 11:08:00 +02:00
|
|
|
public CmdConvert() {
|
|
|
|
this.aliases.add("convert");
|
|
|
|
this.requiredArgs.add("[MYSQL|JSON]");
|
2019-09-14 21:13:01 +02:00
|
|
|
|
2019-09-15 11:08:00 +02:00
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.CONVERT)
|
|
|
|
.build();
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:08:00 +02:00
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
if (!(context.sender instanceof ConsoleCommandSender)) {
|
|
|
|
context.sender.sendMessage(TL.GENERIC_CONSOLEONLY.toString());
|
|
|
|
}
|
|
|
|
Backend nb = Backend.valueOf(context.argAsString(0).toUpperCase());
|
|
|
|
if (nb == Conf.backEnd) {
|
|
|
|
context.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (nb == Backend.JSON) {
|
|
|
|
FactionsJSON.convertTo();
|
|
|
|
} else {
|
|
|
|
context.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Conf.backEnd = nb;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:08:00 +02:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_CONVERT_DESCRIPTION;
|
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
2019-09-14 21:13:01 +02:00
|
|
|
}
|