ChatFeelings API - Historical

Applied By zach_attack: Sep 8, 2019 at 10:50 PM

ChatFeelings API

The ChatFeelingsAPI was created with the developer in mind.
Making it as easy as possible to add your own touch to your server.

Adding a Soft Dependency

First, let's make sure that ChatFeelings is included as a soft-dependency in your plugin.yml so that way ChatFeelings is started before your plugin.
Code (Text):
name: MyTestPlugin
version: 0.1
main: com.zach_attack.my_plugin.Main
softdepend: [ChatFeelings]
api-version: 1.14
As you can see, we added softdepend: ChatFeelings
to our plugin.yml. Do note that the other variables can be changed to your liking :)

Adding an onEnable() check

Second, let's make sure that ChatFeelings is available to use on this server. To do so, we will be using a boolean that we can just check if it's true before using anything.

Code (Java):
public class Main extends JavaPlugin implements Listener {[/SIZE][/LEFT][/SIZE]
[LEFT][SIZE=4][COLOR=rgb(64, 64, 64)][SIZE=4]
    boolean useCF;
    public void onEnable() {
        if (getServer().getPluginManager().isPluginEnabled("ChatFeelings") &&
         (getServer().getPluginManager().getPlugin("ChatFeelings") != null))  {
            useCF = true;
        } else {
            useCF = false;

Code Explanation:
boolean useCF; - This is just a variable that is either true or false. Right now it has no setting until the onEnable() sets it to true or false.

if (getServer().getPluginManager().isPluginEnabled("ChatFeelings") &&
!= null)) - This line checks to see if ChatFeelings is not only enabled, but also not returning null. (Basically ensuring we can use the API without any problems)

useCF = true; - This sets that boolean we told you about earlier to true. Now we can do if(useCF) { } to run things only if ChatFeelings is available.