This repository was archived by the owner on Nov 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 209
Developers
Pyves edited this page Mar 30, 2017
·
31 revisions
- Download the latest version of Advanced Achievements from Bukkit or Spigot.
- Add the file to the build path of your project.
- Add a piece of code similar to the following in your project:
import com.hm.achievement.api.AdvancedAchievementsAPI;
import com.hm.achievement.api.AdvancedAchievementsBukkitAPI;
...
if (Bukkit.getPluginManager().isPluginEnabled("AdvancedAchievements")) {
Plugin pluginInstance = Bukkit.getPluginManager().getPlugin("AdvancedAchievements");
// Check whether the running version contains the API classes.
if (Integer.parseInt(Character.toString(pluginInstance.getDescription().getVersion().charAt(0))) >= 5) {
AdvancedAchievementsAPI advancedAchievementsAPI = AdvancedAchievementsBukkitAPI.linkAdvancedAchievements();
advancedAchievementsAPI. ...
}
}
...
- Use your
AdvancedAchievementsAPI
object as you wish! The interface with commented method signatures is available here.
Adding simple categories is rather straightforward and does not require advanced Java knowledge: it's mostly a matter of following the code that's already written!
- Fork the repository by following the instructions given on the home page.
- Define a new category by adding a value to the
NormalAchievements.java
enum in thecom.hm.achievement.category
package. - Add a new listener class to the
com.hm.achievement.listener
package.AchieveDropListener.java
is a very simple example you can use as a reference. - Add a new field corresponding to your listener class in
AdvancedAchievements.java
. Register your listener in theregisterListeners()
method. Simply follow the existing code. - Add a new default permission value in plugin.yml (
achievement.count.
followed by the category name in lower case). This file is situated in the resources folder. - Add a new default GUI object in gui.yml. This file is situated in the resources folder.
- Add your achievements for this new category in config.yml. You're done!
If you're happy with what you've done, why not contribute and open a pull request?
In your own plugin project, you might want to be notified when a player receives an achievement. That's simple!
- Download the latest version of Advanced Achievements from Bukkit or Spigot.
- Add the file to the build path of your project.
- Add a new class similar to the following in your project:
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.hm.achievement.utils.PlayerAdvancedAchievementEvent;
...
public class PlayerAdvancedAchievementListener implements Listener {
...
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerAdvancedAchievementReception(PlayerAdvancedAchievementEvent event) {
...
}
}
- Register this listener to your plugin. For instance in your main plugin class:
getServer().getPluginManager().registerEvents(new PlayerAdvancedAchievementListener(), this);