RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.achievement.AchievementHandler Class Reference

Handles the achievements. More...

Static Public Member Functions

static void activate (Player player, AchievementKey achievement)
 Activates the achievement for the individual player.
static void activate (Player player, AchievementKey achievement, int increase)
 Activates the achievement for the individual player.
static void completeAll (Player player)
 Completes all the achievements for player (used for administrative purposes).
static boolean completed (Player player, AchievementList achievement)
 Checks if the reward is completed.
static boolean completedAll (Player player)
 Checks if a player has completed all the available achievements.
static int getColor (Player player, AchievementType difficulty)
static int getDifficultyAchievement (AchievementType difficulty)
 Handles getting the amount of achievements based on the difficulty.
static int getDifficultyCompletion (Player player, AchievementType difficulty)
 Handles getting the amount of achievements completed based on it's difficulty.
static int getTotalCompleted (Player player)
 Gets the total amount of achievements completed.
static void set (Player player, AchievementKey achievement, int increase)

Static Package Functions

static int getDifficultyAmount (AchievementType difficulty)

Detailed Description

Handles the achievements.

Author
Daniel

Definition at line 13 of file AchievementHandler.java.

Member Function Documentation

◆ activate() [1/2]

void com.runehive.content.achievement.AchievementHandler.activate ( Player player,
AchievementKey achievement )
static

Activates the achievement for the individual player.

Increments the completed amount for the player. If the player has completed the achievement, they will receive their reward.

Definition at line 20 of file AchievementHandler.java.

20 {
21 activate(player, achievement, 1);
22 }

References activate().

