diff --git a/.gitignore b/.gitignore index 68e0c615a..005d6aae9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ CompiledServer/**/*.jar **/.idea/workspace.xml **/.idea/* *.class +CompiledServer/ diff --git a/Server/.gitignore b/Server/.gitignore index 031002751..ad29d7e67 100644 --- a/Server/.gitignore +++ b/Server/.gitignore @@ -13,3 +13,4 @@ data/profile/** *.eml *.userlibraries data/players/** +data/eco/offer_dispatch_db.emp diff --git a/Server/data/botdata/namesandarmor.txt b/Server/data/botdata/namesandarmor.txt index e9945743d..aa642ede3 100644 --- a/Server/data/botdata/namesandarmor.txt +++ b/Server/data/botdata/namesandarmor.txt @@ -41,7 +41,6 @@ wef6qwe4r561:3:0:0:0:0:0:0:0:0:0:0:0:0: Sister 13:3:12600:9793:0:20590:6186:24325:0:13288:0:0:23285:0: IsidraJr:58:0:0:0:0:0:0:0:0:0:0:0:0: BeDeMaSa0891:3:0:0:0:0:0:0:0:0:0:0:0:0: -Jazzy Otto:101:22689:0:22692:1419:22695:0:0:22698:0:0:22701:0: JustSkillezZ:50:1017:0:0:1387:426:0:0:428:0:0:0:0: Elcangri11:39:1017:1007:1727:1381:1035:1199:0:1033:0:1059:1061:0: haroldas 99r:13:1017:1019:1731:843:0:0:0:1015:0:1059:1061:0: @@ -58,7 +57,6 @@ laitukas29:3:0:0:0:0:0:0:0:0:0:0:0:0: AFRODITA-23:38:0:0:0:0:0:0:0:0:0:0:0:0: Monrojas:50:0:1029:1725:1381:0:0:0:1099:0:1065:1061:0: stejler:114:21266:6570:19553:4151:21301:12954:0:21304:0:7462:11840:0: -r0cK4eV3r:103:11850:11852:0:0:11854:0:0:11856:0:11858:11860:0: Loamjytuner:3:0:0:0:0:0:0:0:0:0:0:0:0: u smoke mid:92:12293:10499:10364:1387:1121:1197:0:1071:0:1065:11840:0: MIMIYEEET:64:0:10499:0:861:0:0:0:0:0:0:0:0: diff --git a/Server/data/botdata/pestcontrolcopies.txt b/Server/data/botdata/pestcontrolcopies.txt index b49c37af7..8227fbbd1 100644 --- a/Server/data/botdata/pestcontrolcopies.txt +++ b/Server/data/botdata/pestcontrolcopies.txt @@ -1 +1,11 @@ -sicriona:103:1163:1023:1725:1333:1127:1201:0:1079:0:2922:1061:0: \ No newline at end of file +#Format: +#name:cblevel:helmet:cape:neck:weapon:chest:shield:unknown:legs:unknown:gloves:boots: +sicriona:103:1163:1023:1725:1333:1127:1201:0:1079:0:2922:1061:0: +czar:110:1149:6568:1704:4587:10564:6524:0:4585:0:1059:1061: +loving puppy:95:11665:6568:1704:4587:8839:14767:0:8840:0:8842:1061: +rattle63:83:14096:10499:1704:4151:14094:14767:0:14095:0:8842:1061: +baluga:110:10828:6568:10354:4151:3140:6524:0:4087:0:8842:11732: +crabcake:115:10828:10446:10354:4151:10564:6524:0:4087:0:8842:11732: +Red:94:1163:6568:10354:7158:10564:0:0:4087:0:1059:11732: +puglet:120:10828:6568:6585:11696:4757:0:0:8840:0:1059:3105: +linux:10000:10828:10069:1725:4151:3140:14767:0:4087:0:1059:3105: diff --git a/Server/data/eco/grand_exchange_db.emp b/Server/data/eco/grand_exchange_db.emp index 162477603..a464ce8d5 100644 Binary files a/Server/data/eco/grand_exchange_db.emp and b/Server/data/eco/grand_exchange_db.emp differ diff --git a/Server/data/eco/offer_dispatch_db.emp b/Server/data/eco/offer_dispatch_db.emp index 8a564cbc2..e72a0c90e 100644 Binary files a/Server/data/eco/offer_dispatch_db.emp and b/Server/data/eco/offer_dispatch_db.emp differ diff --git a/Server/src/org/crandor/game/container/Container.java b/Server/src/org/crandor/game/container/Container.java index 2c7667d31..e9ebf1932 100644 --- a/Server/src/org/crandor/game/container/Container.java +++ b/Server/src/org/crandor/game/container/Container.java @@ -13,888 +13,954 @@ import java.util.Map; /** * Represents a container which contains items. + * * @author Emperor */ public class Container { - /** - * The item array. A crystalline - */ - private Item[] items; + /** + * The item array. A crystalline + */ + private Item[] items; - /** - * The capacity. - */ - private final int capacity; + /** + * The capacity. + */ + private final int capacity; - /** - * The current sort type. - */ - private SortType sortType; + /** + * The current sort type. + */ + private SortType sortType; - /** - * The current container type. - */ - private final ContainerType type; + /** + * The current container type. + */ + private final ContainerType type; - /** - * The current container event. - */ - private ContainerEvent event; + /** + * The current container event. + */ + private ContainerEvent event; - /** - * The container listeners. - */ - private final List listeners = new ArrayList<>(); + /** + * The container listeners. + */ + private final List listeners = new ArrayList<>(); - /** - * Constructs a new {@code Container} {@code Object}. - * @param capacity The capacity. - */ - public Container(int capacity) { - this(capacity, ContainerType.DEFAULT); - } + /** + * Constructs a new {@code Container} {@code Object}. + * + * @param capacity The capacity. + */ + public Container(int capacity) { + this(capacity, ContainerType.DEFAULT); + } - /** - * Constructs a new {@code Container.java} {@code Object}. - * @param capacity the capacity. - * @param items the items to add. - */ - public Container(int capacity, Item... items) { - this(capacity); - add(items); - } + /** + * Constructs a new {@code Container.java} {@code Object}. + * + * @param capacity the capacity. + * @param items the items to add. + */ + public Container(int capacity, Item... items) { + this(capacity); + add(items); + } - /** - * Constructs a new {@code Container} {@code Object}. - * @param capacity The capacity. - * @param type The container type. - */ - public Container(int capacity, ContainerType type) { - this(capacity, type, SortType.ID); - } + /** + * Constructs a new {@code Container} {@code Object}. + * + * @param capacity The capacity. + * @param type The container type. + */ + public Container(int capacity, ContainerType type) { + this(capacity, type, SortType.ID); + } - /** - * Constructs a new {@code Container} {@code Object}. - * @param capacity The capacity. - * @param type The container type. - * @param sortType The sort type. - */ - public Container(int capacity, ContainerType type, SortType sortType) { - this.capacity = capacity; - this.type = type; - this.items = new Item[capacity]; - this.sortType = sortType; - this.event = new ContainerEvent(capacity); - } + /** + * Constructs a new {@code Container} {@code Object}. + * + * @param capacity The capacity. + * @param type The container type. + * @param sortType The sort type. + */ + public Container(int capacity, ContainerType type, SortType sortType) { + this.capacity = capacity; + this.type = type; + this.items = new Item[capacity]; + this.sortType = sortType; + this.event = new ContainerEvent(capacity); + } - /** - * Registers a container listener. - * @param listener The container listener. - * @return This container instance, for chaining. - */ - public Container register(ContainerListener listener) { - listeners.add(listener); - return this; - } + /** + * Registers a container listener. + * + * @param listener The container listener. + * @return This container instance, for chaining. + */ + public Container register(ContainerListener listener) { + listeners.add(listener); + return this; + } - /** - * Adds the items. - * @param items The items to add. - * @return {@code True} if successfully added all items. - */ - public boolean add(Item... items) { - boolean addedAll = true; - for (Item item : items) { - if (item == null) { - continue; - } - if (!add(item, false)) { - addedAll = false; - break; - } - } - update(); - return addedAll; - } + /** + * Adds the items. + * + * @param items The items to add. + * @return {@code True} if successfully added all items. + */ + public boolean add(Item... items) { + boolean addedAll = true; + for (Item item : items) { + if (item == null) { + continue; + } + if (!add(item, false)) { + addedAll = false; + break; + } + } + update(); + return addedAll; + } - /** - * Inserts an item into a specific slot. - * @param fromSlot The original slot of the item. - * @param toSlot The slot to insert into. - */ - public void insert(int fromSlot, int toSlot) { - insert(fromSlot, toSlot, true); - } + /** + * Inserts an item into a specific slot. + * + * @param fromSlot The original slot of the item. + * @param toSlot The slot to insert into. + */ + public void insert(int fromSlot, int toSlot) { + insert(fromSlot, toSlot, true); + } - /** - * Inserts an item into a specific slot. - * @param fromSlot The original slot of the item. - * @param toSlot The slot to insert into. - * @param update If the container packets should be sent. - */ - public void insert(int fromSlot, int toSlot, boolean update) { - Item temp = items[fromSlot]; - if (toSlot > fromSlot) { - for (int i = fromSlot; i < toSlot; i++) { - replace(get(i + 1), i, false); - } - } else if (fromSlot > toSlot) { - for (int i = fromSlot; i > toSlot; i--) { - replace(get(i - 1), i, false); - } - } - replace(temp, toSlot, update); - } + /** + * Inserts an item into a specific slot. + * + * @param fromSlot The original slot of the item. + * @param toSlot The slot to insert into. + * @param update If the container packets should be sent. + */ + public void insert(int fromSlot, int toSlot, boolean update) { + Item temp = items[fromSlot]; + if (toSlot > fromSlot) { + for (int i = fromSlot; i < toSlot; i++) { + replace(get(i + 1), i, false); + } + } else if (fromSlot > toSlot) { + for (int i = fromSlot; i > toSlot; i--) { + replace(get(i - 1), i, false); + } + } + replace(temp, toSlot, update); + } - /** - * Adds an item to this container if full it goes to ground. - * @param item the item. - * @param player the player. - * @param ground - * @return {@code True} if added. - */ - public boolean add(final Item item, final Player player) { - if (!add(item, true, -1)) { - GroundItemManager.create(item, player); - return false; - } - return true; - } + /** + * Adds an item to this container if full it goes to ground. + * + * @param item the item. + * @param player the player. + * @param ground + * @return {@code True} if added. + */ + public boolean add(final Item item, final Player player) { + if (!add(item, true, -1)) { + GroundItemManager.create(item, player); + return false; + } + return true; + } - public boolean addIfDoesntHave(final Item item) { - if(containsItem(item)) { - return false; - } else { - return add(item); + public boolean addIfDoesntHave(final Item item) { + if (containsItem(item)) { + return false; + } else { + return add(item); - } - } + } + } - /** - * Adds an item to this container. - * @param item The item. - * @return {@code True} if the item got added. - */ - public boolean add(Item item) { - return add(item, true, -1); - } + /** + * Adds an item to this container. + * + * @param item The item. + * @return {@code True} if the item got added. + */ + public boolean add(Item item) { + return add(item, true, -1); + } - /** - * Adds an item to this container. - * @param item The item to add. - * @param fireListener If we should update. - * @param preferredSlot The slot to add the item in, when possible. - * @return {@code True} if the item got added. - */ - public boolean add(Item item, boolean fireListener) { - return add(item, fireListener, -1); - } + /** + * Adds an item to this container. + * + * @param item The item to add. + * @param fireListener If we should update. + * @param preferredSlot The slot to add the item in, when possible. + * @return {@code True} if the item got added. + */ + public boolean add(Item item, boolean fireListener) { + return add(item, fireListener, -1); + } - /** - * Adds an item to this container. - * @param item The item to add. - * @param fireListener If we should update. - * @param preferredSlot The slot to add the item in, when possible. - * @return {@code True} if the item got added. - */ - public boolean add(Item item, boolean fireListener, int preferredSlot) { - item = item.copy(); - int maximum = getMaximumAdd(item); - if (maximum == 0) { - return false; - } + /** + * Adds an item to this container. + * + * @param item The item to add. + * @param fireListener If we should update. + * @param preferredSlot The slot to add the item in, when possible. + * @return {@code True} if the item got added. + */ + public boolean add(Item item, boolean fireListener, int preferredSlot) { + item = item.copy(); + int maximum = getMaximumAdd(item); + if (maximum == 0) { + return false; + } // if (preferredSlot > -1 && items[preferredSlot] != null) { // preferredSlot = -1; // } - if (item.getAmount() > maximum) { - item.setAmount(maximum); - } - if (type != ContainerType.NEVER_STACK && (item.getDefinition().isStackable() || type == ContainerType.ALWAYS_STACK || type == ContainerType.SHOP)) { - boolean hashBased = sortType == SortType.HASH; - for (int i = 0; i < items.length; i++) { - if (items[i] != null) { - if ((hashBased && items[i].getIdHash() == item.getIdHash()) || (!hashBased && items[i].getId() == item.getId())) { - int totalCount = item.getAmount() + items[i].getAmount(); - items[i] = new Item(items[i].getId(), totalCount, item.getCharge()); - items[i].setIndex(i); - event.flag(i, items[i]); - if (fireListener) { - update(); - } - return true; - } - } - } - int slot = preferredSlot > -1 ? preferredSlot : freeSlot(); - if (slot == -1) { - return false; - } - items[slot] = item; - item.setIndex(slot); - event.flag(slot, item); - if (fireListener) { - update(); - } - return true; - } - int slots = freeSlots(); - if (slots >= item.getAmount()) { - for (int i = 0; i < item.getAmount(); i++) { - int slot = i == 0 && preferredSlot > -1 ? preferredSlot : freeSlot(); - items[slot] = new Item(item.getId(), 1, item.getCharge()); - items[slot].setIndex(slot); - event.flag(slot, items[slot]); - } - if (fireListener) { - update(); - } - return true; - } - return false; - } + if (item.getAmount() > maximum) { + item.setAmount(maximum); + } + if (type != ContainerType.NEVER_STACK && (item.getDefinition().isStackable() || type == ContainerType.ALWAYS_STACK || type == ContainerType.SHOP)) { + boolean hashBased = sortType == SortType.HASH; + for (int i = 0; i < items.length; i++) { + if (items[i] != null) { + if ((hashBased && items[i].getIdHash() == item.getIdHash()) || (!hashBased && items[i].getId() == item.getId())) { + int totalCount = item.getAmount() + items[i].getAmount(); + items[i] = new Item(items[i].getId(), totalCount, item.getCharge()); + items[i].setIndex(i); + event.flag(i, items[i]); + if (fireListener) { + update(); + } + return true; + } + } + } + int slot = preferredSlot > -1 ? preferredSlot : freeSlot(); + if (slot == -1) { + return false; + } + items[slot] = item; + item.setIndex(slot); + event.flag(slot, item); + if (fireListener) { + update(); + } + return true; + } + int slots = freeSlots(); + if (slots >= item.getAmount()) { + for (int i = 0; i < item.getAmount(); i++) { + int slot = i == 0 && preferredSlot > -1 ? preferredSlot : freeSlot(); + items[slot] = new Item(item.getId(), 1, item.getCharge()); + items[slot].setIndex(slot); + event.flag(slot, items[slot]); + } + if (fireListener) { + update(); + } + return true; + } + return false; + } - /** - * Removes a set of items. - * @param items The set of items. - * @return {@code True} if all items got successfully removed. - */ - public boolean remove(Item... items) { - boolean removedAll = true; - for (Item item : items) { - if (!remove(item, false)) { - removedAll = false; - } - } - update(); - return removedAll; - } + /** + * Removes a set of items. + * + * @param items The set of items. + * @return {@code True} if all items got successfully removed. + */ + public boolean remove(Item... items) { + boolean removedAll = true; + for (Item item : items) { + if (!remove(item, false)) { + removedAll = false; + } + } + update(); + return removedAll; + } - /** - * Removes an item. - * @param item The item. - * @return {@code True} if the item got removed, {@code false} if not. - */ - public boolean remove(Item item) { - return remove(item, true); - } + /** + * Removes an item. + * + * @param item The item. + * @return {@code True} if the item got removed, {@code false} if not. + */ + public boolean remove(Item item) { + return remove(item, true); + } - /** - * Removes an item. - * @param item The item to remove. - * @param fireListener If the fire listener should be "notified". - * @return {@code True} if the item got removed,
{@code false} if not. - */ - public boolean remove(Item item, boolean fireListener) { - int slot = getSlot(item); - if (slot != -1) { - return remove(item, slot, fireListener); - } - return false; - } + /** + * Removes an item. + * + * @param item The item to remove. + * @param fireListener If the fire listener should be "notified". + * @return {@code True} if the item got removed,
{@code false} if not. + */ + public boolean remove(Item item, boolean fireListener) { + int slot = getSlot(item); + if (slot != -1) { + return remove(item, slot, fireListener); + } + return false; + } - /** - * Removes an item from this container. - * @param item The item. - * @param slot The item slot. - * @param fireListener If the fire listener should be "notified". - * @return {@code True} if the item got removed,
{@code false} if the - * item on the slot was null or the ids didn't match. - */ - public boolean remove(Item item, int slot, boolean fireListener) { - Item oldItem = items[slot]; - if (oldItem == null || oldItem.getId() != item.getId()) { - return false; - } - if (item.getAmount() < 1) { - return true; - } - if (oldItem.getDefinition().isStackable() || type.equals(ContainerType.ALWAYS_STACK) || type == ContainerType.SHOP) { - if (item.getAmount() >= oldItem.getAmount()) { - items[slot] = null; - event.flagNull(slot); - if (fireListener) { - update(); - } - return true; - } - items[slot] = new Item(item.getId(), oldItem.getAmount() - item.getAmount(), item.getCharge()); - items[slot].setIndex(slot); - event.flag(slot, items[slot]); - if (fireListener) { - update(); - } - return true; - } - items[slot] = null; - event.flagNull(slot); - int removed = 1; - for (int i = removed; i < item.getAmount(); i++) { - slot = getSlot(item); - if (slot != -1) { - items[slot] = null; - event.flagNull(slot); - } else { - break; - } - } - if (fireListener) { - update(); - } - return true; - } + /** + * Removes an item from this container. + * + * @param item The item. + * @param slot The item slot. + * @param fireListener If the fire listener should be "notified". + * @return {@code True} if the item got removed,
{@code false} if the + * item on the slot was null or the ids didn't match. + */ + public boolean remove(Item item, int slot, boolean fireListener) { + Item oldItem = items[slot]; + if (oldItem == null || oldItem.getId() != item.getId()) { + return false; + } + if (item.getAmount() < 1) { + return true; + } + if (oldItem.getDefinition().isStackable() || type.equals(ContainerType.ALWAYS_STACK) || type == ContainerType.SHOP) { + if (item.getAmount() >= oldItem.getAmount()) { + items[slot] = null; + event.flagNull(slot); + if (fireListener) { + update(); + } + return true; + } + items[slot] = new Item(item.getId(), oldItem.getAmount() - item.getAmount(), item.getCharge()); + items[slot].setIndex(slot); + event.flag(slot, items[slot]); + if (fireListener) { + update(); + } + return true; + } + items[slot] = null; + event.flagNull(slot); + int removed = 1; + for (int i = removed; i < item.getAmount(); i++) { + slot = getSlot(item); + if (slot != -1) { + items[slot] = null; + event.flagNull(slot); + } else { + break; + } + } + if (fireListener) { + update(); + } + return true; + } - /** - * Replaces the item on the given slot with the argued item. - * @param item The item. - * @param slot The slot. - * @return The old item. - */ - public Item replace(Item item, int slot) { - return replace(item, slot, true); - } + /** + * Replaces the item on the given slot with the argued item. + * + * @param item The item. + * @param slot The slot. + * @return The old item. + */ + public Item replace(Item item, int slot) { + return replace(item, slot, true); + } - /** - * Replaces the item on the given slot with the argued item. - * @param item The item. - * @param slot The slot. - * @param fireListener If the listener should be "notified". - * @return The old item. - */ - public Item replace(Item item, int slot, boolean fireListener) { - if (item != null) { - if (item.getAmount() < 1 && type != ContainerType.SHOP) { - item = null; - } else { - item = item.copy(); - } - } - Item oldItem = items[slot]; - items[slot] = item; - if (item == null) { - event.flagNull(slot); - } else { - item.setIndex(slot); - event.flag(slot, item); - } - if (fireListener) { - update(); - } - return oldItem; - } + /** + * Replaces the item on the given slot with the argued item. + * + * @param item The item. + * @param slot The slot. + * @param fireListener If the listener should be "notified". + * @return The old item. + */ + public Item replace(Item item, int slot, boolean fireListener) { + if (item != null) { + if (item.getAmount() < 1 && type != ContainerType.SHOP) { + item = null; + } else { + item = item.copy(); + } + } + Item oldItem = items[slot]; + items[slot] = item; + if (item == null) { + event.flagNull(slot); + } else { + item.setIndex(slot); + event.flag(slot, item); + } + if (fireListener) { + update(); + } + return oldItem; + } - /** - * Updates the container. - */ - public void update() { - if (event.getChangeCount() < 1 && !event.isClear()) { - return; - } - for (ContainerListener listener : listeners) { - listener.update(this, event); - } - event.setClear(false); - event = new ContainerEvent(capacity); - } + /** + * Updates the container. + */ + public void update() { + if (event.getChangeCount() < 1 && !event.isClear()) { + return; + } + for (ContainerListener listener : listeners) { + listener.update(this, event); + } + event.setClear(false); + event = new ContainerEvent(capacity); + } - /** - * Updates the container. - */ - public void update(boolean force) { - if (event.getChangeCount() < 1 && !force) { - return; - } - for (ContainerListener listener : listeners) { - listener.update(this, event); - } - event = new ContainerEvent(capacity); - } + /** + * Updates the container. + */ + public void update(boolean force) { + if (event.getChangeCount() < 1 && !force) { + return; + } + for (ContainerListener listener : listeners) { + listener.update(this, event); + } + event = new ContainerEvent(capacity); + } - /** - * Refreshes the entire container. - */ - public void refresh() { - for (ContainerListener listener : listeners) { - listener.refresh(this); - } - event = new ContainerEvent(capacity); - } + /** + * Refreshes the entire container. + */ + public void refresh() { + for (ContainerListener listener : listeners) { + listener.refresh(this); + } + event = new ContainerEvent(capacity); + } - /** - * Gets the item on the given slot. - * @param slot The slot. - * @return The item on the slot, or {@code null} if the item wasn't there. - */ - public Item get(int slot) { - if (slot < 0 || slot >= items.length) { - return null; - } - return items[slot]; - } + /** + * Gets the item on the given slot. + * + * @param slot The slot. + * @return The id of the item on the slot, or 0 if the item wasn't there. + */ + public int getAsId(int slot) { + if (slot < 0 || slot >= items.length || items[slot] == null) { + return 0; + } + return items[slot].getId(); + } - /** - * Gets the item on the given slot. - * @param slot The slot. - * @return The item on the slot, or a new constructed item with id 0 if the - * item wasn't there. - */ - public Item getNew(int slot) { - Item item = items[slot]; - if (item != null) { - return item; - } - return new Item(0); - } - /** - * Gets the item id on the given slot. - * @param slot The slot. - * @return The id of the item on the slot. - */ - public int getId(int slot) { - if (slot >= items.length) { - return -1; - } - Item item = items[slot]; - if (item != null) { - return item.getId(); - } - return -1; - } + /** + * Gets the item on the given slot. + * + * @param slot The slot. + * @return The item on the slot, or {@code null} if the item wasn't there. + */ + public Item get(int slot) { + if (slot < 0 || slot >= items.length) { + return null; + } + return items[slot]; + } - /** - * Parses the container data from the byte buffer. - * @param buffer The byte buffer. - * @return The total value of all items (G.E price > Store price > High - * alchemy price). - */ - public int parse(ByteBuffer buffer) { - int slot; - int total = 0; - while ((slot = buffer.getShort()) != -1) { - int id = buffer.getShort() & 0xFFFF; - int amount = buffer.getInt(); - int charge = buffer.getInt(); - if (id >= ItemDefinition.getDefinitions().size() || id < 0 || slot >= items.length || slot < 0) { - continue; - } - Item item = items[slot] = new Item(id, amount, charge); - item.setIndex(slot); - total += item.getValue(); - } - return total; - } + /** + * Gets the item on the given slot. + * + * @param slot The slot. + * @return The item on the slot, or a new constructed item with id 0 if the + * item wasn't there. + */ + public Item getNew(int slot) { + Item item = items[slot]; + if (item != null) { + return item; + } + return new Item(0); + } - /** - * Saves the item data on the byte buffer. - * @param buffer The byte buffer. - * @return The total value of all items (G.E price > Store price > High - * alchemy price). - */ - public long save(ByteBuffer buffer) { - long totalValue = 0; - for (int i = 0; i < items.length; i++) { - Item item = items[i]; - if (item == null) { - continue; - } - buffer.putShort((short) i); - buffer.putShort((short) item.getId()); - buffer.putInt(item.getAmount()); - buffer.putInt(item.getCharge()); - totalValue += item.getValue(); - } - buffer.putShort((short) -1); - return totalValue; - } + /** + * Gets the item id on the given slot. + * + * @param slot The slot. + * @return The id of the item on the slot. + */ + public int getId(int slot) { + if (slot >= items.length) { + return -1; + } + Item item = items[slot]; + if (item != null) { + return item.getId(); + } + return -1; + } - /** - * Copies the container to this container. - * @param c The container to copy. - */ - public void copy(Container c) { - items = new Item[c.items.length]; - for (int i = 0; i < items.length; i++) { - Item it = c.items[i]; - if (it == null) { - continue; - } - items[i] = new Item(it.getId(), it.getAmount(), it.getCharge()); - items[i].setIndex(i); - } - } + /** + * Parses the container data from the byte buffer. + * + * @param buffer The byte buffer. + * @return The total value of all items (G.E price > Store price > High + * alchemy price). + */ + public int parse(ByteBuffer buffer) { + int slot; + int total = 0; + while ((slot = buffer.getShort()) != -1) { + int id = buffer.getShort() & 0xFFFF; + int amount = buffer.getInt(); + int charge = buffer.getInt(); + if (id >= ItemDefinition.getDefinitions().size() || id < 0 || slot >= items.length || slot < 0) { + continue; + } + Item item = items[slot] = new Item(id, amount, charge); + item.setIndex(slot); + total += item.getValue(); + } + return total; + } - /** - * Formats a container for the SQL database. - * @return the string. - */ - public String format() { - String log = ""; - Map map = new HashMap<>(); - Integer old = null; - for (Item item : items) { - if (item != null) { - old = map.get(item.getId()); - map.put(item.getId(), old == null ? item.getAmount() : old + item.getAmount()); + /** + * Saves the item data on the byte buffer. + * + * @param buffer The byte buffer. + * @return The total value of all items (G.E price > Store price > High + * alchemy price). + */ + public long save(ByteBuffer buffer) { + long totalValue = 0; + for (int i = 0; i < items.length; i++) { + Item item = items[i]; + if (item == null) { + continue; + } + buffer.putShort((short) i); + buffer.putShort((short) item.getId()); + buffer.putInt(item.getAmount()); + buffer.putInt(item.getCharge()); + totalValue += item.getValue(); + } + buffer.putShort((short) -1); + return totalValue; + } - } - } - for (int i : map.keySet()) { - log += i + "," + map.get(i) + "|"; - } - if (log.length() > 0 && log.charAt(log.length() - 1) == '|') { - log = log.substring(0, log.length() - 1); - } - return log; - } + /** + * Copies the container to this container. + * + * @param c The container to copy. + */ + public void copy(Container c) { + items = new Item[c.items.length]; + for (int i = 0; i < items.length; i++) { + Item it = c.items[i]; + if (it == null) { + continue; + } + items[i] = new Item(it.getId(), it.getAmount(), it.getCharge()); + items[i].setIndex(i); + } + } - /** - * Checks if the container contains an item. - * @param item the Item - * @return {@code True} if so. - */ - public boolean containsItem(Item item) { - return contains(item.getId(), item.getAmount()); - } + /** + * Formats a container for the SQL database. + * + * @return the string. + */ + public String format() { + String log = ""; + Map map = new HashMap<>(); + Integer old = null; + for (Item item : items) { + if (item != null) { + old = map.get(item.getId()); + map.put(item.getId(), old == null ? item.getAmount() : old + item.getAmount()); - /** - * Checks if the containers contains these items. - * @param items the items. - * @return {@code True} if so. - */ - public boolean containsItems(Item... items) { - for (Item i : items) { - if (!containsItem(i)) { - return false; - } - } - return true; - } + } + } + for (int i : map.keySet()) { + log += i + "," + map.get(i) + "|"; + } + if (log.length() > 0 && log.charAt(log.length() - 1) == '|') { + log = log.substring(0, log.length() - 1); + } + return log; + } - /** - * Checks if the container contains an item. - * @param itemId The item id. - * @param amount The amount. - * @return {@code True} if so. - */ - public boolean contains(int itemId, int amount) { - int count = 0; - for (Item item : items) { - if (item != null && item.getId() == itemId) { - if ((count += item.getAmount()) >= amount) { - return true; - } - } - } - return false; - } + /** + * Checks if the container contains an item. + * + * @param item the Item + * @return {@code True} if so. + */ + public boolean containsItem(Item item) { + return contains(item.getId(), item.getAmount()); + } - /** - * Checks if the containers contains ONE item. - * @param itemId - * @return - */ - public boolean containsOneItem(int itemId) { - for (Item item : items) { - if (item != null && item.getId() == itemId && item.getAmount() == 1) { - return true; - } - } - return false; - } - - /** - * Checks if the container contains all items. - * @param the itemIds to check - * @return {@code True} if so. - */ - public boolean containsAll(int...itemIds) { - for (int i : itemIds) { - if (!containsOneItem(i)) { - return false; - } - } - return true; - } + /** + * Checks if the containers contains these items. + * + * @param items the items. + * @return {@code True} if so. + */ + public boolean containsItems(Item... items) { + for (Item i : items) { + if (!containsItem(i)) { + return false; + } + } + return true; + } - /** - * Adds a container to this container. - * @param container The container. - */ - public void addAll(Container container) { - add(container.items); - } + /** + * Checks if the container contains an item. + * + * @param itemId The item id. + * @param amount The amount. + * @return {@code True} if so. + */ + public boolean contains(int itemId, int amount) { + int count = 0; + for (Item item : items) { + if (item != null && item.getId() == itemId) { + if ((count += item.getAmount()) >= amount) { + return true; + } + } + } + return false; + } - /** - * Checks the maximum amount of this item we can add. - * @param item The item. - * @return The maximum amount we can add. - */ - public int getMaximumAdd(Item item) { - if (type != ContainerType.NEVER_STACK) { - if (item.getDefinition().isStackable() || type == ContainerType.ALWAYS_STACK || type == ContainerType.SHOP) { - if (contains(item.getId(), 1)) { - return Integer.MAX_VALUE - getAmount(item); - } - return freeSlots() > 0 ? Integer.MAX_VALUE : 0; - } - } - return freeSlots(); - } + /** + * Checks if the containers contains ONE item. + * + * @param itemId + * @return + */ + public boolean containsOneItem(int itemId) { + for (Item item : items) { + if (item != null && item.getId() == itemId && item.getAmount() == 1) { + return true; + } + } + return false; + } - /** - * Checks if the container has space for the item. - * @param item The item to check. - * @return {@code True} if so. - */ - public boolean hasSpaceFor(Item item) { - return item.getAmount() <= getMaximumAdd(item); - } + /** + * Checks if the container contains all items. + * + * @param the itemIds to check + * @return {@code True} if so. + */ + public boolean containsAll(int... itemIds) { + for (int i : itemIds) { + if (!containsOneItem(i)) { + return false; + } + } + return true; + } - /** - * Checks if this container has space to add the other container. - * @param c The other container. - * @return {@code True} if so. - */ - public boolean hasSpaceFor(Container c) { - if (c == null) { - return false; - } - Container check = new Container(capacity, type); - check.addAll(this); - for (Item item : c.items) { - if (item != null) { - if (!check.add(item, false)) { - return false; - } - } - } - return true; - } + /** + * Adds a container to this container. + * + * @param container The container. + */ + public void addAll(Container container) { + add(container.items); + } - /** - * Gets the item slot. - * @param item The item. - * @return The slot of the item in this container. - */ - public int getSlot(Item item) { - if (item == null) { - return -1; - } - int id = item.getId(); - for (int i = 0; i < items.length; i++) { - Item it = items[i]; - if (it != null && it.getId() == id) { - return i; - } - } - return -1; - } + /** + * Checks the maximum amount of this item we can add. + * + * @param item The item. + * @return The maximum amount we can add. + */ + public int getMaximumAdd(Item item) { + if (type != ContainerType.NEVER_STACK) { + if (item.getDefinition().isStackable() || type == ContainerType.ALWAYS_STACK || type == ContainerType.SHOP) { + if (contains(item.getId(), 1)) { + return Integer.MAX_VALUE - getAmount(item); + } + return freeSlots() > 0 ? Integer.MAX_VALUE : 0; + } + } + return freeSlots(); + } - /** - * Gets the item instance. - * @param item the item. - * @return the item. - */ - public Item getItem(Item item) { - return get(getSlot(item)); - } + /** + * Checks if the container has space for the item. + * + * @param item The item to check. + * @return {@code True} if so. + */ + public boolean hasSpaceFor(Item item) { + return item.getAmount() <= getMaximumAdd(item); + } - /** - * Gets the next free slot. - * @return The slot, or -1 if there are no available slots. - */ - public int freeSlot() { - for (int i = 0; i < items.length; i++) { - if (items[i] == null) { - return i; - } - } - return -1; - } + /** + * Checks if this container has space to add the other container. + * + * @param c The other container. + * @return {@code True} if so. + */ + public boolean hasSpaceFor(Container c) { + if (c == null) { + return false; + } + Container check = new Container(capacity, type); + check.addAll(this); + for (Item item : c.items) { + if (item != null) { + if (!check.add(item, false)) { + return false; + } + } + } + return true; + } - /** - * Gets the slot of where to add the item. - * @param item The item to add. - * @return The slot where the item will go. - */ - public int getAddSlot(Item item) { - if (type != ContainerType.NEVER_STACK && (item.getDefinition().isStackable() || type.equals(ContainerType.ALWAYS_STACK) || type == ContainerType.SHOP)) { - boolean hashBased = sortType == SortType.HASH; - for (int i = 0; i < items.length; i++) { - if (items[i] != null) { - if ((hashBased && items[i].getIdHash() == item.getIdHash()) || (!hashBased && items[i].getId() == item.getId())) { - return i; - } - } - } - } - return freeSlot(); - } + /** + * Gets the item slot. + * + * @param item The item. + * @return The slot of the item in this container. + */ + public int getSlot(Item item) { + if (item == null) { + return -1; + } + int id = item.getId(); + for (int i = 0; i < items.length; i++) { + Item it = items[i]; + if (it != null && it.getId() == id) { + return i; + } + } + return -1; + } - /** - * Gets the number of free slots. - * @return The number of free slots. - */ - public int freeSlots() { - return capacity - itemCount(); - } + /** + * Gets the item instance. + * + * @param item the item. + * @return the item. + */ + public Item getItem(Item item) { + return get(getSlot(item)); + } - /** - * Gets the size of this container. - * @return The size of this container. - */ - public int itemCount() { - int size = 0; - for (int i = 0; i < items.length; i++) { - if (items[i] != null) { - size++; - } - } - return size; - } + /** + * Gets the next free slot. + * + * @return The slot, or -1 if there are no available slots. + */ + public int freeSlot() { + for (int i = 0; i < items.length; i++) { + if (items[i] == null) { + return i; + } + } + return -1; + } - /** - * Checks if the player has all the item ids in the inventory. - * @param itemIds The item ids. - * @return {@code True} if so. - */ - public boolean containItems(int... itemIds) { - for (int i = 0; i < itemIds.length; i++) { - if (!contains(itemIds[i], 1)) { - return false; - } - } - return true; - } + /** + * Gets the slot of where to add the item. + * + * @param item The item to add. + * @return The slot where the item will go. + */ + public int getAddSlot(Item item) { + if (type != ContainerType.NEVER_STACK && (item.getDefinition().isStackable() || type.equals(ContainerType.ALWAYS_STACK) || type == ContainerType.SHOP)) { + boolean hashBased = sortType == SortType.HASH; + for (int i = 0; i < items.length; i++) { + if (items[i] != null) { + if ((hashBased && items[i].getIdHash() == item.getIdHash()) || (!hashBased && items[i].getId() == item.getId())) { + return i; + } + } + } + } + return freeSlot(); + } - /** - * Gets the amount of an item. - * @param item The item. - * @return The amount of this item in this container. - */ - public int getAmount(Item item) { - if (item == null) { - return 0; - } - int count = 0; - for (Item i : items) { - if (i != null && i.getId() == item.getId()) { - count += i.getAmount(); - } - } - return count; - } + /** + * Gets the number of free slots. + * + * @return The number of free slots. + */ + public int freeSlots() { + return capacity - itemCount(); + } - /** - * Gets the amount. - * @param id the id. - * @return the amount. - */ - public int getAmount(int id) { - return getAmount(new Item(id)); - } + /** + * Gets the size of this container. + * + * @return The size of this container. + */ + public int itemCount() { + int size = 0; + for (int i = 0; i < items.length; i++) { + if (items[i] != null) { + size++; + } + } + return size; + } - /** - * Shifts the elements in the Container to the appropriate position. - */ - public void shift() { - final Item itemss[] = items; - clear(false); - for (Item item : itemss) { - if (item == null) { - continue; - } - add(item, false); - } - refresh(); - } + /** + * Checks if the player has all the item ids in the inventory. + * + * @param itemIds The item ids. + * @return {@code True} if so. + */ + public boolean containItems(int... itemIds) { + for (int i = 0; i < itemIds.length; i++) { + if (!contains(itemIds[i], 1)) { + return false; + } + } + return true; + } - /** - * Checks if the container is empty. - * @return {@code True} if so. - */ - public boolean isEmpty() { - for (Item item : items) { - if (item != null) { - return false; - } - } - return true; - } + /** + * Gets the amount of an item. + * + * @param item The item. + * @return The amount of this item in this container. + */ + public int getAmount(Item item) { + if (item == null) { + return 0; + } + int count = 0; + for (Item i : items) { + if (i != null && i.getId() == item.getId()) { + count += i.getAmount(); + } + } + return count; + } - /** - * Checks if the container is full. - * @return {@code True} if so. - */ - public boolean isFull() { - return freeSlots() < 1; - } - - /** - * Clears and updates the container. - */ - public void clear() { - clear(true); - } + /** + * Gets the amount. + * + * @param id the id. + * @return the amount. + */ + public int getAmount(int id) { + return getAmount(new Item(id)); + } - /** - * Clears the container. - * @param update If the container should be updated. - */ - public void clear(boolean update) { - items = new Item[capacity]; - event.flagEmpty(); - if (update) { - refresh(); - } - } + /** + * Shifts the elements in the Container to the appropriate position. + */ + public void shift() { + final Item itemss[] = items; + clear(false); + for (Item item : itemss) { + if (item == null) { + continue; + } + add(item, false); + } + refresh(); + } - /** - * Gets the wealth. - * @return the wealth. - */ - public int getWealth() { - int wealth = 0; - for (Item i : items) { - if (i == null) { - continue; - } - wealth += i.getDefinition().getValue() * i.getAmount(); - } - return wealth; - } + /** + * Checks if the container is empty. + * + * @return {@code True} if so. + */ + public boolean isEmpty() { + for (Item item : items) { + if (item != null) { + return false; + } + } + return true; + } - /** - * Returns an array representing this container. - * @return The array. - */ - public Item[] toArray() { - return items; - } + /** + * Checks if the container is full. + * + * @return {@code True} if so. + */ + public boolean isFull() { + return freeSlots() < 1; + } - /** - * Gets the listeners. - * @return The listeners. - */ - public List getListeners() { - return listeners; - } + /** + * Clears and updates the container. + */ + public void clear() { + clear(true); + } - /** - * Gets the capacity. - * @return The capacity of this container. - */ - public int capacity() { - return capacity; - } + /** + * Clears the container. + * + * @param update If the container should be updated. + */ + public void clear(boolean update) { + items = new Item[capacity]; + event.flagEmpty(); + if (update) { + refresh(); + } + } - /** - * Gets the event. - * @return the event. - */ - public ContainerEvent getEvent() { - return event; - } + /** + * Gets the wealth. + * + * @return the wealth. + */ + public int getWealth() { + int wealth = 0; + for (Item i : items) { + if (i == null) { + continue; + } + wealth += i.getDefinition().getValue() * i.getAmount(); + } + return wealth; + } + + /** + * Returns an array representing this container. + * + * @return The array. + */ + public Item[] toArray() { + return items; + } + + /** + * Gets the listeners. + * + * @return The listeners. + */ + public List getListeners() { + return listeners; + } + + /** + * Gets the capacity. + * + * @return The capacity of this container. + */ + public int capacity() { + return capacity; + } + + /** + * Gets the event. + * + * @return the event. + */ + public ContainerEvent getEvent() { + return event; + } } \ No newline at end of file diff --git a/Server/src/org/crandor/game/content/global/ttrail/ClueScrollPlugin.java b/Server/src/org/crandor/game/content/global/ttrail/ClueScrollPlugin.java index 95a8a6f74..12cb4e3a2 100644 --- a/Server/src/org/crandor/game/content/global/ttrail/ClueScrollPlugin.java +++ b/Server/src/org/crandor/game/content/global/ttrail/ClueScrollPlugin.java @@ -86,6 +86,7 @@ public abstract class ClueScrollPlugin extends MapZone implements Plugin } nextStage(player, clue); if (casket) { + player.getStatisticsManager().getCLUES_COMPLETED().incrementAmount(); player.getInventory().replace(level.getCasket(), clue.getSlot()); } else { player.getInventory().remove(clue); diff --git a/Server/src/org/crandor/game/content/skill/free/gather/GatheringSkillPulse.java b/Server/src/org/crandor/game/content/skill/free/gather/GatheringSkillPulse.java index bc983b197..4c3080b11 100644 --- a/Server/src/org/crandor/game/content/skill/free/gather/GatheringSkillPulse.java +++ b/Server/src/org/crandor/game/content/skill/free/gather/GatheringSkillPulse.java @@ -154,6 +154,7 @@ public final class GatheringSkillPulse extends SkillPulse { Projectile.create(player, null, 1776, 35, 30, 20, 25).transform(player, new Location(player.getLocation().getX() + 2, player.getLocation().getY()), true, 25, 25).send(); player.getSkills().addExperience(Skills.WOODCUTTING, resource.getExperience()); player.getSkills().addExperience(Skills.FIREMAKING, resource.getExperience()); + player.getStatisticsManager().getLOGS_OBTAINED().incrementAmount(); return false; } int reward = resource.getReward(); @@ -176,6 +177,7 @@ public final class GatheringSkillPulse extends SkillPulse { player.getPacketDispatch().sendMessage("You cut a branch from the Dramen tree."); } else { player.getPacketDispatch().sendMessage("You get some " + ItemDefinition.forId(reward).getName().toLowerCase() + "."); + player.getStatisticsManager().getLOGS_OBTAINED().incrementAmount(); } // Calculate if the player should receive a bonus gem or bonus ore or both if (!isMiningEssence && isMining) { diff --git a/Server/src/org/crandor/game/node/entity/Entity.java b/Server/src/org/crandor/game/node/entity/Entity.java index c4549a903..d5f9ef9d4 100644 --- a/Server/src/org/crandor/game/node/entity/Entity.java +++ b/Server/src/org/crandor/game/node/entity/Entity.java @@ -211,6 +211,10 @@ public abstract class Entity extends Node { * @param killer The killer of this entity. */ public void finalizeDeath(Entity killer) { + if (killer.isPlayer()) { + if (!((Player)killer).isArtificial()) + ((Player)killer).getStatisticsManager().getENTITIES_KILLED().incrementAmount(); + } skills.restore(); skills.rechargePrayerPoints(); impactHandler.getImpactQueue().clear(); diff --git a/Server/src/org/crandor/game/node/entity/player/Player.java b/Server/src/org/crandor/game/node/entity/player/Player.java index 414b383e2..869b0ebb6 100644 --- a/Server/src/org/crandor/game/node/entity/player/Player.java +++ b/Server/src/org/crandor/game/node/entity/player/Player.java @@ -65,6 +65,7 @@ import org.crandor.game.node.entity.player.link.prayer.PrayerType; import org.crandor.game.node.entity.player.link.quest.QuestRepository; import org.crandor.game.node.entity.player.link.request.RequestManager; import org.crandor.game.node.entity.player.link.skillertasks.SkillerTasks; +import org.crandor.game.node.entity.player.link.statistics.PlayerStatisticsManager; import org.crandor.game.node.item.GroundItem; import org.crandor.game.node.item.GroundItemManager; import org.crandor.game.node.item.Item; @@ -99,6 +100,7 @@ import org.crandor.net.packet.out.SkillLevel; import org.crandor.net.packet.out.UpdateSceneGraph; import org.crandor.plugin.Plugin; import org.crandor.tools.StringUtils; + import plugin.activity.pyramidplunder.PlunderObjectManager; /** @@ -302,6 +304,11 @@ public class Player extends Entity { * The jobs minigame manager. */ private final JobsMinigameManager jobsManager = new JobsMinigameManager(this); + + /** + * The statistics manager. + */ + private final PlayerStatisticsManager statisticsManager = new PlayerStatisticsManager(this); /** * The logout plugins. @@ -536,6 +543,10 @@ public class Player extends Entity { return; } getPacketDispatch().sendMessage("Oh dear, you are dead!"); + + if (!isArtificial()) { + getStatisticsManager().getDEATHS().incrementAmount(); + } //If player was a Hardcore Ironman, announce that they died if (this.getIronmanManager().getMode().equals(IronmanMode.HARDCORE)){ //if this was checkRestriction, ultimate irons would be moved to HARDCORE_DEAD as well @@ -1342,4 +1353,8 @@ public class Player extends Entity { public JobsMinigameManager getJobsManager() { return jobsManager; } + + public PlayerStatisticsManager getStatisticsManager() { + return statisticsManager; + } } \ No newline at end of file diff --git a/Server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java b/Server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java index 893f6dbb0..36d5139d0 100644 --- a/Server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java +++ b/Server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java @@ -184,12 +184,11 @@ public class AIPlayer extends Player { ++n; String line = sc.nextLine(); if (rand.nextInt(n) == 0) { //Chance of overwriting line is lower and lower - OSRScopyLine = line; - if (line.length() < 3) //probably an empty line + if (line.length() < 3 || line.startsWith("#")) //probably an empty line { - System.out.println("Something went wrong reading line [" + line + "] from /data/botdata/" + fileName); - updateRandomOSRScopyLine(fileName); + continue; } + OSRScopyLine = line; } } } catch (FileNotFoundException e) { @@ -199,7 +198,9 @@ public class AIPlayer extends Player { } private static String retrieveRandomName(String fileName) { - updateRandomOSRScopyLine(fileName); + do { + updateRandomOSRScopyLine(fileName); + } while (OSRScopyLine.startsWith("#")); //Comment return OSRScopyLine.split(":")[0]; } diff --git a/Server/src/org/crandor/game/node/entity/player/ai/minigamebots/pestcontrol/CombatState.java b/Server/src/org/crandor/game/node/entity/player/ai/minigamebots/pestcontrol/CombatState.java index 94875e1eb..3c2c76a38 100644 --- a/Server/src/org/crandor/game/node/entity/player/ai/minigamebots/pestcontrol/CombatState.java +++ b/Server/src/org/crandor/game/node/entity/player/ai/minigamebots/pestcontrol/CombatState.java @@ -66,10 +66,12 @@ public class CombatState { bot.tick--; bot.eat(379); - bot.getSkills().setLevel(Skills.PRAYER, 99); - bot.getSkills().setStaticLevel(Skills.PRAYER, 99); - if (!(bot.getPrayer().getActive().contains(PrayerType.PROTECT_FROM_MELEE))) - bot.getPrayer().toggle(PrayerType.PROTECT_FROM_MELEE); + if (bot.randomType < 30) { + bot.getSkills().setLevel(Skills.PRAYER, 99); + bot.getSkills().setStaticLevel(Skills.PRAYER, 99); + if (!(bot.getPrayer().getActive().contains(PrayerType.PROTECT_FROM_MELEE))) + bot.getPrayer().toggle(PrayerType.PROTECT_FROM_MELEE); + } if (!bot.inCombat()) { diff --git a/Server/src/org/crandor/game/node/entity/player/ai/minigamebots/pestcontrol/PestControlTestBot.java b/Server/src/org/crandor/game/node/entity/player/ai/minigamebots/pestcontrol/PestControlTestBot.java index dbe1310ff..e1eb84570 100644 --- a/Server/src/org/crandor/game/node/entity/player/ai/minigamebots/pestcontrol/PestControlTestBot.java +++ b/Server/src/org/crandor/game/node/entity/player/ai/minigamebots/pestcontrol/PestControlTestBot.java @@ -3,6 +3,7 @@ package org.crandor.game.node.entity.player.ai.minigamebots.pestcontrol; import org.crandor.game.node.Node; import org.crandor.game.node.entity.Entity; import org.crandor.game.node.entity.player.ai.pvmbots.PvMBots; +import org.crandor.game.node.entity.player.link.prayer.PrayerType; import org.crandor.game.world.map.Location; import org.crandor.net.packet.in.InteractionPacket; import org.crandor.tools.RandomFunction; @@ -88,6 +89,7 @@ public class PestControlTestBot extends PvMBots { } private void attackNPCs() { + this.getWalkingQueue().setRunning(true); List creatures = FindTargets(this, 15); if (creatures == null || creatures.isEmpty()) { @@ -96,7 +98,11 @@ public class PestControlTestBot extends PvMBots { this.setCustomState("Going to portals"); combathandler.goToPortals(); } else { - randomWalkAroundPoint(getMyPestControlSession(this).getSquire().getLocation(), 3); + try { + randomWalkAroundPoint(getMyPestControlSession(this).getSquire().getLocation(), 3); + } catch (NullPointerException e) { + //Do nothing, game just finished + } movetimer = new Random().nextInt(15) + 6; } } else { @@ -121,6 +127,10 @@ public class PestControlTestBot extends PvMBots { if (new Random().nextInt(insideBoatWalks) <= 1) { insideBoatWalks *= 1.5; + if (new Random().nextInt(4) == 1) + { + this.getWalkingQueue().setRunning(!this.getWalkingQueue().isRunning()); + } if (new Random().nextInt(7) == 1) { this.walkToPosSmart(new Location(2660, 2638)); @@ -136,6 +146,10 @@ public class PestControlTestBot extends PvMBots { } private void enterBoat() { + if (getPrayer().getActive().contains(PrayerType.PROTECT_FROM_MELEE)) { + getPrayer().toggle(PrayerType.PROTECT_FROM_MELEE); + } + if (new Random().nextInt(3) <= 1) //Don't join instantly { return; diff --git a/Server/src/org/crandor/game/node/entity/player/ai/resource/ResourceAIPManager.java b/Server/src/org/crandor/game/node/entity/player/ai/resource/ResourceAIPManager.java index 6356e7433..668ae4817 100644 --- a/Server/src/org/crandor/game/node/entity/player/ai/resource/ResourceAIPManager.java +++ b/Server/src/org/crandor/game/node/entity/player/ai/resource/ResourceAIPManager.java @@ -9,6 +9,7 @@ import org.crandor.game.node.entity.player.ai.resource.task.ResourceTasks; import org.crandor.game.node.entity.player.ai.skillingbot.SkillingBotsBuilder; import org.crandor.game.system.task.Pulse; import org.crandor.game.world.GameWorld; +import org.crandor.game.world.map.Location; import java.sql.ResultSet; import java.sql.Statement; @@ -39,7 +40,6 @@ public class ResourceAIPManager { public void immerseWorld() { //There's probably a better place for this (it adds bot at bootup) PvMBotsBuilder.immersiveSpawns(); LumbridgeBotHandler.immersiveLumbridge(); - //AIPBuilder.immersiveSpawns(); //SkillingBotsBuilder.immersiveSpawnsSkillingBots(); System.out.println("Loaded immerseWorld"); } diff --git a/Server/src/org/crandor/game/node/entity/player/ai/skillingbot/SkillingBot.java b/Server/src/org/crandor/game/node/entity/player/ai/skillingbot/SkillingBot.java index 0b51ee03c..dda95a72d 100644 --- a/Server/src/org/crandor/game/node/entity/player/ai/skillingbot/SkillingBot.java +++ b/Server/src/org/crandor/game/node/entity/player/ai/skillingbot/SkillingBot.java @@ -36,12 +36,10 @@ public class SkillingBot extends AIPlayer { switch (this.skill) { - case Skills.MINING: - default: - break; + case Skills.MINING: + default: + break; } - - // TODO Auto-generated constructor stub } @Override diff --git a/Server/src/org/crandor/game/node/entity/player/ai/skillingbot/SkillingBotsBuilder.java b/Server/src/org/crandor/game/node/entity/player/ai/skillingbot/SkillingBotsBuilder.java index d828aff8a..978cd7950 100644 --- a/Server/src/org/crandor/game/node/entity/player/ai/skillingbot/SkillingBotsBuilder.java +++ b/Server/src/org/crandor/game/node/entity/player/ai/skillingbot/SkillingBotsBuilder.java @@ -176,7 +176,8 @@ public final class SkillingBotsBuilder extends AIPlayer { bot.getSkills().setLevel(Skills.FISHING, 25); bot.setInteractionRange(25); } - + + //These bots are disabled because they somehow break pets public static void immersiveSpawnsSkillingBots() { // Varrock Mine diff --git a/Server/src/org/crandor/game/node/entity/player/info/login/PlayerParser.java b/Server/src/org/crandor/game/node/entity/player/info/login/PlayerParser.java index a0656b609..5c19f2705 100644 --- a/Server/src/org/crandor/game/node/entity/player/info/login/PlayerParser.java +++ b/Server/src/org/crandor/game/node/entity/player/info/login/PlayerParser.java @@ -149,6 +149,9 @@ public final class PlayerParser { case 46: player.getSkills().parseExpRate(buffer); break; + case 47: + player.getStatisticsManager().parse(buffer); + break; default: System.err.println("[Player parsing] Unhandled opcode: " + opcode + " for " + player.getName() + " - [log=" + Arrays.toString(opcodeLog) + "]."); break; @@ -302,6 +305,8 @@ public final class PlayerParser { } player.getSkills().saveExpRate(buffer.put((byte) 46)); + + player.getStatisticsManager().save(buffer.put((byte)47)); buffer.put((byte) 0); // EOF opcode buffer.flip(); diff --git a/Server/src/org/crandor/game/node/entity/player/link/statistics/PlayerStatisticsManager.java b/Server/src/org/crandor/game/node/entity/player/link/statistics/PlayerStatisticsManager.java new file mode 100644 index 000000000..8978a5aa9 --- /dev/null +++ b/Server/src/org/crandor/game/node/entity/player/link/statistics/PlayerStatisticsManager.java @@ -0,0 +1,115 @@ +package org.crandor.game.node.entity.player.link.statistics; + +import java.nio.ByteBuffer; +import java.util.ArrayList; + +import org.crandor.game.node.entity.player.Player; +import org.crandor.game.node.entity.player.info.login.SavingModule; + +/** + * Stuff + * @author jamix77 + * + */ +public class PlayerStatisticsManager implements SavingModule { + + /** + * Array of statistics. + */ + private final ArrayList STATISTICS = new ArrayList(); + + + private Statistic + AL_KHARID_GATE_PASSES, + FLAX_PICKED, + CLUES_COMPLETED, + ENTITIES_KILLED, + DEATHS, + LOGS_OBTAINED; + + + /** + * The player instance for this manager. + */ + private final Player player; + + + public PlayerStatisticsManager(Player player) { + this.player = player; + if (!player.isArtificial()) + initStats(); + } + + private void initStats() { + AL_KHARID_GATE_PASSES = new Statistic(player,this); + FLAX_PICKED = new Statistic(player,this); + CLUES_COMPLETED = new Statistic(player,this); + LOGS_OBTAINED = new Statistic(player,this); + ENTITIES_KILLED = new Statistic(player,this); + DEATHS = new Statistic(player,this); + } + + @Override + public void save(ByteBuffer buffer) { + for (int i = 0; i < STATISTICS.size(); i++) { + Statistic s = STATISTICS.get(i); + buffer.put((byte) 1).putInt(i).putInt(s.getStatisticalAmount()); + } + buffer.put((byte)0); + } + + @Override + public void parse(ByteBuffer buffer) { + int opcode; + while ((opcode = buffer.get() & 0xFF) != 0) { + switch (opcode) { + case 1: + int index = buffer.getInt(); + int amount = buffer.getInt(); + STATISTICS.get(index).setStatisticalAmount(amount); + break; + } + } + + } + + /** + * Add a statistic to the arraylist. + * @param statistic + */ + public void addStatistic(Statistic statistic) { + STATISTICS.add(statistic); + } + + + public ArrayList getSTATISTICS() { + return STATISTICS; + } + + public Statistic getAL_KHARID_GATE_PASSES() { + return AL_KHARID_GATE_PASSES; + } + + public Statistic getFLAX_PICKED() { + return FLAX_PICKED; + } + + public Statistic getCLUES_COMPLETED() { + return CLUES_COMPLETED; + } + + public Statistic getLOGS_OBTAINED() { + return LOGS_OBTAINED; + } + + public Statistic getENTITIES_KILLED() { + return ENTITIES_KILLED; + } + + public Statistic getDEATHS() { + return DEATHS; + } + + + +} diff --git a/Server/src/org/crandor/game/node/entity/player/link/statistics/Statistic.java b/Server/src/org/crandor/game/node/entity/player/link/statistics/Statistic.java new file mode 100644 index 000000000..56878b1b5 --- /dev/null +++ b/Server/src/org/crandor/game/node/entity/player/link/statistics/Statistic.java @@ -0,0 +1,85 @@ +package org.crandor.game.node.entity.player.link.statistics; + +import org.crandor.game.node.entity.player.Player; + +/** + * A singular statistic. + * @author jamix77 + * + */ +public class Statistic { + + /** + * The player instance for this manager. + */ + private final Player player; + + /** + * The amount of the statistic. + */ + private int statisticalAmount; + + /** + * + * Constructs a new @{Code Statistic} object. + * @param player + */ + public Statistic(Player player, PlayerStatisticsManager sm) { + this(player,0,sm); + } + + /** + * + * Constructs a new @{Code Statistic} object. + * @param player + * @param amount + */ + public Statistic(Player player,int amount, PlayerStatisticsManager sm) { + this.player = player; + this.statisticalAmount = amount; + sm.addStatistic(this); + } + + /** + * Increase only by one. + */ + public void incrementAmount() { + increaseAmount(1); + } + + /** + * Decrease only by one. + */ + public void decrementAmount() { + decreaseAmount(1); + } + + /** + * Increase by a certain amount. + * @param amount + */ + public void increaseAmount(int amount) { + statisticalAmount += amount; + } + + /** + * Decrease by a certain amount. + * @param amount + */ + public void decreaseAmount(int amount) { + statisticalAmount -= amount; + } + + /** + * @return the amount + */ + public int getStatisticalAmount() { + return statisticalAmount; + } + + public void setStatisticalAmount(int statisticalAmount) { + this.statisticalAmount = statisticalAmount; + } + + +} diff --git a/Server/src/plugin/activity/pestcontrol/PCObjectHandler.java b/Server/src/plugin/activity/pestcontrol/PCObjectHandler.java index 65a888bc1..fd349d3c9 100644 --- a/Server/src/plugin/activity/pestcontrol/PCObjectHandler.java +++ b/Server/src/plugin/activity/pestcontrol/PCObjectHandler.java @@ -5,6 +5,7 @@ import org.crandor.game.content.activity.ActivityManager; import org.crandor.game.interaction.OptionHandler; import org.crandor.game.node.Node; import org.crandor.game.node.entity.player.Player; +import org.crandor.game.node.entity.player.ai.pvmbots.PvMBotsBuilder; import org.crandor.game.node.entity.player.info.Rights; import org.crandor.game.node.item.Item; import org.crandor.game.node.object.GameObject; @@ -15,12 +16,17 @@ import org.crandor.game.world.map.RegionManager; import org.crandor.game.world.update.flag.context.Animation; import org.crandor.plugin.Plugin; +import java.util.ArrayList; + /** * Handles pest control objects. * @author Emperor */ public final class PCObjectHandler extends OptionHandler { + public boolean pcbotsSpawned = false; + public ArrayList playersJoined = new ArrayList<>(); + @Override public Plugin newInstance(Object arg) throws Throwable { // Barricades @@ -91,6 +97,17 @@ public final class PCObjectHandler extends OptionHandler { } switch (object.getId()) { case 14315: // Novice + if (!pcbotsSpawned) { //First person to join gets bots to play with + pcbotsSpawned = true; + for (int pestBotsAmount = 0; pestBotsAmount < 20; pestBotsAmount++) { + PvMBotsBuilder.createPestControlTestBot(new Location(2657, 2640)); + } + } + if (!playersJoined.contains(player.getUsername())) { //You also get +1 bot for every friend + playersJoined.add(player.getUsername()); + PvMBotsBuilder.createPestControlTestBot(new Location(2657, 2640)); + } + startActivity(player, "pest control novice", Location.create(2661, 2639, 0)); return true; case 25631: // Intermediate diff --git a/Server/src/plugin/command/AIPCommandPlugin.java b/Server/src/plugin/command/AIPCommandPlugin.java index 88b6c54bb..73349214d 100644 --- a/Server/src/plugin/command/AIPCommandPlugin.java +++ b/Server/src/plugin/command/AIPCommandPlugin.java @@ -1,6 +1,7 @@ package plugin.command; import org.crandor.game.container.Container; +import org.crandor.game.container.impl.EquipmentContainer; import org.crandor.game.content.skill.Skills; import org.crandor.game.interaction.Interaction; import org.crandor.game.node.entity.player.Player; @@ -145,7 +146,7 @@ public final class AIPCommandPlugin extends CommandPlugin { player.setAttribute("aip_legion", PVPAIPActions.pvp_players = new ArrayList<>()); } for (int i = 0; i < size; i++) { - final AIPlayer aip = AIPBuilder.create( generateLocation(player)); + final AIPlayer aip = AIPBuilder.create(generateLocation(player)); aip.setControler(player); aip.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE); @@ -216,6 +217,25 @@ public final class AIPCommandPlugin extends CommandPlugin { case "immersiveworld": case "immersive": ResourceAIPManager.get().immerseWorld(); + player.sendMessage("Started immersive world, 2"); + return true; + case "botdataform": + //Dumps your current character info in the form used by data/botdata + //name:cblevel:helmet:cape:neck:weapon:chest:shield:unknown:legs:unknown:gloves:boots: + System.out.println(player.getUsername() + ":" + + player.getProperties().getCurrentCombatLevel() + ":" + + player.getEquipment().getAsId(EquipmentContainer.SLOT_HAT) + ":" + + player.getEquipment().getAsId(EquipmentContainer.SLOT_CAPE) + ":" + + player.getEquipment().getAsId(EquipmentContainer.SLOT_AMULET) + ":" + + player.getEquipment().getAsId(EquipmentContainer.SLOT_WEAPON) + ":" + + player.getEquipment().getAsId(EquipmentContainer.SLOT_CHEST) + ":" + + player.getEquipment().getAsId(EquipmentContainer.SLOT_SHIELD) + ":" + + "0" + ":" + + player.getEquipment().getAsId(EquipmentContainer.SLOT_LEGS) + ":" + + "0" + ":" + + player.getEquipment().getAsId(EquipmentContainer.SLOT_HANDS) + ":" + + player.getEquipment().getAsId(EquipmentContainer.SLOT_FEET) + ":" + ); return true; case "fishtest": SkillingBotsBuilder.spawnTroutLumbridge(new Location(3241, 3242)); @@ -254,7 +274,7 @@ public final class AIPCommandPlugin extends CommandPlugin { try { arg2 = Integer.parseInt(args[1]); } catch (Exception e) { - arg2 = 123; + arg2 = 20; } for (int pestBotsAmount = 0; pestBotsAmount < arg2; pestBotsAmount++) { PvMBotsBuilder.createPestControlTestBot(player.getLocation()); diff --git a/Server/src/plugin/command/DeveloperCommandPlugin.java b/Server/src/plugin/command/DeveloperCommandPlugin.java index 34d7a0e62..a8b5d3737 100644 --- a/Server/src/plugin/command/DeveloperCommandPlugin.java +++ b/Server/src/plugin/command/DeveloperCommandPlugin.java @@ -26,6 +26,7 @@ import org.crandor.game.node.entity.player.ai.resource.ResourceAIPManager; import org.crandor.game.node.entity.player.info.login.PlayerParser; import org.crandor.game.node.entity.player.link.IronmanMode; import org.crandor.game.node.entity.player.link.appearance.Gender; +import org.crandor.game.node.entity.player.link.music.MusicEntry; import org.crandor.game.node.entity.player.link.quest.Quest; import org.crandor.game.node.entity.player.link.skillertasks.Difficulty; import org.crandor.game.node.entity.state.EntityState; @@ -100,6 +101,17 @@ public final class DeveloperCommandPlugin extends CommandPlugin { @Override public boolean parse(final Player player, String name, String[] args) { switch (name) { + case "unlockmusic": + for (MusicEntry me : MusicEntry.getSongs().values()) { + player.getMusicPlayer().unlock(me.getId()); + } + + break; + + case "playsong": + player.getMusicPlayer().play(MusicEntry.getSongs().get(Integer.parseInt(args[1]))); + player.sendMessage("Playing song: " + MusicEntry.getSongs().get(Integer.parseInt(args[1])).getName()); + break; case "find": try { player.getAttributes().put("spawning_items", true); diff --git a/Server/src/plugin/command/PlayerCommandPlugin.java b/Server/src/plugin/command/PlayerCommandPlugin.java index b8190196f..8550db010 100644 --- a/Server/src/plugin/command/PlayerCommandPlugin.java +++ b/Server/src/plugin/command/PlayerCommandPlugin.java @@ -2,10 +2,14 @@ package plugin.command; import org.crandor.ServerConstants; import org.crandor.game.component.Component; +import org.crandor.game.content.skill.Skills; import org.crandor.game.node.entity.player.Player; +import org.crandor.game.node.entity.player.info.PlayerDetails; import org.crandor.game.node.entity.player.info.Rights; +import org.crandor.game.node.entity.player.info.login.PlayerParser; import org.crandor.game.node.entity.player.link.IronmanMode; import org.crandor.game.node.entity.player.link.RunScript; +import org.crandor.game.node.entity.player.link.music.MusicEntry; import org.crandor.game.node.entity.player.link.quest.Quest; import org.crandor.game.node.entity.player.link.quest.QuestRepository; import org.crandor.game.system.command.CommandPlugin; @@ -53,6 +57,27 @@ public final class PlayerCommandPlugin extends CommandPlugin { TutorialStage.load(player, stage, false); break; */ + case "stats": + + + player.setAttribute("runscript", new RunScript() { + @Override + public boolean handle() { + try { + Player target = new Player(PlayerDetails.getDetails((String)value)); + PlayerParser.parse(target); + if (!target.getDetails().parse()) return true; + sendHiscore(player,target); + } + catch (Exception e) {player.getDialogueInterpreter().sendPlainMessage(false, "That isn't a valid name.");} + return true; + } + }); + player.getDialogueInterpreter().sendInput(true, "Enter a username:"); + + + + break; case "shop": CREDIT_STORE.open(player); @@ -254,6 +279,49 @@ public final class PlayerCommandPlugin extends CommandPlugin { player.getPacketDispatch().sendString("::bankresettabs", 275, lineId++); player.getPacketDispatch().sendString("Reset all of your bank tabs.", 275, lineId++); } + + private void sendHiscore(Player player, Player target) { + if (player.getInterfaceManager().isOpened()) { + player.sendMessage("Finish what you're currently doing."); + return; + } + player.getInterfaceManager().open(new Component(275)); + //CLear old data + for (int i = 0; i < 311; i++) { + player.getPacketDispatch().sendString("", 275, i); + } + // Title + //14 Ult IM + //13 IM + //15 HCIM + player.getPacketDispatch().sendString("" + (target.getRights() == Rights.ADMINISTRATOR ? "" : (target.getRights() == Rights.PLAYER_MODERATOR ? "" : (target.getIronmanManager().getMode() == IronmanMode.STANDARD ? "" : (target.getIronmanManager().getMode() == IronmanMode.ULTIMATE ? "" : (target.getIronmanManager().getMode() == IronmanMode.HARDCORE ? "" : ""))))) + "" + target.getUsername() + "'s stats.", 275, 2); + + // Content + int lineId = 11; + player.getPacketDispatch().sendString("Total level: " + target.getSkills().getTotalLevel(), 275, lineId++); + player.getPacketDispatch().sendString("Total xp: " + StringUtils.getFormattedNumber(target.getSkills().getTotalXp()), 275, lineId++); + for (int i = 0; i < Skills.SKILL_NAME.length; i++) { + player.getPacketDispatch().sendString("" + Skills.SKILL_NAME[i] + ": " + target.getSkills().getStaticLevel(i) + " (" + StringUtils.getFormattedNumber((int) Math.round(target.getSkills().getExperience(i))) + ")", 275, lineId++); + } + + //stats + player.getPacketDispatch().sendString("(Since 27/03/2020) Al kharid passes: " + target.getStatisticsManager().getAL_KHARID_GATE_PASSES().getStatisticalAmount(), 275, lineId++); + player.getPacketDispatch().sendString("(Since 27/03/2020) Logs chopped: " + target.getStatisticsManager().getLOGS_OBTAINED().getStatisticalAmount(), 275, lineId++); + player.getPacketDispatch().sendString("(Since 27/03/2020) Flax picked: " + target.getStatisticsManager().getFLAX_PICKED().getStatisticalAmount(), 275, lineId++); + player.getPacketDispatch().sendString("(Since 27/03/2020) Clue scrolls completed: " + target.getStatisticsManager().getCLUES_COMPLETED().getStatisticalAmount(), 275, lineId++); + player.getPacketDispatch().sendString("(Since 27/03/2020) Enemies killed: " + target.getStatisticsManager().getENTITIES_KILLED().getStatisticalAmount(), 275, lineId++); + player.getPacketDispatch().sendString("(Since 27/03/2020) Deaths: " + target.getStatisticsManager().getDEATHS().getStatisticalAmount(), 275, lineId++); + player.getPacketDispatch().sendString("Music tracks unlocked: " + target.getMusicPlayer().getUnlocked().size() + "/" + MusicEntry.getSongs().size(), 275, lineId++); + + + //quests + player.getPacketDispatch().sendString("", 275, lineId++); + player.getPacketDispatch().sendString("Quests Completed:", 275, lineId++); + for (Quest q : QuestRepository.getQuests().values()) { + player.getPacketDispatch().sendString("" + (q.isCompleted(target) ? "" : "") + q.getName() + " ", 275, lineId++); + } + + } /** * Sends information about donating. diff --git a/Server/src/plugin/dialogue/BorderGuardDialogue.java b/Server/src/plugin/dialogue/BorderGuardDialogue.java index 7641844ac..6303b87c3 100644 --- a/Server/src/plugin/dialogue/BorderGuardDialogue.java +++ b/Server/src/plugin/dialogue/BorderGuardDialogue.java @@ -103,6 +103,7 @@ public final class BorderGuardDialogue extends DialoguePlugin { } if (player.getInventory().remove(COINS)) { DoorActionHandler.handleAutowalkDoor(player, door); + player.getStatisticsManager().getAL_KHARID_GATE_PASSES().incrementAmount(); } else { player.getPacketDispatch().sendMessage("You need 10 gold coins to pay the toll."); } diff --git a/Server/src/plugin/dialogue/CaveMonk.java b/Server/src/plugin/dialogue/CaveMonk.java index 3deb89351..66d1e8453 100644 --- a/Server/src/plugin/dialogue/CaveMonk.java +++ b/Server/src/plugin/dialogue/CaveMonk.java @@ -2,6 +2,7 @@ package plugin.dialogue; import org.crandor.game.content.dialogue.DialoguePlugin; import org.crandor.game.content.dialogue.FacialExpression; +import org.crandor.game.content.skill.Skills; import org.crandor.game.node.entity.npc.NPC; import org.crandor.game.node.entity.player.Player; import org.crandor.game.node.entity.player.link.quest.Quest; @@ -104,6 +105,9 @@ public final class CaveMonk extends DialoguePlugin { end(); break; case 20: + if (player.getSkills().getLevel(Skills.PRAYER) > 2 && player.getSkills().getPrayerPoints() > 2) { + player.getSkills().decrementPrayerPoints(player.getSkills().getLevel(Skills.PRAYER) - 2); + } player.getProperties().setTeleportLocation(DUNGEON); end(); break; diff --git a/Server/src/plugin/interaction/object/FieldPickingPlugin.java b/Server/src/plugin/interaction/object/FieldPickingPlugin.java index 7f8eb79a0..34d8dee0e 100644 --- a/Server/src/plugin/interaction/object/FieldPickingPlugin.java +++ b/Server/src/plugin/interaction/object/FieldPickingPlugin.java @@ -120,6 +120,7 @@ public final class FieldPickingPlugin extends OptionHandler { int charge = object.getCharge(); player.getAudioManager().send(2581); player.getPacketDispatch().sendMessage("You pick some flax."); + player.getStatisticsManager().getFLAX_PICKED().incrementAmount(); if (charge > 1000 + RandomFunction.random(2, 8)) { object.setActive(false); object.setCharge(1000); diff --git a/Server/src/plugin/interaction/object/TollGateOptionPlugin.java b/Server/src/plugin/interaction/object/TollGateOptionPlugin.java index 88e3409b7..15197865a 100644 --- a/Server/src/plugin/interaction/object/TollGateOptionPlugin.java +++ b/Server/src/plugin/interaction/object/TollGateOptionPlugin.java @@ -25,6 +25,7 @@ public class TollGateOptionPlugin extends OptionHandler { player.getInventory().remove(new Item(995, 10)); player.getPacketDispatch().sendMessage("You quickly pay the 10 gold toll and go through the gates."); DoorActionHandler.handleAutowalkDoor(player, (GameObject) node); + player.getStatisticsManager().getAL_KHARID_GATE_PASSES().incrementAmount(); return true; } else { player.getPacketDispatch().sendMessage("You need 10 gold to pass through the gates.");