Guest User

Untitled

a guest
Aug 17th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 113.39 KB | None | 0 0
  1. package com.rs2.model.players;
  2.  
  3. import com.rs2.Constants;
  4. import com.rs2.GlobalVariables;
  5. import com.rs2.HostGateway;
  6. import com.rs2.Server;
  7. import com.rs2.cache.interfaces.RSInterface;
  8. import com.rs2.model.Entity;
  9. import com.rs2.model.Graphic;
  10. import com.rs2.model.Position;
  11. import com.rs2.model.World;
  12. import com.rs2.model.content.*;
  13. import com.rs2.model.content.combat.AttackType;
  14. import com.rs2.model.content.combat.CombatCycleEvent;
  15. import com.rs2.model.content.combat.CombatManager;
  16. import com.rs2.model.content.combat.SkullRecord;
  17. import com.rs2.model.content.combat.effect.impl.PoisonEffect;
  18. import com.rs2.model.content.combat.hit.Hit;
  19. import com.rs2.model.content.combat.hit.HitDef;
  20. import com.rs2.model.content.combat.hit.HitType;
  21. import com.rs2.model.content.combat.special.SpecialType;
  22. import com.rs2.model.content.combat.util.WeaponDegrading;
  23. import com.rs2.model.content.combat.weapon.Weapon;
  24. import com.rs2.model.content.consumables.Food;
  25. import com.rs2.model.content.consumables.Potion;
  26. import com.rs2.model.content.dialogue.DialogueManager;
  27. import com.rs2.model.content.minigames.duelarena.DuelAreas;
  28. import com.rs2.model.content.minigames.duelarena.DuelInterfaces;
  29. import com.rs2.model.content.minigames.duelarena.DuelMainData;
  30. import com.rs2.model.content.minigames.duelarena.PlayerInteraction;
  31. import com.rs2.model.content.minigames.ffa.GlobalGameHandling;
  32. import com.rs2.model.content.minigames.fightcaves.WavesHandling;
  33. import com.rs2.model.content.minigames.magetrainingarena.AlchemistPlayground;
  34. import com.rs2.model.content.minigames.magetrainingarena.CreatureGraveyard;
  35. import com.rs2.model.content.minigames.magetrainingarena.EnchantingChamber;
  36. import com.rs2.model.content.minigames.magetrainingarena.TelekineticTheatre;
  37. import com.rs2.model.content.randomevents.InterfaceClicking.impl.InterfaceClickHandler;
  38. import com.rs2.model.content.randomevents.RandomEvent;
  39. import com.rs2.model.content.skills.ItemOnItemHandling;
  40. import com.rs2.model.content.skills.Skill;
  41. import com.rs2.model.content.skills.SkillResources;
  42. import com.rs2.model.content.skills.cooking.BrewData;
  43. import com.rs2.model.content.skills.cooking.Cooking;
  44. import com.rs2.model.content.skills.cooking.Wine;
  45. import com.rs2.model.content.skills.farming.*;
  46. import com.rs2.model.content.skills.firemaking.Firemaking;
  47. import com.rs2.model.content.skills.fishing.Fishing;
  48. import com.rs2.model.content.skills.magic.Spell;
  49. import com.rs2.model.content.skills.magic.SpellBook;
  50. import com.rs2.model.content.skills.magic.Teleportation;
  51. import com.rs2.model.content.skills.mining.MineOre;
  52. import com.rs2.model.content.skills.prayer.BoneBurying;
  53. import com.rs2.model.content.skills.prayer.Prayer;
  54. import com.rs2.model.content.skills.runecrafting.Tiaras;
  55. import com.rs2.model.content.skills.slayer.Slayer;
  56. import com.rs2.model.content.treasuretrails.ClueScroll;
  57. import com.rs2.model.content.treasuretrails.CoordinateScrolls.CoordinateData;
  58. import com.rs2.model.content.tutorialisland.NewComersSide;
  59. import com.rs2.model.content.tutorialisland.StagesLoader;
  60. import com.rs2.model.ground.GroundItem;
  61. import com.rs2.model.ground.GroundItemManager;
  62. import com.rs2.model.npcs.Npc;
  63. import com.rs2.model.npcs.NpcDefinition;
  64. import com.rs2.model.npcs.NpcLoader;
  65. import com.rs2.model.npcs.drop.NpcDropController;
  66. import com.rs2.model.npcs.drop.NpcDropItem;
  67. import com.rs2.model.objects.GameObject;
  68. import com.rs2.model.players.container.Container;
  69. import com.rs2.model.players.container.Container.Type;
  70. import com.rs2.model.players.container.equipment.Equipment;
  71. import com.rs2.model.players.container.inventory.Inventory;
  72. import com.rs2.model.players.item.Item;
  73. import com.rs2.model.players.item.ItemDefinition;
  74. import com.rs2.model.players.item.ItemManager;
  75. import com.rs2.model.region.music.MusicHandler;
  76. import com.rs2.model.tick.CycleEvent;
  77. import com.rs2.model.tick.CycleEventContainer;
  78. import com.rs2.model.tick.CycleEventHandler;
  79. import com.rs2.model.tick.Tick;
  80. import com.rs2.model.transport.MagicCarpet;
  81. import com.rs2.model.transport.Sailing;
  82. import com.rs2.net.*;
  83. import com.rs2.net.packet.Packet;
  84. import com.rs2.net.packet.PacketManager;
  85. import com.rs2.util.*;
  86. import com.rs2.util.plugin.LocalPlugin;
  87. import com.rs2.util.plugin.PluginManager;
  88. import mysql.impl.Hiscores;
  89.  
  90. import java.io.*;
  91. import java.nio.ByteBuffer;
  92. import java.nio.channels.SelectionKey;
  93. import java.nio.channels.SocketChannel;
  94. import java.util.*;
  95.  
  96. /**
  97. * Represents a logged-in player.
  98. *
  99. * @author blakeman8192
  100. * @author BFMV
  101. */
  102. public class Player extends Entity {
  103.  
  104. private int combatLevel;
  105. private final transient SelectionKey key;
  106. private final transient ByteBuffer inData;
  107. private final transient ByteBuffer outData;
  108. private int uid;
  109. private transient SocketChannel socketChannel;
  110. private transient LoginStages loginStage = LoginStages.CONNECTED;
  111. private transient ISAACCipher encryptor;
  112. private transient ISAACCipher decryptor;
  113. private int opcode = -1;
  114. private int packetLength = -1;
  115. String username;
  116. String password;
  117. private int macAddress;
  118. private int clientVersion;
  119. private int magicId;
  120. private int lastNpc = -1;
  121. private int inter = -1;
  122.  
  123. /*Daily skilling tasks */
  124. public boolean hasTask;
  125. public boolean taskCompleted;
  126. public int givenTask;
  127. public int taskAmount;
  128.  
  129. public int bonusXpTime;
  130.  
  131. public int activityPoints;
  132. public int votePoints;
  133. public int donationPoints;
  134.  
  135. private final Misc.Stopwatch timeoutStopwatch = new Misc.Stopwatch();
  136. private final transient List<Player> players = new LinkedList<Player>();
  137. private final transient List<Npc> npcs = new LinkedList<Npc>();
  138. public Inventory inventory = new Inventory(this);
  139. private Equipment equipment = new Equipment(this);
  140. private BankManager bankmanager = new BankManager();
  141. private PrivateMessaging privateMessaging = new PrivateMessaging(this);
  142. private Prayer prayer = new Prayer(this);
  143. private Teleportation teleportation = new Teleportation(this);
  144. private Emotes emotes = new Emotes(this);
  145. Skill skill = new Skill(this);
  146. private ActionSender actionSender = new ActionSender(this);
  147. private Slayer slayer = new Slayer(this);
  148. private NewComersSide newComersSide = new NewComersSide(this);
  149. private PlayerInteraction playerInteraction = new PlayerInteraction(this);
  150. private DuelMainData duelMainData = new DuelMainData(this);
  151. private AlchemistPlayground alchemistPlayground = new AlchemistPlayground(this);
  152. private CreatureGraveyard creatureGraveyard = new CreatureGraveyard(this);
  153. private TelekineticTheatre telekineticTheatre = new TelekineticTheatre(this);
  154. private EnchantingChamber enchantingChamber = new EnchantingChamber(this);
  155. private DuelInterfaces duelInterfaces = new DuelInterfaces(this);
  156. private DuelAreas duelAreas = new DuelAreas(this);
  157. private Wine wine = new Wine(this);
  158. private Fishing fishing = new Fishing(this);
  159. private ItemOnItemHandling itemOnItem = new ItemOnItemHandling(this);
  160. private SkillGuides skillGuides = new SkillGuides(this);
  161. private Food food = new Food(this);
  162. private Potion potion = new Potion(this);
  163. private MineOre mining = new MineOre(this);
  164. private Cooking cooking = new Cooking(this);
  165. private Compost compost = new Compost(this);
  166. private Allotments allotment = new Allotments(this);
  167. private Flowers flower = new Flowers(this);
  168. private Herbs herb = new Herbs(this);
  169. private Hops hops = new Hops(this);
  170. private Bushes bushes = new Bushes(this);
  171. private Seedling seedling = new Seedling(this);
  172. private WoodTrees trees = new WoodTrees(this);
  173. private FruitTree fruitTrees = new FruitTree((this));
  174. private SpecialPlantOne specialPlantOne = new SpecialPlantOne(this);
  175. private SpecialPlantTwo specialPlantTwo = new SpecialPlantTwo(this);
  176. private ToolLeprechaun toolLeprechaun = new ToolLeprechaun(this);
  177. private Firemaking firemaking = new Firemaking(this);
  178. private BoneBurying boneBurying = new BoneBurying(this);
  179. private SkillResources skillResources = new SkillResources(this);
  180. private BrewData brewData = new BrewData(this);
  181. private Pets pets = new Pets(this);
  182. private InterfaceClickHandler randomInterfaceClick = new InterfaceClickHandler(this);
  183. private DialogueManager dialogue = new DialogueManager(this);
  184. private BankPin bankPin = new BankPin(this);
  185. private Login login = new Login();
  186. private Position currentRegion = new Position(0, 0, 0);
  187. private int staffRights = 0;
  188. public int donator = 0;
  189. private boolean member;
  190. private int chatColor;
  191. private byte[] chatText;
  192. private int pouchData[] = {0, 0, 0, 0};
  193. private int gender = Constants.GENDER_MALE;
  194. private final int[] appearance = new int[7];
  195. private final int[] colors = new int[5];
  196. private Container bank = new Container(Type.ALWAYS_STACK, BankManager.SIZE);
  197. private Container trade = new Container(Type.STANDARD, Inventory.SIZE);
  198. private boolean pickupItem;
  199. private int clickX = -1;
  200. private int clickY = -1;
  201. private int clickZ = -1;
  202. private int clickId = -1;
  203. private int clickItemId = -1;
  204. private int interfaceId = -1;
  205. private int slot = -1;
  206. private int npcClickIndex;
  207. private boolean withdrawAsNote;
  208. private int enterXId;
  209. private int enterXSlot;
  210. private int enterXInterfaceId;
  211. private BankOptions bankOptions = BankOptions.SWAP_ITEM;
  212. private int shopId;
  213. private boolean isLoggedIn;
  214. private Map<Integer, Integer> bonuses = new HashMap<Integer, Integer>();
  215. private long[] friends = new long[200];
  216. private long[] ignores = new long[100];
  217. private int currentDialogueId;
  218. private int currentOptionId;
  219. private int optionClickId;
  220. private int currentGloryId;
  221. private int returnCode = Constants.LOGIN_RESPONSE_OK;
  222. private TradeStage tradeStage = TradeStage.WAITING;
  223. private int[] pendingItems = new int[Inventory.SIZE];
  224. private int[] pendingItemsAmount = new int[Inventory.SIZE];
  225. private boolean usingShop = false;
  226. private double energy = 100;
  227. private boolean needsPlacement;
  228. private boolean resetMovementQueue;
  229. private boolean appearanceUpdateRequired;
  230. private boolean killedTreeSpirit;
  231. private boolean resetbank;
  232. private boolean killedJungleDemon;
  233. private int prayerIcon = -1;
  234. private int skullIcon = -1;
  235. private int serverPoints = 0;
  236. private boolean[] isUsingPrayer = new boolean[18];
  237. private int prayerDrainTimer = 6;
  238. private SpellBook magicBookType = SpellBook.MODERN;
  239. private boolean autoRetaliate = false;
  240. private boolean isSkulled;
  241. private boolean stopPlayerPacket;
  242. private int screenBrightness = 2;
  243. private int mouseButtons = 0;
  244. private int chatEffects = 1;
  245. private int splitPrivateChat = 0;
  246. private int acceptAid = 0;
  247. private int musicVolume = 0;
  248. private int effectVolume = 0;
  249. private int questPoints = 0;
  250. private boolean specialAttackActive = false;
  251. private double specialDamage = 1, specialAccuracy = 1;
  252. private int specialAmount = 100;
  253. private int ringOfRecoilLife = 40;
  254. private int ringOfForgingLife = 140;
  255. private int bindingNeckCharge = 15;
  256. private int fightMode, fightType, fightStyle, fightXp;
  257. private boolean usingBow, usingCross, usingCrystalBow, usingArrows, usingBolts, usingOtherRangedWeapon, dropArrow;
  258. private boolean fullDharok, fullAhrim, fullKaril, fullTorag, fullGuthan, fullVerac;
  259. private transient List<LocalPlugin> plugins = new ArrayList<LocalPlugin>();
  260. private long lastFire;
  261. private long stopProtectPrayer;
  262. private int currentWalkableInterface;
  263. private int oldItem;
  264. private int oldObject;
  265. private int smithInterface;
  266. private int runecraftNpc = 553;
  267. public ArrayList<Position> followPath = new ArrayList<Position>();
  268. public String statedInterface = "";
  269. public transient Npc spawnedNpc;
  270. private long usernameAsLong;
  271. private boolean hamTrapDoor;
  272. private Weapon equippedWeapon = Weapon.FISTS;
  273. private SpecialType specialType;
  274. private List<SkullRecord> skullRecords;
  275. private Spell castedSpell, autoSpell;
  276. private boolean autoCasting = false;
  277. public int currentX, currentY;
  278. private boolean hideWeapons;
  279. String[] badNames = {"mod", "Mod", "admin", "Admin", "owner", "Owner"};
  280. private Area loadedLandscape;
  281. private transient List<GroundItem> groundItems = new LinkedList<GroundItem>();
  282. private long muteExpire, banExpire;
  283. private boolean barrowsNpcDead[] = new boolean[6];
  284. private int killCount;
  285. private int randomGrave;
  286. private boolean loggingOut;
  287. private boolean brimhavenDungeonOpen;
  288. private Position teleotherPosition;
  289. private Item destroyItem;
  290. private boolean hearMessage = true;
  291. private boolean bankWarning;
  292. private boolean debugCombat;
  293. private transient Npc randomEventNpc;
  294. private Item randomHerb;
  295. private int genieSelect;
  296. private boolean hideYell = false;
  297. public boolean usedFreeShilo;
  298.  
  299. private HourlyTasks hourly = new HourlyTasks(this);
  300. private BlastFurnace bF = new BlastFurnace(this);
  301. private BlastFurnaceItems bFItems = new BlastFurnaceItems(this);
  302. private ServerTime serverTime = new ServerTime(this);
  303. private GlobalGameHandling gameHandling = new GlobalGameHandling(this);
  304.  
  305. public int PREVIOUS_X = 0;
  306. public int PREVIOUS_Y = 0;
  307.  
  308. public Object[][] questData = {
  309. // questName, currentStage, finishedStage, questPoints
  310. {"Getting Started", 0, 2, 1}};
  311.  
  312. private int[] sidebarInterfaceId = {2423, 3917, 638, 3213, 1644, 5608, 0, -1, 5065,
  313. 5715, 2449, 904, 147, 962};
  314.  
  315. // Public ints
  316. public int moveToX, moveToY, moveToH, objectWalkX, objectWalkY, objectX, objectY, objectXOffset, objectYOffset, objectXSize, objectYSize;
  317.  
  318. public Position npcClickingLocation, objectClickingLocation;
  319.  
  320. public boolean visible = true;
  321. public boolean tempBoolean = false;
  322. public boolean wildyWarned = false;
  323. public int transformNpc = -1;
  324. public double totalWeight;
  325. public double sextantBarDegree;
  326. public int sextantSunCoords;
  327. public int rotationFactor;
  328. public int sextantGlobalPiece;
  329. public int sextantLandScapeCoords;
  330. public int clue1Amount;
  331. public int clue2Amount;
  332. public int clue3Amount;
  333. public boolean killedClueAttacker;
  334. public int clueLevel;
  335. public int challengeScroll;
  336. public Item[] puzzleStoredItems = new Item[ClueScroll.PUZZLE_LENGTH];
  337. private int tempInteger;
  338. public boolean isCrossingObstacle = false;
  339. public int currentSong;
  340. private int runAnim = -1, standAnim = -1, walkAnim = -1;
  341. private String host;
  342. private int sideBarOpen;
  343. private int[] pinAttempt = new int[4];
  344. private long logoutTimer;
  345. private int coalTruckAmount;
  346.  
  347. private transient Player lastPersonTraded;
  348. private transient Player lastPersonChallenged;
  349.  
  350.  
  351. /*
  352. * Ironman data
  353. */
  354.  
  355. public boolean isIron = false;
  356. public boolean isUltimateIron = false;
  357. public boolean isHardcoreIron = false;
  358. public boolean isDuoIron = false;
  359.  
  360. public String duoPartner = "";
  361.  
  362. public boolean isIron() { // return true or false
  363. return isIron;
  364. }
  365.  
  366. public void setIron(boolean isIron) { // set ironman to true or false, use as setIron(true/false);
  367. this.isIron = isIron;
  368. setStaffRights(3);
  369. }
  370.  
  371. public boolean isHardcoreIron() {
  372. return isHardcoreIron;
  373. }
  374.  
  375. public void setHardcoreIron(boolean isHardcoreIron) {
  376. this.isHardcoreIron = isHardcoreIron;
  377. setStaffRights(4);
  378. }
  379.  
  380.  
  381. public boolean isUltimateIron() {
  382. return isUltimateIron;
  383. }
  384.  
  385. public void setUltimateIron(boolean isUltimateIron) {
  386. this.isUltimateIron = isUltimateIron;
  387. setStaffRights(5);
  388. }
  389.  
  390. public boolean isDuoIron() {
  391. return isDuoIron;
  392. }
  393.  
  394. public void setDuoIron(boolean isDuoIron) {
  395. this.isDuoIron = isDuoIron;
  396. setStaffRights(6);
  397. }
  398.  
  399. public boolean ironPlayer() { // returns false if player isnt in any ironman mode
  400. if (this.isIron()) {
  401. return true;
  402. }
  403. if (this.isHardcoreIron()) {
  404. return true;
  405. }
  406. if (this.isUltimateIron()) {
  407. return true;
  408. }
  409. /*if (this.isDuoIron()) {
  410. return true;
  411. }*/
  412.  
  413. return false;
  414. }
  415.  
  416. public HourlyTasks getHourlyTask() {
  417. return hourly;
  418. }
  419.  
  420. public BlastFurnace getBlastFurnace() {
  421. return bF;
  422. }
  423.  
  424. public BlastFurnaceItems getBlastFurnaceItems() {
  425. return bFItems;
  426. }
  427.  
  428. public ServerTime getServerTime() {
  429. return serverTime;
  430. }
  431.  
  432. public GlobalGameHandling getGameHandling() {
  433. return gameHandling;
  434. }
  435.  
  436. public void resetAnimation() {
  437. getUpdateFlags().sendAnimation(-1);
  438. }
  439.  
  440. public int uid() {
  441. return uid;
  442. }
  443.  
  444. public void setUid(int uid) {
  445. this.uid = uid;
  446. }
  447.  
  448. @Override
  449. public void reset() {
  450. getUpdateFlags().reset();
  451. setPrimaryDirection(-1);
  452. setSecondaryDirection(-1);
  453. setAppearanceUpdateRequired(false);
  454. setResetMovementQueue(false);
  455. setNeedsPlacement(false);
  456. setUsingShop(false);
  457. setChatText(null);
  458. }
  459.  
  460. @Override
  461. public void initAttributes() {
  462. getAttributes().put("smithing", Boolean.FALSE);
  463. getAttributes().put("smelting", Boolean.FALSE);
  464. getAttributes().put("isBanking", Boolean.FALSE);
  465. getAttributes().put("isShopping", Boolean.FALSE);
  466. getAttributes().put("canPickup", Boolean.FALSE);
  467. getAttributes().put("canTakeDamage", Boolean.TRUE);
  468. }
  469.  
  470. public Item destroyedBarrow(Item item) {
  471. if (item != null) {
  472. for (String s : WeaponDegrading.barrowsEquipments) {
  473. if (item.getDefinition().getName().toLowerCase().contains(s)) {
  474. if (item.getDefinition().getName().toLowerCase().contains("100"))
  475. return new Item(item.getId() + 4, item.getCount());
  476. if (item.getDefinition().getName().toLowerCase().contains("75"))
  477. return new Item(item.getId() + 3, item.getCount());
  478. if (item.getDefinition().getName().toLowerCase().contains("50"))
  479. return new Item(item.getId() + 2, item.getCount());
  480. if (item.getDefinition().getName().toLowerCase().contains("25"))
  481. return new Item(item.getId() + 1, item.getCount());
  482.  
  483. return new Item(WeaponDegrading.getFirstDegraded(item.getId()) + 4, item.getCount());
  484. }
  485. }
  486. return item;
  487. }
  488. return null;
  489. }
  490.  
  491. public void handleDropItems(int amountToDrop, Player player) {
  492. ArrayList<Item> items = new ArrayList<Item>();
  493. for (int i = 0; i < Inventory.SIZE; i++)
  494. if (getInventory().getItemContainer().get(i) != null && !ItemManager.getInstance().isUntradeable(getInventory().getItemContainer().get(i).getId()))
  495. items.add(destroyedBarrow(getInventory().getItemContainer().get(i)));
  496.  
  497. for (int i = 0; i < Equipment.SIZE; i++)
  498. if (getEquipment().getItemContainer().get(i) != null && !ItemManager.getInstance().isUntradeable(getEquipment().getItemContainer().get(i).getId()))
  499. items.add(destroyedBarrow(getEquipment().getItemContainer().get(i)));
  500.  
  501. if (items.size() == 0)
  502. return;
  503. // getting the highest price in the list
  504. items = getHighestPriceListed(items);
  505. getInventory().getItemContainer().clear();
  506. getInventory().refresh();
  507. getEquipment().getItemContainer().clear();
  508. getEquipment().refresh();
  509. if (amountToDrop != 0)
  510. for (int i = 0; i < amountToDrop; i++)
  511. getInventory().addItem(items.get(i));
  512. for (int i = amountToDrop; i < items.size(); i++) {
  513. ItemManager.getInstance().createGroundItem(player, items.get(i), new Position(getPosition().getX(), getPosition().getY(), getPosition().getZ()));
  514. }
  515. player.getActionSender().sendSound(376, 0, 0);
  516. }
  517.  
  518. public ArrayList<Item> getHighestPriceListed(ArrayList<Item> array) {
  519. ArrayList<Item> tempArray = array;
  520. ArrayList<Item> listedArray = new ArrayList<Item>();
  521. Item highest;
  522. for (int i = 0; i < tempArray.size(); i++) {
  523. highest = new Item(0);
  524. for (Item items : tempArray) {
  525. if (items == null)
  526. continue;
  527. if (items.getDefinition().getPrice() >= highest.getDefinition().getPrice())
  528. highest = items;
  529. }
  530. tempArray.remove(highest);
  531. listedArray.add(highest);
  532. }
  533. return listedArray;
  534. }
  535.  
  536. public Player(SelectionKey key) {
  537. this.key = key;
  538. inData = ByteBuffer.allocateDirect(512);
  539. outData = ByteBuffer.allocateDirect(8192);
  540. if (key != null) {
  541. socketChannel = (SocketChannel) key.channel();
  542. host = socketChannel.socket().getInetAddress().getHostAddress();
  543. }
  544. setPosition(new Position(Constants.START_X, Constants.START_Y, Constants.START_Z));
  545. initAttributes();
  546.  
  547. // Set the default appearance.
  548. setDefaultAppearance();
  549.  
  550. // Set the default colors.
  551. getColors()[0] = 7;
  552. getColors()[1] = 0;
  553. getColors()[2] = 9;
  554. getColors()[3] = 5;
  555. getColors()[4] = 0;
  556. for (int i = 0; i < pendingItems.length; i++) {
  557. pendingItems[i] = -1;
  558. pendingItemsAmount[i] = 0;
  559. }
  560. this.skullRecords = new LinkedList<SkullRecord>();
  561. }
  562.  
  563. public void setDefaultAppearance() {
  564. setGender(0);
  565. int[] defaultAppearances = Constants.APPEARANCE_RANGES[gender][0];
  566. System.arraycopy(defaultAppearances, 0, appearance, 0, appearance.length);
  567. int[] defaultColors = Constants.COLOR_RANGES[gender][0];
  568. System.arraycopy(defaultColors, 0, colors, 0, colors.length);
  569. }
  570.  
  571. public void handlePacket() {
  572. StreamBuffer.InBuffer in = StreamBuffer.newInBuffer(inData);
  573. Packet p = new Packet(opcode, packetLength, in);
  574. boolean dispatch = true;
  575. PacketManager.packetBenchmarks[p.getOpcode()].start();
  576. for (LocalPlugin lp : plugins) {
  577. if (!lp.onPacketArrival(p)) {
  578. dispatch = false;
  579. }
  580. }
  581. if (dispatch) {
  582. PacketManager.handlePacket(this, p);
  583. }
  584. PacketManager.packetBenchmarks[p.getOpcode()].stop();
  585.  
  586. }
  587.  
  588. public boolean timeOutCheck() {
  589. // If no packet for more than 5 seconds, disconnect.
  590. if (isLoggedIn() && getTimeoutStopwatch().elapsed() > 5000) {
  591. disconnect();
  592. return true; // true;
  593. }
  594. return false;
  595. }
  596.  
  597. public void send(ByteBuffer buffer) {
  598. if (!socketChannel.isOpen())
  599. return;
  600.  
  601. // Prepare the buffer for writing.
  602. buffer.flip();
  603.  
  604. try {
  605. // ...and write it!
  606. socketChannel.write(buffer);
  607.  
  608. // If not all the data was sent
  609. if (buffer.hasRemaining()) {
  610. // Queue it
  611. synchronized (getOutData()) {
  612. getOutData().put(buffer);
  613. }
  614.  
  615. // And flag write interest
  616. synchronized (DedicatedReactor.getInstance()) {
  617. DedicatedReactor.getInstance().getSelector().wakeup();
  618. key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
  619. }
  620. }
  621. } catch (Exception ex) {
  622. disconnect();
  623. }
  624. }
  625.  
  626. /**
  627. * Here we can allow updating of methods who write data to the buffer This
  628. * updates all the time and prevents buffer writing bug
  629. */
  630. public void sendTickUpdatesOnLogin() {
  631. final Player player = this;
  632. World.submit(new Tick(3) {
  633. @Override
  634. public void execute() {
  635. this.stop();
  636. getAttributes().put("canPickup", Boolean.TRUE);
  637. getPrivateMessaging().refresh(false);
  638. WalkInterfaces.addWalkableInterfaces(player);
  639. getActionSender().sendEnergy();
  640. }
  641. });
  642. }
  643.  
  644. public void disconnect() {
  645. if (loginStage.compareTo(LoginStages.LOGGED_IN) > 0)
  646. return;
  647. setLogoutTimer(System.currentTimeMillis() + 900000);
  648. setLoginStage(LoginStages.LOGGING_OUT);
  649. key.attach(null);
  650. key.cancel();
  651. try {
  652. socketChannel.close();
  653. HostGateway.exit(host);
  654. } catch (Exception ex) {
  655. ex.printStackTrace();
  656. } finally {
  657. if (getIndex() != -1) {
  658. synchronized (Server.getDisconnectedPlayers()) {
  659. Server.getDisconnectedPlayers().offer(this);
  660. }
  661. }
  662. }
  663. }
  664.  
  665.  
  666. /* public void disconnect() {
  667. try {
  668. logout();
  669. socketChannel.close();
  670. } catch (Exception ex) {
  671. ex.printStackTrace();
  672. } finally {
  673. HostGateway.exit(host);
  674. key.attach(null);
  675. key.cancel();
  676. }
  677. }*/
  678.  
  679. public int counter = 120; // change this to the a few minutes or so
  680.  
  681. public void countdownToStart() {
  682. CycleEventHandler.getInstance().addEvent(this, new CycleEvent() { // wait 3 seconds after the last player dies before calling end method
  683. @Override
  684. public void execute(CycleEventContainer container) {
  685. counter--;
  686. if (counter <= 0)
  687. container.stop();
  688. }
  689.  
  690. @Override
  691. public void stop() {
  692. getGameHandling().sendAllPlayersToGame();
  693. }
  694. }, 2);
  695. }
  696.  
  697. long lastYell;
  698.  
  699. @Override
  700. public void process() {
  701. /*if (timeOutCheck()) {
  702. return;
  703. }*/
  704. serverTime.GetTime(); // updates game clock and generates task messages currently
  705. expireHitRecords();
  706. expireSkullRecords();
  707. prayer.prayerTick();
  708. skill.skillTick();
  709. for (LocalPlugin lp : plugins) {
  710. lp.onTick();
  711. }
  712. checkNpcAggressiveness();
  713. getFollowing().followTick();
  714. if (energy < 100 && !isRunning()) {
  715. energy += (100 / (222 - (double) getSkill().getLevel()[Skill.AGILITY])) * 0.6;
  716. actionSender.sendEnergy();
  717. }
  718. // Npc.checkAggressiveness(this);
  719. }
  720.  
  721. /**
  722. * Adds to the Players position.
  723. */
  724. public void appendPlayerPosition(int xModifier, int yModifier) {
  725. getPosition().move(xModifier, yModifier);
  726. }
  727.  
  728. /**
  729. * Handles a player command.
  730. *
  731. * @param keyword the command keyword
  732. * @param args the arguments (separated by spaces)
  733. */
  734. public void handleCommand(String keyword, String[] args, String fullString) {
  735. keyword = keyword.toLowerCase();
  736. if (getStaffRights() == 2) { // Administrators
  737. saveCommand(getUsername(), keyword + " " + fullString);
  738. if (keyword.equals("coordinate")) {
  739. final int id = Integer.parseInt(args[0]);
  740. CoordinateData clue = CoordinateData.forIdClue(id);
  741. actionSender.sendMessage(clue.getDiggingPosition().getX() + " " + clue.getDiggingPosition().getY());
  742. }
  743.  
  744. if (keyword.equals("run")) {
  745. final int id = Integer.parseInt(args[0]);
  746. setRunAnim(id);
  747. setAppearanceUpdateRequired(true);
  748. }
  749. if (keyword.equals("walk")) {
  750. final int id = Integer.parseInt(args[0]);
  751. setWalkAnim(id);
  752. setAppearanceUpdateRequired(true);
  753. }
  754. if (keyword.equals("stand")) {
  755. final int id = Integer.parseInt(args[0]);
  756. setStandAnim(id);
  757. setAppearanceUpdateRequired(true);
  758. }
  759. if (keyword.equals("poison")) {
  760. HitDef hitDef = new HitDef(null, HitType.POISON, Math.ceil(4.0)).setStartingHitDelay(1);
  761. Hit hit = new Hit(this, this, hitDef);
  762. PoisonEffect p = new PoisonEffect(4.0, false);
  763. p.initialize(hit);
  764. }
  765. /* else if (keyword.equals("dbhs")) {
  766. HighscoresManager.debug = !HighscoresManager.debug;
  767. getActionSender().sendMessage("Highscores debug mode: " + HighscoresManager.debug);
  768. } else if (keyword.equals("hsstatus")) {
  769. getActionSender().sendMessage("Highscores are "+(HighscoresManager.running ? "running" : "stopped")+" "+(HighscoresManager.debug ? "in debug mode" : ""));
  770. } else if (keyword.equals("rebooths")) {
  771. HighscoresManager.running = !HighscoresManager.running;
  772. getActionSender().sendMessage("Highscores are "+(HighscoresManager.running ? "running" : "stopped")+" "+(HighscoresManager.debug ? "in debug mode" : ""));
  773. }*/
  774. else if (keyword.equals("uptime")) {
  775. getActionSender().sendMessage("Server has been online for: " + Misc.durationFromTicks(World.SERVER_TICKS, false));
  776. } else if (keyword.equals("save")) {
  777. PlayerSave.saveAllPlayers();
  778. actionSender.sendMessage("Saved players");
  779. } else if (keyword.equals("error")) {
  780. Player p = World.getPlayers()[9999];
  781. p.getActionSender().sendMessage("trolol");
  782. } else if (keyword.equals("staff")) {
  783. World.messageToStaff(fullString);
  784. }
  785. /*
  786. * if (keyword.equals("forcespace")) { String name = fullString;
  787. * getActionSender().sendMessage("You have sent " +
  788. * args[0].toLowerCase() + "to space."); for (Player player :
  789. * World.getPlayers()) { if (player == null) continue; if
  790. * (player.getUsername().equalsIgnoreCase(name)) {
  791. * player.teleport(new Position(20, 20));
  792. * player.getActionSender().sendMessage
  793. * ("You have been sent to space. Good luck escaping!"); return; } }
  794. * getActionSender
  795. * ().sendMessage("The player is not online at the moment."); }
  796. */
  797. else if (keyword.equalsIgnoreCase("fillspec")) {
  798. if (inWild()) {
  799. getActionSender().sendMessage("You can't use this command in the wilderness.");
  800. return;
  801. }
  802. setSpecialAmount(100);
  803. updateSpecialBar();
  804. } else if (keyword.equals("master")) {
  805. if (inWild()) {
  806. getActionSender().sendMessage("You can't use this command in the wilderness.");
  807. return;
  808. }
  809. for (int i = 0; i < skill.getLevel().length; i++) {
  810. skill.getLevel()[i] = 99;
  811. skill.getExp()[i] = 200000000;
  812. }
  813. skill.refresh();
  814. } else if (keyword.equals("pure")) {
  815. if (inWild()) {
  816. getActionSender().sendMessage("You can't use this command in the wilderness.");
  817. return;
  818. }
  819. skill.getLevel()[0] = 60;
  820. skill.getExp()[0] = 273742;
  821.  
  822. skill.getLevel()[1] = 1;
  823. skill.getExp()[1] = 0;
  824.  
  825. skill.getLevel()[2] = 99;
  826. skill.getLevel()[3] = 99;
  827. skill.getLevel()[4] = 99;
  828. skill.getLevel()[5] = 52;
  829. skill.getExp()[5] = 123660;
  830.  
  831. skill.getLevel()[6] = 99;
  832. skill.refresh();
  833. } else if (keyword.equals("pnpc")) {
  834. final int index = Integer.parseInt(args[0]);
  835. transformNpc = index;
  836. setAppearanceUpdateRequired(true);
  837. setSize(new Npc(index).getDefinition().getSize());
  838. } else if (keyword.equals("invisible")) {
  839. visible = !visible;
  840. getActionSender().sendMessage("Invisible: " + !visible);
  841. } else if (keyword.equals("scan")) {
  842. for (int i = 0; i < Constants.MAX_NPC_ID; i++) {
  843. for (NpcDropItem item : NpcDropController.forId(i).getDropList()) {
  844. for (int c : item.getCount()) {
  845. if (c > 1000) {
  846. System.out.println(c);
  847. }
  848. }
  849. }
  850. }
  851. } else if (keyword.equals("bank")) {
  852. BankManager.openBank(this);
  853. } else if (keyword.equals("npc")) {
  854. int npcId = Integer.parseInt(args[0]);
  855. Npc npc = new Npc(npcId);
  856. npc.setPosition(new Position(getPosition().getX(), getPosition().getY(), getPosition().getZ()));
  857. npc.setSpawnPosition(new Position(getPosition().getX(), getPosition().getY(), getPosition().getZ()));
  858. npc.setCurrentX(getPosition().getX());
  859. npc.setCurrentY(getPosition().getY());
  860. World.register(npc);
  861. getActionSender().sendMessage("You spawn NPC #" + npcId);
  862. setLastNpc(npc.getNpcId());
  863. } else if (keyword.equals("tfra")) {
  864. actionSender.sendFrame106(Integer.parseInt(args[0]));
  865.  
  866. } else if (keyword.equals("removenpc")) {
  867. for (Npc npc : World.getNpcs()) {
  868. if (npc != null) {
  869. if (npc.getPosition().equals(getPosition())) {
  870. getActionSender().sendMessage("You remove NPC #" + npc.getNpcId());
  871. npc.setVisible(false);
  872. World.unregister(npc);
  873. break;
  874. }
  875. }
  876. }
  877. } else if (keyword.equals("object")) {
  878. int objectId = Integer.parseInt(args[0]);
  879. int face = args.length > 1 ? Integer.parseInt(args[1]) : 0;
  880. int type = args.length > 2 ? Integer.parseInt(args[2]) : 10;
  881. new GameObject(objectId, getPosition().getX(), getPosition().getY(), getPosition().getZ(), face, type, 0, 999999, false);
  882. } else if (keyword.equals("item")) {
  883. if (inWild()) {
  884. getActionSender().sendMessage("You can't use this command in the wilderness.");
  885. return;
  886. }
  887. int id = Integer.parseInt(args[0]);
  888. int amount = 1;
  889. if (args.length > 1) {
  890. amount = Integer.parseInt(args[1]);
  891. amount = amount > Constants.MAX_ITEM_COUNT ? Constants.MAX_ITEM_COUNT : amount;
  892. }
  893. inventory.addItem(new Item(id, amount));
  894. getActionSender().sendMessage("You spawn a " + new Item(id).getDefinition().getName().toLowerCase() + " (" + id + ").");
  895. } else if (keyword.equals("runes")) {
  896. if (inWild()) {
  897. getActionSender().sendMessage("You can't use this command in the wilderness.");
  898. return;
  899. }
  900. for (int i = 0; i < 566 - 554 + 1; i++) {
  901. inventory.addItem(new Item(554 + i, 1000));
  902. }
  903. inventory.addItem(new Item(1381, 1));
  904. inventory.addItem(new Item(4675, 1));
  905. } else if (keyword.equals("tele")) {
  906. try {
  907. int x = Integer.parseInt(args[0]);
  908. int y = Integer.parseInt(args[1]);
  909. int z = Integer.parseInt(args[2]);
  910. teleport(new Position(x, y, z));
  911. getActionSender().sendMessage("You teleported to: " + x + ", " + y + ", " + z);
  912. } catch (Exception e) {
  913. try {
  914. int x = Integer.parseInt(args[0]);
  915. int y = Integer.parseInt(args[1]);
  916. teleport(new Position(x, y, getPosition().getZ()));
  917. getActionSender().sendMessage("You teleported to: " + x + ", " + y + ", " + getPosition().getZ());
  918. } catch (Exception e1) {
  919. getActionSender().sendMessage("Please use the synthax ::tele x y (optional z)");
  920. }
  921. }
  922. } else if (keyword.equals("empty")) {
  923. getInventory().getItemContainer().clear();
  924. getInventory().refresh();
  925. } else if (keyword.equals("removebankpin")) {
  926. Player player = World.getPlayerByName(fullString);
  927. if (player == null)
  928. return;
  929. player.getBankPin().deleteBankPin();
  930. } else if (keyword.equals("melee")) {
  931. if (inWild()) {
  932. getActionSender().sendMessage("You can't use this command in the wilderness.");
  933. return;
  934. }
  935. inventory.addItem(new Item(4152, 100));
  936. inventory.addItem(new Item(1164, 100));
  937. inventory.addItem(new Item(1128, 100));
  938. inventory.addItem(new Item(1080, 100));
  939. inventory.addItem(new Item(4132, 100));
  940. inventory.addItem(new Item(1202, 100));
  941. inventory.addItem(new Item(1732, 100));
  942. inventory.addItem(new Item(6570, 1));
  943. inventory.addItem(new Item(7462, 1));
  944. } else if (keyword.equals("range")) {
  945. if (inWild()) {
  946. getActionSender().sendMessage("You can't use this command in the wilderness.");
  947. return;
  948. }
  949. inventory.addItem(new Item(2492, 100));
  950. inventory.addItem(new Item(2498, 100));
  951. inventory.addItem(new Item(2504, 100));
  952. inventory.addItem(new Item(862, 100));
  953. inventory.addItem(new Item(1479, 100));
  954. inventory.addItem(new Item(6329, 100));
  955. inventory.addItem(new Item(892, 100000));
  956. inventory.addItem(new Item(6570, 1));
  957. inventory.addItem(new Item(7462, 1));
  958. } else if (keyword.equals("mage")) {
  959. if (inWild()) {
  960. getActionSender().sendMessage("You can't use this command in the wilderness.");
  961. return;
  962. }
  963. getActionSender().sendMessage("Use the ::runes command for runes.");
  964. inventory.addItem(new Item(4090, 100));
  965. inventory.addItem(new Item(4092, 100));
  966. inventory.addItem(new Item(4094, 100));
  967. inventory.addItem(new Item(4096, 100));
  968. inventory.addItem(new Item(4098, 100));
  969. inventory.addItem(new Item(1382, 100));
  970. inventory.addItem(new Item(1728, 100));
  971. inventory.addItem(new Item(6890, 100));
  972. inventory.addItem(new Item(6570, 1));
  973. inventory.addItem(new Item(7462, 1));
  974. } else if (keyword.equals("potions")) {
  975. if (inWild()) {
  976. getActionSender().sendMessage("You can't use this command in the wilderness.");
  977. return;
  978. }
  979. inventory.addItem(new Item(2437, 100));
  980. inventory.addItem(new Item(2441, 100));
  981. inventory.addItem(new Item(2443, 100));
  982. inventory.addItem(new Item(2435, 100));
  983. } else if (keyword.equals("food")) {
  984. if (inWild()) {
  985. getActionSender().sendMessage("You can't use this command in the wilderness.");
  986. return;
  987. }
  988. inventory.addItem(new Item(391, 28));
  989. } else if (keyword.equals("spawn")) {
  990. int id = Integer.parseInt(args[0]);
  991. NpcDefinition npc = NpcDefinition.forId(id);
  992. appendToAutoSpawn(npc);
  993. } else if (keyword.equals("wave")) {
  994. int index = Integer.parseInt(args[0]);
  995. WavesHandling.spawnWave(this, index);
  996. } else if (keyword.equals("team")) {
  997. int cape = Integer.parseInt(args[0]);
  998. int count = 0;
  999. for (Player player : World.getPlayers()) {
  1000. if (player == null)
  1001. continue;
  1002. if (player.getEquipment().getId(Constants.CAPE) == cape) {
  1003. player.teleport(getPosition());
  1004. count++;
  1005. }
  1006. }
  1007. getActionSender().sendMessage("You have " + count + " teammates on your team.");
  1008. } else if (keyword.equals("teleto")) {
  1009. String name = fullString;
  1010. for (Player player : World.getPlayers()) {
  1011. if (player == null)
  1012. continue;
  1013. if (player.getUsername().equalsIgnoreCase(name)) {
  1014. teleport(player.getPosition().clone());
  1015. break;
  1016. }
  1017. }
  1018. } else if (keyword.equals("teletome")) {
  1019. String name = fullString;
  1020. // if (inWild()) {
  1021. // actionSender.sendMessage("You can't teleport someone into the wild!");
  1022. // return;
  1023. //}
  1024. Player player = World.getPlayerByName(name);
  1025. if (player == null) {
  1026. actionSender.sendMessage("Cannot find player: " + name);
  1027. return;
  1028. }
  1029. if (player.inDuelArena()) {
  1030. actionSender.sendMessage("That person is dueling right now.");
  1031. return;
  1032. }
  1033. player.teleport(getPosition().clone());
  1034. } else if (keyword.equals("modern")) {
  1035. if (inWild()) {
  1036. getActionSender().sendMessage("You can't use this command in the wilderness.");
  1037. return;
  1038. }
  1039. getActionSender().sendSidebarInterface(6, 1151);
  1040. magicBookType = SpellBook.MODERN;
  1041. } else if (keyword.equals("ancient")) {
  1042. if (inWild()) {
  1043. getActionSender().sendMessage("You can't use this command in the wilderness.");
  1044. return;
  1045. }
  1046. getActionSender().sendSidebarInterface(6, 12855);
  1047. magicBookType = SpellBook.ANCIENT;
  1048. } else if (keyword.equals("hitz")) {
  1049. int hits = Integer.parseInt(args[0]);
  1050. for (int i = 0; i < hits; i++) {
  1051. hit(i, HitType.NORMAL);
  1052. }
  1053. } else if (keyword.equals("mypos")) {
  1054. getActionSender().sendMessage("You are at: " + getPosition());
  1055. } else if (keyword.equalsIgnoreCase("shiptest")) {
  1056. Sailing.sailShip(this, Sailing.ShipRoute.values()[Integer.parseInt(args[0])]);
  1057. } else if (keyword.equalsIgnoreCase("carpet")) {
  1058. int xDiff = Integer.parseInt(args[0]);
  1059. int yDiff = Integer.parseInt(args[1]);
  1060. Position pos = new Position(getPosition().getX() + xDiff, getPosition().getY() + yDiff);
  1061. MagicCarpet.ride(this, pos);
  1062. } else if (keyword.equals("anim")) {
  1063. int animationId = Integer.parseInt(args[0]);
  1064. getUpdateFlags().sendAnimation(animationId, 0);
  1065. getActionSender().sendMessage("Animation #" + animationId);
  1066. } else if (keyword.equals("gfx")) {
  1067. int gfxId = Integer.parseInt(args[0]);
  1068. Graphic graphic = new Graphic(gfxId, 100);
  1069. getUpdateFlags().sendGraphic(graphic.getId(), graphic.getValue());
  1070. getActionSender().sendMessage("GFX #" + gfxId);
  1071. } else if (keyword.equals("interface")) {
  1072. actionSender.sendInterface(Integer.parseInt(args[0]));
  1073. } else if (keyword.equals("unmute")) {
  1074. Player player = World.getPlayerByName(fullString);
  1075. if (player == null) {
  1076. actionSender.sendMessage("Could not find player " + fullString);
  1077. return;
  1078. }
  1079. actionSender.sendMessage("Unmuted " + fullString);
  1080. player.setMuteExpire(System.currentTimeMillis());
  1081. } else if (keyword.equals("ban")) {
  1082. if (args.length < 2) {
  1083. actionSender.sendMessage("::ban hours username");
  1084. return;
  1085. }
  1086. int hours = Integer.parseInt(args[0]);
  1087. if (hours <= 0 || hours > 100) {
  1088. actionSender.sendMessage("Ban between 0 and 100 hours");
  1089. return;
  1090.  
  1091. }
  1092. String name = "";
  1093. for (int i = 1; i < args.length; i++) {
  1094. name += args[i];
  1095. }
  1096. Player player = World.getPlayerByName(name);
  1097. if (player == null) {
  1098. actionSender.sendMessage("Could not find player");
  1099. return;
  1100. }
  1101. if (player.isBanned()) {
  1102. actionSender.sendMessage("Player is already banned");
  1103. return;
  1104. }
  1105. try {
  1106. OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream("./data/modlog.out", true));
  1107. out.write(player.getUsername() + " was banned by " + username + " for " + hours + " hours.");
  1108. out.flush();
  1109. } catch (FileNotFoundException e) {
  1110. e.printStackTrace();
  1111. } catch (IOException e) {
  1112. e.printStackTrace();
  1113. }
  1114. actionSender.sendMessage("Banned " + player.getUsername() + " for " + hours + " hours.");
  1115. player.setBanExpire(System.currentTimeMillis() + (hours * 60 * 60 * 1000));
  1116. player.disconnect();
  1117. } else if (getUsername().equalsIgnoreCase("Lucid")) {
  1118. if (keyword.equals("update")) {
  1119. final int seconds = Integer.parseInt(args[0]);
  1120. if (seconds <= 0) {
  1121. getActionSender().sendMessage("Invalid timer parameter provided.");
  1122. return;
  1123. }
  1124. final int ticks = seconds * 1000 / 600;
  1125. if (GlobalVariables.getServerUpdateTimer() != null) {
  1126. getActionSender().sendMessage("An update has already been executed.");
  1127. return;
  1128. }
  1129. Constants.SYSTEM_UPDATE = true;
  1130. for (Player player : World.getPlayers()) {
  1131. if (player == null || player.getIndex() == -1)
  1132. continue;
  1133. player.getActionSender().sendUpdateServer(ticks);
  1134. TradeManager.declineTrade(player);
  1135. }
  1136.  
  1137. new ShutdownWorldProcess(seconds).start();
  1138. } else if (keyword.equals("stat")) {
  1139. try {
  1140. if (fullString.indexOf("-") == 0) {
  1141. getActionSender().sendMessage("Don't forget - before player name!");
  1142. return;
  1143. }
  1144. int skillId = Integer.parseInt(args[0]);
  1145. int lvl = Integer.parseInt(args[1]);
  1146. String name = fullString.substring(fullString.indexOf("-") + 1);
  1147. long nameLong = NameUtil.nameToLong(NameUtil.uppercaseFirstLetter(name));
  1148. Player player = World.getPlayerByName(nameLong);
  1149. if (player == null) {
  1150. getActionSender().sendMessage("Can't find player " + name);
  1151. return;
  1152. }
  1153. player.getSkill().getLevel()[skillId] = lvl > 99 ? 99 : lvl;
  1154. player.getSkill().getExp()[skillId] = getSkill().getXPForLevel(lvl);
  1155. player.getSkill().refresh(skillId);
  1156. } catch (Exception e) {
  1157. e.printStackTrace();
  1158.  
  1159. }
  1160.  
  1161. }
  1162. }
  1163. }
  1164. if (getStaffRights() == 1 || getStaffRights() == 2) { // Moderators
  1165. String name = fullString;
  1166. if (keyword.equals("kick")) {
  1167. Player player = World.getPlayerByName(fullString);
  1168. if (player == null)
  1169. return;
  1170. player.disconnect();
  1171. actionSender.sendMessage("You have kicked " + player.getUsername());
  1172. } else if (keyword.equals("mute")) {
  1173. if (args.length < 2) {
  1174. actionSender.sendMessage("::mute hours username");
  1175. return;
  1176. }
  1177. int hours = Integer.parseInt(args[0]);
  1178. int maxHours = getStaffRights() == 1 ? 48 : 100;
  1179. if (hours <= 0 || hours > maxHours) {
  1180. actionSender.sendMessage("Mute between 0 and " + maxHours + " hours");
  1181. return;
  1182. }
  1183. name = "";
  1184. for (int i = 1; i < args.length; i++) {
  1185. name += args[i];
  1186. }
  1187. Player player = World.getPlayerByName(name);
  1188. if (player == null) {
  1189. actionSender.sendMessage("Could not find " + name);
  1190. return;
  1191. }
  1192. if (player.isMuted()) {
  1193. actionSender.sendMessage("Player is already muted");
  1194. return;
  1195. }
  1196. try {
  1197. OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream("./data/modlog.out", true));
  1198. out.write(player.getUsername() + " was muted by " + username + " for " + hours + " hours.");
  1199. out.flush();
  1200. } catch (FileNotFoundException e) {
  1201. e.printStackTrace();
  1202. } catch (IOException e) {
  1203. e.printStackTrace();
  1204. }
  1205. actionSender.sendMessage("Muted " + player.getUsername() + " for " + hours + " hours.");
  1206. player.actionSender.sendMessage("You have been muted for " + hours + " hours");
  1207. player.setMuteExpire(System.currentTimeMillis() + (hours * 60 * 60 * 1000));
  1208. }
  1209. }
  1210. if (getStaffRights() >= 0) { // Everyone
  1211. if (keyword.equals("outfit")) {
  1212. getActionSender().sendInterface(3559);
  1213. }
  1214. if (keyword.equals("completetask") && hasTask) {
  1215. getActionSender().sendMessage("Lol kid. Get " + player.taskAmount + " "
  1216. + ItemManager.getInstance().getItemName(player.givenTask) + ".");
  1217. }
  1218. if (keyword.equals("start")) {
  1219. getGameHandling().sendAllPlayersToGame();
  1220. }
  1221. if (keyword.equals("mode")) {
  1222. getActionSender().sendMessage("Free: " + getGameHandling().freeMode + ", Member: " + getGameHandling().memberMode);
  1223. }
  1224. if (keyword.equals("removepoints")) {
  1225. setActivityPoints(0);
  1226. }
  1227. if (keyword.equals("points")) {
  1228. getActionSender().sendMessage("" + activityPoints);
  1229. }
  1230. if (keyword.equals("addpoints")) {
  1231. activityPoints += 20;
  1232. getActionSender().sendMessage("" + activityPoints);
  1233. }
  1234.  
  1235. if (keyword.equals("vote")) {
  1236. getInventory().addItem(new Item(3230));
  1237. }
  1238.  
  1239. if (keyword.equals("double")) {
  1240. getActionSender().sendMessage("You have " + bonusXpTime / 60 + " minutes of bonus experience remaining.");
  1241. }
  1242.  
  1243. if (keyword.equals("setlevel")) {
  1244. int id = Integer.parseInt(args[0]);
  1245. int lvl = Integer.parseInt(args[1]);
  1246.  
  1247. player.getSkill().getLevel()[id] = ((byte) lvl);
  1248. // player.getSkill().getSkill[id] = ((byte) lvl);
  1249. //player.getSkill().getExp()[id] = player.getSkill().getLevelForXP(id, lvl);
  1250. //player.getSkill().update(id);
  1251.  
  1252. player.getSkill().calculateCombatLevel();
  1253. }
  1254. if (keyword.equals("yell")) {
  1255. if (getStaffRights() == 0 || getStaffRights() > 2) {
  1256. if (System.currentTimeMillis() - lastYell < 60000) {
  1257. getActionSender().sendMessage("You can only yell once per 60 seconds!");
  1258. return;
  1259. }
  1260. }
  1261. lastYell = System.currentTimeMillis();
  1262. for (Player player : World.getPlayers()) {
  1263. String yeller = NameUtil.formatName(getUsername());
  1264. String text = fullString;
  1265. String[] bad = {":chalreq:", ":tradereq:", "flavius", ":duelreq:", "is gay", "cunt", "fuck off"};
  1266. if (player == null)
  1267. continue;
  1268. for (int i = 0; i < bad.length; i++) {
  1269. if (text.indexOf(bad[i]) >= 0) {
  1270. getActionSender().sendMessage("You are trying to say something that should not be said!");
  1271. return;
  1272. }
  1273. }
  1274. if (isMuted()) {
  1275. getActionSender().sendMessage("You are muted and cannot use yell.");
  1276. return;
  1277. } else if (getStaffRights() == 6) {
  1278. player.getActionSender().sendMessage("[Duo Ironman][" + yeller + "]" + NameUtil.uppercaseFirstLetter(text));
  1279. } else if (getStaffRights() == 5) {
  1280. player.getActionSender().sendMessage("[Ultimate Ironman][" + yeller + "]" + NameUtil.uppercaseFirstLetter(text));
  1281. } else if (getStaffRights() == 4) {
  1282. player.getActionSender().sendMessage("[Hardcore Ironman][" + yeller + "]" + NameUtil.uppercaseFirstLetter(text));
  1283. } else if (getStaffRights() == 3) {
  1284. player.getActionSender().sendMessage("[Ironman][" + yeller + "]" + NameUtil.uppercaseFirstLetter(text));
  1285. } else if (getStaffRights() == 2) {
  1286. player.getActionSender().sendMessage("[Owner][" + yeller + "]" + NameUtil.uppercaseFirstLetter(text));
  1287. } else if (getStaffRights() == 1) {
  1288. player.getActionSender().sendMessage("[Moderator][" + yeller + "]" + NameUtil.uppercaseFirstLetter(text));
  1289. } else if (getStaffRights() >= 0) {
  1290. player.getActionSender().sendMessage("[" + yeller + "]" + NameUtil.uppercaseFirstLetter(text));
  1291. }
  1292. }
  1293. }
  1294. if (keyword.equals("hideyell")) {
  1295. hideYell = !hideYell;
  1296. getActionSender().sendMessage("You have had your yell " + (!hideYell ? "enabled" : "disabled"));
  1297. }
  1298.  
  1299. if (keyword.equals("home")) {
  1300. if (inWild() || inStarter() || isAttacking() || inDuelArena() || isDead() || !getInCombatTick().completed()) {
  1301. getActionSender().sendMessage("You cannot do that here!");
  1302. } else {
  1303. teleport(new Position(Constants.HOME_X, Constants.HOME_Y, 0));
  1304. getActionSender().sendMessage("You teleported home.");
  1305. }
  1306. } else if (keyword.equals("players")) {
  1307. actionSender.sendMessage("There are currently " + World.playerAmount() + " players online.");
  1308. } else if (keyword.equals("commands")) {
  1309. actionSender.sendMessage("There are few of them use them wisely!");
  1310. actionSender.sendMessage("::changepass, ::home ::players, ::hideyell, ::outfit");
  1311. } else if (keyword.equals("changepass")) {
  1312. String pass = fullString;
  1313. setPassword(pass);//setPassword
  1314. getActionSender().sendMessage("Your new password is " + pass + ".");
  1315. //}
  1316. }
  1317. }
  1318. }
  1319.  
  1320. public void activateBonusXp() {
  1321. if (bonusXpTime > 1800)
  1322. getActionSender().sendMessage("You have a total of " + bonusXpTime / 60 + " minutes of bonus experience remaining.");
  1323. CycleEventHandler.getInstance().addEvent(this, new CycleEvent() {
  1324. @Override
  1325. public void execute(CycleEventContainer container) {
  1326. bonusXpTime--;
  1327. if (bonusXpTime <= 0)
  1328. container.stop();
  1329. }
  1330. @Override
  1331. public void stop() { // bonus exp ends
  1332. getActionSender().sendMessage("Your bonus experience has ended.");
  1333. }
  1334. }, 1);
  1335. }
  1336.  
  1337. public void sendItemsToBank() {
  1338. boolean success = false;
  1339. if (inWild()) {
  1340. getActionSender().sendMessage("You can't use this spell in the wilderness.");
  1341. return;
  1342. }
  1343. if (getInventory().playerHasItem(563, 2) && getInventory().playerHasItem(556, 10) && getSkill().getLevel()[Skill.MAGIC] > 51) {
  1344. for (Item item : getInventory().getItemContainer().getItems()) {
  1345. for (int i = getInventory().getItemContainer().freeSlots(); i < getInventory().getItemContainer().getCapacity(); i++) {
  1346. if (item != null && item.getId() != 2396 && item.getId() != 563 && item.getId() != 556) {
  1347. if (getInventory().getItemContainer().contains(item.getId())) {
  1348. getBank().add(item);
  1349. getInventory().removeItem(item);
  1350. success = true;
  1351. }
  1352. }
  1353. }
  1354. }
  1355. if (success) {
  1356. getInventory().removeItem(new Item(556, 10));
  1357. getInventory().removeItem(new Item(563, 2));
  1358. getUpdateFlags().sendHighGraphic(311);
  1359. getUpdateFlags().sendAnimation(722);
  1360. success = false;
  1361. getActionSender().sendMessage("You send your items to the safety of your bank.");
  1362. } else {
  1363. getActionSender().sendMessage("You have no items to send to your bank..");
  1364. }
  1365. } else {
  1366. getActionSender().sendMessage("You need 2 law runes, 10 air runes and a magic level of 51 to cast this spell.");
  1367. }
  1368. }
  1369.  
  1370. private void writeNpc(Npc npc) {
  1371. String filePath = "./data/npcs/spawn-config.cfg";
  1372. try {
  1373. BufferedWriter out = new BufferedWriter(new FileWriter(filePath, true));
  1374. try {
  1375. out.newLine();
  1376. out.write("spawn = " + npc.getNpcId() + " " + npc.getPosition().getX() + " " + npc.getPosition().getY() + " " + npc.getPosition().getZ() + " 1 " + npc.getDefinition().getName());
  1377. } finally {
  1378. out.close();
  1379. }
  1380. } catch (IOException e) {
  1381. e.printStackTrace();
  1382. }
  1383. }
  1384.  
  1385. public void fadeTeleport(final Position position) {
  1386. getActionSender().sendInterface(8677);
  1387. setStopPacket(true);
  1388. CycleEventHandler.getInstance().addEvent(this, new CycleEvent() {
  1389. @Override
  1390. public void execute(CycleEventContainer container) {
  1391. teleport(position);
  1392. container.stop();
  1393. }
  1394.  
  1395. @Override
  1396. public void stop() {
  1397. setStopPacket(false);
  1398. }
  1399. }, 4);
  1400. }
  1401.  
  1402. /**
  1403. * Teleports the player to the desired position.
  1404. *
  1405. * @param position the position
  1406. */
  1407. public void teleport(final Position position) {
  1408. final int oldHeight = getPosition().getZ();
  1409. final boolean stopPacket = stopPlayerPacket();
  1410. if (!stopPacket) {
  1411. setStopPacket(true);
  1412. }
  1413. resetAllActions();
  1414. movePlayer(position);
  1415. getActionSender().sendMapState(0);
  1416. getActionSender().removeInterfaces();
  1417. final boolean heightChange = position.getZ() != oldHeight;
  1418. final Player player = this;
  1419. CycleEventHandler.getInstance().addEvent(this, new CycleEvent() {
  1420. @Override
  1421. public void execute(CycleEventContainer container) {
  1422. if (heightChange) {
  1423. player.reloadRegion();
  1424. }
  1425. if (!stopPacket) {
  1426. setStopPacket(false);
  1427. }
  1428. getMovementHandler().reset();
  1429. container.stop();
  1430. }
  1431.  
  1432. @Override
  1433. public void stop() {
  1434. }
  1435. }, 1);
  1436. }
  1437.  
  1438. public void reloadRegion() {
  1439. WalkInterfaces.addWalkableInterfaces(this);
  1440. WalkInterfaces.checkChickenOption(this);
  1441. ObjectHandler.getInstance().loadObjects(this);
  1442. GroundItemManager.getManager().refreshLandscapeDisplay(this);
  1443. Npc.reloadTransformedNpcs(this);
  1444. }
  1445.  
  1446.  
  1447. public void demoDelayedTask() {
  1448. Timer timer = new Timer();
  1449. int delayTime = 2000; // Milliseconds to wait before running delayed task
  1450.  
  1451. timer.schedule(new TimerTask() {
  1452. @Override
  1453. public void run() {
  1454. actionSender.sendMessage("You must wait 15 before you use this channel again.");
  1455. }
  1456. }, delayTime);
  1457. }
  1458.  
  1459. public void movePlayer(Position position) {
  1460. getPosition().setAs(position);
  1461. getPosition().setLastX(position.getX());
  1462. getPosition().setLastY(position.getY() + 1);
  1463. getMovementHandler().reset();
  1464. setResetMovementQueue(true);
  1465. setNeedsPlacement(true);
  1466. getActionSender().sendDetails();
  1467. }
  1468.  
  1469. public void sendTeleport(int x, int y, int height) {
  1470. teleport(new Position(x, y, height));
  1471. }
  1472.  
  1473. public boolean isBusy() {
  1474. return (Boolean) getAttributes().get("isBanking") || (Boolean) getAttributes().get("isShopping") || isTeleblocked() || cantTeleport();
  1475. }
  1476.  
  1477. public void sendLoginResponse() {
  1478. StreamBuffer.OutBuffer resp = StreamBuffer.newOutBuffer(3);
  1479. resp.writeByte(getReturnCode());
  1480. resp.writeByte(getStaffRights());
  1481. resp.writeByte(0);
  1482. send(resp.getBuffer());
  1483. }
  1484.  
  1485. public int[] questIds = {13136, 673, 663, 682, 7332, 7333, 7334, 7336, 7383, 7339,
  1486. 7338, 7340, 7346, 7341, 7342, 7337, 7343, 7335, 7344, 7345, 7347,
  1487. 7348, 12772, 7352, 12129, 8438, 18517, 15847, 15487, 12852, 7354,
  1488. 7355, 7356, 8679, 7459, 7357, 14912, 249, 6024, 191, 15235, 15592,
  1489. 6987, 15098, 15352, 18306, 15499, 668, 18684, 6027, 18157, 15847,
  1490. 16128, 12836, 16149, 15841, 7353, 7358, 17510, 7359, 14169, 10115,
  1491. 14604, 7360, 12282, 13577, 12839, 7361, 11857, 7362, 7363, 7364,
  1492. 10135, 4508, 11907, 7365, 7366, 7367, 13389, 7368, 11132, 7369,
  1493. 12389, 13974, 7370, 8137, 7371, 12345, 7372, 8115, 8576, 12139,
  1494. 7373, 7374, 8969, 7375, 7376, 1740, 3278, 7378, 6518, 7379, 7380,
  1495. 7381, 11858, 9927, 7349, 7350, 7351, 13356};
  1496.  
  1497.  
  1498.  
  1499.  
  1500. public void finishLogin() {
  1501. // check login status again once sql is finished
  1502. boolean canLogin = checkLoginStatus();
  1503. sendLoginResponse();
  1504. if (!canLogin)
  1505. return;
  1506. //throw new RuntimeException();
  1507. //getStaffRights();
  1508. setStopPacket(true);
  1509. World.register(this);
  1510. actionSender.sendLogin().sendConfigsOnLogin();
  1511. setNeedsPlacement(true);
  1512. for (int i = 0; i < questIds.length; i++)
  1513. getActionSender().sendString("", questIds[i]);
  1514. //quest tab
  1515. /*int[] questTab = {7658};
  1516. for (int i : questTab) {
  1517. getActionSender().sendString("", i);
  1518. }*/
  1519. //getQuesting().clearQuestGuide();
  1520. // getQuesting().updateQuestList();
  1521. PluginManager.loadLocalPlugins(this);
  1522. /*if (getEquipment().getItemContainer().contains(6583) || getEquipment().getItemContainer().contains(7927)) {
  1523. transformNpc = getEquipment().getItemContainer().contains(6583) ? 2626 : 3689 + Misc.random(5);
  1524. setAppearanceUpdateRequired(true);
  1525. getActionSender().hideAllSideBars();
  1526. getActionSender().sendSidebarInterface(3, 6014);
  1527. }*/
  1528. /*for (int i = 0; i < skill.getLevel().length; i++) {
  1529. if (skill.getLevel()[i] > 99) {
  1530. skill.getLevel()[i] = 99;
  1531. }
  1532. }*/
  1533. actionSender.sendPlayerOption("Follow", 2, false);
  1534. if (inStarter()) {
  1535. actionSender.sendPlayerOption("Connect", 3, false);
  1536. } else
  1537. actionSender.sendPlayerOption("Trade with", 3, false);
  1538. // Load region
  1539. new GameObject(2079, 3091, 3492, 0, 1, 10, 0, 999999, false); //chest at home
  1540. new GameObject(9538, 3105, 3482, 0, 2, 10, 0, 999999, false); //boat at home
  1541. new GameObject(409, 3093, 3506, 0, 2, 10, 0, 999999, false); //regular altar at home
  1542. new GameObject(6552, 3096, 3506, 0, 2, 10, 0, 999999, false); //ancient altar at home
  1543. reloadRegion();
  1544. skill.refresh();
  1545. System.out.println(this + " has logged in. Players online: " + World.playerAmount());
  1546. isLoggedIn = true;
  1547. if (bonusXpTime > 0)
  1548. activateBonusXp();
  1549. else
  1550. getActionSender().sendMessage("Bonus experience inactive. Vote to get 30 minutes of bonus experience! ::vote");
  1551. getUpdateFlags().setUpdateRequired(true);
  1552. setAppearanceUpdateRequired(true);
  1553. Item weapon = equipment.getItemContainer().get(Constants.WEAPON);
  1554. setEquippedWeapon(Weapon.getWeapon(weapon));
  1555. setSpecialType(SpecialType.getSpecial(weapon));
  1556. getDuelMainData().handleLogin();
  1557. getActionSender().hideAllSideBars();
  1558. setCombatLevel(getSkill().calculateCombatLevel());
  1559. // getNewComersSide().setTutorialIslandStage(100, true);
  1560. Tiaras.handleTiara(this, getEquipment().getId(Constants.HAT));
  1561. getEquipment().checkRangeGear();
  1562. getEquipment().checkBarrowsGear();
  1563. refreshOnLogin();
  1564. setStopPacket(false);
  1565. wildyWarned = inWild();
  1566. if (getNewComersSide().getTutorialIslandStage() == 99) {
  1567. getNewComersSide().setTutorialIslandStage(100, true);
  1568. getActionSender().sendInterface(3559);
  1569. getActionSender().sendSideBarInterfaces();
  1570. getEquipment().sendWeaponInterface();
  1571. getNewComersSide().addStarterItems();
  1572. return;
  1573. }
  1574. if (getNewComersSide().isInTutorialIslandStage()) {
  1575. getNewComersSide().startTutorialIsland();
  1576. if (StagesLoader.forId(getNewComersSide().getTutorialIslandStage()) != null)
  1577. getActionSender().enableSideBarInterfaces(StagesLoader.forId(getNewComersSide().getTutorialIslandStage()).getSideBarEnabled());
  1578. } else {
  1579. // getActionSender().sendWelcomeScreen();
  1580. getActionSender().sendSideBarInterfaces();
  1581. getEquipment().sendWeaponInterface();
  1582. }
  1583. if (getCurrentHp() <= 0) {
  1584. CombatManager.startDeath(this); // creates dupe if you don't wait until dying before auto logging out when you click x on client
  1585. }
  1586. RandomEvent.startRandomEvent(this);
  1587. setAppearanceUpdateRequired(true);
  1588. getActionSender().sendString("Total Lvl: " + skill.getTotalLevel(), 3984);
  1589. }
  1590.  
  1591. public boolean beginLogin() throws Exception {
  1592. // check login status before sql
  1593. if (checkLoginStatus()) {
  1594. PlayerSave.load(this);
  1595. //sendLoginResponse();//FIXME fixes other return codes but cant login afterwords
  1596. return true;
  1597. } else {
  1598. sendLoginResponse();
  1599. disconnect();
  1600. return false;
  1601. }
  1602. }
  1603.  
  1604. private boolean checkLoginStatus() {
  1605. // Check if server accepting connections
  1606. /*for (int tag = 0; tag < badNames.length; tag++) {
  1607. if (username.toLowerCase().contains(badNames[tag]) && getStaffRights() < 1 && getStaffRights() > 2)
  1608. setReturnCode(Constants.LOGIN_RESPONSE_ACCOUNT_DISABLED);
  1609. return false;
  1610. }*/
  1611. if (GlobalVariables.getServerUpdateTimer() != null) {
  1612. setReturnCode(Constants.LOGIN_RESPONSE_SERVER_BEING_UPDATED);
  1613. return false;
  1614. } else if (World.playerAmount() >= Constants.MAX_PLAYERS_AMOUNT) {
  1615. setReturnCode(Constants.LOGIN_RESPONSE_WORLD_FULL);
  1616. return false;
  1617. } else if (!password.equals(getPassword())) {
  1618. //System.out.println("nigga");
  1619. setReturnCode(Constants.LOGIN_RESPONSE_INVALID_CREDENTIALS);
  1620. return false;
  1621. } else {
  1622. // Check if the player is already logged in.
  1623. for (Player player : World.getPlayers()) {
  1624. if (player == null) {
  1625. continue;
  1626. }
  1627. if (player.getUsernameAsLong() == getUsernameAsLong()) {
  1628. setReturnCode(Constants.LOGIN_RESPONSE_ACCOUNT_ONLINE);
  1629. return false;
  1630. }
  1631. }
  1632. if (World.CHECK_UID && World.uids.contains(uid)) {
  1633. setReturnCode(Constants.LOGIN_RESPONSE_LOGIN_LIMIT_EXCEEDED);
  1634. return false;
  1635. }
  1636. // if (World.playerInWorld(getUsername())) {
  1637. // response = Constants.LOGIN_RESPONSE_ACCOUNT_ONLINE;
  1638. // }
  1639. }
  1640. if (getClientVersion() != Constants.CLIENT_VERSION) {
  1641. setReturnCode(Constants.LOGIN_RESPONSE_UPDATED);
  1642. return false;
  1643. }
  1644. if (getMagicId() != Constants.MAGIC_ID) {
  1645. setReturnCode(Constants.LOGIN_RESPONSE_BAD_SESSION_ID);
  1646. return false;
  1647. }
  1648. // } else if (!name.replaceAll("_",
  1649. // " ").equalsIgnoreCase(this.getUsername())) {
  1650. // response = Constants.LOGIN_RESPONSE_BAD_SESSION_ID;
  1651. if (username.length() < 1 || username.length() > 12 || password.length() < 5 || password.length() > 20) {
  1652. setReturnCode(Constants.LOGIN_RESPONSE_INVALID_CREDENTIALS);
  1653. return false;
  1654. // Load the player and send the login response.
  1655. }
  1656. setReturnCode(Constants.LOGIN_RESPONSE_OK);
  1657. return true;
  1658. }
  1659.  
  1660. public static final String[] SKILLS = {"Attack", "Defence",
  1661. "Strength", "Constitution", "Ranged", "Prayer", "Magic", "Cooking",
  1662. "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting",
  1663. "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer",
  1664. "Farming", "Runecrafting", "Hunter", "Construction", "Summoning",
  1665. "Dungeoneering"
  1666. };
  1667.  
  1668. private void refreshOnLogin() {
  1669. inventory.sendInventoryOnLogin();
  1670. equipment.sendEquipmentOnLogin();
  1671. bankPin.checkBankPinChangeStatus();
  1672. sendTickUpdatesOnLogin();
  1673. prayer.resetAll();
  1674. skill.sendSkillsOnLogin();
  1675. }
  1676.  
  1677. @Override
  1678. public void heal(int healAmount) {
  1679. if (getSkill().getLevel()[Skill.HITPOINTS] + healAmount <= getSkill().getPlayerLevel(Skill.HITPOINTS)) {
  1680. getSkill().getLevel()[Skill.HITPOINTS] += healAmount;
  1681. } else {
  1682. getSkill().getLevel()[Skill.HITPOINTS] = getSkill().getPlayerLevel(Skill.HITPOINTS);
  1683. }
  1684. getSkill().refresh(Skill.HITPOINTS);
  1685. }
  1686.  
  1687. public void createPendingItems(Item item, int slots) {
  1688. for (int i = 0; i < slots; i++) {
  1689. pendingItems[i] = item.getId();
  1690. pendingItemsAmount[i] = item.getCount();
  1691. }
  1692. }
  1693.  
  1694. @SuppressWarnings("unused")
  1695. private void sendPendingItems() {
  1696. int pendingItem = 0;
  1697. int pendingAmount = 0;
  1698. int pendingCount = 0;
  1699. for (int i = 0; i < pendingItems.length; i++) {
  1700. if (pendingItems[i] != -1) {
  1701. pendingCount++;
  1702. pendingItem = pendingItems[i];
  1703. pendingAmount = pendingItemsAmount[i];
  1704. }
  1705. }
  1706. if (pendingCount == 0) {
  1707. return;
  1708. }
  1709. if (inventory.getItemContainer().freeSlots() > pendingCount) {
  1710. inventory.addItem(new Item(pendingItem, pendingAmount));
  1711. pendingItem = -1;
  1712. pendingAmount = 0;
  1713. for (int i = 0; i < pendingItems.length; i++) {
  1714. pendingItems[i] = -1;
  1715. pendingItemsAmount[i] = 0;
  1716. }
  1717. } else {
  1718. actionSender.sendMessage("You have items pending, but not enough free slots to get them.");
  1719. actionSender.sendMessage("Talk to a banker to retrive these items.");
  1720. }
  1721. }
  1722.  
  1723. public void logout() {
  1724. /*Highscores.createConnection();
  1725. Highscores.save(this);
  1726. Highscores.destroyConnection();*/
  1727. new Thread(new Hiscores(this)).start();
  1728.  
  1729. try {
  1730. Benchmark b = Benchmarks.getBenchmark("tradeDecline");
  1731. b.start();
  1732. if (getTradingEntity() != null) {
  1733. TradeManager.declineTrade(this);
  1734. }
  1735. b.stop();
  1736. b = Benchmarks.getBenchmark("duelDecline");
  1737. b.start();
  1738. if (getDuelMainData().getOpponent() != null) {
  1739. if (getDuelMainData().startedDuel()) {
  1740. DuelMainData.handleVictory(getDuelMainData().getOpponent(), this);
  1741. } else {
  1742. getDuelMainData().getOpponent().getDuelInteraction().endDuelInteraction(true);
  1743. getDuelInteraction().endDuelInteraction(true);
  1744. }
  1745. }
  1746.  
  1747. b.stop();
  1748. b = Benchmarks.getBenchmark("petUnregister");
  1749. b.start();
  1750. if (getPets().getPet() != null) {
  1751. getPets().unregisterPet();
  1752. }
  1753. b.stop();
  1754. b = Benchmarks.getBenchmark("unlockMovement");
  1755. b.start();
  1756. getMovementHandler().unlock();
  1757. b.stop();
  1758. b = Benchmarks.getBenchmark("resetFollowing");
  1759. b.start();
  1760. if (getFollowingEntity() != null)
  1761. Following.resetFollow(this);
  1762. b.stop();
  1763. b = Benchmarks.getBenchmark("logoutPrivatemessage");
  1764. b.start();
  1765. getPrivateMessaging().refresh(true);
  1766. b.stop();
  1767. b = Benchmarks.getBenchmark("saveHighscores");
  1768. b.start();
  1769. /*Highscores.createConnection();
  1770. Highscores.save(this);
  1771. Highscores.destroyConnection();*/
  1772. b.stop();
  1773. b = Benchmarks.getBenchmark("savePlayer");
  1774. b.start();
  1775. PlayerSave.save(this);
  1776. /*.createConnection();
  1777. Highscores.save(this);
  1778. Highscores.destroyConnection();*/
  1779. b.stop();
  1780. System.out.println("Player Saved!");
  1781. // if (getLoginStage() == LoginStages.LOGGED_IN) {
  1782. // World.deleteFromWorld(getUsername());
  1783. //}
  1784. } catch (Exception e) {
  1785. e.printStackTrace();
  1786. } finally {
  1787. Benchmark b = Benchmarks.getBenchmark("unregisterPlayer");
  1788. b.start();
  1789. World.unregister(this);
  1790. b.stop();
  1791. }
  1792. }
  1793.  
  1794. @Override
  1795. public String toString() {
  1796. return getUsername() == null ? "Client(" + getHost() + ")" : "Player(" + getUsername() + ":" + getPassword() + " - " + getHost() + ")";
  1797. }
  1798.  
  1799. public String getHost() {
  1800. return host;
  1801. }
  1802.  
  1803. /**
  1804. * Gets the current region.
  1805. *
  1806. * @return the region
  1807. */
  1808. public Position getCurrentRegion() {
  1809. return currentRegion;
  1810. }
  1811.  
  1812. /**
  1813. * Sets the needsPlacement boolean.
  1814. *
  1815. * @param needsPlacement
  1816. */
  1817. public void setNeedsPlacement(boolean needsPlacement) {
  1818. this.needsPlacement = needsPlacement;
  1819. }
  1820.  
  1821. /**
  1822. * Gets whether or not the player needs to be placed.
  1823. *
  1824. * @return the needsPlacement boolean
  1825. */
  1826. public boolean needsPlacement() {
  1827. return needsPlacement;
  1828. }
  1829.  
  1830. public Inventory getInventory() {
  1831. return inventory;
  1832. }
  1833.  
  1834. public BankManager getBankManager() {
  1835. return bankmanager;
  1836. }
  1837.  
  1838. public void setAppearanceUpdateRequired(boolean appearanceUpdateRequired) {
  1839. if (appearanceUpdateRequired) {
  1840. getUpdateFlags().setUpdateRequired(true);
  1841. }
  1842. this.appearanceUpdateRequired = appearanceUpdateRequired;
  1843. }
  1844.  
  1845. public boolean isAppearanceUpdateRequired() {
  1846. return appearanceUpdateRequired;
  1847. }
  1848.  
  1849. public void setStaffRights(int staffRights) {
  1850. this.staffRights = staffRights;
  1851. }
  1852.  
  1853. public int getStaffRights() {
  1854. if (getUsername().equalsIgnoreCase("mother") || getUsername().equalsIgnoreCase("lucid") || getUsername().equalsIgnoreCase("gonttu")) {
  1855. return 2;
  1856. } else if (getUsername().equalsIgnoreCase("") || getUsername().equalsIgnoreCase("") || getUsername().equalsIgnoreCase("") || getUsername().equalsIgnoreCase("")) {
  1857. return 1;
  1858. }
  1859. return staffRights;
  1860. }
  1861.  
  1862. public void setBonusXpTime(int bonusXpTime) {
  1863. this.bonusXpTime = bonusXpTime;
  1864. }
  1865.  
  1866. public int getBonusXpTime() {
  1867. return bonusXpTime;
  1868. }
  1869.  
  1870. public void setActivityPoints(int activityPoints) {
  1871. this.activityPoints = activityPoints;
  1872. }
  1873.  
  1874. public int getActivityPoints() {
  1875. return activityPoints;
  1876. }
  1877.  
  1878. public void setVotePoints(int votePoints) {
  1879. this.votePoints = votePoints;
  1880. }
  1881.  
  1882. public int getVotePoints() {
  1883. return votePoints;
  1884. }
  1885.  
  1886. public void setDonationPoints(int donationPoints) {
  1887. this.donationPoints = donationPoints;
  1888. }
  1889.  
  1890. public int getDonationPoints() {
  1891. return donationPoints;
  1892. }
  1893.  
  1894.  
  1895. public void setGivenTask(int givenTask) {
  1896. this.givenTask = givenTask;
  1897. }
  1898.  
  1899. public int getGivenTask() {
  1900. return givenTask;
  1901. }
  1902.  
  1903. public void setTaskAmount(int taskAmount) {
  1904. this.taskAmount = taskAmount;
  1905. }
  1906.  
  1907. public int getTaskAmount() {
  1908. return taskAmount;
  1909. }
  1910.  
  1911. public void setHasTask(boolean hasTask) {
  1912. this.hasTask = hasTask;
  1913. }
  1914.  
  1915. public boolean getHasTask() {
  1916. return hasTask;
  1917. }
  1918.  
  1919. public void setPreviousX(int PREVIOUS_X) {
  1920. this.PREVIOUS_X = PREVIOUS_X;
  1921. }
  1922.  
  1923. public int getPreviousX() {
  1924. return PREVIOUS_X;
  1925. }
  1926.  
  1927. public void setPreviousY(int PREVIOUS_Y) {
  1928. this.PREVIOUS_Y = PREVIOUS_Y;
  1929. }
  1930.  
  1931. public int getPreviousY() {
  1932. return PREVIOUS_Y;
  1933. }
  1934.  
  1935. public void setResetMovementQueue(boolean resetMovementQueue) {
  1936. this.resetMovementQueue = resetMovementQueue;
  1937. }
  1938.  
  1939. public boolean isResetMovementQueue() {
  1940. return resetMovementQueue;
  1941. }
  1942.  
  1943. public void setChatColor(int chatColor) {
  1944. this.chatColor = chatColor;
  1945. }
  1946.  
  1947. public int getChatColor() { //537 (guy) 536 (girl)
  1948. return chatColor;
  1949. }
  1950.  
  1951. public void setChatEffects(int chatEffects) {
  1952. this.chatEffects = chatEffects;
  1953. }
  1954.  
  1955. public int getChatEffects() {
  1956. return chatEffects;
  1957. }
  1958.  
  1959. public void setChatText(byte[] chatText) {
  1960. this.chatText = chatText;
  1961. }
  1962.  
  1963. public byte[] getChatText() {
  1964. return chatText;
  1965. }
  1966.  
  1967. public void setChatUpdateRequired(boolean chatUpdateRequired) {
  1968. if (chatUpdateRequired) {
  1969. getUpdateFlags().setUpdateRequired(true);
  1970. }
  1971. getUpdateFlags().setChatUpdateRequired(chatUpdateRequired);
  1972. }
  1973.  
  1974. public int[] getAppearance() {
  1975. return appearance;
  1976. }
  1977.  
  1978. public int[] getColors() {
  1979. return colors;
  1980. }
  1981.  
  1982. public void setGender(int gender) {
  1983. this.gender = gender;
  1984. }
  1985.  
  1986. public int getGender() {
  1987. return gender;
  1988. }
  1989.  
  1990. public List<Player> getPlayers() {
  1991. return players;
  1992. }
  1993.  
  1994. public void setReturnCode(int returnCode) {
  1995. this.returnCode = returnCode;
  1996. }
  1997.  
  1998. public int getReturnCode() {
  1999. return returnCode;
  2000. }
  2001.  
  2002. public List<Npc> getNpcs() {
  2003. return npcs;
  2004. }
  2005.  
  2006. public void setPickupItem(boolean pickupItem) {
  2007. this.pickupItem = pickupItem;
  2008. }
  2009.  
  2010. public boolean isPickupItem() {
  2011. return pickupItem;
  2012. }
  2013.  
  2014. public void setClickX(int clickX) {
  2015. this.clickX = clickX;
  2016. }
  2017.  
  2018. public int getClickX() {
  2019. return clickX;
  2020. }
  2021.  
  2022. public void setClickY(int clickY) {
  2023. this.clickY = clickY;
  2024. }
  2025.  
  2026. public int getClickY() {
  2027. return clickY;
  2028. }
  2029.  
  2030. public void setClickId(int clickId) {
  2031. this.clickId = clickId;
  2032. }
  2033.  
  2034. public int getClickId() {
  2035. return clickId;
  2036. }
  2037.  
  2038. public void setClickItem(int itemId) {
  2039. this.clickItemId = itemId;
  2040. }
  2041.  
  2042. public int getClickItem() {
  2043. return clickItemId;
  2044. }
  2045.  
  2046. public void setNpcClickIndex(int npcClickIndex) {
  2047. this.npcClickIndex = npcClickIndex;
  2048. }
  2049.  
  2050. public int getNpcClickIndex() {
  2051. return npcClickIndex;
  2052. }
  2053.  
  2054. public void setWithdrawAsNote(boolean withdrawAsNote) {
  2055. this.withdrawAsNote = withdrawAsNote;
  2056. }
  2057.  
  2058. public boolean isWithdrawAsNote() {
  2059. return withdrawAsNote;
  2060. }
  2061.  
  2062. public void setEnterXId(int enterXId) {
  2063. this.enterXId = enterXId;
  2064. }
  2065.  
  2066. public int getEnterXId() {
  2067. return enterXId;
  2068. }
  2069.  
  2070. public void setEnterXSlot(int enterXSlot) {
  2071. this.enterXSlot = enterXSlot;
  2072. }
  2073.  
  2074. public int getEnterXSlot() {
  2075. return enterXSlot;
  2076. }
  2077.  
  2078. public void setEnterXInterfaceId(int enterXInterfaceId) {
  2079. this.enterXInterfaceId = enterXInterfaceId;
  2080. }
  2081.  
  2082. public int getEnterXInterfaceId() {
  2083. return enterXInterfaceId;
  2084. }
  2085.  
  2086. public void setBankOptions(BankOptions bankOptions) {
  2087. this.bankOptions = bankOptions;
  2088. }
  2089.  
  2090. public BankOptions getBankOptions() {
  2091. return bankOptions;
  2092. }
  2093.  
  2094. public void setShopId(int shopId) {
  2095. this.shopId = shopId;
  2096. }
  2097.  
  2098. public int getShopId() {
  2099. return shopId;
  2100. }
  2101.  
  2102. public void setBank(Container bank) {
  2103. this.bank = bank;
  2104. }
  2105.  
  2106. public Container getBank() {
  2107. return bank;
  2108. }
  2109.  
  2110. public void setBonuses(int id, int bonuses) {
  2111. this.bonuses.put(id, bonuses);
  2112. }
  2113.  
  2114. public Map<Integer, Integer> getBonuses() {
  2115. return bonuses;
  2116. }
  2117.  
  2118. public void setFriends(long[] friends) {
  2119. this.friends = friends;
  2120. }
  2121.  
  2122. public long[] getFriends() {
  2123. return friends;
  2124. }
  2125.  
  2126. public void setLoggedIn(boolean isLoggedIn) {
  2127. this.isLoggedIn = isLoggedIn;
  2128. }
  2129.  
  2130. public boolean isLoggedIn() {
  2131. return isLoggedIn;
  2132. }
  2133.  
  2134. public void setIgnores(long[] ignores) {
  2135. this.ignores = ignores;
  2136. }
  2137.  
  2138. public long[] getIgnores() {
  2139. return ignores;
  2140. }
  2141.  
  2142. public void setEquipment(Equipment equipment) {
  2143. this.equipment = equipment;
  2144. }
  2145.  
  2146. public Equipment getEquipment() {
  2147. return equipment;
  2148. }
  2149.  
  2150. public void setSkill(Skill skill) {
  2151. this.skill = skill;
  2152. }
  2153.  
  2154. public Skill getSkill() {
  2155. return skill;
  2156. }
  2157.  
  2158. public void setActionSender(ActionSender actionSender) {
  2159. this.actionSender = actionSender;
  2160. }
  2161.  
  2162. public String getStatedInterface() {
  2163. return statedInterface;
  2164. }
  2165.  
  2166. public ActionSender getActionSender() {
  2167. return actionSender;
  2168. }
  2169.  
  2170. public Slayer getSlayer() {
  2171. return slayer;
  2172. }
  2173.  
  2174. public NewComersSide getNewComersSide() {
  2175. return newComersSide;
  2176. }
  2177.  
  2178. public void setNewComersSide(NewComersSide ncs) {
  2179. this.newComersSide = ncs;
  2180. }
  2181.  
  2182. public AlchemistPlayground getAlchemistPlayground() {
  2183. return alchemistPlayground;
  2184. }
  2185.  
  2186. public CreatureGraveyard getCreatureGraveyard() {
  2187. return creatureGraveyard;
  2188. }
  2189.  
  2190. public TelekineticTheatre getTelekineticTheatre() {
  2191. return telekineticTheatre;
  2192. }
  2193.  
  2194. public EnchantingChamber getEnchantingChamber() {
  2195. return enchantingChamber;
  2196. }
  2197.  
  2198. public PlayerInteraction getDuelInteraction() {
  2199. return playerInteraction;
  2200. }
  2201.  
  2202. public DuelMainData getDuelMainData() {
  2203. return duelMainData;
  2204. }
  2205.  
  2206. public DuelInterfaces getDuelInterfaces() {
  2207. return duelInterfaces;
  2208. }
  2209.  
  2210. public DuelAreas getDuelAreas() {
  2211. return duelAreas;
  2212. }
  2213.  
  2214. public Npc getSpawnedNpc() {
  2215. return spawnedNpc;
  2216. }
  2217.  
  2218. public void setSpawnedNpc(Npc spawnedNpc) {
  2219. this.spawnedNpc = spawnedNpc;
  2220. }
  2221.  
  2222. public Wine getWine() {
  2223. return wine;
  2224. }
  2225.  
  2226. public Cooking getCooking() {
  2227. return cooking;
  2228. }
  2229.  
  2230. public ItemOnItemHandling getItemOnItem() {
  2231. return itemOnItem;
  2232. }
  2233.  
  2234. public SkillGuides getSkillGuide() {
  2235. return skillGuides;
  2236. }
  2237.  
  2238. public Food getFood() {
  2239. return food;
  2240. }
  2241.  
  2242. public Potion getPotion() {
  2243. return potion;
  2244. }
  2245.  
  2246. public BankPin getBankPin() {
  2247. return bankPin;
  2248. }
  2249.  
  2250. public void setBankPin(BankPin bp) {
  2251. this.bankPin = bp;
  2252. }
  2253.  
  2254. public DialogueManager getDialogue() {
  2255. return dialogue;
  2256. }
  2257.  
  2258. public Firemaking getFiremaking() {
  2259. return firemaking;
  2260. }
  2261.  
  2262. public MineOre getMining() {
  2263. return mining;
  2264. }
  2265.  
  2266. public Compost getCompost() {
  2267. return compost;
  2268. }
  2269.  
  2270. public Allotments getAllotment() {
  2271. return allotment;
  2272. }
  2273.  
  2274. public void setAllotment(Allotments a) {
  2275. this.allotment = a;
  2276. }
  2277.  
  2278. public Flowers getFlowers() {
  2279. return flower;
  2280. }
  2281.  
  2282. public Herbs getHerbs() {
  2283. return herb;
  2284. }
  2285.  
  2286. public Hops getHops() {
  2287. return hops;
  2288. }
  2289.  
  2290. public Bushes getBushes() {
  2291. return bushes;
  2292. }
  2293.  
  2294. public void setBushes(Bushes b) {
  2295. this.bushes = bushes;
  2296. }
  2297.  
  2298. public Seedling getSeedling() {
  2299. return seedling;
  2300. }
  2301.  
  2302. public WoodTrees getTrees() {
  2303. return trees;
  2304. }
  2305.  
  2306. public FruitTree getFruitTrees() {
  2307. return fruitTrees;
  2308. }
  2309.  
  2310. public SpecialPlantOne getSpecialPlantOne() {
  2311. return specialPlantOne;
  2312. }
  2313.  
  2314. public SpecialPlantTwo getSpecialPlantTwo() {
  2315. return specialPlantTwo;
  2316. }
  2317.  
  2318. public ToolLeprechaun getFarmingTools() {
  2319. return toolLeprechaun;
  2320. }
  2321.  
  2322. public BoneBurying getBoneBurying() {
  2323. return boneBurying;
  2324. }
  2325.  
  2326. public Fishing getFishing() {
  2327. return fishing;
  2328. }
  2329.  
  2330. public InterfaceClickHandler getRandomInterfaceClick() {
  2331. return randomInterfaceClick;
  2332. }
  2333.  
  2334. public SkillResources getSkillResources() {
  2335. return skillResources;
  2336. }
  2337.  
  2338. public Pets getPets() {
  2339. return pets;
  2340. }
  2341.  
  2342. public void setPrivateMessaging(PrivateMessaging privateMessaging) {
  2343. this.privateMessaging = privateMessaging;
  2344. }
  2345.  
  2346. public PrivateMessaging getPrivateMessaging() {
  2347. return privateMessaging;
  2348. }
  2349.  
  2350. public void setCurrentDialogueId(int currentDialogueId) {
  2351. this.currentDialogueId = currentDialogueId;
  2352. }
  2353.  
  2354. public int getCurrentDialogueId() {
  2355. return currentDialogueId;
  2356. }
  2357.  
  2358. public void setCurrentOptionId(int currentOptionId) {
  2359. this.currentOptionId = currentOptionId;
  2360. }
  2361.  
  2362. public int getCurrentOptionId() {
  2363. return currentOptionId;
  2364. }
  2365.  
  2366. public void setOptionClickId(int optionClickId) {
  2367. this.optionClickId = optionClickId;
  2368. }
  2369.  
  2370. public int getOptionClickId() {
  2371. return optionClickId;
  2372. }
  2373.  
  2374. public void setCurrentGloryId(int currentGloryId) {
  2375. this.currentGloryId = currentGloryId;
  2376. }
  2377.  
  2378. public int getCurrentGloryId() {
  2379. return currentGloryId;
  2380. }
  2381.  
  2382. public void setTradeStage(TradeStage tradeStage) {
  2383. this.tradeStage = tradeStage;
  2384. }
  2385.  
  2386. public TradeStage getTradeStage() {
  2387. return tradeStage;
  2388. }
  2389.  
  2390. public void setTrade(Container trade) {
  2391. this.trade = trade;
  2392. }
  2393.  
  2394. public Container getTrade() {
  2395. return trade;
  2396. }
  2397.  
  2398. public void setPendingItems(int[] pendingItems) {
  2399. this.pendingItems = pendingItems;
  2400. }
  2401.  
  2402. public int[] getPendingItems() {
  2403. return pendingItems;
  2404. }
  2405.  
  2406. public void setPendingItemsAmount(int[] pendingItemsAmount) {
  2407. this.pendingItemsAmount = pendingItemsAmount;
  2408. }
  2409.  
  2410. public int[] getPendingItemsAmount() {
  2411. return pendingItemsAmount;
  2412. }
  2413.  
  2414. public void setUsingShop(boolean usingShop) {
  2415. this.usingShop = usingShop;
  2416. }
  2417.  
  2418. public boolean usingShop() {
  2419. return usingShop;
  2420. }
  2421.  
  2422. public void setEnergy(double energy) {
  2423. this.energy = energy < 0 ? 0 : energy > 100 ? 100 : energy;
  2424. }
  2425.  
  2426. public double getEnergy() {
  2427. return energy;
  2428. }
  2429.  
  2430. public double getWeight() {
  2431. return totalWeight;
  2432. }
  2433.  
  2434. public Misc.Stopwatch getTimeoutStopwatch() {
  2435. return timeoutStopwatch;
  2436. }
  2437.  
  2438. public ByteBuffer getInData() {
  2439. return inData;
  2440. }
  2441.  
  2442. public SelectionKey getKey() {
  2443. return key;
  2444. }
  2445.  
  2446. public void setSocketChannel(SocketChannel socketChannel) {
  2447. this.socketChannel = socketChannel;
  2448. }
  2449.  
  2450. public SocketChannel getSocketChannel() {
  2451. return socketChannel;
  2452. }
  2453.  
  2454. public void setEncryptor(ISAACCipher encryptor) {
  2455. this.encryptor = encryptor;
  2456. }
  2457.  
  2458. public ISAACCipher getEncryptor() {
  2459. return encryptor;
  2460. }
  2461.  
  2462. public void setDecryptor(ISAACCipher decryptor) {
  2463. this.decryptor = decryptor;
  2464. }
  2465.  
  2466. public ISAACCipher getDecryptor() {
  2467. return decryptor;
  2468. }
  2469.  
  2470. public void setLoginStage(LoginStages loginStage) {
  2471. this.loginStage = loginStage;
  2472. }
  2473.  
  2474. public LoginStages getLoginStage() {
  2475. return loginStage;
  2476. }
  2477.  
  2478. public void setLogin(Login login) {
  2479. this.login = login;
  2480. }
  2481.  
  2482. public Login getLogin() {
  2483. return login;
  2484. }
  2485.  
  2486. public void setOpcode(int opcode) {
  2487. this.opcode = opcode;
  2488. }
  2489.  
  2490. public int getOpcode() {
  2491. return opcode;
  2492. }
  2493.  
  2494. public int getPacketLength() {
  2495. return packetLength;
  2496. }
  2497.  
  2498. public void setPacketLength(int packetLength) {
  2499. this.packetLength = packetLength;
  2500. }
  2501.  
  2502. public void setUsername(String username) {
  2503. this.username = username;
  2504. }
  2505.  
  2506. public String getUsername() {
  2507. return username;
  2508. }
  2509.  
  2510. public void setPassword(String password) {
  2511. this.password = password;
  2512. }
  2513.  
  2514.  
  2515. public String getPassword() {
  2516. return password;
  2517. }
  2518.  
  2519. public void setMacAddress(int macAddress) {
  2520. this.macAddress = macAddress;
  2521. }
  2522.  
  2523. public int getMacAddress() {
  2524. return macAddress;
  2525. }
  2526.  
  2527. public void setPrayerIcon(int prayerIcon) {
  2528. this.prayerIcon = prayerIcon;
  2529. }
  2530.  
  2531. public int getPrayerIcon() {
  2532. return prayerIcon;
  2533. }
  2534.  
  2535. public void decreaseActivityPoints(int activityPoints) {
  2536. this.activityPoints = this.activityPoints - activityPoints;
  2537. }
  2538.  
  2539. public void decreaseVotePoints(int votePoints) {
  2540. this.votePoints = this.votePoints - votePoints;
  2541. }
  2542.  
  2543. public void decreaseDonationPoints(int donationPoints) {
  2544. this.donationPoints = this.donationPoints - donationPoints;
  2545. }
  2546.  
  2547. public void addToServerPoints(int serverPoints) {
  2548. actionSender.sendMessage("You have received " + serverPoints + " server points!");
  2549. this.serverPoints += serverPoints;
  2550. }
  2551.  
  2552. public void decreaseServerPoints(int serverPoints) {
  2553. this.serverPoints = this.serverPoints - serverPoints;
  2554. }
  2555.  
  2556. public int getServerPoints() {
  2557. return serverPoints;
  2558. }
  2559.  
  2560. public void setSkullIcon(int skullIcon) {
  2561. this.skullIcon = skullIcon;
  2562. }
  2563.  
  2564. public int getSkullIcon() {
  2565. return skullIcon;
  2566. }
  2567.  
  2568. public void setIsUsingPrayer(boolean[] isUsingPrayer) {
  2569. this.isUsingPrayer = isUsingPrayer;
  2570. }
  2571.  
  2572. public boolean[] getIsUsingPrayer() {
  2573. return isUsingPrayer;
  2574. }
  2575.  
  2576. public void setPrayerDrainTimer(int prayerDrainTimer) {
  2577. this.prayerDrainTimer = prayerDrainTimer;
  2578. }
  2579.  
  2580. public int getPrayerDrainTimer() {
  2581. return prayerDrainTimer;
  2582. }
  2583.  
  2584. public void setPrayer(Prayer prayer) {
  2585. this.prayer = prayer;
  2586. }
  2587.  
  2588. public Prayer getPrayer() {
  2589. return prayer;
  2590. }
  2591.  
  2592. public Teleportation getTeleportation() {
  2593. return teleportation;
  2594. }
  2595.  
  2596. public Emotes getEmotes() {
  2597. return emotes;
  2598. }
  2599.  
  2600. public boolean shouldAutoRetaliate() {
  2601. return autoRetaliate;
  2602. }
  2603.  
  2604. public void setAutoRetaliate(boolean autoRetaliate) {
  2605. this.autoRetaliate = autoRetaliate;
  2606. }
  2607.  
  2608. public int getScreenBrightness() {
  2609. return screenBrightness;
  2610. }
  2611.  
  2612. public void setScreenBrightness(int screenBrightness) {
  2613. this.screenBrightness = screenBrightness;
  2614. }
  2615.  
  2616. public int getMouseButtons() {
  2617. return mouseButtons;
  2618. }
  2619.  
  2620. public void setMouseButtons(int mouseButtons) {
  2621. this.mouseButtons = mouseButtons;
  2622. }
  2623.  
  2624. public int getSplitPrivateChat() {
  2625. return splitPrivateChat;
  2626. }
  2627.  
  2628. public void setSplitPrivateChat(int splitPrivateChat) {
  2629. this.splitPrivateChat = splitPrivateChat;
  2630. }
  2631.  
  2632. public boolean isAcceptingAid() {
  2633. return acceptAid == 0;
  2634. }
  2635.  
  2636. public int getAcceptAid() {
  2637. return acceptAid;
  2638. }
  2639.  
  2640. public void setAcceptAid(int acceptAid) {
  2641. this.acceptAid = acceptAid;
  2642. }
  2643.  
  2644. public int getMusicVolume() {
  2645. return musicVolume;
  2646. }
  2647.  
  2648.  
  2649. public String getDuoPartner() {
  2650. return duoPartner;
  2651. }
  2652.  
  2653.  
  2654. public void setDuoPartner(String duoPartner) {
  2655. this.duoPartner = duoPartner;
  2656. }
  2657.  
  2658. public void setMusicVolume(int musicVolume) {
  2659. this.musicVolume = musicVolume;
  2660. }
  2661.  
  2662. public int getEffectVolume() {
  2663. return effectVolume;
  2664. }
  2665.  
  2666. public void setEffectVolume(int effectVolume) {
  2667. this.effectVolume = effectVolume;
  2668. }
  2669.  
  2670. public int getQuestPoints() {
  2671. return questPoints;
  2672. }
  2673.  
  2674. public void setQuestPoints(int questPoints) {
  2675. this.questPoints = questPoints;
  2676. }
  2677.  
  2678. public void setMagicBookType(SpellBook magicBookType) {
  2679. this.magicBookType = magicBookType;
  2680. }
  2681.  
  2682. public SpellBook getMagicBookType() {
  2683. return magicBookType;
  2684. }
  2685.  
  2686. public void addPlugin(LocalPlugin lp) {
  2687. plugins.add(lp);
  2688. }
  2689.  
  2690. public List<LocalPlugin> getPlugins() {
  2691. return plugins;
  2692. }
  2693.  
  2694. public void removePlugin(LocalPlugin lp) {
  2695. plugins.remove(lp);
  2696. }
  2697.  
  2698. public void setSpecialAmount(int specialAmount) {
  2699. this.specialAmount = specialAmount;
  2700. if (this.specialAmount > 100) {
  2701. this.specialAmount = 100;
  2702. }
  2703. }
  2704.  
  2705. public int getSpecialAmount() {
  2706. return specialAmount;
  2707. }
  2708.  
  2709. public void setSpecialDamage(double specialDamage) {
  2710. this.specialDamage = specialDamage;
  2711. }
  2712.  
  2713. public double getSpecialDamage() {
  2714. return specialDamage;
  2715. }
  2716.  
  2717. public void setSpecialAccuracy(double specialAccuracy) {
  2718. this.specialAccuracy = specialAccuracy;
  2719. }
  2720.  
  2721. public double getSpecialAccuracy() {
  2722. return specialAccuracy;
  2723. }
  2724.  
  2725. public boolean isSpecialAttackActive() {
  2726. return specialAttackActive;
  2727. }
  2728.  
  2729. public void setSpecialAttackActive(boolean specialAttackActive) {
  2730. this.specialAttackActive = specialAttackActive;
  2731. }
  2732.  
  2733. public void setRingOfRecoilLife(int ringOfRecoilLife) {
  2734. this.ringOfRecoilLife = ringOfRecoilLife;
  2735. }
  2736.  
  2737. public int getRingOfRecoilLife() {
  2738. return ringOfRecoilLife;
  2739. }
  2740.  
  2741. public void setRingOfForgingLife(int ringOfForgingLife) {
  2742. this.ringOfForgingLife = ringOfForgingLife;
  2743. }
  2744.  
  2745. public int getRingOfForgingLife() {
  2746. return ringOfForgingLife;
  2747. }
  2748.  
  2749. public int getBindingNeckCharge() {
  2750. return bindingNeckCharge;
  2751. }
  2752.  
  2753. public void setBindingNeckCharge(int bindingNeckCharge) {
  2754. this.bindingNeckCharge = bindingNeckCharge;
  2755. }
  2756.  
  2757. public void setFightMode(int fightMode) {
  2758. this.fightMode = fightMode;
  2759. }
  2760.  
  2761. public int getFightMode() {
  2762. return fightMode;
  2763. }
  2764.  
  2765. public void setFightStyle(int fightStyle) {
  2766. this.fightStyle = fightStyle;
  2767. }
  2768.  
  2769. public int getFightStyle() {
  2770. return fightStyle;
  2771. }
  2772.  
  2773. public void setFightType(int fightType) {
  2774. this.fightType = fightType;
  2775. }
  2776.  
  2777. public int getFightType() {
  2778. return fightType;
  2779. }
  2780.  
  2781. public void setFightXp(int fightXp) {
  2782. this.fightXp = fightXp;
  2783. }
  2784.  
  2785. public int getFightXp() {
  2786. return fightXp;
  2787. }
  2788.  
  2789. public void setUsingBow(boolean usingBow) {
  2790. this.usingBow = usingBow;
  2791. }
  2792.  
  2793. public boolean isUsingBow() {
  2794. return usingBow;
  2795. }
  2796.  
  2797. public void setUsingCross(boolean usingCross) {
  2798. this.usingCross = usingCross;
  2799. }
  2800.  
  2801. public boolean isUsingCross() {
  2802. return usingCross;
  2803. }
  2804.  
  2805. public void setUsingCrystalBow(boolean usingCrystalBow) {
  2806. this.usingCrystalBow = usingCrystalBow;
  2807. }
  2808.  
  2809. public boolean isUsingCrystalBow() {
  2810. return usingCrystalBow;
  2811. }
  2812.  
  2813. public void setStopPacket(boolean stopPlayerPacket) {
  2814. this.stopPlayerPacket = stopPlayerPacket;
  2815. }
  2816.  
  2817. public boolean stopPlayerPacket() {
  2818. if (transformNpc == 2626 || (transformNpc >= 3689 && transformNpc <= 3694)) {
  2819. return true;
  2820. }
  2821. return stopPlayerPacket;
  2822. }
  2823.  
  2824. public void setUsingArrows(boolean usingArrows) {
  2825. this.usingArrows = usingArrows;
  2826. }
  2827.  
  2828. public boolean isUsingArrows() {
  2829. return usingArrows;
  2830. }
  2831.  
  2832. public void setUsingBolts(boolean usingBolts) {
  2833. this.usingBolts = usingBolts;
  2834. }
  2835.  
  2836. public boolean isUsingBolts() {
  2837. return usingBolts;
  2838. }
  2839.  
  2840. public void setUsingOtherRangedWeapon(boolean usingOtherRangedWeapon) {
  2841. this.usingOtherRangedWeapon = usingOtherRangedWeapon;
  2842. }
  2843.  
  2844. public boolean isUsingOtherRangedWeapon() {
  2845. return usingOtherRangedWeapon;
  2846. }
  2847.  
  2848. public void setDropArrow(boolean dropArrow) {
  2849. this.dropArrow = dropArrow;
  2850. }
  2851.  
  2852. public boolean isDropArrow() {
  2853. return dropArrow;
  2854. }
  2855.  
  2856. public void setFullDharok(boolean fullDharok) {
  2857. this.fullDharok = fullDharok;
  2858. }
  2859.  
  2860. public boolean hasFullDharok() {
  2861. return fullDharok;
  2862. }
  2863.  
  2864. public void setFullAhrim(boolean fullAhrim) {
  2865. this.fullAhrim = fullAhrim;
  2866. }
  2867.  
  2868. public boolean hasFullAhrim() {
  2869. return fullAhrim;
  2870. }
  2871.  
  2872. public void setFullKaril(boolean fullKaril) {
  2873. this.fullKaril = fullKaril;
  2874. }
  2875.  
  2876. public boolean hasFullKaril() {
  2877. return fullKaril;
  2878. }
  2879.  
  2880. public void setFullTorag(boolean fullTorag) {
  2881. this.fullTorag = fullTorag;
  2882. }
  2883.  
  2884. public boolean hasFullTorag() {
  2885. return fullTorag;
  2886. }
  2887.  
  2888. public void setFullGuthan(boolean fullGuthan) {
  2889. this.fullGuthan = fullGuthan;
  2890. }
  2891.  
  2892. public boolean hasFullGuthan() {
  2893. return fullGuthan;
  2894. }
  2895.  
  2896. public void setFullVerac(boolean fullVerac) {
  2897. this.fullVerac = fullVerac;
  2898. }
  2899.  
  2900. public boolean hasFullVerac() {
  2901. return fullVerac;
  2902. }
  2903.  
  2904. public long getLastFire() {
  2905. return lastFire;
  2906. }
  2907.  
  2908. public void setLastFire(long lastFire) {
  2909. this.lastFire = lastFire;
  2910. }
  2911.  
  2912. public void setStopProtectPrayer(long stopProtectPrayer) {
  2913. this.stopProtectPrayer = stopProtectPrayer;
  2914. }
  2915.  
  2916. public long getStopProtectPrayer() {
  2917. return stopProtectPrayer;
  2918. }
  2919.  
  2920. /*public boolean isMoving() {
  2921. return getPrimaryDirection() != -1 || getSecondaryDirection() != -1;
  2922. }*/
  2923.  
  2924. @Override
  2925. public int getCurrentHp() {
  2926. return skill.getLevel()[Skill.HITPOINTS];
  2927. }
  2928.  
  2929. @Override
  2930. public int getMaxHp() {
  2931. return skill.getPlayerLevel(Skill.HITPOINTS);
  2932. }
  2933.  
  2934. @Override
  2935. public int getDeathAnimation() {
  2936. return 2304;
  2937. }
  2938.  
  2939. @Override
  2940. public int getBlockAnimation() {
  2941. Item shield = equipment.getItemContainer().get(Constants.SHIELD);
  2942. if (shield != null) {
  2943. String name = ItemDefinition.forId(shield.getId()).getName().toLowerCase();
  2944. if (name.contains("shield"))
  2945. return 1156;
  2946. }
  2947. return equippedWeapon.getBlockAnimation();
  2948. }
  2949.  
  2950. @Override
  2951. public int getDeathAnimationLength() {
  2952. return 6;
  2953. }
  2954.  
  2955. @Override
  2956. public int getBaseAttackLevel(AttackType attackType) {
  2957. if (attackType == AttackType.RANGED)
  2958. return skill.getLevel()[Skill.RANGED];
  2959. else if (attackType == AttackType.MAGIC)
  2960. return skill.getLevel()[Skill.MAGIC];
  2961. return skill.getLevel()[Skill.ATTACK];
  2962. }
  2963.  
  2964. @Override
  2965. public int getBaseDefenceLevel(AttackType attackType) {
  2966. if (attackType == AttackType.MAGIC)
  2967. return skill.getLevel()[Skill.MAGIC];
  2968. return skill.getLevel()[Skill.DEFENCE];
  2969. }
  2970.  
  2971. @Override
  2972. public boolean isProtectingFromCombat(AttackType attackType, Entity attacker) {
  2973. if (attackType == AttackType.MELEE)
  2974. return isUsingPrayer[Prayer.PROTECT_FROM_MELEE];
  2975. else if (attackType == AttackType.RANGED)
  2976. return isUsingPrayer[Prayer.PROTECT_FROM_RANGED];
  2977. else if (attackType == AttackType.MAGIC)
  2978. return isUsingPrayer[Prayer.PROTECT_FROM_MAGIC];
  2979. return false;
  2980. }
  2981.  
  2982. @Override
  2983. public void setCurrentHp(int hp) {
  2984. skill.setSkillLevel(Skill.HITPOINTS, hp);
  2985. skill.refresh(Skill.HITPOINTS);
  2986. }
  2987.  
  2988. public long getUsernameAsLong() {
  2989. return usernameAsLong;
  2990. }
  2991.  
  2992. public void setUsernameAsLong(long usernameAsLong) {
  2993. this.usernameAsLong = usernameAsLong;
  2994. }
  2995.  
  2996. public void setCurrentWalkableInterface(int currentWalkableInterface) {
  2997. this.currentWalkableInterface = currentWalkableInterface;
  2998. }
  2999.  
  3000. public int getCurrentWalkableInterface() {
  3001. return currentWalkableInterface;
  3002. }
  3003.  
  3004. public void setSpecialType(SpecialType specialType) {
  3005. this.specialType = specialType;
  3006. }
  3007.  
  3008. public SpecialType getSpecialType() {
  3009. return specialType;
  3010. }
  3011.  
  3012. public void setEquippedWeapon(Weapon weapon) {
  3013. if (weapon == null)
  3014. weapon = Weapon.FISTS;
  3015. this.equippedWeapon = weapon;
  3016. }
  3017.  
  3018. public Weapon getEquippedWeapon() {
  3019. return equippedWeapon;
  3020. }
  3021.  
  3022. public boolean clickSpecialBar(int buttonId) {
  3023. switch (buttonId) { // Instant specs
  3024. case 29063:
  3025. if (getEquipment().getId(Constants.WEAPON) == 1377) {
  3026. SpecialType.dbaxeSpec(this);
  3027. return true;
  3028. }
  3029. break;
  3030. case 29163:
  3031. if (getEquipment().getId(Constants.WEAPON) == 35) {
  3032. SpecialType.excaliburSpec(this);
  3033. return true;
  3034. }
  3035. break;
  3036. case 29038:
  3037. if (getEquipment().getId(Constants.WEAPON) == 4153) {
  3038. if (getCombatingEntity() == null) {
  3039. getActionSender().sendMessage("You can only use this special when attacking something.");
  3040. return true;
  3041. }
  3042. SpecialType.gmaulSpec(this);
  3043. return true;
  3044. }
  3045. break;
  3046. }
  3047. boolean before = specialAttackActive;
  3048. if (equippedWeapon.getWeaponInterface().getSpecialBarButtonId() != buttonId)
  3049. return false;
  3050. setSpecialAttackActive(!specialAttackActive);
  3051. if (specialAttackActive && specialType == null)
  3052. setSpecialAttackActive(false);
  3053. if (specialAttackActive != before)
  3054. updateSpecialBar();
  3055. return true;
  3056. }
  3057.  
  3058. public void updateSpecialBar() {
  3059. if (equippedWeapon.getWeaponInterface().getSpecialBarId() < 1) {
  3060. return;
  3061. }
  3062. actionSender.updateSpecialAmount(equippedWeapon.getWeaponInterface().getSpecialTextId());
  3063. actionSender.updateSpecialBarText(equippedWeapon.getWeaponInterface().getSpecialTextId());
  3064. }
  3065.  
  3066. public int getSkullTimer() {
  3067. int size = skullRecords.size();
  3068. if (size == 0)
  3069. return 0;
  3070. int timer = 0;
  3071. for (Iterator<SkullRecord> skullRecordIterator = skullRecords.iterator(); skullRecordIterator.hasNext(); ) {
  3072. int nextTime = skullRecordIterator.next().ticksRemaining();
  3073. if (nextTime > timer) {
  3074. timer = nextTime;
  3075. }
  3076. }
  3077. return timer;
  3078. }
  3079.  
  3080. public void expireSkullRecords() {
  3081. int size = skullRecords.size();
  3082. if (size == 0)
  3083. return;
  3084. for (Iterator<SkullRecord> skullRecordIterator = skullRecords.iterator(); skullRecordIterator.hasNext(); ) {
  3085. if (skullRecordIterator.next().expired())
  3086. skullRecordIterator.remove();
  3087. }
  3088. size = skullRecords.size();
  3089. if (size == 0) {
  3090. setSkulled(false);
  3091. }
  3092. }
  3093.  
  3094. public boolean containsSkullRecord(Player other) {
  3095. for (SkullRecord skullRecord : skullRecords)
  3096. if (skullRecord.getEntity() == other)
  3097. return true;
  3098. return false;
  3099. }
  3100.  
  3101. public void addSkull(Player victim, int timer) {
  3102. SkullRecord skullRecord = new SkullRecord(victim, timer);
  3103. skullRecords.add(skullRecord);
  3104. setSkulled(true);
  3105. }
  3106.  
  3107. public void addPossibleSkull(Player victim) {
  3108. if (!victim.isPlayer())
  3109. return;
  3110. Player other = (Player) victim;
  3111. if (inDuelArena())
  3112. return;
  3113. if (other.containsSkullRecord(this))
  3114. return;
  3115. for (SkullRecord skullRecord : skullRecords)
  3116. if (skullRecord.getEntity() == victim) {
  3117. skullRecord.refresh();
  3118. return;
  3119. }
  3120. addSkull(victim, SkullRecord.PK_EXPIRE_TIME);
  3121. }
  3122.  
  3123. public void setSkulled(boolean isSkulled) {
  3124. this.isSkulled = isSkulled;
  3125. setSkullIcon(isSkulled ? 0 : -1);
  3126. setAppearanceUpdateRequired(true);
  3127. }
  3128.  
  3129. public ArrayList<Item> getItemsKeptOnDeath(Item[] items) {
  3130. PriorityQueue<Item> allItems = new PriorityQueue<Item>(1, new Comparator<Item>() {
  3131. @Override
  3132. public int compare(Item a, Item b) {
  3133. return ItemDefinition.forId(b.getId()).getHighAlcValue() - ItemDefinition.forId(a.getId()).getHighAlcValue();
  3134. }
  3135. });
  3136.  
  3137. for (Item item : items) {
  3138. if (item == null)
  3139. continue;
  3140. if (!item.getDefinition().isUntradable())
  3141. allItems.add(new Item(item.getId()));
  3142. }
  3143. ArrayList<Item> keptItems = new ArrayList<Item>();
  3144. int itemsKept = isSkulled ? 0 : 3;
  3145. if (isUsingPrayer[Prayer.PROTECT_ITEM])
  3146. itemsKept += 1;
  3147. while (keptItems.size() < itemsKept && allItems.size() > 0) {
  3148. keptItems.add(allItems.poll());
  3149. }
  3150. return keptItems;
  3151. }
  3152.  
  3153. transient Player player;
  3154.  
  3155. @Override
  3156. public void dropItems(Entity killer) {
  3157. /*if (getStaffRights() >= 2 || inDuelArena() || creatureGraveyard.isInCreatureGraveyard())
  3158. return;*/
  3159. if (killer == null) {
  3160. killer = this;
  3161. }
  3162. Item[] items = new Item[equipment.getItemContainer().capacity() + inventory.getItemContainer().capacity()];
  3163. System.arraycopy(equipment.getItemContainer().getItems(), 0, items, 0, equipment.getItemContainer().getItems().length);
  3164. System.arraycopy(inventory.getItemContainer().getItems(), 0, items, equipment.getItemContainer().getItems().length, inventory.getItemContainer().getItems().length);
  3165. ArrayList<Item> keptItems = getItemsKeptOnDeath(items);
  3166. List<Item> allItems = new ArrayList<Item>(Arrays.asList(items));
  3167. for (Item kept : keptItems) {
  3168. if (kept == null)
  3169. continue;
  3170. for (Iterator<Item> droppedItems = allItems.iterator(); droppedItems.hasNext(); ) {
  3171. Item dropped = droppedItems.next();
  3172. if (dropped != null) {
  3173. if (dropped.getId() == kept.getId()) {
  3174. dropped.setCount(dropped.getCount() - 1);
  3175. if (dropped.getCount() <= 0)
  3176. droppedItems.remove();
  3177. break;
  3178. }
  3179. }
  3180. }
  3181. }
  3182. equipment.getItemContainer().clear();
  3183. inventory.getItemContainer().clear();
  3184. for (Item kept : keptItems)
  3185. inventory.addItem(kept);
  3186. for (Item dropped : allItems) {
  3187. if (dropped == null)
  3188. continue;
  3189. if (!dropped.getDefinition().isUntradable()) {
  3190. GroundItem item = new GroundItem(new Item(dropped.getId(), dropped.getCount()), this, killer, getDeathPosition());
  3191. GroundItemManager.getManager().dropItem(item);
  3192. }
  3193. }
  3194. System.out.println("PRINTED OUT PRINTED OUT PRINTED OUT ITEMS");
  3195. equipment.refresh();
  3196. inventory.refresh();
  3197. }
  3198.  
  3199. public Spell getCastedSpell() {
  3200. return castedSpell;
  3201. }
  3202.  
  3203. public Spell getAutoSpell() {
  3204. return autoSpell;
  3205. }
  3206.  
  3207. public void setCastedSpell(Spell spell) {
  3208. this.castedSpell = spell;
  3209. }
  3210.  
  3211. public boolean isAutoCasting() {
  3212. return autoCasting;
  3213. }
  3214.  
  3215. public void setAutoCasting(boolean autoCasting) {
  3216. if (autoCasting) {
  3217. getActionSender().sendConfig(108, 3);
  3218. getActionSender().sendConfig(43, 3);
  3219. } else {
  3220. getActionSender().resetAutoCastInterface();
  3221. }
  3222. this.autoCasting = autoCasting;
  3223. }
  3224.  
  3225. public void setAutoSpell(Spell spell) {
  3226. if (spell == null) {
  3227. getActionSender().resetAutoCastInterface();
  3228. this.autoCasting = false;
  3229. } else {
  3230. getActionSender().sendSidebarInterface(0, 328);
  3231. getActionSender().updateAutoCastInterface(spell);
  3232. this.autoCasting = true;
  3233. }
  3234. this.autoSpell = spell;
  3235. }
  3236.  
  3237. public void disableAutoCast() { // ONLY for fight mode switch
  3238. this.getActionSender().sendConfig(108, 2);
  3239. this.autoCasting = false;
  3240. }
  3241.  
  3242. public void setMember(boolean member) {
  3243. this.member = member;
  3244. }
  3245.  
  3246. public boolean isMember() {
  3247. return member;
  3248. }
  3249.  
  3250. /**
  3251. * Gets the
  3252. *
  3253. * @return The outData
  3254. */
  3255. public ByteBuffer getOutData() {
  3256. return outData;
  3257. }
  3258.  
  3259. public void setStatedInterface(String statedInterface) {
  3260. this.statedInterface = statedInterface;
  3261. }
  3262.  
  3263. public void setTempInteger(int tempInteger) {
  3264. this.tempInteger = tempInteger;
  3265. }
  3266.  
  3267. public int getTempInteger() {
  3268. return tempInteger; // To change body of created methods use File |
  3269. // Settings | File Templates.
  3270. }
  3271.  
  3272. public List<SkullRecord> getSkullRecords() {
  3273. return skullRecords;
  3274. }
  3275.  
  3276. public void setOldItem(int oldItem) {
  3277. this.oldItem = oldItem;
  3278. }
  3279.  
  3280. public int getOldItem() {
  3281. return oldItem;
  3282. }
  3283.  
  3284. public void setSmithInterface(int smithInterface) {
  3285. this.smithInterface = smithInterface;
  3286. }
  3287.  
  3288. public int getSmithInterface() {
  3289. return smithInterface;
  3290. }
  3291.  
  3292. public int getStandAnim() {
  3293. if (standAnim == -1)
  3294. return getEquipment().getStandAnim();
  3295. return standAnim;
  3296. }
  3297.  
  3298. public int getWalkAnim() {
  3299. if (walkAnim == -1)
  3300. return getEquipment().getWalkAnim();
  3301. return walkAnim;
  3302. }
  3303.  
  3304. public int getRunAnim() {
  3305. if (runAnim == -1)
  3306. return getEquipment().getRunAnim();
  3307. return runAnim;
  3308. }
  3309.  
  3310. public void setRunAnim(int runAnim) {
  3311. this.runAnim = runAnim;
  3312. }
  3313.  
  3314. public void setWalkAnim(int walkAnim) {
  3315. this.walkAnim = walkAnim;
  3316. }
  3317.  
  3318. public void setStandAnim(int standAnim) {
  3319. this.standAnim = standAnim;
  3320. }
  3321.  
  3322. public int getStandTurn() {
  3323. int curWalkAnim = getWalkAnim();
  3324. if (curWalkAnim != Weapon.FISTS.getMovementAnimations()[1])
  3325. return curWalkAnim;
  3326. else
  3327. return 0x337;
  3328. }
  3329.  
  3330. public int get180Turn() {
  3331. int curWalkAnim = getWalkAnim();
  3332. if (curWalkAnim != Weapon.FISTS.getMovementAnimations()[1])
  3333. return curWalkAnim;
  3334. return 0x334;
  3335. }
  3336.  
  3337. public int get90TurnCW() {
  3338. int curWalkAnim = getWalkAnim();
  3339. if (curWalkAnim != Weapon.FISTS.getMovementAnimations()[1])
  3340. return curWalkAnim;
  3341. return 0x335;
  3342. }
  3343.  
  3344. public int get90TurnCCW() {
  3345. int curWalkAnim = getWalkAnim();
  3346. if (curWalkAnim != Weapon.FISTS.getMovementAnimations()[1])
  3347. return curWalkAnim;
  3348. return 0x336;
  3349. }
  3350.  
  3351. public void setMuteExpire(long l) {
  3352. this.muteExpire = l;
  3353. }
  3354.  
  3355. public void setBanExpire(long l) {
  3356. this.banExpire = l;
  3357. }
  3358.  
  3359. public long getMuteExpire() {
  3360. return muteExpire;
  3361. }
  3362.  
  3363. public long getBanExpire() {
  3364. return banExpire;
  3365. }
  3366.  
  3367. public void resetEffects() {
  3368. getSkullRecords().clear();
  3369. setSkulled(false);
  3370. getPrayer().resetAll();
  3371. setEnergy(100);
  3372. setSpecialAmount(100);
  3373. updateSpecialBar();
  3374. resetEffectTimers();
  3375. resetImmuneTimers();
  3376. int skills[] = getSkill().getLevel();
  3377. for (int i = 0; i < skills.length; i++)
  3378. getSkill().setSkillLevel(i, getSkill().getPlayerLevel(i));
  3379. }
  3380.  
  3381. public boolean logoutDisabled() {
  3382. if (getLoginStage() == LoginStages.LOGGING_OUT && getLogoutTimer() < System.currentTimeMillis()) {
  3383. return false;
  3384. }
  3385. return !getInCombatTick().completed();
  3386. }
  3387.  
  3388. public boolean hasInterfaceOpen(RSInterface inter) {
  3389. if (inter == null)
  3390. return false;
  3391. if (getInterface() == inter.getParentId())
  3392. return true;
  3393. if (sideBarOpen == inter.getParentId())
  3394. return true;
  3395. for (int i : sidebarInterfaceId)
  3396. if (i == inter.getParentId())
  3397. return true;
  3398. return false;
  3399. }
  3400.  
  3401. public void setInventory(Inventory inventory) {
  3402. this.inventory = inventory;
  3403. }
  3404.  
  3405. public void setFlowers(Flowers flowers) {
  3406. this.flower = flowers;
  3407. }
  3408.  
  3409. public void setFruitTrees(FruitTree fruitTrees) {
  3410. this.fruitTrees = fruitTrees;
  3411. }
  3412.  
  3413. public void setHerbs(Herbs herbs) {
  3414. this.herb = herbs;
  3415. }
  3416.  
  3417. public void setHops(Hops hops) {
  3418. this.hops = hops;
  3419. }
  3420.  
  3421. public void setSpecialPlantOne(SpecialPlantOne specialPlantOne) {
  3422. this.specialPlantOne = specialPlantOne;
  3423. }
  3424.  
  3425. public void setSpecialPlantTwo(SpecialPlantTwo specialPlantTwo) {
  3426. this.specialPlantTwo = specialPlantTwo;
  3427. }
  3428.  
  3429. public void setTrees(WoodTrees trees) {
  3430. this.trees = trees;
  3431. }
  3432.  
  3433. public void setCompost(Compost compost) {
  3434. this.compost = compost;
  3435. }
  3436.  
  3437. public void setFarmingTools(ToolLeprechaun farmingTools) {
  3438. this.toolLeprechaun = farmingTools;
  3439. }
  3440.  
  3441. public void setSlayer(Slayer slayer) {
  3442. this.slayer = slayer;
  3443. }
  3444.  
  3445. public enum BankOptions {
  3446. SWAP_ITEM, INSERT_ITEM, ITEM_WITHDRAW, NOTE_WITHDRAW
  3447. }
  3448.  
  3449. public enum TradeStage {
  3450. WAITING, SEND_REQUEST, ACCEPT, SEND_REQUEST_ACCEPT, SECOND_TRADE_WINDOW
  3451. }
  3452.  
  3453. public enum LoginStages {
  3454. CONNECTED, LOGGING_IN, AWAITING_LOGIN_COMPLETE, LOGGED_IN, LOGGING_OUT, LOGGED_OUT
  3455. }
  3456.  
  3457. public void appendToBugList(String bug) {
  3458. String filePath = "./data/bugs.txt";
  3459. try {
  3460. BufferedWriter out = new BufferedWriter(new FileWriter(filePath, true));
  3461. try {
  3462. out.write("Bug reported by " + getUsername() + " about : " + bug);
  3463. out.newLine();
  3464. } finally {
  3465. out.close();
  3466. }
  3467. } catch (IOException e) {
  3468. e.printStackTrace();
  3469. }
  3470. }
  3471.  
  3472. public void appendToAutoSpawn(NpcDefinition npc) {
  3473. int randNum = Misc.random(4) + 2;
  3474. String filePath = "./data/spawns.txt";
  3475. try {
  3476. BufferedWriter out = new BufferedWriter(new FileWriter(filePath, true));
  3477. try {
  3478. out.write("spawn = " + npc.getId() + "\t " + getPosition().getX() + " " + getPosition().getY() + " 0 " + randNum + " " + npc.getName());
  3479. out.newLine();
  3480. out.flush();
  3481. } finally {
  3482. out.close();
  3483. }
  3484. } catch (IOException e) {
  3485. e.printStackTrace();
  3486. }
  3487. NpcLoader.newNPC(npc.getId(), getPosition().getX(), getPosition().getY(), getPosition().getZ(), randNum);
  3488. }
  3489.  
  3490. public void resetAllActions() {
  3491. setCurrentSkillTask();
  3492. getTask();
  3493. resetPacketVariables();
  3494. Following.resetFollow(this);
  3495. setInteractingEntity(null);
  3496. CombatManager.resetCombat(this);
  3497. getDialogue().endDialogue();
  3498. if (getUpdateFlags().getEntityFaceIndex() != 65535) {
  3499. getUpdateFlags().faceEntity(65535);
  3500. }
  3501. }
  3502.  
  3503. public void resetSkillActions() {
  3504. getTask();
  3505. setCurrentSkillTask();
  3506. resetPacketVariables();
  3507. }
  3508.  
  3509. public void resetPacketVariables() {
  3510. setInterfaceId(-1);
  3511. setClickId(-1);
  3512. setClickY(-1);
  3513. setSlot(-1);
  3514. setClickX(-1);
  3515. setClickZ(-1);
  3516. setClickItem(-1);
  3517. }
  3518.  
  3519. public boolean shouldHideWeapons() {
  3520. return hideWeapons;
  3521. }
  3522.  
  3523. public void setHideWeapons(boolean hideWeapons) {
  3524. this.hideWeapons = hideWeapons;
  3525. }
  3526.  
  3527. public boolean isVisible() {
  3528. return visible;
  3529. }
  3530.  
  3531. public int antiFire() {
  3532. int fire = 0;
  3533. if (isFireImmune()) {
  3534. fire += 1;
  3535. }
  3536. if (getEquipment().getId(Constants.SHIELD) == 1540) {
  3537. fire += 1;
  3538. }
  3539. return fire;
  3540. }
  3541.  
  3542. public boolean npcCanAttack(Npc npc) {
  3543. if (npc.isAttacking() || !npc.getDefinition().isAttackable()) {
  3544. return false;
  3545. }
  3546. if (npc.getNpcId() == 2429 || npc.getNpcId() == 1827 || npc.getNpcId() == 1266 || npc.getNpcId() == 1268 || npc.getNpcId() == 2453 || npc.getNpcId() == 2890) {
  3547. return true;
  3548. }
  3549. if (npc.getNpcId() == 18) {
  3550. return getCombatingEntity() != null;
  3551. }
  3552. if (npc.inWild()) {
  3553. return true;
  3554. }
  3555. if (!npc.getDefinition().isAggressive()) {
  3556. return false;
  3557. }
  3558. if (getCombatLevel() <= npc.getDefinition().getCombat() * 2) {
  3559. return true;
  3560. }
  3561. return false;
  3562. }
  3563.  
  3564. public void checkNpcAggressiveness() {
  3565. if (!getInCombatTick().completed() && !inMulti()) {
  3566. return;
  3567. }
  3568. for (Npc npc : getNpcs()) {
  3569. if (npc.getPlayerOwner() != null) {
  3570. continue;
  3571. }
  3572. if (!npcCanAttack(npc)) {
  3573. continue;
  3574. }
  3575. if (Misc.goodDistance(npc.getSpawnPosition(), getPosition(), npc.getNpcId() == 1266 || npc.getNpcId() == 1268 || npc.getNpcId() == 2453 || npc.getNpcId() == 2890 ? 1 : 4)) {
  3576. //if (npc.getWalkableArea().contains(getPosition().getX(), getPosition().getY())) {
  3577. CombatCycleEvent.CanAttackResponse response = CombatCycleEvent.canAttack(npc, this);
  3578. if (response != CombatCycleEvent.CanAttackResponse.SUCCESS)
  3579. continue;
  3580. if (npc.getNpcId() == 180) {
  3581. npc.getUpdateFlags().setForceChatMessage("Stand and deliver!");
  3582. }
  3583. if (npc.getNpcId() == 18 && npc.getCurrentHp() > 0) {
  3584. npc.getUpdateFlags().setForceChatMessage("Brother, I will help thee with this infidel!");
  3585. }
  3586. if (npc.getTransformTimer() < 1 && npc.isTransformOnAggression() > 0) {
  3587. npc.sendTransform(npc.isTransformOnAggression(), 999999);
  3588. }
  3589. CombatManager.attack(npc, this);
  3590. return;
  3591. }
  3592. }
  3593. }
  3594.  
  3595. public int getPouchData(int i) {
  3596. return pouchData[i];
  3597. }
  3598.  
  3599. public void setPouchData(int i, int amount) {
  3600. pouchData[i] = amount;
  3601. }
  3602.  
  3603. /**
  3604. * @param hamTrapDoor the hamTrapDoor to set
  3605. */
  3606. public void setHamTrapDoor(boolean hamTrapDoor) {
  3607. this.hamTrapDoor = hamTrapDoor;
  3608. }
  3609.  
  3610. /**
  3611. * @return the hamTrapDoor
  3612. */
  3613. public boolean isHamTrapDoor() {
  3614. return hamTrapDoor;
  3615. }
  3616.  
  3617. public int getClientVersion() {
  3618. return clientVersion;
  3619. }
  3620.  
  3621. public void setClientVersion(int clientVersion) {
  3622. this.clientVersion = clientVersion;
  3623. }
  3624.  
  3625. public int getMagicId() {
  3626. return magicId;
  3627. }
  3628.  
  3629. public void setMagicId(int magicId) {
  3630. this.magicId = magicId;
  3631. }
  3632.  
  3633. /**
  3634. * @param runecraftNpc the runecraftNpc to set
  3635. */
  3636. public void setRunecraftNpc(int runecraftNpc) {
  3637. this.runecraftNpc = runecraftNpc;
  3638. }
  3639.  
  3640. /**
  3641. * @return the runecraftNpc
  3642. */
  3643. public int getRunecraftNpc() {
  3644. return runecraftNpc;
  3645. }
  3646.  
  3647. public BrewData getBrewData() {
  3648. return brewData;
  3649. }
  3650.  
  3651. public boolean hasCombatEquipment() {
  3652. for (Item item : getInventory().getItemContainer().getItems()) {
  3653. if (item == null)
  3654. continue;
  3655. for (int b : item.getDefinition().getBonuses())
  3656. if (b > 0) {
  3657. return true;
  3658. }
  3659. }
  3660. for (Item item : getEquipment().getItemContainer().getItems()) {
  3661. if (item == null)
  3662. continue;
  3663. for (int b : item.getDefinition().getBonuses())
  3664. if (b > 0) {
  3665. return true;
  3666. }
  3667. }
  3668. return false;
  3669. }
  3670.  
  3671. private Position getLoadedLandscapeCorner() {
  3672. int x = getPosition().getLocalX(getCurrentRegion());
  3673. int y = getPosition().getLocalY(getCurrentRegion());
  3674. int cornerX = (getPosition().getX() - x);
  3675. int cornerY = (getPosition().getY() - y);
  3676. return new Position(cornerX, cornerY, getPosition().getZ());
  3677. }
  3678.  
  3679. public Area getLoadedLandscape() {
  3680. return loadedLandscape;
  3681. }
  3682.  
  3683. public void calculateLoadedLandscape() {
  3684. Position corner = getLoadedLandscapeCorner();
  3685. this.loadedLandscape = Area.areaFromCorner(corner, 104, 104);
  3686. }
  3687.  
  3688. public boolean hasItem(int id) {
  3689. for (Item item : getInventory().getItemContainer().getItems()) {
  3690. if (item != null && item.getId() == id) {
  3691. return true;
  3692. }
  3693. }
  3694. for (Item item : getBank().getItems()) {
  3695. if (item != null && item.getId() == id) {
  3696. return true;
  3697. }
  3698. }
  3699. return false;
  3700. }
  3701.  
  3702. public boolean hasClueScroll() {
  3703. for (Item item : getInventory().getItemContainer().getItems()) {
  3704. if (item != null && item.getDefinition().getName().toLowerCase().contains("clue scroll")) {
  3705. return true;
  3706. }
  3707. }
  3708. for (Item item : getBank().getItems()) {
  3709. if (item != null && item.getDefinition().getName().toLowerCase().contains("clue scroll")) {
  3710. return true;
  3711. }
  3712. }
  3713. return false;
  3714. }
  3715.  
  3716. public boolean hasPuzzle() {
  3717. for (Item item : getInventory().getItemContainer().getItems()) {
  3718. if (item != null && (item.getId() == 2800 || item.getId() == 3565 || item.getId() == 3571)) {
  3719. return true;
  3720. }
  3721. }
  3722. for (Item item : getBank().getItems()) {
  3723. if (item != null && (item.getId() == 2800 || item.getId() == 3565 || item.getId() == 3571)) {
  3724. return true;
  3725. }
  3726. }
  3727. return false;
  3728. }
  3729.  
  3730. public List<GroundItem> getGroundItems() {
  3731. return groundItems;
  3732. }
  3733.  
  3734. /**
  3735. * @param oldObject the oldObject to set
  3736. */
  3737. public void setOldObject(int oldObject) {
  3738. this.oldObject = oldObject;
  3739. }
  3740.  
  3741. /**
  3742. * @return the oldObject
  3743. */
  3744. public int getOldObject() {
  3745. return oldObject;
  3746. }
  3747.  
  3748. public boolean isMuted() {
  3749. return muteExpire != 0 && muteExpire > System.currentTimeMillis();
  3750. }
  3751.  
  3752. public boolean isBanned() {
  3753. return banExpire != 0 && banExpire > System.currentTimeMillis();
  3754. }
  3755.  
  3756. /**
  3757. * @param lastNpc the lastNpc to set
  3758. */
  3759. public void setLastNpc(int lastNpc) {
  3760. this.lastNpc = lastNpc;
  3761. }
  3762.  
  3763. /**
  3764. * @return the lastNpc
  3765. */
  3766. public int getLastNpc() {
  3767. return lastNpc;
  3768. }
  3769.  
  3770. public void setKilledTreeSpirit(boolean killedTreeSpirit) {
  3771. this.killedTreeSpirit = killedTreeSpirit;
  3772. }
  3773.  
  3774. public void setResetBank(boolean resetbank) {
  3775. this.resetbank = resetbank;
  3776. }
  3777.  
  3778. public boolean hasResetBank() {
  3779. return resetbank;
  3780. }
  3781.  
  3782. /**
  3783. * @return the killedEvilSpirit
  3784. */
  3785. public boolean hasKilledTreeSpirit() {
  3786. return killedTreeSpirit;
  3787. }
  3788.  
  3789. public void setKilledJungleDemon(boolean killedJungleDemon) {
  3790. this.killedJungleDemon = killedJungleDemon;
  3791. }
  3792.  
  3793. /**
  3794. * @return the killedJungleDemon
  3795. */
  3796. public boolean hasKilledJungleDemon() {
  3797. return killedJungleDemon;
  3798. }
  3799.  
  3800. public int getInterface() {
  3801. return inter;
  3802. }
  3803.  
  3804. public void setInterface(int inter) {
  3805. this.inter = inter;
  3806. }
  3807.  
  3808. public void setBarrowsNpcDead(int index, boolean dead) {
  3809. this.barrowsNpcDead[index] = dead;
  3810. }
  3811.  
  3812. /**
  3813. * @return the barrowsNpcDead
  3814. */
  3815. public boolean[] getBarrowsNpcDead() {
  3816. return barrowsNpcDead;
  3817. }
  3818.  
  3819. /**
  3820. * @return the barrowsNpcDead
  3821. */
  3822. public boolean getBarrowsNpcDead(int id) {
  3823. return barrowsNpcDead[id];
  3824. }
  3825.  
  3826. /**
  3827. * @param killCount the killCount to set
  3828. */
  3829. public void setKillCount(int killCount) {
  3830. this.killCount = killCount;
  3831. }
  3832.  
  3833. /**
  3834. * @return the killCount
  3835. */
  3836. public int getKillCount() {
  3837. return killCount;
  3838. }
  3839.  
  3840. /**
  3841. * @param randomGrave the randomGrave to set
  3842. */
  3843. public void setRandomGrave(int randomGrave) {
  3844. this.randomGrave = randomGrave;
  3845. }
  3846.  
  3847. /**
  3848. * @return the randomGrave
  3849. */
  3850. public int getRandomGrave() {
  3851. return randomGrave;
  3852. }
  3853.  
  3854. public int getCombatLevel() {
  3855. return combatLevel;
  3856. }
  3857.  
  3858. public void setCombatLevel(int combatLevel) {
  3859. this.combatLevel = combatLevel;
  3860. }
  3861.  
  3862. /**
  3863. * @param loggingOut the loggingOut to set
  3864. */
  3865. public void setLoggingOut(boolean loggingOut) {
  3866. this.loggingOut = loggingOut;
  3867. }
  3868.  
  3869. /**
  3870. * @return the loggingOut
  3871. */
  3872. public boolean isLoggingOut() {
  3873. return loggingOut;
  3874. }
  3875.  
  3876. /**
  3877. * @param lastPersonTraded the lastPersonTraded to set
  3878. */
  3879. public void setLastPersonTraded(Player lastPersonTraded) {
  3880. this.lastPersonTraded = lastPersonTraded;
  3881. }
  3882.  
  3883. /**
  3884. * @return the lastPersonTraded
  3885. */
  3886. public Player getLastPersonTraded() {
  3887. return lastPersonTraded;
  3888. }
  3889.  
  3890. /**
  3891. * @param clickZ the clickZ to set
  3892. */
  3893. public void setClickZ(int clickZ) {
  3894. this.clickZ = clickZ;
  3895. }
  3896.  
  3897. /**
  3898. * @return the clickZ
  3899. */
  3900. public int getClickZ() {
  3901. return clickZ;
  3902. }
  3903.  
  3904. public void setSideBarInterfaceId(int slot, int id) {
  3905. sidebarInterfaceId[slot] = id;
  3906. }
  3907.  
  3908. public void setSideBarOpen(int id) {
  3909. this.sideBarOpen = id;
  3910. }
  3911.  
  3912. /**
  3913. * @param interfaceId the interfaceId to set
  3914. */
  3915. public void setInterfaceId(int interfaceId) {
  3916. this.interfaceId = interfaceId;
  3917. }
  3918.  
  3919. /**
  3920. * @return the interfaceId
  3921. */
  3922. public int getInterfaceId() {
  3923. return interfaceId;
  3924. }
  3925.  
  3926. /**
  3927. * @param slot the slot to set
  3928. */
  3929. public void setSlot(int slot) {
  3930. this.slot = slot;
  3931. }
  3932.  
  3933. /**
  3934. * @return the slot
  3935. */
  3936. public int getSlot() {
  3937. return slot;
  3938. }
  3939.  
  3940. /**
  3941. * @param brimhavenDungeonOpen the brimhavenDungeonOpen to set
  3942. */
  3943. public void setBrimhavenDungeonOpen(boolean brimhavenDungeonOpen) {
  3944. this.brimhavenDungeonOpen = brimhavenDungeonOpen;
  3945. }
  3946.  
  3947. /**
  3948. * @return the brimhavenDungeonOpen
  3949. */
  3950. public boolean isBrimhavenDungeonOpen() {
  3951. return brimhavenDungeonOpen;
  3952. }
  3953.  
  3954. /**
  3955. * @param set usedFreeShilo
  3956. */
  3957. public void setUsedFreeShilo(boolean usedFreeShilo) {
  3958. this.usedFreeShilo = usedFreeShilo;
  3959. }
  3960.  
  3961. /**
  3962. * @return usedFreeShilo
  3963. */
  3964. public boolean getUsedFreeShilo() {
  3965. return usedFreeShilo;
  3966. }
  3967.  
  3968. /**
  3969. * @param set taskCompleted
  3970. */
  3971. public void setTaskCompleted(boolean taskCompleted) {
  3972. this.taskCompleted = taskCompleted;
  3973. }
  3974.  
  3975. /**
  3976. * @return taskCompleted
  3977. */
  3978. public boolean getTaskCompleted() {
  3979. return taskCompleted;
  3980. }
  3981.  
  3982. private void saveCommand(String user, String command) {
  3983. String filePath = "./data/commands.txt";
  3984. try {
  3985. BufferedWriter out = new BufferedWriter(new FileWriter(filePath, true));
  3986. try {
  3987. out.write(user + " used " + command);
  3988. out.newLine();
  3989. } finally {
  3990. out.close();
  3991. }
  3992. } catch (IOException e) {
  3993. e.printStackTrace();
  3994. }
  3995. }
  3996.  
  3997. /**
  3998. * @param teleotherPosition the teleotherPosition to set
  3999. */
  4000. public void setTeleotherPosition(Position teleotherPosition) {
  4001. this.teleotherPosition = teleotherPosition;
  4002. }
  4003.  
  4004. /**
  4005. * @return the teleotherPosition
  4006. */
  4007. public Position getTeleotherPosition() {
  4008. return teleotherPosition;
  4009. }
  4010.  
  4011. /**
  4012. * @param destroyItem the destroyItem to set
  4013. */
  4014. public void setDestroyItem(Item destroyItem) {
  4015. this.destroyItem = destroyItem;
  4016. }
  4017.  
  4018. /**
  4019. * @return the destroyItem
  4020. */
  4021. public Item getDestroyItem() {
  4022. return destroyItem;
  4023. }
  4024.  
  4025. public boolean isHearMessage() {
  4026. return hearMessage;
  4027. }
  4028.  
  4029. public void setHearMessage(boolean hearMessage) {
  4030. this.hearMessage = hearMessage;
  4031. }
  4032.  
  4033. /**
  4034. * @param bankWarning the bankWarning to set
  4035. */
  4036. public void setBankWarning(boolean bankWarning) {
  4037. this.bankWarning = bankWarning;
  4038. }
  4039.  
  4040. /**
  4041. * @return the bankWarning
  4042. */
  4043. public boolean isBankWarning() {
  4044. return bankWarning;
  4045. }
  4046.  
  4047. /**
  4048. * @param pinAttempt the pinAttempt to set
  4049. */
  4050. public void setPinAttempt(int pinAttempt, int index) {
  4051. this.pinAttempt[index] = pinAttempt;
  4052. }
  4053.  
  4054. /**
  4055. * @param pinAttempt the pinAttempt to set
  4056. */
  4057. public void resetPinAttempt() {
  4058. this.pinAttempt = new int[4];
  4059. }
  4060.  
  4061. /**
  4062. * @return the pinAttempt
  4063. */
  4064. public int[] getPinAttempt() {
  4065. return pinAttempt;
  4066. }
  4067.  
  4068. public boolean isDebugCombat() {
  4069. return debugCombat;
  4070. }
  4071.  
  4072. /**
  4073. * @param randomEventNpc the randomEventNpc to set
  4074. */
  4075. public void setRandomEventNpc(Npc randomEventNpc) {
  4076. this.randomEventNpc = randomEventNpc;
  4077. }
  4078.  
  4079. /**
  4080. * @return the randomEventNpc
  4081. */
  4082. public Npc getRandomEventNpc() {
  4083. return randomEventNpc;
  4084. }
  4085.  
  4086. /**
  4087. * @param randomHerb the randomHerb to set
  4088. */
  4089. public void setRandomHerb(Item randomHerb) {
  4090. this.randomHerb = randomHerb;
  4091. }
  4092.  
  4093. /**
  4094. * @return the randomHerb
  4095. */
  4096. public Item getRandomHerb() {
  4097. return randomHerb;
  4098. }
  4099.  
  4100. private MusicHandler musichandler = new MusicHandler(this);
  4101. public int skillingTask;
  4102.  
  4103. /**
  4104. * Gets the associated music handler.
  4105. *
  4106. * @return
  4107. */
  4108. public MusicHandler getMusicHandler() {
  4109. return musichandler;
  4110. }
  4111.  
  4112. /**
  4113. * @param genieSelect the genieSelect to set
  4114. */
  4115. public void setGenieSelect(int genieSelect) {
  4116. this.genieSelect = genieSelect;
  4117. }
  4118.  
  4119. /**
  4120. * @return the genieSelect
  4121. */
  4122. public int getGenieSelect() {
  4123. return genieSelect;
  4124. }
  4125.  
  4126. public boolean hasKilledClueAttacker() {
  4127. return killedClueAttacker;
  4128. }
  4129.  
  4130. public void setKilledClueAttacker(boolean killedClueAttacker) {
  4131. this.killedClueAttacker = killedClueAttacker;
  4132. }
  4133.  
  4134. /**
  4135. * @param logoutTimer the logoutTimer to set
  4136. */
  4137. public void setLogoutTimer(long logoutTimer) {
  4138. this.logoutTimer = logoutTimer;
  4139. }
  4140.  
  4141. /**
  4142. * @return the logoutTimer
  4143. */
  4144. public long getLogoutTimer() {
  4145. return logoutTimer;
  4146. }
  4147.  
  4148. /**
  4149. * @param coalTruckAmount the coalTruckAmount to set
  4150. */
  4151. public void setCoalTruckAmount(int coalTruckAmount) {
  4152. this.coalTruckAmount = coalTruckAmount;
  4153. }
  4154.  
  4155. /**
  4156. * @return the coalTruckAmount
  4157. */
  4158. public int getCoalTruckAmount() {
  4159. return coalTruckAmount;
  4160. }
  4161.  
  4162. /**
  4163. * @param lastPersonChallenged the lastPersonChallenged to set
  4164. */
  4165. public void setLastPersonChallenged(Player lastPersonChallenged) {
  4166. this.lastPersonChallenged = lastPersonChallenged;
  4167. }
  4168.  
  4169. /**
  4170. * @return the lastPersonChallenged
  4171. */
  4172. public Player getLastPersonChallenged() {
  4173. return lastPersonChallenged;
  4174. }
  4175.  
  4176. public void skillingTask(int randomTask) {
  4177. // TODO Auto-generated method stub
  4178.  
  4179. }
  4180.  
  4181.  
  4182. }
Add Comment
Please, Sign In to add comment