Search in sources :

Example 1 with Profiles

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

the class ProfilesTest method testProfileSuccess.

@Test
public void testProfileSuccess() throws Exception {
    String good = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + "<profiles>" + "	<profile id=\"profile1\">" + "		<type>mysql</type>" + "		<database>db_name1</database>" + "		<username>username1</username>" + "		<password>password1</password>" + "	</profile>" + "	<profile id=\"profile2\">" + "		<type>mysql</type>" + "		<database>db_name2</database>" + "		<username>username2</username>" + "		<password>password2</password>" + "	</profile>" + "</profiles>";
    Profiles profiles = new Profiles(good);
}
Also used : Profiles(com.laytonsmith.core.Profiles) Test(org.junit.Test)

Example 2 with Profiles

use of com.laytonsmith.core.Profiles 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

Profiles (com.laytonsmith.core.Profiles)2 MethodScriptExecutionQueue (com.laytonsmith.core.MethodScriptExecutionQueue)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 Test (org.junit.Test)1