DRC-API

About the API
This API add some usefull methods to avoid to write a ton of code over and over again.
 
Methods
MainHelper.reformateText("&cSome text");
This will give back the colored text. You can use '&' and '§'.
 
MainHelper.hasPermission(player, permission);
Will check if the given Player has op, * or the given permission
permission can be of type String or Permission
 
MainHelper.isPluginThere(mainPlugin, "Litebans");
Will check if the given pluginname is in the Pluginsfolder.
 
MainHelper.addLore(lore, itemstack);
Will add the given lore to the itemstack
lore has to be a list of Strings
 
MainHelper.getRenamedItemstack(customname, itemstack);
Will rename the given itemstack with the given name. (The name can be colored)
 
Other features
- Adds an UpdateChecker function
 
private void checkUpdate() {
    UpdateChecker updater = new UpdateChecker(this, 52712, false);
 
    UpdateChecker.UpdateResult result = updater.getResult();
 
    switch (result) {
        case NO_UPDATE: {
            getLogger().info(perfix + MainHelper.reformateText("&6There is no update available! Everything is up to date!"));
            break;
        }
        case UPDATE_AVAILABLE: {
            // TODO: 4/12/2017 Fix link
            getLogger().info(perfix + MainHelper.reformateText("&aThere is an update available! You can download it at https://www.spigotmc.org/resources/anti-combat-log.52712/"));
            break;
        }
 
        case FAIL_SPIGOT: {
            getLogger().info(perfix + MainHelper.reformateText("&cThere is a problem with Spigot. sorry for the inconvenience"));
            break;
        }
        case BAD_RESOURCEID: {
            getLogger().info(perfix + MainHelper.reformateText("&cStupid me. I placed the wrong ResourceID. Contact him on Spigot!"));
            break;
        }
    }
}
If you insert and call this in your main plugin class it will check if the given resourceID has an update. (Change "52712" to your plugin id and ofcourse the link)
 
- A ConfigHandler which makes it super easy to have more than 1 config file. Just make a class for each configfile and extends ConfigHandler. Implement the constructor.
Once you've done that, go to where you want to init your configs and use the following syntax:
For example:
Config config = new Config(plugin, "config.yml");
After you made the config.yml file inside the src folder, add static methods for each value you want to have access to. Add a load methode and add getters and you can access them from everywhere in your project. 
Here is an example Configfile from AntiCombatLog.
config.yml
#Enables if you want to auto check for updates
updatechecker: true
#These commands will be disabled when being in combat.
command-blacklist:
- /spawn
- /ci
 
#When this is allowed, players can be punished for combat logging
allow-punishments: true
Config.java
public class Config extends ConfigHandler {
private static boolean updateChecker;
private static boolean punishmentsAllowed;
private static List<String> blacklistedCommands;
 
public Config(JavaPlugin plugin, String filename) {
     super(plugin, filename);
     loadConfig();
}
 
private void loadConfig() {
     updateChecker = getConfig().getBoolean("updatechecker");
 
     punishmentsAllowed = getConfig().getBoolean("allow-punishments");
 
     blacklistedCommands= getConfig().getStringList("command-blacklist");
}
 
public static List<String> getBlacklistedCommands() {
        return blacklistedCommands;
}
 
public static boolean isUpdateChecker() {
        return updateChecker;
}
 
public static boolean ispunishmentsAllowed () {
        return punishmentsAllowed ;
}
 
}
Now wherever you need it, you can call
Config.ispunishmentsAllowed();
Plugins who currently use this API
If you are using this plugin feel free to let me know and I'll add you on this list.
 
Developers
Feel free to add this plugin to your libraries. No maven support yet.
 

Download

File Name Status Version Downloads Date
DRCAPI-1.0 R 1.12 +8 82 10/02/2018
DRC-API 1.20.2 Updating 1.20.2 Updating Updating
DRC-API 1.20.1 Updating 1.20.1 Updating Updating
DRC-API 1.20 Updating 1.20 Updating Updating
DRC-API 1.19.2 Updating 1.19.2 Updating Updating
DRC-API 1.19.1 Updating 1.19.1 Updating Updating
DRC-API 1.19 Updating 1.19 Updating Updating
DRC-API 1.18 Updating 1.18 Updating Updating
DRC-API 1.17.1 Updating 1.17.1 Updating Updating
DRC-API Forge Updating Forge Updating Updating
DRC-API Fabric Updating Fabric Updating Updating
DRC-API
DRC-API

Dear youtuber!
Have you a channel youtube and want to bring your Video to quality visitors?
Do you want your video to appear on our website?
Do you want to become partner with us?
Just 3 steps to become our partner:
Step 1: Make video review for mods, addons, plugins, ... which you like
Step 2: Upload this video to youtube and our link to your video description
Step 3: Send the youtube video link via message to http://fb.com/9lifehack or leave a comment in the post. We will add your video in the our post, it will help you have more view.
JOIN to get more youtube view with us!!!!

Related Posts

Smarty Productivity Happiness

9LifeHack.com - make things smart