com.dsh105.commodus.config.YAMLConfigManager Java Examples

The following examples show how to use com.dsh105.commodus.config.YAMLConfigManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HoloAPICore.java    From HoloAPI with GNU General Public License v3.0 5 votes vote down vote up
public void loadConfiguration() {
    configManager = new YAMLConfigManager(this);
    YAMLConfig config,
            dataConfig,
            langConfig;

    config = configManager.getNewConfig("config.yml", new String[]{
            "HoloAPI",
            "---------------------",
            "Configuration File",
            "",
            "See the HoloAPI Wiki before editing this file",
            "(https://github.com/DSH105/HoloAPI/wiki)"
    });
    langConfig = configManager.getNewConfig("messages.yml", new String[]{"HoloAPI", "---------------------", "Language Configuration File"});
    dataConfig = configManager.getNewConfig("data.yml");

    CONFIG_FILES.put(ConfigType.MAIN, config);
    CONFIG_FILES.put(ConfigType.LANG, langConfig);
    CONFIG_FILES.put(ConfigType.DATA, dataConfig);

    for (YAMLConfig yamlConfig : CONFIG_FILES.values()) {
        yamlConfig.reloadConfig();
    }

    SETTINGS.put(ConfigType.MAIN, new Settings(config));
    SETTINGS.put(ConfigType.LANG, new Lang(langConfig));
}
 
Example #2
Source File: EchoPetPlugin.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
@SneakyThrows(IOException.class)
public void onEnable() {
    EchoPet.setPlugin(this);
    isUsingNetty = CommonReflection.isUsingNetty();

    this.configManager = new YAMLConfigManager(this);
    COMMAND_MANAGER = new CommandManager(this);
    // Make sure that the plugin is running under the correct version to prevent errors

    if (NmsVersion.current() == null || !INMS.isSupported()) {
        EchoPet.LOG.log(ChatColor.RED + "SonarPet " + ChatColor.GOLD
                + this.getDescription().getVersion() + ChatColor.RED
                + " is not compatible with this version of CraftBukkit");
        EchoPet.LOG.log(ChatColor.RED + "Initialisation failed. Please update the plugin.");

        DynamicPluginCommand cmd = new DynamicPluginCommand(this.cmdString, new String[0], "", "",
                new VersionIncompatibleCommand(this, this.cmdString, ChatColor.YELLOW +
                        "SonarPet " + ChatColor.GOLD + this.getDescription().getVersion() + ChatColor.YELLOW + " is not compatible with this version of CraftBukkit. Please update the plugin.",
                        "echopet.pet", ChatColor.YELLOW + "You are not allowed to do that."),
                null, this);
        COMMAND_MANAGER.register(cmd);
        return;
    }
    EntityRegistry entityRegistry;
    if (CitizensEntityRegistryHack.isNeeded()) {
        getLogger().warning("Attempting to inject citizens compatibility hack....");
        entityRegistry = CitizensEntityRegistryHack.createInstance();
        getLogger().warning("Successfully injected citizens compatibility hack!");
    } else {
        //noinspection deprecation // We check for citizens first ;)
        entityRegistry = INMS.getInstance().createDefaultEntityRegistry();
    }
    this.entityRegistry = Objects.requireNonNull(entityRegistry);

    this.loadConfiguration();

    PluginManager manager = getServer().getPluginManager();

    MANAGER = new PetManager();
    SQL_MANAGER = new SqlPetManager();

    if (OPTIONS.useSql()) {
        this.prepareSqlDatabase();
    }

    // Register custom commands
    // Command string based off the string defined in config.yml
    // By default, set to 'pet'
    // PetAdmin command draws from the original, with 'admin' on the end
    this.cmdString = OPTIONS.getCommandString();
    this.adminCmdString = OPTIONS.getCommandString() + "admin";
    DynamicPluginCommand petCmd = new DynamicPluginCommand(this.cmdString, new String[0], "Create and manage your own custom pets.", "Use /" + this.cmdString + " help to see the command list.", new PetCommand(this.cmdString), null, this);
    petCmd.setTabCompleter(new CommandComplete());
    COMMAND_MANAGER.register(petCmd);
    COMMAND_MANAGER.register(new DynamicPluginCommand(this.adminCmdString, new String[0], "Create and manage the pets of other players.", "Use /" + this.adminCmdString + " help to see the command list.", new PetAdminCommand(this.adminCmdString), null, this));

    // Initialize hook classes
    for (ClassPath.ClassInfo hookType : ClassPath.from(getClass().getClassLoader()).getTopLevelClasses("net.techcable.sonarpet.nms.entity.type")) {
        if (!hookType.load().isAnnotationPresent(EntityHook.class)) continue;
        for (EntityHookType type : hookType.load().getAnnotation(EntityHook.class).value()) {
            if (!type.isActive()) continue;
            hookRegistry.registerHookClass(type, hookType.load().asSubclass(IEntityPet.class));
        }
    }

    // Register listeners
    manager.registerEvents(new MenuListener(), this);
    manager.registerEvents(new PetEntityListener(this), this);
    manager.registerEvents(new PetOwnerListener(), this);
    if (VersionNotificationListener.isNeeded()) {
        manager.registerEvents(new VersionNotificationListener(), this);
        PluginVersioning.INSTANCE.sendOutdatedVersionNotification(Bukkit.getConsoleSender());
    }
    //manager.registerEvents(new ChunkListener(), this);

    this.vanishProvider = new VanishProvider(this);
    this.worldGuardProvider = new WorldGuardProvider(this);
}