RuneHive-Game
Loading...
Searching...
No Matches
PlayerKilling.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.mob.player;
2
3import com.runehive.content.EmblemData;
4import com.runehive.content.clanchannel.content.ClanAchievement;
5import com.runehive.content.pet.PetData;
6import com.runehive.content.pet.Pets;
7import com.runehive.content.writer.InterfaceWriter;
8import com.runehive.content.writer.impl.InformationWriter;
9import com.runehive.game.world.items.Item;
10import com.runehive.util.Utility;
11import static com.runehive.content.clanchannel.content.ClanTaskKey.PLAYER_KILLING;
12
13public class PlayerKilling {
14
15 public static void handle(Player killer, Player victim) {
16 if (killer.isBot) {
17 return;
18 }
19
20 if (killer.lastHost.equalsIgnoreCase(victim.lastHost)) {
21 killer.message("<col=FF0019>You were not rewarded since you killed someone with your same IP.");
22 return;
23 }
24
25 if (killer.clanChannel != null && victim.clanChannel != null && killer.clanChannel.getName().equalsIgnoreCase(victim.clanChannel.getName())) {
26 if (!killer.clanChannel.getName().equals("osroyale")) {
27 killer.message("<col=FF0019>You were not rewarded since you killed someone from your clan.");
28 return;
29 }
30 }
31
32 int reward = PlayerRight.getBloodMoney(killer);
33
34 killer.inventory.addOrDrop(new Item(13307, reward));
35 killer.message("<col=295EFF>You were rewarded with " + reward + " blood money for that kill.");
36 killer.killstreak.add();
37
38 for (Item item : killer.inventory) {
39 if (item == null)
40 continue;
41 EmblemData emblem = EmblemData.forId(item.getId());
42 if (emblem == null)
43 continue;
44 if (emblem.getNext() == -1)
45 continue;
46 killer.inventory.replace(item.getId(), emblem.getNext(), true);
47 break;
48 }
49
50 killer.forClan(channel -> {
51 channel.activateTask(PLAYER_KILLING, killer.getName());
52 channel.activateAchievement(ClanAchievement.PLAYER_KILLER_I);
53 channel.activateAchievement(ClanAchievement.PLAYER_KILLER_II);
54 channel.activateAchievement(ClanAchievement.PLAYER_KILLER_III);
55 });
56
59 add(killer, victim.lastHost);
60 }
61
62 public static void add(Player player, String host) {
63 if (host == null || host.isEmpty()) {
64 return;
65 }
66 if (player.lastKilled.contains(host)) {
67 return;
68 }
69 if (player.lastKilled.size() >= 2) {
70 player.lastKilled.removeFirst();
71 }
72 player.lastKilled.add(host);
73 }
74
75 public static boolean remove(Player player, String host) {
76 return player.lastKilled.remove(host);
77 }
78
79 public static boolean contains(Player player, String host) {
80 return player.lastKilled != null && player.lastKilled.contains(host);
81 }
82}
Handles spawning, rewarding and picking up of pets.
Definition Pets.java:27
static void onReward(Player player, int item, int chance)
Handles calculating the chance of a player receiving a skilling pet.
Definition Pets.java:33
Handles writing on an itemcontainer.
static void write(InterfaceWriter writer)
Class handles writing on the quest tab itemcontainer.
This class represents a character controlled by a player.
Definition Player.java:125
void forClan(Consumer< ClanChannel > action)
Definition Player.java:568
String getName()
Gets the name of this entity.
Definition Player.java:774
static boolean contains(Player player, String host)
static void add(Player player, String host)
static void handle(Player killer, Player victim)
The container class that represents an item that can be interacted with.
Definition Item.java:21
final int getId()
Gets the identification of this item.
Definition Item.java:324
final boolean replace(int oldId, int newId, int index, boolean refresh)
Replaces the first occurrence of the Item having the identifier oldId with newId.
void addOrDrop(List< Item > items)
Attempts to deposit an item to the players inventory, if there is no space it'll bank the item instea...
Created by Daniel on 2018-02-06.
static EmblemData forId(int id)
Holds the data for pets.
Definition PetData.java:14