RuneHive-Game
Loading...
Searching...
No Matches
Player.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.mob.player;
2
3import com.runehive.Config;
4import com.runehive.content.ActivityLog;
5import com.runehive.content.ActivityLogger;
6import com.runehive.content.achievement.AchievementKey;
7import com.runehive.content.activity.Activity;
8import com.runehive.content.activity.impl.barrows.BrotherData;
9import com.runehive.content.activity.record.PlayerRecord;
10import com.runehive.content.bags.impl.CoalBag;
11import com.runehive.content.bags.impl.GemBag;
12import com.runehive.content.clanchannel.channel.ClanChannel;
13import com.runehive.content.clanchannel.channel.ClanChannelHandler;
14import com.runehive.content.clanchannel.content.ClanViewer;
15import com.runehive.content.collectionlog.CollectionLog;
16import com.runehive.content.collectionlog.CollectionLogData;
17import com.runehive.content.collectionlog.CollectionLogPage;
18import com.runehive.content.collectionlog.CollectionLogSaving;
19import com.runehive.content.combat.Killstreak;
20import com.runehive.content.combat.Skulling;
21import com.runehive.content.dailyeffect.DailyEffect;
22import com.runehive.content.dailyeffect.impl.DailySlayerTaskSkip;
23import com.runehive.content.dailyeffect.impl.DailySlayerTaskTeleport;
24import com.runehive.content.dailyeffect.impl.DailySpellBookSwap;
25import com.runehive.content.dialogue.ChatBoxItemDialogue;
26import com.runehive.content.dialogue.Dialogue;
27import com.runehive.content.dialogue.DialogueFactory;
28import com.runehive.content.dialogue.OptionDialogue;
29import com.runehive.content.donators.Donation;
30import com.runehive.content.emote.EmoteUnlockable;
31import com.runehive.content.event.EventDispatcher;
32import com.runehive.content.event.impl.LogInEvent;
33import com.runehive.content.gambling.GambleManager;
34import com.runehive.content.lms.LMSGame;
35import com.runehive.content.lms.lobby.LMSLobby;
36import com.runehive.content.lms.lobby.LMSLobbyEvent;
37import com.runehive.content.mysterybox.MysteryBoxManager;
38import com.runehive.content.overrides.Overrides;
39import com.runehive.content.pet.PetData;
40import com.runehive.content.pet.Pets;
41import com.runehive.content.preset.PresetManager;
42import com.runehive.content.prestige.Prestige;
43import com.runehive.content.puzzle.PuzzleDisplay;
44import com.runehive.content.skill.impl.construction.House;
45import com.runehive.content.skill.impl.farming.Farming;
46import com.runehive.content.skill.impl.hunter.birdhouse.PlayerBirdHouseData;
47import com.runehive.content.skill.impl.hunter.trap.TrapManager;
48import com.runehive.content.skill.impl.magic.RunePouch;
49import com.runehive.content.skill.impl.magic.Spellbook;
50import com.runehive.content.skill.impl.magic.spell.SpellCasting;
51import com.runehive.content.skill.impl.runecrafting.RunecraftPouch;
52import com.runehive.content.skill.impl.slayer.Slayer;
53import com.runehive.content.store.impl.PersonalStore;
54import com.runehive.content.teleport.Teleport;
55import com.runehive.content.tittle.PlayerTitle;
56import com.runehive.content.tradingpost.TradingPost;
57import com.runehive.game.event.impl.MovementEvent;
58import com.runehive.game.plugin.PluginManager;
59import com.runehive.game.service.Highscores;
60import com.runehive.game.task.impl.PvPTimerTask;
61import com.runehive.game.task.impl.TeleblockTask;
62import com.runehive.game.world.World;
63import com.runehive.game.world.entity.EntityType;
64import com.runehive.game.world.entity.combat.Combat;
65import com.runehive.game.world.entity.combat.CombatConstants;
66import com.runehive.game.world.entity.combat.attack.FightType;
67import com.runehive.game.world.entity.combat.effect.AntifireDetails;
68import com.runehive.game.world.entity.combat.magic.CombatSpell;
69import com.runehive.game.world.entity.combat.ranged.RangedAmmunition;
70import com.runehive.game.world.entity.combat.ranged.RangedWeaponDefinition;
71import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
72import com.runehive.game.world.entity.combat.strategy.player.special.CombatSpecial;
73import com.runehive.game.world.entity.combat.weapon.WeaponInterface;
74import com.runehive.game.world.entity.mob.Mob;
75import com.runehive.game.world.entity.mob.UpdateFlag;
76import com.runehive.game.world.entity.mob.Viewport;
77import com.runehive.game.world.entity.mob.movement.waypoint.PickupWaypoint;
78import com.runehive.game.world.entity.mob.movement.waypoint.Waypoint;
79import com.runehive.game.world.entity.mob.npc.Npc;
80import com.runehive.game.world.entity.mob.player.appearance.Appearance;
81import com.runehive.game.world.entity.mob.player.exchange.ExchangeSessionManager;
82import com.runehive.game.world.entity.mob.player.relations.ChatMessage;
83import com.runehive.game.world.entity.mob.player.relations.PlayerRelation;
84import com.runehive.game.world.entity.mob.player.requests.PlayerPunishment;
85import com.runehive.game.world.entity.mob.player.requests.RequestManager;
86import com.runehive.game.world.entity.mob.prayer.Prayer;
87import com.runehive.game.world.entity.mob.prayer.PrayerBook;
88import com.runehive.game.world.items.Item;
89import com.runehive.game.world.items.containers.bank.Bank;
90import com.runehive.game.world.items.containers.bank.BankPin;
91import com.runehive.game.world.items.containers.bank.BankVault;
92import com.runehive.game.world.items.containers.bank.DonatorDeposit;
93import com.runehive.game.world.items.containers.equipment.Equipment;
94import com.runehive.game.world.items.containers.impl.LootingBag;
95import com.runehive.game.world.items.containers.impl.LostUntradeables;
96import com.runehive.game.world.items.containers.inventory.Inventory;
97import com.runehive.game.world.items.containers.pricechecker.PriceChecker;
98import com.runehive.game.world.object.CustomGameObject;
99import com.runehive.game.world.object.ObjectDirection;
100import com.runehive.game.world.object.ObjectType;
101import com.runehive.game.world.position.Area;
102import com.runehive.game.world.position.Boundary;
103import com.runehive.game.world.position.Position;
104import com.runehive.game.world.region.Region;
105import com.runehive.net.packet.OutgoingPacket;
106import com.runehive.net.packet.out.*;
107import com.runehive.net.session.GameSession;
108import com.runehive.util.*;
109import org.apache.logging.log4j.LogManager;
110import org.apache.logging.log4j.Logger;
111import org.jire.runehiveps.event.Events;
112
113import java.util.*;
114import java.util.concurrent.TimeUnit;
115import java.util.concurrent.atomic.AtomicBoolean;
116import java.util.concurrent.atomic.AtomicInteger;
117import java.util.function.Consumer;
118
119/**
120 * This class represents a character controlled by a player.
121 *
122 * @author Daniel
123 * @author Michael | Chex
124 */
125public class Player extends Mob {
126
127 private final Events events = new Events();
128
129 public List<PlayerBirdHouseData> birdHouseData = new ArrayList<>();
131 public int menuOpened, optionOpened = -1;
132
134 public Map<String, Position> waypoints = new HashMap<>();
135 public Teleport lastTeleport = null;
137 return gamblingManager;
138 }
139
140 private long lastModification;
141
143 this.lastModification = lastModification;
144 }
145
146 public long getLastModification() {
147 return lastModification;
148 }
149
150 private boolean gambleLocked;
151
152 public void setGambleLock(boolean gambleLocked) {
153 this.gambleLocked = gambleLocked;
154 }
155
156 public boolean isGambleLocked() {
157 return gambleLocked;
158 }
159
160 /**
161 * LMS Variables
162 */
163 public int lastFogSent;
164 public transient long lmsImmunity;
165 public long lastLMSRopeCross;
166
167 /** Dialogue camera system */
169 = com.runehive.game.world.entity.mob.player.camera.DialogueCameraDirector.Mode.OFF;
171 /** While >0, camera turns use slightly faster "swap" speeds for a smoother P↔NPC flip. */
172 public transient int dialogueCamSwapBoostTicks = 0;
173 /** Delay ticks before camera activates (prevents coordinate misalignment at dialogue start). */
174 public transient int dialogueCamDelayTicks = 0;
175
176 /** Client's current scene base, in 8x8 chunks (set when SendMapRegion is sent). */
177 private transient int sceneBaseChunkX;
178 private transient int sceneBaseChunkY;
179 public List<Integer> unlockedLMSItems = new ArrayList<>();
180 public int lmsKills;
181 public int lmsDeaths;
182
183 public int answeredTrivias;
184 public int lmsPoints;
185 public int lmsTotalKills;
186 public int lmsTotalDeaths;
187 public int lmsWins;
188
189 public GemBag gemBag = new GemBag();
190
191 public CoalBag coalBag = new CoalBag();
192
195
197
199 this.collectionLog = collectionLog;
200 }
201
202 public HashMap<WeaponInterface, FightType> fightStyles = new HashMap<>();
203
205 return this.collectionLog;
206 }
207
208 private static final Logger logger = LogManager.getLogger(Player.class);
209 private int memberId = -1;
210 public final Viewport viewport = new Viewport(this);
211 public boolean debug;
212 public Npc pet;
221 private Optional<ChatMessage> chatMessage = Optional.empty();
226 public HashSet<Prayer> unlockedPrayers = new HashSet<>();
232 public Optional<Player> managing;
233 public boolean completedMageArena;
234 public boolean pvpInstance;
235 public boolean hasPvPTimer;
237 public Optional<Dialogue> dialogue = Optional.empty();
238 public Optional<OptionDialogue> optionDialogue = Optional.empty();
239 public Optional<Consumer<String>> enterInputListener = Optional.empty();
240 public boolean[] barrowKills = new boolean[BrotherData.values().length];
241 public final PlayerRelation relations = new PlayerRelation(this);
242 public final Donation donation = new Donation(this);
244 public LinkedList<Item> lostItems = new LinkedList<>();
247 public int sequence;
248 public int playTime;
249 public int kill;
250 public int death;
251 public int shop;
252 public int headIcon;
253 public int valueIcon = -1;
254 public int skillingPoints;
255 public int pestPoints;
256 public int votePoints;
257 public int totalVotes;
258 public int[] achievedSkills = new int[7];
259
260 public int mageArenaPoints;
261 public int ringOfRecoil = 40;
262 public int whipCharges = 2500;
263 public int agsCharges = 750;
264 public int wilderness;
265 public int runEnergy;
266 public int energyRate;
267 public int glovesTier;
268 public int royaltyLevel = 1;
269 public int royalty;
270
271 public int smallPouch;
272 public int mediumPouch;
273 public int largePouch;
274 public int giantPouch;
277 public long usernameLong;
278 public boolean idle;
279 public boolean resting;
280 public boolean newPlayer;
281 public boolean needsStarter;
282 public boolean venged;
283 private boolean specialActivated;
284 public boolean warriorGuidTask;
285 public boolean isBot;
286 public int trapsLaid;
287 private String username = "";
288 private String password = "";
289 public String uuid;
290 public String lastHost;
291 public String created = Utility.getDate();
292 public String lastClan = "";
294 public String clan = "";
295 public String clanTag = "";
296 public String clanTagColor = "";
297 public final AtomicBoolean saved = new AtomicBoolean(false);
306 public int cooldown = 7 * 60 * 1000;
307 public long lastUsed = 0;
312 public Set<PetData> petInsurance = new HashSet<>();
313 public Set<PetData> lostPets = new HashSet<>();
314 public final PuzzleDisplay puzzle = new PuzzleDisplay(this);
315 public final ClanViewer clanViewer = new ClanViewer(this);
316 public final PlayerRecord gameRecord = new PlayerRecord(this);
317 public final Farming farming = new Farming(this);
319 public final Map<Integer, PersonalStore> viewing_shops = new HashMap<>();
324 public final Settings settings = new Settings(this);
325 public final Inventory inventory = new Inventory(this);
326 public final Inventory inventory_copy = new Inventory(this);
327 public final Bank bank = new Bank(this);
328 public final BankVault bankVault = new BankVault(this);
329 public final BankPin bankPin = new BankPin(this);
330 public final RunePouch runePouch = new RunePouch(this);
331 public final RunePouch runePouch_copy = new RunePouch(this);
332 public final Killstreak killstreak = new Killstreak(this);
333 public final LootingBag lootingBag = new LootingBag(this);
335 public final Equipment equipment = new Equipment(this);
336 public final Equipment equipment_copy = new Equipment(this);
337 public final PresetManager presetManager = new PresetManager(this);
338 public final Prestige prestige = new Prestige(this);
339 public final PriceChecker priceChecker = new PriceChecker(this);
342 public final House house = new House(this);
343 public Slayer slayer = new Slayer(this);
344 public Skulling skulling = new Skulling(this);
346 private final Combat<Player> combat = new Combat<>(this);
351 public Deque<String> lastKilled = new ArrayDeque<>(3);
352 public List<EmoteUnlockable> emoteUnlockable = new LinkedList<>();
353 public List<Teleport> favoriteTeleport = new ArrayList<>();
354 public final Set<String> hostList = new HashSet<>();
355 public final TradingPost tradingPost = new TradingPost(this);
356 public final Overrides overrides = new Overrides(this);
357
358
359 public HashMap<ActivityLog, Integer> loggedActivities = new HashMap<ActivityLog, Integer>(ActivityLog.values().length) {
360 {
361 for (final ActivityLog achievement : ActivityLog.values())
362 put(achievement, 0);
363 }
364 };
365
366 public HashMap<AchievementKey, Integer> playerAchievements = new HashMap<AchievementKey, Integer>(AchievementKey.values().length) {
367 {
368 for (final AchievementKey achievement : AchievementKey.values())
369 put(achievement, 0);
370 }
371 };
372
373 public float blowpipeScales;
375
376
377 public int crawsBowCharges;
382
384
388
390 private Optional<GameSession> session = Optional.empty();
392 public long dragonfireUsed;
393
394 public Player(String username) {
395 super(Config.DEFAULT_POSITION, false);
396 this.username = username;
397 this.usernameLong = Utility.nameToLong(username);
398 }
399
402 this.setPosition(position);
403 this.setUsername(username);
404 this.isBot = true;
405 }
406
408 if (!chatMessage.isValid()) {
409 return;
410 }
411 this.chatMessage = Optional.of(chatMessage);
412 this.updateFlags.add(UpdateFlag.CHAT);
413 }
414
415 public void setUsername(String username) {
416 this.username = username;
417 this.usernameLong = Utility.nameToLong(username);
418 }
419
420 public void send(OutgoingPacket encoder) {
421 encoder.execute(this);
422 }
423
424 private void login() {
425 positionChange = true;
426 regionChange = true;
427
428 onStep();
429
430 skills.login();
431
432 mobAnimation.reset();
433
434 inventory.refresh();
435
437 equipment.login();
438
439 settings.login();
440
441 relations.onLogin();
442
444
445 playerAssistant.login();
446
447
448 send(new SendSpecialEnabled(0));
449 send(new SendConfig(301, 0));
450
452 if (isAutocast() && equipment.hasWeapon()) {
453 send(new SendConfig(43, 3));
454 send(new SendConfig(108, 1));
455 } else {
456 setAutocast(null);
457 send(new SendConfig(108, 0));
458 send(new SendString("Spell", 18584));
459 }
460 }
461
462 private void sendInitialPackets() {
463 int players = World.getPlayerCount();
464 send(new SendRunEnergy());
465 send(new SendPlayerDetails());
466 send(new SendCameraReset());
467 send(new SendExpCounter(skills.getExpCounter()));
468 World.sendMessage("<img=15> " +getPlayer().getName()+ " has logged in.");
469 message(true, String.format("Welcome to %s. ", Config.SERVER_NAME));
470 message(true, "We are currently in early access.");
471
473 message("Double experience is currently active!");
474 }
475
476 if (players > GameSaver.MAX_PLAYERS) {
477 GameSaver.MAX_PLAYERS = players;
478 }
479 if (needsStarter) {
480 newPlayer = true;
481 }
482
483 playerAssistant.welcomeScreen();
484 }
485
486 private boolean canLogout() {
487 if (getCombat().inCombat()) {
488 send(new SendMessage("You can not logout whilst in combat!"));
489 return false;
490 }
491
493 final long seconds = TimeUnit.SECONDS.convert(
495 TimeUnit.MILLISECONDS);
496 send(new SendMessage("You must wait " + seconds + " second" + (seconds > 1 ? "s" : "")
497 + " before you can logout as you were recently in combat."));
498 return false;
499 }
500
501 if (!interfaceManager.isMainClear()) {
502 send(new SendMessage("Please close what you are doing before logging out!"));
503 return false;
504 }
505
506 return !Activity.evaluate(this, it -> !it.canLogout(this));
507 }
508
509 public final Set<PlayerOption> contextMenus = new HashSet<>();
510
511 public final void logout() {
512 logout(false);
513 }
514
515 public final void logout(boolean force) {
516 if (!canLogout() && !force) {
517 return;
518 }
519
520 send(new SendLogout());
521 setVisible(false);
522 World.queueLogout(this);
523 }
524
525 public void loadRegion() {
526 for(PlayerBirdHouseData playerBirdHouseData : birdHouseData) {
527
528 if(Utility.goodDistance(playerBirdHouseData.birdhousePosition.getX(), playerBirdHouseData.birdhousePosition.getY(), getPosition().getX(), getPosition().getY(), 60)) {
529 int objectId = playerBirdHouseData.birdhouseData.objectData[playerBirdHouseData.seedAmount >= 10 ? 1 : 0];
530 send(new SendAddObject(new CustomGameObject(objectId, playerBirdHouseData.birdhousePosition, ObjectDirection.valueOf(playerBirdHouseData.rotation).get(), ObjectType.valueOf(playerBirdHouseData.type).get())));
531 }
532 }
533
534 Activity.forActivity(this, minigame -> minigame.onRegionChange(this));
535
537
538 for (Region region : surrounding) {
539 region.sendGroundItems(this);
540 region.sendGameObjects(this);
541
542 //Npc Face
543 for (Npc npc : region.getNpcs(getHeight())) {
544 if (!npc.getCombat().inCombat())
545 npc.face(npc.faceDirection);
546 }
547 }
548
549 farming.regionChange(this);
551
552 if (debug && PlayerRight.isDeveloper(this)) {
553 send(new SendMessage("[REGION] Loaded new region.", MessageColor.DEVELOPER));
554 }
555 }
556
557 public void pickup(Item item, Position position) {
558 Waypoint waypoint = new PickupWaypoint(this, item, position);
559 if (cachedWaypoint == null || (!cachedWaypoint.isRunning() || !waypoint.equals(cachedWaypoint))) {
561 action.clearNonWalkableActions();
562 movement.reset();
563 getCombat().reset();
564 World.schedule(cachedWaypoint = waypoint);
565 }
566 }
567
568 public void forClan(Consumer<ClanChannel> action) {
569 if (clanChannel != null)
570 action.accept(clanChannel);
571 }
572 public void message(String message) {
574 }
575
576 @Override
577 public void register() {
578 if (!isRegistered() && !World.getPlayers().contains(this)) {
579 setRegistered(World.getPlayers().add(this));
581
582 login();
583
584 logger.info("[REGISTERED]: " + Utility.formatName(getName()) + " [" + lastHost + "]");
586 }
587 }
588
589 @Override
590 public void unregister() {
591 if (!isRegistered()) {
592 return;
593 }
594
595 if (!World.getPlayers().contains(this)) {
596 return;
597 }
598 if (LMSGame.isActivePlayer(this))
599 LMSGame.onDeath(this, true);
600 World.sendMessage("<img=15> " +getPlayer().getName()+ " has logged out.");
601 send(new SendLogout());
602 Activity.forActivity(this, minigame -> minigame.onLogout(this));
603 relations.updateLists(false);
605 ClanChannelHandler.disconnect(this, true);
606 interfaceManager.close();
607 new Highscores(this).execute();
608 //HighscoreService.saveHighscores(this);
609 World.cancelTask(this, true);
610 Pets.onLogout(this);
612 World.getPlayers().remove((Player) destroy());
613 getGambling().decline(this);
614 com.runehive.content.ai.LazyAIManager.clearPlayerConsent(getUsername());
615 logger.info(String.format("[UNREGISTERED]: %s [%s]", getName(), lastHost));
616 }
617
618 @Override
619 public void addToRegion(Region region) {
620 region.addPlayer(this);
621 aggressionTimer.reset();
622 }
623
624 @Override
626 region.removePlayer(this);
627 }
628
629 @Override
630 public void sequence() {
631 if (!idle) {
632 playTime++;
633 }
634
635 action.sequence();
636 playerAssistant.sequence();
637 sequence++;
638
639 // Dialogue camera tick
640 com.runehive.game.world.entity.mob.player.camera.DialogueCameraDirector.tick(this);
641
642 if(Area.inLMSLobby(this) || Area.inLMSBuilding(this)) {
643 send(new SendString("Next Game: ", 44654));
644 send(new SendString("" + ((LMSLobbyEvent.lobbyTicks * 600) / 1000), 44655));
645 send(new SendString("" + LMSLobby.currentGameType.getClass().getSimpleName(), 44657));
646 send(new SendString("<col="+(LMSLobby.lobbyMembers.size() >= LMSLobby.requiredPlayers ? "65280" : "ff0000")+">" + LMSLobby.lobbyMembers.size() + "/" + LMSLobby.maxPlayers + "</col>", 44659));
647 }
648 }
649
650 @Override
651 public void onStep() {
653 send(new SendMultiIcon(Area.inMulti(this) ? 1 : -1));
654
655 if (Activity.evaluate(this, activity -> activity.onStep(this))) {
656 return;
657 }
658
659 // Reset the options
661 send(new SendPlayerOption(PlayerOption.ATTACK, false, true));
666
668 //send(new SendPlayerOption(PlayerOption.TRADE_REQUEST, false, true));
670 }
671 else if(LMSGame.inGameArea(this)){
673 if (interfaceManager.getWalkable() != 44660)
674 interfaceManager.openWalkable(44660);
675 }
676 else if(Area.inLMSLobby(this) || Area.inLMSBuilding(this)) {
677 if (interfaceManager.getWalkable() != 44650)
678 interfaceManager.openWalkable(44650);
679 }
680 // pvp instance
681 else if (pvpInstance) {
682 if (hasPvPTimer) {
685 } else if (Area.inPvP(this)) {
686 send(new SendString("<col=E68A00>" + playerAssistant.getCombatRange(), 23327));
689 if (interfaceManager.getWalkable() != 23400) {
690 interfaceManager.openWalkable(23400);
691 }
692 return;
693 } else {
694 if (!hasPvPTimer && getCombat().inCombat()) {
695 World.schedule(new PvPTimerTask(this));
696 } else {
697 send(new SendString("<col=36CF4D>Safe", 23327));
698 send(new SendPlayerOption(PlayerOption.ATTACK, false, true));
700 }
701 }
702 if (interfaceManager.getWalkable() != 23410) {
703 interfaceManager.openWalkable(23410);
704 }
705
706 // wilderness
707 } else if (Area.inWilderness(this)) {
708 int modY = getPosition().getY() > 6400 ? getPosition().getY() - 6400 : getPosition().getY();
709 wilderness = (((modY - 3521) / 8) + 1);
710 send(new SendString("Level " + wilderness, 23327));
713 if (interfaceManager.getWalkable() != 23400)
714 interfaceManager.openWalkable(23400);
715
716 // duel arena lobby
717 } else if (Area.inDuelArenaLobby(this)) {
719 send(new SendPlayerOption(PlayerOption.ATTACK, false, true));
720 if (interfaceManager.getWalkable() != 201)
721 interfaceManager.openWalkable(201);
722 // duel arena
723 } else if (Area.inDuelArena(this) || Area.inDuelObsticleArena(this)) {
726 if (interfaceManager.getWalkable() != 201)
727 interfaceManager.openWalkable(201);
728
729 // event arena
730 /* } else if (Area.inEventArena(this)) {
731 send(new SendPlayerOption(PlayerOption.ATTACK, true));
732 send(new SendPlayerOption(PlayerOption.DUEL_REQUEST, false, true));
733 send(new SendString("Fun PK", 23327));
734 if (interfaceManager.getWalkable() != 23400)
735 interfaceManager.openWalkable(23400);*/
736
737 //
738 } else if (Area.inSuperDonatorZone(this) && (Area.inRegularDonatorZone(this) && !PlayerRight.isDonator(this))) {
740 send(new SendMessage("You're not supposed to be here!"));
741
742 // clear
743 } else if (!inActivity()) {
745 send(new SendPlayerOption(PlayerOption.ATTACK, false, true));
750//
751// if (!interfaceManager.isClear())
752 interfaceManager.close();
753 if (wilderness > 0)
754 wilderness = 0;
755 }
756 }
757
758 @Override
760 return combat;
761 }
762
763 @Override
765 return playerAssistant.getStrategy();
766 }
767
768 @Override
769 public void appendDeath() {
770 World.schedule(new PlayerDeath(this));
771 }
772
773 @Override
774 public String getName() {
776 }
777
778 @Override
780 return EntityType.PLAYER;
781 }
782
783 @Override
784 public boolean isValid() {
785 return (isBot || session != null) && super.isValid();
786 }
787
788 @Override
789 public boolean equals(Object obj) {
790 if (obj == this) {
791 return true;
792 }
793
794 if (obj == null || !(obj instanceof Player)) {
795 return false;
796 }
797
798 Player other = (Player) obj;
799 return Objects.equals(getIndex(), other.getIndex()) && Objects.equals(username, other.username) && Objects.equals(password, other.password) && Objects.equals(isBot, other.isBot);
800 }
801
802 @Override
803 public int hashCode() {
804 return Objects.hash(getIndex(), username);
805 }
806
807 @Override
808 public String toString() {
809 return String.format("Player[index=%d member_id=%d username=%s pos=%s bot=%b]", getIndex(), getMemberId(), getUsername(), getPosition(), isBot);
810 }
811
812 public void message(boolean filtered, String... messages) {
813 for (String message : messages) {
814 send(new SendMessage(message, filtered));
815 }
816 }
817
818 public void message(String... messages) {
819 for (String message : messages) {
821 }
822 }
823
824 public boolean isAutoRetaliate() {
825 return settings.autoRetaliate;
826 }
827
828 public boolean isSpecialActivated() {
829 return specialActivated;
830 }
831
832 public void setSpecialActivated(boolean activated) {
833 this.specialActivated = activated;
834 }
835
836 public void setCombatSpecial(CombatSpecial special) {
837 this.combatSpecial = special;
838 }
839
840 public boolean isSingleCast() {
841 return singleCast != null;
842 }
843
847
849 this.singleCast = singleCast;
850 }
851
852 public boolean isAutocast() {
853 return autocast != null;
854 }
855
857 return autocast;
858 }
859
861 this.autocast = autocast;
862 }
863
867
868 public final AtomicInteger teleblockTimer = new AtomicInteger(0);
869
870 public void teleblock(int time) {
871 if (time <= 0 || (teleblockTimer.get() > 0)) {
872 return;
873 }
874
875 teleblockTimer.set(time);
876 send(new SendMessage("A teleblock spell has been casted on you!"));
877 send(new SendWidget(SendWidget.WidgetType.TELEBLOCK, (int) ((double) teleblockTimer.get() / 1000D * 600D)));
878 World.schedule(new TeleblockTask(this));
879 }
880
881 public boolean isTeleblocked() {
882 return teleblockTimer.get() > 0;
883 }
884
886 return combatSpecial;
887 }
888
890 return weapon;
891 }
892
894 this.weapon = weapon;
895 }
896
897 public Optional<AntifireDetails> getAntifireDetails() {
898 return Optional.ofNullable(antifireDetails);
899 }
900
902 this.antifireDetails = antifireDetails;
903 }
904
906 return poisonImmunity;
907 }
908
910 return venomImmunity;
911 }
912
913 public Optional<ChatMessage> getChatMessage() {
914 return chatMessage;
915 }
916
917 public String getUsername() {
918 return username;
919 }
920
921 public void setMemberId(int memberId) {
922 this.memberId = memberId;
923 }
924
925 public int getMemberId() {
926 return memberId;
927 }
928
929 public Optional<GameSession> getSession() {
930 return session;
931 }
932
934 this.session = Optional.of(session);
935
936 final String host = session.getHost();
937 this.lastHost = host;
938 this.hostList.add(host);
939 }
940
941 public void setPassword(String password) {
942 this.password = password;
943 }
944
945 public String getPassword() {
946 return password;
947 }
948
950 return appearance;
951 }
952
953 public Events getEvents() {
954 return events;
955 }
956
957 // Scene base accessors for camera system
958 public int getSceneBaseChunkX() {
959 return sceneBaseChunkX;
960 }
961
962 public int getSceneBaseChunkY() {
963 return sceneBaseChunkY;
964 }
965
966 public void setSceneBaseChunks(int chunkX, int chunkY) {
967 this.sceneBaseChunkX = chunkX;
968 this.sceneBaseChunkY = chunkY;
969 }
970
971 // World to scene-local helpers for camera packets (in tiles)
972 public int toSceneLocalX(int worldX) {
973 return worldX - (sceneBaseChunkX * 8);
974 }
975
976 public int toSceneLocalY(int worldY) {
977 return worldY - (sceneBaseChunkY * 8);
978 }
979
980 public int toSceneLocalX(Position pos) {
981 return toSceneLocalX(pos.getX());
982 }
983
984 public int toSceneLocalY(Position pos) {
985 return toSceneLocalY(pos.getY());
986 }
987
988}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final Appearance DEFAULT_APPEARANCE
The default appearance of a player.
Definition Config.java:212
static final Position DEFAULT_POSITION
The default, i.e.
Definition Config.java:197
static boolean DOUBLE_EXPERIENCE
Definition Config.java:139
static final double COMBAT_MODIFICATION
The experience modification for combat.
Definition Config.java:244
static final String SERVER_NAME
The name of the server.
Definition Config.java:111
Handles displaying player's activity log.
A Activity object constructs an in-game activity and sequences it through the start() and finish() me...
Definition Activity.java:31
static boolean evaluate(Mob mob, Predicate< Activity > predicate)
Definition Activity.java:74
static void forActivity(Mob mob, Consumer< Activity > consumer)
Definition Activity.java:78
static boolean disconnect(Player player, boolean logout)
Handles player joining a clan channel.
Handles the skulling class.
Definition Skulling.java:18
Represents a factory class that contains important functions for building dialogues.
This class handles everything related to donators.
Definition Donation.java:19
static boolean execute(Player player, InteractionEvent event)
void decline(Player player)
Handles declining the gamble.
static boolean isActivePlayer(Player player)
Checks if a player is a active player within the LMS game.
Definition LMSGame.java:151
static boolean inGameArea(Player player)
Handles checking if the player is in the LMS game area.
Definition LMSGame.java:142
static void onDeath(Player player, boolean forceRemove)
Handles when a player within the LMS game dies.
Definition LMSGame.java:634
static int maxPlayers
The max amount of players allowed in a single game.
Definition LMSLobby.java:38
static List< Player > lobbyMembers
A list with all the players in the lobby.
Definition LMSLobby.java:28
static LMSLoadout currentGameType
The current game type.
Definition LMSLobby.java:43
static int requiredPlayers
The amount of players in the lobby required.
Definition LMSLobby.java:33
Handles spawning, rewarding and picking up of pets.
Definition Pets.java:27
static void onLogout(Player player)
Handles what happens to a pet when a player logouts.
Definition Pets.java:217
Handles managing the preset system.
Handles the prestige class.
Definition Prestige.java:24
Handles a player casting a non-combat spell (mostly on items).
static PlayerTitle empty()
Creates an empty player title.
boolean publish(Player player, Event event)
This class handles how plugins are loaded/unloaded and accessed.
This randomevent handles the teleblock counter.
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
static int getPlayerCount()
Gets the amount of valid players online.
Definition World.java:490
static void cancelTask(Object attachment)
Definition World.java:536
static void sendMessage(String... messages)
Sends a global message.
Definition World.java:396
static MobList< Player > getPlayers()
Definition World.java:544
static RegionManager getRegions()
Definition World.java:552
static void queueLogout(Player player)
Handles queueing the player logouts.
Definition World.java:138
void setVisible(boolean visible)
Definition Entity.java:102
void setRegistered(boolean registered)
Definition Entity.java:98
Entity destroy()
Destroys this entity.
Definition Entity.java:143
void setPosition(Position position)
Definition Entity.java:106
static final int COMBAT_LOGOUT_COOLDOWN
The amount of time it takes in milliseconds it takes to logout.
final EnumSet< UpdateFlag > updateFlags
Definition Mob.java:94
final void resetWaypoint()
Resets the waypoint.
Definition Mob.java:249
Mob(Position position)
Constructs a new Mob.
Definition Mob.java:114
void move(Position position)
Moves the mob to a set position.
Definition Mob.java:340
Represents a viewport in which a Player can see.
Definition Viewport.java:15
Represents a non-player character in the in-game world.
Definition Npc.java:29
Contains information about the state of interfaces enter in the client.
Method handles small methods for players that do not have any parent class.
HashMap< WeaponInterface, FightType > fightStyles
Definition Player.java:202
void message(boolean filtered, String... messages)
Definition Player.java:812
void forClan(Consumer< ClanChannel > action)
Definition Player.java:568
transient int dialogueCamDelayTicks
Delay ticks before camera activates (prevents coordinate misalignment at dialogue start).
Definition Player.java:174
void setCombatSpecial(CombatSpecial special)
Definition Player.java:836
CombatStrategy< Player > getStrategy()
The combat strategy of the mob.
Definition Player.java:764
void unregister()
Unregisters an entity from the World.
Definition Player.java:590
String getName()
Gets the name of this entity.
Definition Player.java:774
transient int dialogueCamSwapBoostTicks
While >0, camera turns use slightly faster "swap" speeds for a smoother P↔NPC flip.
Definition Player.java:172
void appendDeath()
Handles the mob death.
Definition Player.java:769
void setAntifireDetail(AntifireDetails antifireDetails)
Definition Player.java:901
boolean isAutoRetaliate()
State of the mob's auto retaliate.
Definition Player.java:824
transient com.runehive.game.world.entity.mob.player.camera.DialogueCameraDirector.Mode dialogueCamMode
Dialogue camera system.
Definition Player.java:169
transient com.runehive.game.world.entity.mob.npc.Npc dialogueCamNpc
Definition Player.java:170
void removeFromRegion(Region region)
Removes this entity from the specified region.
Definition Player.java:625
Player(String username, Position position)
Definition Player.java:400
void pickup(Item item, Position position)
Definition Player.java:557
void setSceneBaseChunks(int chunkX, int chunkY)
Definition Player.java:966
HashMap< AchievementKey, Integer > playerAchievements
Definition Player.java:366
void setSingleCast(CombatSpell singleCast)
Definition Player.java:848
List< PlayerBirdHouseData > birdHouseData
Definition Player.java:129
Optional< OptionDialogue > optionDialogue
Definition Player.java:238
HashMap< ActivityLog, Integer > loggedActivities
Definition Player.java:359
transient int sceneBaseChunkX
Client's current scene base, in 8x8 chunks (set when SendMapRegion is sent).
Definition Player.java:177
void sequence()
The method which is invoked every tick.
Definition Player.java:630
void setCollectionLog(CollectionLog collectionLog)
Definition Player.java:198
Optional< AntifireDetails > getAntifireDetails()
Definition Player.java:897
void setWeapon(WeaponInterface weapon)
Definition Player.java:893
void addToRegion(Region region)
Adds this entity to the specified region.
Definition Player.java:619
EntityType getType()
Gets the EntityType.
Definition Player.java:779
Combat< Player > getCombat()
The combat of the mob.
Definition Player.java:759
void register()
Registers an entity to the World.
Definition Player.java:577
Optional< Consumer< String > > enterInputListener
Definition Player.java:239
final ExchangeSessionManager exchangeSession
Definition Player.java:318
final Map< Integer, PersonalStore > viewing_shops
Definition Player.java:319
void setLastModification(long lastModification)
Definition Player.java:142
boolean isValid()
Validates this npc based on its current region and registered state.
Definition Player.java:784
Represents a chat message that can be displayed over an entities head.
The container class that represents an item that can be interacted with.
Definition Item.java:21
The container that manages the equipment for a player.
An ItemContainer implementation that manages the inventory for a Player.
Represents a static game object loaded from the map fs.
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inLMSBuilding(Interactable entity)
Definition Area.java:223
static boolean inMulti(Entity entity)
Definition Area.java:263
static boolean inRegularDonatorZone(Interactable entity)
Definition Area.java:151
static boolean inDuelArenaLobby(Entity entity)
Definition Area.java:293
static boolean inDuelArena(Interactable entity)
Definition Area.java:311
static boolean inWilderness(Position position)
Definition Area.java:272
static boolean inLMSLobby(Interactable entity)
Definition Area.java:214
static boolean inDuelObsticleArena(Interactable entity)
Definition Area.java:302
static boolean inSuperDonatorZone(Interactable entity)
Definition Area.java:148
static boolean inPvP(Interactable entity)
Definition Area.java:355
Created by Daniel on 2017-11-24.
Definition Boundary.java:12
static boolean isIn(Mob mob, Boundary... boundaries)
Definition Boundary.java:49
Represents a single tile on the game world.
Definition Position.java:14
int getY()
Gets the absolute y coordinate.
Definition Position.java:46
int getX()
Gets the absolute x coordinate.
Definition Position.java:41
Represents a single region.
Definition Region.java:21
Region[] getSurroundingRegions(Position position)
Gets the regions surrounding a position.
The OutgoingPacket resets the camera position for Player.
The OutgoingPacket responsible for changing settings on a client.
Sends experience to the client's experience counter.
The OutgoingPacket that sends a message to a Players chatbox in the client.
Shows a player options such as right clicking a player.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Represents a Session when a Player has been authenticated and active in the game world.
Created by Daniel on 2017-11-05.
The container class that contains functions to simplify the modification of a number.
static Stopwatch start()
Handles miscellaneous methods.
Definition Utility.java:27
static String formatName(final String input)
Definition Utility.java:645
static long nameToLong(String text)
Converts the first 12 characters in a string of text to a hash.
Definition Utility.java:185
static final boolean goodDistance(int objectX, int objectY, int playerX, int playerY, int distance)
Definition Utility.java:903
static String getDate()
Gets the date of server.
Definition Utility.java:126
The activity log class.
The in-game spellbooks for players.
Definition Spellbook.java:8
The enumerated type whose elements represent the combat special attacks.
The enumerated type whose elements represent the weapon interfaces.
Represents the options for right-clicking players.
DUEL_REQUEST
The option for challenging another player to a duel.
ATTACK
The option for attacking another player.
FOLLOW
The option for following another player.
VIEW_PROFILE
The option for moderators and staff which brings up the report abuse option.
TRADE_REQUEST
The option for trading another player.
static boolean isDonator(Player player)
Checks if the player has donator status.
static boolean isDeveloper(Player player)
Checks if the player has developer status.
The enumerated type whose elements represent the directions for objects.
static Optional< ObjectDirection > valueOf(final int id)
Returns a ObjectDirection wrapped in an Optional for the specified id.
The enumerated type whose elements represent all of the object types.
static Optional< ObjectType > valueOf(final int id)
Returns a ObjectType wrapped in an Optional for the specified id.
Holds an enum of colors for ease.