• Hello Guest! Did you know that ProjectKorra has an official Discord server? A lot of discussion about the official server, development process, and community discussion happens over there. Feel free to join now by clicking the link below.

    Join the Discord Server
Resource icon

Side Plugin PKConfigAPI 1.3

PKConfigAPI is an API for ProjectKorra that allows developers to forget about Configs, setting them and getting values from it, probably the most boring part when making an ability, maybe even the most time-consuming.

THIS API NEEDS TO BE AS A PLUGIN IN THE SERVER, OTHERWISE, IT WON'T WORK, SHADING IT INTO THE ABILITY ALSO WON'T WORK.

If you are using this for a side plugin, then it may be necessary to add
YAML:
depend: [PKConfigApi]
in plugin.yml

This should work on all PK versions, but it was tested on 1.8.7 and 1.9.0


This plugin comes with the command: /pkc reload
It reloads every ConfigAbility with new values from the config, it is a lot faster than ProjectKorra's reload.
Permission is the same as ProjectKorra's reload command.

A quick tutorial on how to use it:


First, you have to tag the ability as a "ConfigAbility", for example, like this:
Java:
@ConfigAbility()
public final class Ricochet extends AirAbility implements AddonAbility {
    // code
}
ConfigAbility() can take 4 arguments:
Java:
    String value() default "ExtraAbilities"; // Prefix to the config path.
    String configPath() default "config.yml"; // Ability config path (From the PK plugin directory).
    String languagePath() default "language.yml"; // Language config path (From the PK plugin directory)
    String plugin() default "ProjectKorra";
So, for example, if you want:
1. An ability with the path prefix "CoolAbilities"
2. Path equal to "BetterAbilities", and make the ability config file path as myconfigs/coolConfig.yml
3. Same as 2, but also with the language config file the same as the ability config file.
4. (For side plugins) You want your config to be in your plugin folder, for example, JedCore and have the JedCore prefix.
Java:
// 1.
@ConfigAbility("CoolAbilities")
public class Ricochet extends AirAbility implements AddonAbility {
    // code
}

// 2.
@ConfigAbility(value = "BetterAbilities", configPath = "myconfigs/coolConfig.yml")
public class Ricochet extends AirAbility implements AddonAbility {
    // code
}

// 3.
@ConfigAbility(value = "BetterAbilities", configPath = "myconfigs/coolConfig.yml", languagePath =  "myconfigs/coolConfig.yml")
public class Ricochet extends AirAbility implements AddonAbility {
    // code
}

// 4.
@ConfigAbility(value = "JedCore", plugin = "JedCore")
public class Ricochet extends AirAbility implements AddonAbility {
    // code
}
Now to create a ConfigValue (that will automatically update after a reload, the whole purpose of this API)
Java:
    // IT HAS TO BE STATIC NON-FINAL, otherwise, it won't work! Also, preferably don't update the values yourself, otherwise, it may change the default value.

    @ConfigValue("cooldown")
    private static long cooldown = 1000;

    @ConfigValue("damage")
    private static int damage = 1;

    @LanguageValue("Description")
    private static String description = "Some description {author} {element} {name}";

    // {author} will be changed to the ability author
    // {element} to the element of the ability
    // {name} to the name of the ability

    @LanguageValue("Usage")
    private static String usage = "Some usage";
How to include:
(Works for: Maven, Gradle, sbt and leiningen)

Maven:
XML:
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

    <dependency>
        <groupId>com.github.DomiRusz24</groupId>
        <artifactId>PKConfigAPI</artifactId>
        <version>LATEST</version>
        <scope>provided</scope>
    </dependency>
Pretty self-explanatory.
Upon loading the plugin, all of the values that are assigned in the code (damage = 1, usage = "Some usage", etc.) will be saved as default values.
If you want to use a custom config, the plugin will automatically create it for you and update it.
Author
DomiRusz24
Downloads
1,826
First release
Last update
Rating
4.33 star(s) 3 ratings

More resources from DomiRusz24

Latest updates

  1. Added support for JitPack

    Added support for JitPack
  2. Added support to more ability types and side plugins.

    Added support for Abilities that don't implement AddonAbility, and the option to choose the...

Latest reviews

This is pretty good, has saved me countless hours making configs
I dont know where I need to type in the plugin.yml the code: "[PKConfig] depend" And its not working. You can please doing a guide?
DomiRusz24
DomiRusz24
Please add me on discord: DomiRusz24#2701, I'll tell you exactly what to do. The guide that is on the page is enough, counting on that the user has basic knowledge of Java, Spigot and Maven, if you'll add me on Discord we can talk this through. But next time please do your own research. As for the "depend: [PKConfigApi]", if you are writing a side plugin, then just write it into plugin.yml below any other information, if you are writing a single ability, then you don't have to include that. Remember that the plugin also needs to be on the server, otherwise, it won't work.
This is some amazing stuff! 5 stars for you.
DomiRusz24
DomiRusz24
Thanks!
Top