Referenced by activate(), com.runehive.content.skill.impl.slayer.Slayer.activate(), com.runehive.game.world.entity.skill.SkillManager.addExperience(), com.runehive.content.combat.Killstreak.announce(), com.runehive.content.triviabot.TriviaBot.answered(), com.runehive.content.skill.impl.woodcutting.WoodcuttingAction.chop(), com.runehive.game.service.VoteService.claimReward(), com.runehive.content.skill.impl.runecrafting.Runecraft.clickObject(), com.runehive.game.world.entity.mob.player.PlayerDeath.death(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.drop(), com.runehive.content.skill.impl.magic.spell.SpellCasting.enchant(), com.runehive.content.skill.impl.magic.spell.impl.HighAlchemy.execute(), com.runehive.content.activity.impl.kraken.KrakenActivity.finish(), com.runehive.content.activity.impl.pestcontrol.PestControlGame.PestControlNode.finish(), com.runehive.content.activity.impl.VorkathActivity.finish(), com.runehive.game.action.impl.TutorialActivity.finish(), com.runehive.content.skill.impl.fletching.Fletching.fletch(), com.runehive.content.activity.impl.barrows.BarrowsUtility.generateRewards(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.handleBoneCrusher(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.handleMessages(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.handleMiscDrops(), com.runehive.game.world.entity.combat.strategy.player.special.melee.AncientGodsword.hitsplat(), com.runehive.game.world.entity.combat.strategy.player.special.melee.ArmadylGodsword.hitsplat(), com.runehive.game.world.entity.combat.strategy.player.special.melee.DragonMace.hitsplat(), com.runehive.content.skill.impl.mining.MiningAction.mine(), com.runehive.content.skill.impl.herblore.Herblore.mix(), com.runehive.game.action.impl.ChestAction.onCancel(), com.runehive.game.action.impl.BuryBoneAction.onExecute(), com.runehive.game.world.entity.combat.attack.listener.item.DharokListener.onKill(), com.runehive.game.world.entity.combat.strategy.player.special.melee.AncientGodsword.onKill(), com.runehive.game.world.entity.combat.strategy.player.special.melee.ArmadylGodsword.onKill(), com.runehive.game.world.entity.combat.strategy.player.special.melee.DragonDagger.onKill(), com.runehive.game.world.entity.combat.strategy.player.special.melee.DragonMace.onKill(), com.runehive.game.world.entity.combat.strategy.player.special.melee.GraniteMaul.onKill(), com.runehive.game.world.entity.combat.strategy.player.special.range.DarkBow.onKill(), com.runehive.content.pet.Pets.onSpawn(), com.runehive.game.world.entity.mob.npc.NpcDeath.postDeath(), com.runehive.content.skill.impl.agility.obstacle.ObstacleInteraction.rewards(), com.runehive.game.world.entity.skill.SkillManager.updateSkill(), and com.runehive.content.preset.PresetManager.upload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ activate() [2/2]

void com.runehive.content.achievement.AchievementHandler.activate ( Player player,
AchievementKey achievement,
int increase )
static

Activates the achievement for the individual player.

Increments the completed amount for the player. If the player has completed the achievement, they will receive their reward.

Definition at line 29 of file AchievementHandler.java.

29 {
30 final int current = player.playerAchievements.computeIfAbsent(achievement, a -> 0);
31 for (AchievementList list : AchievementList.values()) {
32 if (list.getKey() == achievement) {
33 if (current >= list.getAmount())
34 continue;
35 player.playerAchievements.put(achievement, current + increase);
36 if (player.playerAchievements.get(achievement) >= list.getAmount()) {
37 player.bankVault.add(VaultCurrency.BLOOD_MONEY, list.getReward().getAmount());
38 player.send(new SendAnnouncement("You've completed the achievement", "'" + list.getTask() + "'", list.getType().getColor()));
39 }
40 }
41 }
42 }

References com.runehive.game.world.items.containers.bank.BankVault.add(), com.runehive.game.world.entity.mob.player.Player.bankVault, com.runehive.game.world.items.containers.bank.VaultCurrency.BLOOD_MONEY, com.runehive.game.world.entity.mob.player.Player.playerAchievements, and com.runehive.game.world.entity.mob.player.Player.send().

Here is the call graph for this function:

◆ completeAll()

void com.runehive.content.achievement.AchievementHandler.completeAll ( Player player)
static

Completes all the achievements for player (used for administrative purposes).

Definition at line 60 of file AchievementHandler.java.

60 {
61 if (!completedAll(player)) {
62 for (AchievementList achievement : AchievementList.values()) {
63 if (!player.playerAchievements.containsKey(achievement.getKey())) {
64 player.playerAchievements.put(achievement.getKey(), achievement.getAmount());
65 continue;
66 }
67 player.playerAchievements.replace(achievement.getKey(), achievement.getAmount());
68 }
69 player.send(new SendMessage("You have successfully mastered all achievements."));
70 }
71 }

References completedAll(), com.runehive.game.world.entity.mob.player.Player.playerAchievements, and com.runehive.game.world.entity.mob.player.Player.send().

Here is the call graph for this function:

◆ completed()

boolean com.runehive.content.achievement.AchievementHandler.completed ( Player player,
AchievementList achievement )
static

Checks if the reward is completed.

Definition at line 74 of file AchievementHandler.java.

74 {
75 if (!player.playerAchievements.containsKey(achievement.getKey()))
76 player.playerAchievements.put(achievement.getKey(), 0);
77 return player.playerAchievements.get(achievement.getKey()) >= achievement.getAmount();
78 }

References com.runehive.game.world.entity.mob.player.Player.playerAchievements.

Referenced by getDifficultyCompletion(), and getTotalCompleted().

Here is the caller graph for this function:

◆ completedAll()

boolean com.runehive.content.achievement.AchievementHandler.completedAll ( Player player)
static

Checks if a player has completed all the available achievements.

Definition at line 123 of file AchievementHandler.java.

123 {
124 return getTotalCompleted(player) == AchievementList.getTotal();
125 }

References com.runehive.content.achievement.AchievementList.getTotal(), and getTotalCompleted().

Referenced by completeAll(), and com.runehive.net.packet.in.WieldItemPacketListener.handlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getColor()

int com.runehive.content.achievement.AchievementHandler.getColor ( Player player,
AchievementType difficulty )
static

Definition at line 93 of file AchievementHandler.java.

93 {
94 int count = getDifficultyCompletion(player, difficulty);
95
96 if (count == 0) {
97 return 0xFF0000;
98 }
99
100 return count == getDifficultyAmount(difficulty) ? 0x257A1A : 0xFFFF00;
101 }

References getDifficultyAmount(), and getDifficultyCompletion().

Referenced by com.runehive.content.achievement.AchievementWriter.AchievementWriter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDifficultyAchievement()

int com.runehive.content.achievement.AchievementHandler.getDifficultyAchievement ( AchievementType difficulty)
static

Handles getting the amount of achievements based on the difficulty.

Definition at line 114 of file AchievementHandler.java.

114 {
115 int count = 0;
116 for (AchievementList achievement : AchievementList.values()) {
117 if (achievement.getType() == difficulty) count++;
118 }
119 return count;
120 }

◆ getDifficultyAmount()

int com.runehive.content.achievement.AchievementHandler.getDifficultyAmount ( AchievementType difficulty)
staticpackage

Definition at line 89 of file AchievementHandler.java.

89 {
90 return AchievementList.asList(difficulty).size();
91 }

References com.runehive.content.achievement.AchievementList.asList().

Referenced by com.runehive.content.achievement.AchievementWriter.AchievementWriter(), and getColor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDifficultyCompletion()

int com.runehive.content.achievement.AchievementHandler.getDifficultyCompletion ( Player player,
AchievementType difficulty )
static

Handles getting the amount of achievements completed based on it's difficulty.

Definition at line 104 of file AchievementHandler.java.

104 {
105 int count = 0;
106 for (AchievementList achievement : AchievementList.values()) {
107 if (player.playerAchievements.containsKey(achievement.getKey()) && achievement.getType() == difficulty && completed(player, achievement))
108 count++;
109 }
110 return count;
111 }

References completed(), and com.runehive.game.world.entity.mob.player.Player.playerAchievements.

Referenced by com.runehive.content.achievement.AchievementWriter.AchievementWriter(), and getColor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTotalCompleted()

int com.runehive.content.achievement.AchievementHandler.getTotalCompleted ( Player player)
static

Gets the total amount of achievements completed.

Definition at line 81 of file AchievementHandler.java.

81 {
82 int count = 0;
83 for (AchievementList achievement : AchievementList.values()) {
84 if (player.playerAchievements.containsKey(achievement.getKey()) && completed(player, achievement)) count++;
85 }
86 return count;
87 }

References completed(), and com.runehive.game.world.entity.mob.player.Player.playerAchievements.

Referenced by com.runehive.content.achievement.AchievementWriter.AchievementWriter(), completedAll(), and com.runehive.content.ProfileViewer.string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set()

void com.runehive.content.achievement.AchievementHandler.set ( Player player,
AchievementKey achievement,
int increase )
static

Definition at line 44 of file AchievementHandler.java.

44 {
45 final int current = player.playerAchievements.computeIfAbsent(achievement, a -> 0);
46 for (AchievementList list : AchievementList.values()) {
47 if (list.getKey() == achievement) {
48 if (current >= list.getAmount())
49 continue;
50 player.playerAchievements.put(achievement, increase);
51 if (player.playerAchievements.get(achievement) >= list.getAmount()) {
52 player.bankVault.add(VaultCurrency.BLOOD_MONEY, list.getReward().getAmount());
53 player.send(new SendAnnouncement("You've completed the achievement", "'" + list.getTask() + "'", list.getType().getColor()));
54 }
55 }
56 }
57 }

References com.runehive.game.world.items.containers.bank.VaultCurrency.BLOOD_MONEY.

Referenced by com.runehive.game.world.entity.skill.SkillManager.updateSkill().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: