api

Skillz API

This page is severely outdated! This is an example on how the API works:https:github.com/Lolmen/SkillzAPI

How to

Import the Skillz.jar into your libraries (In eclipse, rightmouseclick your project, Properties, Java Build Path, then Libraries). Click on 'Add External Jars...', and locate the Skillz.jar

Checking if server has Skillz installed

A simple method will tell us if Skillz is installed:

1
2
3
4
5
6
7
8
private boolean getSkills() {
        Plugin test = getServer().getPluginManager().getPlugin("Skillz");
        if(test != null){
            return true;
        }else{
            return false;
        }
    }

Use this in your on-enable:

1
2
3
4
5
6
7
if(getSkills()){
            getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, list, Priority.Normal, this);
            log.info("Enabled!");
        }else{
            log.info("Skillz not found! Disabling!");
            getServer().getPluginManager().disablePlugin(this);
        }

Registering a Level-Up

Make a new class, for example: SkillzLevelUpListener. In your main class, add this:

public SkillzLevelUpListener list = new SkillzLevelUpListener(this); 

In the SkillzLevelUpListener, add this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
public void onCustomEvent(Event event){
        if(event instanceof SkillzLevelEvent){
            doEvent((SkillzLevelEvent)event);
        }
    }

    private void doEvent(SkillzLevelEvent event) {
        Player p = event.getPlayer();
        String skill = event.getSkill();
        p.sendMessage("Skill " + skill + " leveled!");
    }

The doEvent will now send a message to your player on leveling up! Keep in mind that any changes made while leveling up, for example the change of a config value, will happen BEFORE the leveling up process has been completed. This means that you can listen for what level you leveled, set a certain reward for that level and then let it run.


Comments

Posts Quoted:
Reply
Clear All Quotes