Search in sources :

Example 1 with MethodScriptExecutionQueue

use of com.laytonsmith.core.MethodScriptExecutionQueue in project CommandHelper by EngineHub.

the class Manager method start.

@SuppressWarnings("ResultOfObjectAllocationIgnored")
public static void start() throws IOException, DataSourceException, URISyntaxException, Profiles.InvalidProfileException {
    Implementation.useAbstractEnumThread(false);
    Implementation.forceServerType(Implementation.Type.BUKKIT);
    ConnectionMixinFactory.ConnectionMixinOptions options = new ConnectionMixinFactory.ConnectionMixinOptions();
    options.setWorkingDirectory(chDirectory);
    persistenceNetwork = new PersistenceNetwork(CommandHelperFileLocations.getDefault().getPersistenceConfig(), CommandHelperFileLocations.getDefault().getDefaultPersistenceDBFile().toURI(), options);
    Installer.Install(chDirectory);
    CHLog.initialize(chDirectory);
    profiler = new Profiler(CommandHelperFileLocations.getDefault().getProfilerConfigFile());
    gEnv = new GlobalEnv(new MethodScriptExecutionQueue("Manager", "default"), profiler, persistenceNetwork, chDirectory, new Profiles(MethodScriptFileLocations.getDefault().getProfilesFile()), new TaskManager());
    cls();
    pl("\n" + Static.Logo() + "\n\n" + Static.DataManagerLogo());
    pl("Starting the Data Manager...");
    try {
        Environment env = Environment.createEnvironment(gEnv, new CommandHelperEnvironment());
        MethodScriptCompiler.execute(MethodScriptCompiler.compile(MethodScriptCompiler.lex("player()", null, true)), env, null, null);
    } catch (ConfigCompileException | ConfigCompileGroupException ex) {
    }
    pl(GREEN + "Welcome to the CommandHelper " + CYAN + "Data Manager!");
    pl(BLINKON + RED + "Warning!" + BLINKOFF + YELLOW + " Be sure your server is not running before using this tool to make changes to your database!");
    pl("------------------------");
    boolean finished = false;
    do {
        pl(YELLOW + "What function would you like to run? Type \"help\" for a full list of options.");
        String input = prompt();
        pl();
        if (input.toLowerCase().startsWith("help")) {
            help(input.replaceFirst("help ?", "").toLowerCase().split(" "));
        } else if (input.equalsIgnoreCase("refactor")) {
            refactor();
        } else if (input.toLowerCase().startsWith("print")) {
            print(input.replaceFirst("print ?", "").toLowerCase().split(" "));
        } else if (input.equalsIgnoreCase("cleardb")) {
            cleardb();
        } else if (input.equalsIgnoreCase("edit")) {
            edit();
        } else if (input.equalsIgnoreCase("merge")) {
            merge();
        } else if (input.equalsIgnoreCase("interpreter")) {
            new Interpreter(null, System.getProperty("user.dir"));
        } else if (input.equalsIgnoreCase("hidden-keys")) {
            hiddenKeys();
        } else if (input.equalsIgnoreCase("exit")) {
            pl("Thanks for using the " + CYAN + BOLD + "Data Manager!" + reset());
            finished = true;
        } else {
            pl("I'm sorry, that's not a valid command. Here's the help:");
            help(new String[] {});
        }
    } while (finished == false);
    StreamUtils.GetSystemOut().println(TermColors.reset());
}
Also used : PersistenceNetwork(com.laytonsmith.persistence.PersistenceNetwork) ConfigCompileException(com.laytonsmith.core.exceptions.ConfigCompileException) TaskManager(com.laytonsmith.core.taskmanager.TaskManager) Profiler(com.laytonsmith.core.profiler.Profiler) Profiles(com.laytonsmith.core.Profiles) ConnectionMixinFactory(com.laytonsmith.persistence.io.ConnectionMixinFactory) MethodScriptExecutionQueue(com.laytonsmith.core.MethodScriptExecutionQueue) CommandHelperEnvironment(com.laytonsmith.core.environments.CommandHelperEnvironment) Environment(com.laytonsmith.core.environments.Environment) CommandHelperEnvironment(com.laytonsmith.core.environments.CommandHelperEnvironment) GlobalEnv(com.laytonsmith.core.environments.GlobalEnv) ConfigCompileGroupException(com.laytonsmith.core.exceptions.ConfigCompileGroupException)

Aggregations

MethodScriptExecutionQueue (com.laytonsmith.core.MethodScriptExecutionQueue)1 Profiles (com.laytonsmith.core.Profiles)1 CommandHelperEnvironment (com.laytonsmith.core.environments.CommandHelperEnvironment)1 Environment (com.laytonsmith.core.environments.Environment)1 GlobalEnv (com.laytonsmith.core.environments.GlobalEnv)1 ConfigCompileException (com.laytonsmith.core.exceptions.ConfigCompileException)1 ConfigCompileGroupException (com.laytonsmith.core.exceptions.ConfigCompileGroupException)1 Profiler (com.laytonsmith.core.profiler.Profiler)1 TaskManager (com.laytonsmith.core.taskmanager.TaskManager)1 PersistenceNetwork (com.laytonsmith.persistence.PersistenceNetwork)1 ConnectionMixinFactory (com.laytonsmith.persistence.io.ConnectionMixinFactory)1