Moved /mmocore admin transferdata

This commit is contained in:
Indyuce 2022-07-26 15:33:23 +02:00
parent a7e2773ff7
commit 7c79f9cee3
4 changed files with 25 additions and 31 deletions

View File

@ -6,7 +6,6 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.command.rpg.CoinsCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.NoteCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.ReloadCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.TransferDataTreeNode;
import net.Indyuce.mmocore.command.rpg.admin.AdminCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.booster.BoosterCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.debug.DebugCommandTreeNode;
@ -16,24 +15,23 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.TabCompleter;
public class MMOCoreCommandTreeRoot extends CommandTreeRoot implements CommandExecutor, TabCompleter {
public static final Parameter PROFESSION = new Parameter("<profession/main>", (explorer, list) -> {
MMOCore.plugin.professionManager.getAll().forEach(profession -> list.add(profession.getId()));
list.add("main");
});
public static final Parameter QUEST = new Parameter("<quest>",
(explorer, list) -> MMOCore.plugin.questManager.getAll().forEach(quest -> list.add(quest.getId())));
public static final Parameter PROFESSION = new Parameter("<profession/main>", (explorer, list) -> {
MMOCore.plugin.professionManager.getAll().forEach(profession -> list.add(profession.getId()));
list.add("main");
});
public static final Parameter QUEST = new Parameter("<quest>",
(explorer, list) -> MMOCore.plugin.questManager.getAll().forEach(quest -> list.add(quest.getId())));
public MMOCoreCommandTreeRoot() {
super("mmocore", "mmocore.admin");
public MMOCoreCommandTreeRoot() {
super("mmocore", "mmocore.admin");
addChild(new ReloadCommandTreeNode(this));
addChild(new TransferDataTreeNode(this));
addChild(new CoinsCommandTreeNode(this));
addChild(new NoteCommandTreeNode(this));
addChild(new AdminCommandTreeNode(this));
addChild(new DebugCommandTreeNode(this));
addChild(new BoosterCommandTreeNode(this));
addChild(new WaypointsCommandTreeNode(this));
addChild(new QuestCommandTreeNode(this));
}
addChild(new ReloadCommandTreeNode(this));
addChild(new CoinsCommandTreeNode(this));
addChild(new NoteCommandTreeNode(this));
addChild(new AdminCommandTreeNode(this));
addChild(new DebugCommandTreeNode(this));
addChild(new BoosterCommandTreeNode(this));
addChild(new WaypointsCommandTreeNode(this));
addChild(new QuestCommandTreeNode(this));
}
}

View File

@ -15,6 +15,7 @@ public class AdminCommandTreeNode extends CommandTreeNode {
addChild(new InfoCommandTreeNode(this));
addChild(new ClassCommandTreeNode(this));
addChild(new ForceClassCommandTreeNode(this));
addChild(new TransferDataTreeNode(this));
addChild(new ExperienceCommandTreeNode(this));
addChild(new LevelCommandTreeNode(this));

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.command.rpg;
package net.Indyuce.mmocore.command.rpg.admin;
import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmocore.MMOCore;
@ -12,19 +12,17 @@ import org.bukkit.scheduler.BukkitRunnable;
/**
* This command allows to transfer data from your actual datatype (yaml or sql) to the other one to make a change
* in the data storage type.
* This command allows to transfer data from your actual storage type
* to the other one which lets the user switch between storage types.
*/
public class TransferDataTreeNode extends CommandTreeNode {
public TransferDataTreeNode(CommandTreeNode parent) {
super(parent, "transferdata");
}
@Override
public CommandResult execute(CommandSender commandSender, String[] strings) {
DataProvider provider=null;
DataProvider provider = null;
try {
@ -46,7 +44,7 @@ public class TransferDataTreeNode extends CommandTreeNode {
} catch (Exception e) {
commandSender.sendMessage("Couldn't transfer properly the data.");
e.printStackTrace();
if(provider!=null&&provider instanceof MySQLDataProvider) {
if (provider != null && provider instanceof MySQLDataProvider) {
((MySQLDataProvider) provider).close();
}
return CommandResult.FAILURE;
@ -58,14 +56,12 @@ public class TransferDataTreeNode extends CommandTreeNode {
@Override
public void run() {
if(finalProvider !=null&& finalProvider instanceof MySQLDataProvider) {
if (finalProvider != null && finalProvider instanceof MySQLDataProvider) {
((MySQLDataProvider) finalProvider).close();
}
}
}.runTaskLater(MMOCore.plugin,200);
}.runTaskLater(MMOCore.plugin, 200);
return CommandResult.SUCCESS;
}
}

View File

@ -8,7 +8,6 @@ import net.Indyuce.mmocore.manager.data.yaml.YAMLGuildDataManager;
import org.bukkit.configuration.file.FileConfiguration;
import java.sql.SQLException;
import java.util.concurrent.CompletableFuture;
public class MySQLDataProvider extends MMODataSource implements DataProvider {
private final MySQLPlayerDataManager playerManager = new MySQLPlayerDataManager(this);