mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-03 07:54:07 +01:00
79 lines
2.3 KiB
Java
79 lines
2.3 KiB
Java
package com.gamingmesh.jobs.commands.list;
|
|
|
|
import java.io.IOException;
|
|
import java.sql.SQLException;
|
|
import java.util.List;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import com.gamingmesh.jobs.Jobs;
|
|
import com.gamingmesh.jobs.commands.Cmd;
|
|
import com.gamingmesh.jobs.commands.JobCommand;
|
|
import com.gamingmesh.jobs.container.Convert;
|
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
|
|
|
public class convert implements Cmd {
|
|
|
|
@Override
|
|
@JobCommand(2600)
|
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
|
|
|
if (sender instanceof Player) {
|
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.fromconsole"));
|
|
return true;
|
|
}
|
|
|
|
if (args.length > 0) {
|
|
Jobs.getCommandManager().sendUsage(sender, "convert");
|
|
return true;
|
|
}
|
|
|
|
List<Convert> list = null;
|
|
List<Convert> archivelist = null;
|
|
|
|
try {
|
|
list = Jobs.getJobsDAO().convertDatabase("jobs");
|
|
archivelist = Jobs.getJobsDAO().convertDatabase("archive");
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
sender.sendMessage(ChatColor.RED + "Can't read data from data base, please send error log to dev's.");
|
|
return true;
|
|
}
|
|
|
|
Jobs.ChangeDatabase();
|
|
|
|
if (list == null & archivelist == null)
|
|
return false;
|
|
try {
|
|
Jobs.getJobsDAO().continueConvertions(list, "jobs");
|
|
Jobs.getJobsDAO().continueConvertions(archivelist, "archive");
|
|
Jobs.getJobsDAO().transferUsers();
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
sender.sendMessage(ChatColor.RED + "Can't write data to data base, please send error log to dev's.");
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
Jobs.reload();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
String from = "MysSQL";
|
|
String to = "SqLite";
|
|
|
|
if (Jobs.getGCManager().storageMethod.equalsIgnoreCase("sqlite")) {
|
|
from = "SqLite";
|
|
to = "MySQL";
|
|
}
|
|
|
|
sender.sendMessage(ChatColor.GOLD + "Data base was converted from " + ChatColor.GREEN + from + ChatColor.GOLD + " to " + ChatColor.GREEN + to + ChatColor.GOLD
|
|
+ "! Now you can stop the server, change storage-method to " + ChatColor.GREEN + to + ChatColor.GOLD
|
|
+ " in general config file and start server again on your new database system.");
|
|
|
|
return true;
|
|
}
|
|
}
|