48public final class PlayerDeath
extends MobDeath<Player> {
49 private boolean safe =
false;
52 private static final String[] DEATH_MESSAGES = {
53 "You have defeated $VICTIM.",
54 "With a crushing blow, you defeat $VICTIM.",
55 "It's a humiliating defeat for $VICTIM.",
56 "$VICTIM didn't stand a chance against you.",
57 "You have defeated $VICTIM.",
58 "It's all over for $VICTIM.",
59 "$VICTIM regrets the day they met you in combat.",
60 "$VICTIM falls before your might.",
61 "Can anyone defeat you? Certainly not $VICTIM.",
62 "You were clearly a better fighter than $VICTIM."
80 Mob killer =
mob.getCombat().getDamageCache().calculateProperKiller().orElse(
null);
82 if (
mob.inActivity()) {
94 calculateDropItems(
mob, killer,
false);
96 calculateDropItems(
mob, killer,
true);
97 mob.message(
"You have lost your items. Speak to Lord Marshal Brogan at home to claim them!");
101 if(
mob.playTime < 6000) {
102 System.out.println(
"Safe death");
104 mob.message(
"Your death is safe because you have less than 1 hour of playtime.");
125 calculateDropItems(
mob, killer,
false);
128 if (killer ==
null || !killer.
isPlayer())
131 Player playerKiller = killer.getPlayer();
134 playerKiller.message(
"<col=295EFF>You were rewarded with 100 blood money for that bot kill.");
135 playerKiller.inventory.
addOrDrop(
new Item(13307, 100));
147 playerKiller.message(
"<col=FF0019>You have recently killed " +
mob.getName() +
" and were not rewarded. You must kill 2 other players to reset this!");
161 mob.playerAssistant.restore();
168 if (
mob.inActivity()) {
173 ImbuedHeartPlugin.resetCooldown(
mob);
175 mob.hasPvPTimer =
false;
180 mob.equipment.updateAnimation();
181 mob.equipment.refresh();
189 if (killer !=
null && killer.
isPlayer() && !
mob.equals(killer)) {
190 mob.killstreak.end(killer.getPlayer());
195 mob.send(
new SendMessage(
"You have lost your hardcore iron man status since you died!"));
196 World.
sendMessage(
"<icon=1> <col=FF0000>Tarnish: <col=" +
mob.right.getColor() +
">" +
mob.getName() +
"</col>'s hardcore iron man account was lost!");
200 if (
mob.presetManager.deathOpen) {
204 if (!
mob.lostItems.isEmpty()) {
205 mob.dialogueFactory.sendStatement(
"There are lost items waiting for you!",
"Speak to Lord Marshal Brogan at home to claim them!").execute();
210 private void calculateDropItems(
Player character,
Mob killer,
boolean purchase) {
211 Player theKiller = killer ==
null || killer.
isNpc() ? character : killer.getPlayer();
213 if (character.right.equals(
PlayerRight.ULTIMATE_IRONMAN)) {
214 List<Item> items =
new LinkedList<>();
215 character.equipment.
forEach(items::add);
216 character.inventory.
forEach(items::add);
217 character.lootingBag.
forEach(items::add);
218 character.equipment.
clear();
219 character.inventory.
clear();
220 character.lootingBag.
clear();
221 items.forEach(item -> {
222 if (!item.isTradeable()) {
223 if (!character.lostUntradeables.deposit(item)) {
227 GroundItem.create(theKiller, item, character.
getPosition());
233 LinkedList<Item> toDrop =
new LinkedList<>();
234 List<Item> keep =
new LinkedList<>();
235 List<Item> items =
new LinkedList<>();
236 character.equipment.
forEach(items::add);
237 Item[] lootingBag = character.lootingBag.getDeathItems();
238 character.inventory.
forEach(item -> {
239 if (!LootingBagPlugin.isLootingBag(item)) {
243 character.equipment.
clear();
244 character.inventory.
clear();
246 if (lootingBag !=
null) {
247 items.addAll(Arrays.asList(lootingBag));
248 character.lootingBag.
clear();
251 toDrop.addAll(items);
253 toDrop.sort((first, second) -> second.getValue() - first.getValue());
255 if (!character.skulling.isSkulled()) {
256 keep.add(toDrop.pollFirst());
257 keep.add(toDrop.pollFirst());
258 keep.add(toDrop.pollFirst());
261 if (character.prayer.
isActive(Prayer.PROTECT_ITEM)) {
262 keep.add(toDrop.pollFirst());
265 keep.forEach(item -> {
270 character.inventory.
add(
new Item(item.getId()));
271 if (item.isStackable() && item.getAmount() > 1) {
272 toDrop.add(item.createAndDecrement(1));
276 if (theKiller.isBot) {
277 toDrop.forEach(item -> {
278 if (character.runecraftPouch.
death(item))
281 if (character.runePouch.death(item))
284 if (!item.isTradeable()) {
285 if (!character.lostUntradeables.deposit(item)) {
286 GroundItem.create(character, item);
291 if (theKiller.isBot && item.getValue() >= 50_000) {
295 BotUtility.logLoot(item);
298 GroundItem drop = GroundItem.create(theKiller,
new Item(526), character.
getPosition());
299 if (!theKiller.equals(character) && PlayerRight.isIronman(theKiller)) {
300 drop.canIronMenPickThisItemUp =
false;
305 toDrop.forEach(item -> {
306 if (character.runecraftPouch.
death(item))
309 if (character.runePouch.death(item))
313 character.lostItems.add(item);
317 if (!item.isTradeable()) {
318 if (!character.lostUntradeables.deposit(item)) {
319 GroundItem.create(character, item);
324 if (theKiller.isBot && item.getValue() >= 50_000) {
328 switch(item.getId()) {
329 case CrawsBow.CRAWS_CHARGED_ID -> {
330 item.setId(CrawsBow.CRAWS_UNCHARGED_ID);
331 GroundItem drop = GroundItem.create(theKiller,
new Item(CrawsBow.ETHER_ID, 1000 + character.crawsBowCharges), character.
getPosition());
332 if (!theKiller.equals(character) && PlayerRight.isIronman(theKiller)) {
333 drop.canIronMenPickThisItemUp =
false;
335 character.crawsBowCharges = 0;
337 case ViggorasChainmace.VIGGORAS_CHAINMACE_CHARGED_ID -> {
338 item.setId(ViggorasChainmace.VIGGORAS_CHAINMACE_UNCHARGED_ID);
339 GroundItem drop = GroundItem.create(theKiller,
new Item(CrawsBow.ETHER_ID, 1000 + character.viggorasChainmaceCharges), character.
getPosition());
340 if (!theKiller.equals(character) && PlayerRight.isIronman(theKiller)) {
341 drop.canIronMenPickThisItemUp =
false;
343 character.viggorasChainmaceCharges = 0;
345 case ThammaronsSceptre.THAMMARONS_SCEPTRE_CHARGED_ID -> {
346 item.setId(ViggorasChainmace.VIGGORAS_CHAINMACE_UNCHARGED_ID);
347 GroundItem drop = GroundItem.create(theKiller,
new Item(CrawsBow.ETHER_ID, 1000 + character.thammoranSceptreCharges), character.
getPosition());
348 if (!theKiller.equals(character) && PlayerRight.isIronman(theKiller)) {
349 drop.canIronMenPickThisItemUp =
false;
351 character.thammoranSceptreCharges = 0;
355 GroundItem drop = GroundItem.create(theKiller, item, character.
getPosition());
356 if (!theKiller.equals(character) && PlayerRight.isIronman(theKiller)) {
357 drop.canIronMenPickThisItemUp =
false;
361 GroundItem drop = GroundItem.create(theKiller,
new Item(526), character.
getPosition());
362 if (!theKiller.equals(character) && PlayerRight.isIronman(theKiller)) {
363 drop.canIronMenPickThisItemUp =
false;
static void activate(Player player, AchievementKey achievement)
static void onDeath(Player player, boolean forceRemove)
static boolean inGameArea(Player player)
static boolean isActivePlayer(Player player)
static void onDeath(Player player)