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
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:
ConfigAbility() can take 4 arguments:
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.
Now to create a ConfigValue (that will automatically update after a reload, the whole purpose of this API)
How to include:
(Works for: Maven, Gradle, sbt and leiningen)
Maven:
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.
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]
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
}
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";
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
}
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";
JitPack | Publish JVM and Android libraries
JitPack makes it easy to release your Java or Android library. Publish straight from GitHub or Bitbucket.
jitpack.io
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>
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.
Likes:
DreamerBoy, Aztl and Hiro3