RuneHive-Game
Loading...
Searching...
No Matches
CombatAntifireEffect.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.effect.impl;
2
3import com.runehive.net.packet.out.SendMessage;
4import com.runehive.game.world.entity.combat.effect.AntifireDetails;
5import com.runehive.game.world.entity.combat.effect.CombatEffect;
6import com.runehive.game.world.entity.mob.Mob;
7import com.runehive.game.world.entity.mob.player.Player;
8
9/**
10 * The class which is responsible for the effect when you drink an anti-fire potion.
11 * @author <a href="http://www.rune-server.org/members/stand+up/">Stand Up</a>
12 */
13public final class CombatAntifireEffect extends CombatEffect {
14
15 /**
16 * The type of antifire this player has drunk.
17 */
19
20 /**
21 * Constructs a new {@link CombatAntifireEffect}.
22 * @param type {@link #type}.
23 */
25 super(1);
26 this.type = type;
27 }
28
29 @Override
30 public boolean apply(Mob mob) {
31 if(!mob.isPlayer()) {
32 return false;
33 }
34
35 Player player = mob.getPlayer();
36
37 if(player.getAntifireDetails().isPresent()) {
39 return false;
40 }
41
43 return true;
44 }
45
46 @Override
47 public boolean removeOn(Mob mob) {
48 if(mob.isPlayer()) {
49 Player player = mob.getPlayer();
50
51 return !player.getAntifireDetails().isPresent();
52
53 }
54 return true;
55 }
56
57 @Override
58 public void process(Mob mob) {
59 if(mob.isPlayer() && mob.getPlayer().getAntifireDetails().isPresent()) {
60 Player player = mob.getPlayer();
61 AntifireDetails detail = player.getAntifireDetails().get();
62 int count = detail.getAntifireDelay().decrementAndGet();
63 if(count == 30) {
64 player.send(new SendMessage("@red@Your resistance to dragon fire is about to wear off!"));
65 }
66 if(count < 1) {
67 player.setAntifireDetail(null);
68 player.send(new SendMessage("Your resistance to dragon fire has worn off!"));
69 }
70 }
71 }
72
73 @Override
74 public boolean onLogin(Mob mob) {
75 return mob.isPlayer() && mob.getPlayer().getAntifireDetails().isPresent();
76 }
77
78}
CombatEffect(int delay)
Creates a new CombatEffect.
boolean removeOn(Mob mob)
Removes this effect from mob if needed.
void process(Mob mob)
Provides processing for this effect on mob.
final AntifireDetails.AntifireType type
The type of antifire this player has drunk.
CombatAntifireEffect(AntifireDetails.AntifireType type)
Constructs a new CombatAntifireEffect.
boolean onLogin(Mob mob)
Executed on login, primarily used to re-apply the effect to mob.
Handles the mob class.
Definition Mob.java:66
This class represents a character controlled by a player.
Definition Player.java:125
void setAntifireDetail(AntifireDetails antifireDetails)
Definition Player.java:901
Optional< AntifireDetails > getAntifireDetails()
Definition Player.java:897
The OutgoingPacket that sends a message to a Players chatbox in the client.
int decrementAndGet(int amount, int minimum)
Decrements the value within this counter by amount to a minimum of minimum and then returns it.