RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
CombatAntifireEffect.java
1package com.osroyale.game.world.entity.combat.effect.impl;
2
3import com.osroyale.net.packet.out.SendMessage;
4import com.osroyale.game.world.entity.combat.effect.AntifireDetails;
5import com.osroyale.game.world.entity.combat.effect.CombatEffect;
6import com.osroyale.game.world.entity.mob.Mob;
7import com.osroyale.game.world.entity.mob.player.Player;
8
35
36* The class which is responsible for the effect when you drink an anti-fire potion.
37 * @author <a href="http://www.rune-server.org/members/stand+up/">Stand Up</a>
38 */
39public final class CombatAntifireEffect extends CombatEffect {
40
44 private final AntifireDetails.AntifireType type;
45
50 public CombatAntifireEffect(AntifireDetails.AntifireType type) {
51 super(1);
52 this.type = type;
53 }
54
55 @Override
56 public boolean apply(Mob mob) {
57 if(!mob.isPlayer()) {
58 return false;
59 }
60
61 Player player = mob.getPlayer();
62
63 if(player.getAntifireDetails().isPresent()) {
64 player.setAntifireDetail(new AntifireDetails(type));
65 return false;
66 }
67
68 player.setAntifireDetail(new AntifireDetails(type));
69 return true;
70 }
71
72 @Override
73 public boolean removeOn(Mob mob) {
74 if(mob.isPlayer()) {
75 Player player = mob.getPlayer();
76
77 return !player.getAntifireDetails().isPresent();
78
79 }
80 return true;
81 }
82
83 @Override
84 public void process(Mob mob) {
85 if(mob.isPlayer() && mob.getPlayer().getAntifireDetails().isPresent()) {
86 Player player = mob.getPlayer();
87 AntifireDetails detail = player.getAntifireDetails().get();
88 int count = detail.getAntifireDelay().decrementAndGet();
89 if(count == 30) {
90 player.send(new SendMessage("@red@Your resistance to dragon fire is about to wear off!"));
91 }
92 if(count < 1) {
93 player.setAntifireDetail(null);
94 player.send(new SendMessage("Your resistance to dragon fire has worn off!"));
95 }
96 }
97 }
98
99 @Override
100 public boolean onLogin(Mob mob) {
101 return mob.isPlayer() && mob.getPlayer().getAntifireDetails().isPresent();
102 }
103
104}