Search in sources :

Example 1 with CloudNetWrapperConfig

use of de.dytanic.cloudnetwrapper.CloudNetWrapperConfig in project CloudNet by Dytanic.

the class CloudBootstrap method main.

public static void main(String[] args) throws Exception {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);
    System.setProperty("file.encoding", "UTF-8");
    System.setProperty("java.net.preferIPv4Stack", "true");
    System.setProperty("io.netty.noPreferDirect", "true");
    System.setProperty("client.encoding.override", "UTF-8");
    System.setProperty("io.netty.maxDirectMemory", "0");
    System.setProperty("io.netty.leakDetectionLevel", "DISABLED");
    System.setProperty("io.netty.recycler.maxCapacity", "0");
    System.setProperty("io.netty.recycler.maxCapacity.default", "0");
    OptionParser optionParser = new OptionParser();
    optionParser.allowsUnrecognizedOptions();
    optionParser.acceptsAll(Arrays.asList("version", "v"));
    optionParser.acceptsAll(Arrays.asList("help", "?"));
    optionParser.accepts("disable-queue");
    optionParser.accepts("ssl");
    optionParser.accepts("systemTimer");
    optionParser.accepts("noconsole");
    optionParser.accepts("systemTimer");
    optionParser.accepts("debug");
    optionParser.accepts("disable-autoupdate");
    optionParser.accepts("disallow_bukkit_download");
    OptionSet optionSet = optionParser.parse(args);
    if (optionSet.has("help") || optionSet.has("?")) {
        HelpService helpService = new HelpService();
        helpService.getDescriptions().put("help", new ServiceDescription[] { new ServiceDescription("--help | --?", "This is the main argument to get all information about other parameters") });
        helpService.getDescriptions().put("ssl", new ServiceDescription[] { new ServiceDescription("--ssl", "Allows SSL encryption via a system-contained certificate or an open SSL certificate") });
        helpService.getDescriptions().put("noconsole", new ServiceDescription[] { new ServiceDescription("--noconsole", "Disables the console, for the rest of the service run time") });
        helpService.getDescriptions().put("disable-autoupdate", new ServiceDescription[] { new ServiceDescription("--disable-autoupdate", "Disabled the autoupdate function of cloudnet 2") });
        helpService.getDescriptions().put("version", new ServiceDescription[] { new ServiceDescription("--version | --v", "Displays the current version of CloudNet used") });
        helpService.getDescriptions().put("systemTimer", new ServiceDescription[] { new ServiceDescription("--systemTimer", "Time all informations of this instance into a custom log file") });
        System.out.println(helpService.toString());
        return;
    }
    if (optionSet.has("systemTimer")) {
        new SystemTimer();
    }
    if (optionSet.has("version") || optionSet.has("v")) {
        System.out.println("CloudNet-Wrapper RezSyM Version " + CloudBootstrap.class.getPackage().getImplementationVersion() + "-" + CloudBootstrap.class.getPackage().getSpecificationVersion());
        return;
    }
    /*==============================================*/
    try {
        FileUtils.deleteDirectory(new File("temp"));
    } catch (Exception ex) {
    }
    if (Files.exists(Paths.get("local"))) {
        try {
            FileUtils.deleteDirectory(new File("local/cache"));
        } catch (Exception ex) {
        }
    }
    /*==============================================*/
    CloudLogger cloudNetLogging = new CloudLogger();
    if (optionSet.has("debug"))
        cloudNetLogging.setDebugging(true);
    new HeaderFunction();
    CloudNetWrapperConfig cloudNetWrapperConfig = new CloudNetWrapperConfig(cloudNetLogging.getReader());
    CloudNetWrapper cloudNetWrapper = new CloudNetWrapper(optionSet, cloudNetWrapperConfig, cloudNetLogging);
    if (!cloudNetWrapper.bootstrap()) {
        System.exit(0);
    }
    if (!optionSet.has("noconsole")) {
        System.out.println("Use the command \"help\" for further information!");
        String commandLine;
        while (true) try {
            while ((commandLine = cloudNetLogging.getReader().readLine()) != null) {
                if (!cloudNetWrapper.getCommandManager().dispatchCommand(commandLine)) {
                    System.out.println("Command not found. Use the command \"help\" for further information!");
                }
            }
        } catch (Exception ex) {
        }
    } else {
        while (true) NetworkUtils.sleepUninterruptedly(Long.MAX_VALUE);
    }
}
Also used : CloudNetWrapper(de.dytanic.cloudnetwrapper.CloudNetWrapper) ServiceDescription(de.dytanic.cloudnet.help.ServiceDescription) OptionParser(joptsimple.OptionParser) HeaderFunction(de.dytanic.cloudnet.logging.util.HeaderFunction) CloudNetWrapperConfig(de.dytanic.cloudnetwrapper.CloudNetWrapperConfig) OptionSet(joptsimple.OptionSet) File(java.io.File) CloudLogger(de.dytanic.cloudnet.logging.CloudLogger) HelpService(de.dytanic.cloudnet.help.HelpService) SystemTimer(de.dytanic.cloudnet.lib.SystemTimer)

Aggregations

HelpService (de.dytanic.cloudnet.help.HelpService)1 ServiceDescription (de.dytanic.cloudnet.help.ServiceDescription)1 SystemTimer (de.dytanic.cloudnet.lib.SystemTimer)1 CloudLogger (de.dytanic.cloudnet.logging.CloudLogger)1 HeaderFunction (de.dytanic.cloudnet.logging.util.HeaderFunction)1 CloudNetWrapper (de.dytanic.cloudnetwrapper.CloudNetWrapper)1 CloudNetWrapperConfig (de.dytanic.cloudnetwrapper.CloudNetWrapperConfig)1 File (java.io.File)1 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1