API
Add soft-depend: [AchievementsPlus] to your plugin.yml
- First, add this to the top of you main class:
public AchievementsPlusAPI api = null;
- Then put this in you onEnable method:
if(Bukkit.getServer().getPluginManager().getPlugin("AchievementsPlus").isEnabled()) { api = new AchievementsPlusAPI(this); }
- Use this to create an achievement:
if(api != null) { try { api.registerAchievement("Test", "It's a test", RewardType.MONEY, String.valueOf(50)); } catch (AchievementCreateException e) { //Name is already used } }
- Now let's add the achievement to a player. This will check if the player already has the achievement and if not, it will add it.
Achievement achievement = plugin.api.getAchievementByName("Test"); if(achievement != null) { try { plugin.api.addAchievementToPlayer(player, achievement); } catch(AchievementAccessException e) { //Don't have access to that achievement } }
- You can get every achievement created by your plugin with:
ArrayList achievementList = api.getAchievements();
- With this you can delete an achievement:
try { api.deleteAchievement(achievement); } catch (AchievementAccessException e) { //Don't have access to that achievement }
- Finally use this if you want to check if a player already got the achievement:
if(api.playerHasAchievement(player, achievement)) { //Do something }
Comments