Package net.visualillusionsent.utils

Examples of net.visualillusionsent.utils.PropertiesFile


        File test = new File(path);

        if (!test.exists()) {
            Canary.logInfo("Could not find the world configuration for " + worldname + " at " + path + ", creating default.");
        }
        cfg = new PropertiesFile(path + File.separatorChar + worldname + ".cfg");
        verifyConfig();
    }
View Full Code Here


    private static final Object lock = new Object();

    public PluginLoader() {
        plugins = new LinkedHashMap<String, Plugin>();
        pluginInf = new HashMap<String, PropertiesFile>();
        this.pluginPriorities = new PropertiesFile("config" + File.separator + "plugin_priorities.cfg");
    }
View Full Code Here

            jars.add(jarfile);
        }
        HashMap<String, PropertiesFile> canLoad = new HashMap<String, PropertiesFile>();
        int numLoaded = 1;
        for (String jar : jars) {
            PropertiesFile check = scan(jar, numLoaded);
            if (check == null) {
                continue;
            }
            else {
                canLoad.put(jar, check);
View Full Code Here

        return true;
    }

    private boolean createServerProperties(String worldname) {

        PropertiesFile props = new PropertiesFile("vanilla/server.properties");

        ServerConfiguration server = Configuration.getServerConfig();
        WorldConfiguration world = Configuration.getWorldConfig(worldname);

        props.setBoolean("allow-flight", world.isFlightAllowed());
        props.setBoolean("allow-nether", world.isNetherAllowed());
        props.setInt("difficulty", world.getDifficulty().getId());
        props.setBoolean("enable-query", server.isQueryEnabled());
        props.setBoolean("enable-rcon", server.isRconEnabled());
        props.setInt("gamemode", world.getGameMode().getId());
        props.setBoolean("generate-structures", world.generatesStructures());
        props.setString("level-name", world.getWorldName());
        props.setString("level-seed", world.getWorldSeed());
        props.setString("level-type", world.getWorldType().toString());
        props.setInt("max-build-height", world.getMaxBuildHeight());
        props.setInt("max-players", server.getMaxPlayers());
        props.setString("motd", server.getMotd());
        props.setBoolean("online-mode", server.isOnlineMode());
        props.setBoolean("pvp", world.isPvpEnabled());
        props.setInt("query.port", server.getQueryPort());
        props.setString("rcon.password", server.getRconPassword());
        props.setInt("rcon.port", server.getRconPort());
        props.setString("server-ip", server.getBindIp());
        props.setInt("server-port", server.getPort());
        props.setBoolean("spawn-animals", world.canSpawnAnimals());
        props.setBoolean("spawn-monsters", world.canSpawnMonsters());
        props.setBoolean("spawn-npcs", world.canSpawnVillagers());
        props.setInt("view-distance", server.getViewDistance());
        props.setBoolean("white-list", false);

        props.save();

        return true;
    }
View Full Code Here

     *         The base for plugin priority which is used to calculate the priority of new Plugins
     *
     * @return
     */
    private final PropertiesFile scan(String filename, int priorityBase) {
        PropertiesFile inf;
        try {
            File file = new File("plugins/" + filename);
            String jarName = filename.substring(0, filename.lastIndexOf("."));
            inf = new PropertiesFile(file.getAbsolutePath(), "Canary.inf");

            if (!inf.containsKey("main-class")) {
                Canary.logSevere("Failed to read main-class for '" + file.getName() + "' in Canary.inf Please specify a main-class entry in Canary.inf");
                return null;
            }
            inf.setString("jarName", jarName);
            inf.setString("jarPath", "plugins/".concat(filename));
            if (!inf.containsKey("name")) {
                inf.setString("name", simpleMain(inf.getString("main-class")));
            }

            if (!pluginPriorities.containsKey(inf.getString("name"))) {
                pluginPriorities.setInt(inf.getString("name"), priorityBase * 10);
                pluginPriorities.save();
            }
            else if (pluginPriorities.getInt(inf.getString("name")) < 0) {
                return null;
            }
        }
        catch (Throwable ex) {
            Canary.logStacktrace("Exception while loading plugin jar '" + filename + "' (Canary.inf missing?)", ex);
View Full Code Here

        for (File file : dbFolder.listFiles()) {
            if (!file.getName().endsWith(".jar")) {
                continue;
            }
            try {
                PropertiesFile inf = new PropertiesFile(file.getAbsolutePath(), "Canary.inf");
                CanaryClassLoader ploader = new CanaryClassLoader(file.toURI().toURL(), DatabaseLoader.class.getClassLoader());
                String mainclass = inf.getString("main-class");
                String dbName = inf.getString("database-name");
                Class<?> dbClass = ploader.loadClass(mainclass);

                Database db = (Database) dbClass.newInstance();
                if (db != null) {
                    Database.Type.registerDatabase(dbName, db);
View Full Code Here

        for (File jar : dir.listFiles()) {
            if (!jar.isFile() || !jar.getName().endsWith(".jar")) {
                continue;
            }
            try {
                PropertiesFile inf = new PropertiesFile(jar.getAbsolutePath(), "Canary.inf");
                if (!inf.containsKey("name")) {
                    if (!simpleMain(inf.getString("main-class")).equals(name)) {
                        continue;
                    }
                    inf.setString("name", simpleMain(inf.getString("main-class")));
                }
                else if (!inf.getString("name").equals(name)) {
                    continue;
                }
                inf.setString("jarPath", "plugins/".concat(jar.getName()));
                inf.setString("jarName", jar.getName().replace(".jar", ""));

                if (inf.containsKey("dependencies")) {
                    for (String dep : inf.getStringArray("dependencies", ";")) {
                        if (!plugins.containsKey(dep)) {
                            // Unsatisfied dependency
                            return null;
                        }
                    }
View Full Code Here

    private static PropertiesFile getPluginCachedConfig(Plugin plugin, String filepath) {
        if (!plugin_cfg_cache.containsKey(plugin)) {
            plugin_cfg_cache.put(plugin, new HashMap<String, PropertiesFile>());
        }
        if (!plugin_cfg_cache.get(plugin).containsKey(filepath)) {
            PropertiesFile file = new PropertiesFile(filepath);
            file.save();

            plugin_cfg_cache.get(plugin).put(filepath, file);
        }
        return plugin_cfg_cache.get(plugin).get(filepath);
    }
View Full Code Here

     *         the world
     *
     * @return configuration of a {@link Plugin}
     */
    public static PropertiesFile getPluginConfig(Plugin plugin, World world) {
        PropertiesFile file = Configuration.getPluginCachedConfig(plugin, "config" + File.separatorChar + plugin.getName() + File.separatorChar + "worlds" + File.separatorChar + world.getFqName() + File.separatorChar + plugin.getName() + ".cfg");

        if (file == null) {
            file = Configuration.getPluginCachedConfig(plugin, "config" + File.separatorChar + plugin.getName() + File.separatorChar + plugin.getName() + ".cfg");
        }
        return file;
View Full Code Here

     *         the world
     *
     * @return configuration of a {@link Plugin}
     */
    public static PropertiesFile getPluginConfig(Plugin plugin, String module, World world) {
        PropertiesFile file = Configuration.getPluginCachedConfig(plugin, "config" + File.separatorChar + plugin.getName() + File.separatorChar + "worlds" + File.separatorChar + world.getFqName() + File.separatorChar + plugin.getName() + "." + module + ".cfg");

        if (file == null) {
            file = Configuration.getPluginCachedConfig(plugin, "config" + File.separatorChar + plugin.getName() + File.separatorChar + plugin.getName() + "." + module + ".cfg");
        }
        return file;
View Full Code Here

TOP

Related Classes of net.visualillusionsent.utils.PropertiesFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.