Rename and clean up MapleMapItem
This commit is contained in:
@@ -1501,14 +1501,14 @@ public class Character extends AbstractCharacterObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MapleMap map = this.getMap();
|
MapleMap map = this.getMap();
|
||||||
List<MapleMapItem> partyItems = null;
|
List<MapItem> partyItems = null;
|
||||||
|
|
||||||
int partyId = exPartyMembers != null ? -1 : this.getPartyId();
|
int partyId = exPartyMembers != null ? -1 : this.getPartyId();
|
||||||
for (WeakReference<MapleMap> mapRef : mapids) {
|
for (WeakReference<MapleMap> mapRef : mapids) {
|
||||||
MapleMap mapObj = mapRef.get();
|
MapleMap mapObj = mapRef.get();
|
||||||
|
|
||||||
if (mapObj != null) {
|
if (mapObj != null) {
|
||||||
List<MapleMapItem> partyMapItems = mapObj.updatePlayerItemDropsToParty(partyId, id, partyMembers, partyLeaver);
|
List<MapItem> partyMapItems = mapObj.updatePlayerItemDropsToParty(partyId, id, partyMembers, partyLeaver);
|
||||||
if (map.hashCode() == mapObj.hashCode()) {
|
if (map.hashCode() == mapObj.hashCode()) {
|
||||||
partyItems = partyMapItems;
|
partyItems = partyMapItems;
|
||||||
}
|
}
|
||||||
@@ -1911,13 +1911,13 @@ public class Character extends AbstractCharacterObject {
|
|||||||
pickupItem(ob, -1);
|
pickupItem(ob, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void pickupItem(MapleMapObject ob, int petIndex) { // yes, one picks the MapleMapObject, not the MapleMapItem
|
public final void pickupItem(MapleMapObject ob, int petIndex) { // yes, one picks the MapleMapObject, not the MapItem
|
||||||
if (ob == null) { // pet index refers to the one picking up the item
|
if (ob == null) { // pet index refers to the one picking up the item
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ob instanceof MapleMapItem) {
|
if (ob instanceof MapItem) {
|
||||||
MapleMapItem mapitem = (MapleMapItem) ob;
|
MapItem mapitem = (MapItem) ob;
|
||||||
if (System.currentTimeMillis() - mapitem.getDropTime() < 400 || !mapitem.canBePickedBy(this)) {
|
if (System.currentTimeMillis() - mapitem.getDropTime() < 400 || !mapitem.canBePickedBy(this)) {
|
||||||
sendPacket(PacketCreator.enableActions());
|
sendPacket(PacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ package client.command.commands.gm2;
|
|||||||
|
|
||||||
import client.Client;
|
import client.Client;
|
||||||
import client.command.Command;
|
import client.command.Command;
|
||||||
import server.maps.MapleMapItem;
|
import server.maps.MapItem;
|
||||||
import server.maps.MapleMapObject;
|
import server.maps.MapleMapObject;
|
||||||
import server.maps.MapleMapObjectType;
|
import server.maps.MapleMapObjectType;
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ public class LootCommand extends Command {
|
|||||||
public void execute(Client c, String[] params) {
|
public void execute(Client c, String[] params) {
|
||||||
List<MapleMapObject> items = c.getPlayer().getMap().getMapObjectsInRange(c.getPlayer().getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
|
List<MapleMapObject> items = c.getPlayer().getMap().getMapObjectsInRange(c.getPlayer().getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
|
||||||
for (MapleMapObject item : items) {
|
for (MapleMapObject item : items) {
|
||||||
MapleMapItem mapItem = (MapleMapItem) item;
|
MapItem mapItem = (MapItem) item;
|
||||||
if (mapItem.getOwnerId() == c.getPlayer().getId() || mapItem.getOwnerId() == c.getPlayer().getPartyId()) {
|
if (mapItem.getOwnerId() == c.getPlayer().getId() || mapItem.getOwnerId() == c.getPlayer().getPartyId()) {
|
||||||
c.getPlayer().pickupItem(mapItem);
|
c.getPlayer().pickupItem(mapItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import client.Client;
|
|||||||
import client.command.Command;
|
import client.command.Command;
|
||||||
import client.inventory.Pet;
|
import client.inventory.Pet;
|
||||||
import client.inventory.manipulator.InventoryManipulator;
|
import client.inventory.manipulator.InventoryManipulator;
|
||||||
import server.maps.MapleMapItem;
|
import server.maps.MapItem;
|
||||||
import server.maps.MapleMapObject;
|
import server.maps.MapleMapObject;
|
||||||
import server.maps.MapleMapObjectType;
|
import server.maps.MapleMapObjectType;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
@@ -46,7 +46,7 @@ public class ForceVacCommand extends Command {
|
|||||||
Character player = c.getPlayer();
|
Character player = c.getPlayer();
|
||||||
List<MapleMapObject> items = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
|
List<MapleMapObject> items = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
|
||||||
for (MapleMapObject item : items) {
|
for (MapleMapObject item : items) {
|
||||||
MapleMapItem mapItem = (MapleMapItem) item;
|
MapItem mapItem = (MapItem) item;
|
||||||
|
|
||||||
mapItem.lockItem();
|
mapItem.lockItem();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import scripting.AbstractPlayerInteraction;
|
|||||||
import server.MapleStatEffect;
|
import server.MapleStatEffect;
|
||||||
import server.TimerManager;
|
import server.TimerManager;
|
||||||
import server.life.*;
|
import server.life.*;
|
||||||
|
import server.maps.MapItem;
|
||||||
import server.maps.MapleMap;
|
import server.maps.MapleMap;
|
||||||
import server.maps.MapleMapItem;
|
|
||||||
import server.maps.MapleMapObject;
|
import server.maps.MapleMapObject;
|
||||||
import server.maps.MapleMapObjectType;
|
import server.maps.MapleMapObjectType;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
@@ -153,7 +153,7 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
|
|||||||
for (Integer oned : attack.allDamage.keySet()) {
|
for (Integer oned : attack.allDamage.keySet()) {
|
||||||
MapleMapObject mapobject = map.getMapObject(oned);
|
MapleMapObject mapobject = map.getMapObject(oned);
|
||||||
if (mapobject != null && mapobject.getType() == MapleMapObjectType.ITEM) {
|
if (mapobject != null && mapobject.getType() == MapleMapObjectType.ITEM) {
|
||||||
final MapleMapItem mapitem = (MapleMapItem) mapobject;
|
final MapItem mapitem = (MapItem) mapobject;
|
||||||
if (mapitem.getMeso() == 0) { //Maybe it is possible some how?
|
if (mapitem.getMeso() == 0) { //Maybe it is possible some how?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import client.Client;
|
|||||||
import client.inventory.Pet;
|
import client.inventory.Pet;
|
||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import server.maps.MapleMapItem;
|
import server.maps.MapItem;
|
||||||
import server.maps.MapleMapObject;
|
import server.maps.MapleMapObject;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public final class PetLootHandler extends AbstractPacketHandler {
|
|||||||
int oid = p.readInt();
|
int oid = p.readInt();
|
||||||
MapleMapObject ob = chr.getMap().getMapObject(oid);
|
MapleMapObject ob = chr.getMap().getMapObject(oid);
|
||||||
try {
|
try {
|
||||||
MapleMapItem mapitem = (MapleMapItem) ob;
|
MapItem mapitem = (MapItem) ob;
|
||||||
if (mapitem.getMeso() > 0) {
|
if (mapitem.getMeso() > 0) {
|
||||||
if (!chr.isEquippedMesoMagnet()) {
|
if (!chr.isEquippedMesoMagnet()) {
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
|
|||||||
+34
-32
@@ -30,7 +30,7 @@ import tools.PacketCreator;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
|
|
||||||
public class MapleMapItem extends AbstractMapObject {
|
public class MapItem extends AbstractMapObject {
|
||||||
protected Client ownerClient;
|
protected Client ownerClient;
|
||||||
protected Item item;
|
protected Item item;
|
||||||
protected MapleMapObject dropper;
|
protected MapleMapObject dropper;
|
||||||
@@ -38,9 +38,9 @@ public class MapleMapItem extends AbstractMapObject {
|
|||||||
protected byte type;
|
protected byte type;
|
||||||
protected boolean pickedUp = false, playerDrop, partyDrop;
|
protected boolean pickedUp = false, playerDrop, partyDrop;
|
||||||
protected long dropTime;
|
protected long dropTime;
|
||||||
private Lock itemLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.MAP_ITEM);
|
private final Lock itemLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.MAP_ITEM);
|
||||||
|
|
||||||
public MapleMapItem(Item item, Point position, MapleMapObject dropper, Character owner, Client ownerClient, byte type, boolean playerDrop) {
|
public MapItem(Item item, Point position, MapleMapObject dropper, Character owner, Client ownerClient, byte type, boolean playerDrop) {
|
||||||
setPosition(position);
|
setPosition(position);
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.dropper = dropper;
|
this.dropper = dropper;
|
||||||
@@ -53,7 +53,7 @@ public class MapleMapItem extends AbstractMapObject {
|
|||||||
this.playerDrop = playerDrop;
|
this.playerDrop = playerDrop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleMapItem(Item item, Point position, MapleMapObject dropper, Character owner, Client ownerClient, byte type, boolean playerDrop, int questid) {
|
public MapItem(Item item, Point position, MapleMapObject dropper, Character owner, Client ownerClient, byte type, boolean playerDrop, int questid) {
|
||||||
setPosition(position);
|
setPosition(position);
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.dropper = dropper;
|
this.dropper = dropper;
|
||||||
@@ -67,7 +67,7 @@ public class MapleMapItem extends AbstractMapObject {
|
|||||||
this.questid = questid;
|
this.questid = questid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleMapItem(int meso, Point position, MapleMapObject dropper, Character owner, Client ownerClient, byte type, boolean playerDrop) {
|
public MapItem(int meso, Point position, MapleMapObject dropper, Character owner, Client ownerClient, byte type, boolean playerDrop) {
|
||||||
setPosition(position);
|
setPosition(position);
|
||||||
this.item = null;
|
this.item = null;
|
||||||
this.dropper = dropper;
|
this.dropper = dropper;
|
||||||
@@ -96,21 +96,21 @@ public class MapleMapItem extends AbstractMapObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final MapleMapObject getDropper() {
|
public final MapleMapObject getDropper() {
|
||||||
return dropper;
|
return dropper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getOwnerId() {
|
public final int getOwnerId() {
|
||||||
return character_ownerid;
|
return character_ownerid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getPartyOwnerId() {
|
public final int getPartyOwnerId() {
|
||||||
return party_ownerid;
|
return party_ownerid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setPartyOwnerId(int partyid) {
|
public final void setPartyOwnerId(int partyid) {
|
||||||
party_ownerid = partyid;
|
party_ownerid = partyid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getClientsideOwnerId() { // thanks nozphex (RedHat) for noting an issue with collecting party items
|
public final int getClientsideOwnerId() { // thanks nozphex (RedHat) for noting an issue with collecting party items
|
||||||
if (this.party_ownerid == -1) {
|
if (this.party_ownerid == -1) {
|
||||||
return this.character_ownerid;
|
return this.character_ownerid;
|
||||||
@@ -118,22 +118,24 @@ public class MapleMapItem extends AbstractMapObject {
|
|||||||
return this.party_ownerid;
|
return this.party_ownerid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean hasClientsideOwnership(Character player) {
|
public final boolean hasClientsideOwnership(Character player) {
|
||||||
return this.character_ownerid == player.getId() || this.party_ownerid == player.getPartyId() || hasExpiredOwnershipTime();
|
return this.character_ownerid == player.getId() || this.party_ownerid == player.getPartyId() || hasExpiredOwnershipTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isFFADrop() {
|
public final boolean isFFADrop() {
|
||||||
return type == 2 || type == 3 || hasExpiredOwnershipTime();
|
return type == 2 || type == 3 || hasExpiredOwnershipTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean hasExpiredOwnershipTime() {
|
public final boolean hasExpiredOwnershipTime() {
|
||||||
return System.currentTimeMillis() - dropTime >= 15 * 1000;
|
return System.currentTimeMillis() - dropTime >= 15 * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean canBePickedBy(Character chr) {
|
public final boolean canBePickedBy(Character chr) {
|
||||||
if (character_ownerid <= 0 || isFFADrop()) return true;
|
if (character_ownerid <= 0 || isFFADrop()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (party_ownerid == -1) {
|
if (party_ownerid == -1) {
|
||||||
if (chr.getId() == character_ownerid) {
|
if (chr.getId() == character_ownerid) {
|
||||||
return true;
|
return true;
|
||||||
@@ -149,30 +151,30 @@ public class MapleMapItem extends AbstractMapObject {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasExpiredOwnershipTime();
|
return hasExpiredOwnershipTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Client getOwnerClient() {
|
public final Client getOwnerClient() {
|
||||||
return (ownerClient.isLoggedIn() && !ownerClient.getPlayer().isAwayFromWorld()) ? ownerClient : null;
|
return (ownerClient.isLoggedIn() && !ownerClient.getPlayer().isAwayFromWorld()) ? ownerClient : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getMeso() {
|
public final int getMeso() {
|
||||||
return meso;
|
return meso;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isPlayerDrop() {
|
public final boolean isPlayerDrop() {
|
||||||
return playerDrop;
|
return playerDrop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isPickedUp() {
|
public final boolean isPickedUp() {
|
||||||
return pickedUp;
|
return pickedUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPickedUp(final boolean pickedUp) {
|
public void setPickedUp(final boolean pickedUp) {
|
||||||
this.pickedUp = pickedUp;
|
this.pickedUp = pickedUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDropTime() {
|
public long getDropTime() {
|
||||||
return dropTime;
|
return dropTime;
|
||||||
}
|
}
|
||||||
@@ -182,34 +184,34 @@ public class MapleMapItem extends AbstractMapObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte getDropType() {
|
public byte getDropType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lockItem() {
|
public void lockItem() {
|
||||||
itemLock.lock();
|
itemLock.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unlockItem() {
|
public void unlockItem() {
|
||||||
itemLock.unlock();
|
itemLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final MapleMapObjectType getType() {
|
public final MapleMapObjectType getType() {
|
||||||
return MapleMapObjectType.ITEM;
|
return MapleMapObjectType.ITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendSpawnData(final Client client) {
|
public void sendSpawnData(final Client client) {
|
||||||
Character chr = client.getPlayer();
|
Character chr = client.getPlayer();
|
||||||
|
|
||||||
if (chr.needQuestItem(questid, getItemId())) {
|
if (chr.needQuestItem(questid, getItemId())) {
|
||||||
this.lockItem();
|
this.lockItem();
|
||||||
try {
|
try {
|
||||||
client.sendPacket(PacketCreator.dropItemFromMapObject(chr, this, null, getPosition(), (byte) 2));
|
client.sendPacket(PacketCreator.dropItemFromMapObject(chr, this, null, getPosition(), (byte) 2));
|
||||||
} finally {
|
} finally {
|
||||||
this.unlockItem();
|
this.unlockItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,7 +93,7 @@ public class MapleMap {
|
|||||||
private final Map<Integer, MaplePortal> portals = new HashMap<>();
|
private final Map<Integer, MaplePortal> portals = new HashMap<>();
|
||||||
private final Map<Integer, Integer> backgroundTypes = new HashMap<>();
|
private final Map<Integer, Integer> backgroundTypes = new HashMap<>();
|
||||||
private final Map<String, Integer> environment = new LinkedHashMap<>();
|
private final Map<String, Integer> environment = new LinkedHashMap<>();
|
||||||
private final Map<MapleMapItem, Long> droppedItems = new LinkedHashMap<>();
|
private final Map<MapItem, Long> droppedItems = new LinkedHashMap<>();
|
||||||
private final LinkedList<WeakReference<MapleMapObject>> registeredDrops = new LinkedList<>();
|
private final LinkedList<WeakReference<MapleMapObject>> registeredDrops = new LinkedList<>();
|
||||||
private final Map<MobLootEntry, Long> mobLootEntries = new HashMap(20);
|
private final Map<MobLootEntry, Long> mobLootEntries = new HashMap(20);
|
||||||
private final List<Runnable> statUpdateRunnables = new ArrayList(50);
|
private final List<Runnable> statUpdateRunnables = new ArrayList(50);
|
||||||
@@ -861,7 +861,7 @@ public class MapleMap {
|
|||||||
return droppedItemCount.get();
|
return droppedItemCount.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void instantiateItemDrop(MapleMapItem mdrop) {
|
private void instantiateItemDrop(MapItem mdrop) {
|
||||||
if (droppedItemCount.get() >= YamlConfig.config.server.ITEM_LIMIT_ON_MAP) {
|
if (droppedItemCount.get() >= YamlConfig.config.server.ITEM_LIMIT_ON_MAP) {
|
||||||
MapleMapObject mapobj;
|
MapleMapObject mapobj;
|
||||||
|
|
||||||
@@ -893,11 +893,11 @@ public class MapleMap {
|
|||||||
droppedItemCount.incrementAndGet();
|
droppedItemCount.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerItemDrop(MapleMapItem mdrop) {
|
private void registerItemDrop(MapItem mdrop) {
|
||||||
droppedItems.put(mdrop, !everlast ? Server.getInstance().getCurrentTime() + YamlConfig.config.server.ITEM_EXPIRE_TIME : Long.MAX_VALUE);
|
droppedItems.put(mdrop, !everlast ? Server.getInstance().getCurrentTime() + YamlConfig.config.server.ITEM_EXPIRE_TIME : Long.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unregisterItemDrop(MapleMapItem mdrop) {
|
private void unregisterItemDrop(MapItem mdrop) {
|
||||||
objectWLock.lock();
|
objectWLock.lock();
|
||||||
try {
|
try {
|
||||||
droppedItems.remove(mdrop);
|
droppedItems.remove(mdrop);
|
||||||
@@ -907,13 +907,13 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void makeDisappearExpiredItemDrops() {
|
private void makeDisappearExpiredItemDrops() {
|
||||||
List<MapleMapItem> toDisappear = new LinkedList<>();
|
List<MapItem> toDisappear = new LinkedList<>();
|
||||||
|
|
||||||
objectRLock.lock();
|
objectRLock.lock();
|
||||||
try {
|
try {
|
||||||
long timeNow = Server.getInstance().getCurrentTime();
|
long timeNow = Server.getInstance().getCurrentTime();
|
||||||
|
|
||||||
for (Entry<MapleMapItem, Long> it : droppedItems.entrySet()) {
|
for (Entry<MapItem, Long> it : droppedItems.entrySet()) {
|
||||||
if (it.getValue() < timeNow) {
|
if (it.getValue() < timeNow) {
|
||||||
toDisappear.add(it.getKey());
|
toDisappear.add(it.getKey());
|
||||||
}
|
}
|
||||||
@@ -922,13 +922,13 @@ public class MapleMap {
|
|||||||
objectRLock.unlock();
|
objectRLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MapleMapItem mmi : toDisappear) {
|
for (MapItem mmi : toDisappear) {
|
||||||
makeDisappearItemFromMap(mmi);
|
makeDisappearItemFromMap(mmi);
|
||||||
}
|
}
|
||||||
|
|
||||||
objectWLock.lock();
|
objectWLock.lock();
|
||||||
try {
|
try {
|
||||||
for (MapleMapItem mmi : toDisappear) {
|
for (MapItem mmi : toDisappear) {
|
||||||
droppedItems.remove(mmi);
|
droppedItems.remove(mmi);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -993,7 +993,7 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MapleMapItem> getDroppedItems() {
|
private List<MapItem> getDroppedItems() {
|
||||||
objectRLock.lock();
|
objectRLock.lock();
|
||||||
try {
|
try {
|
||||||
return new LinkedList<>(droppedItems.keySet());
|
return new LinkedList<>(droppedItems.keySet());
|
||||||
@@ -1004,7 +1004,7 @@ public class MapleMap {
|
|||||||
|
|
||||||
public int getDroppedItemsCountById(int itemid) {
|
public int getDroppedItemsCountById(int itemid) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (MapleMapItem mmi : getDroppedItems()) {
|
for (MapItem mmi : getDroppedItems()) {
|
||||||
if (mmi.getItemId() == itemid) {
|
if (mmi.getItemId() == itemid) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@@ -1013,7 +1013,7 @@ public class MapleMap {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pickItemDrop(Packet pickupPacket, MapleMapItem mdrop) { // mdrop must be already locked and not-pickedup checked at this point
|
public void pickItemDrop(Packet pickupPacket, MapItem mdrop) { // mdrop must be already locked and not-pickedup checked at this point
|
||||||
broadcastMessage(pickupPacket, mdrop.getPosition());
|
broadcastMessage(pickupPacket, mdrop.getPosition());
|
||||||
|
|
||||||
droppedItemCount.decrementAndGet();
|
droppedItemCount.decrementAndGet();
|
||||||
@@ -1022,10 +1022,10 @@ public class MapleMap {
|
|||||||
unregisterItemDrop(mdrop);
|
unregisterItemDrop(mdrop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MapleMapItem> updatePlayerItemDropsToParty(int partyid, int charid, List<Character> partyMembers, Character partyLeaver) {
|
public List<MapItem> updatePlayerItemDropsToParty(int partyid, int charid, List<Character> partyMembers, Character partyLeaver) {
|
||||||
List<MapleMapItem> partyDrops = new LinkedList<>();
|
List<MapItem> partyDrops = new LinkedList<>();
|
||||||
|
|
||||||
for (MapleMapItem mdrop : getDroppedItems()) {
|
for (MapItem mdrop : getDroppedItems()) {
|
||||||
if (mdrop.getOwnerId() == charid) {
|
if (mdrop.getOwnerId() == charid) {
|
||||||
mdrop.lockItem();
|
mdrop.lockItem();
|
||||||
try {
|
try {
|
||||||
@@ -1068,8 +1068,8 @@ public class MapleMap {
|
|||||||
return partyDrops;
|
return partyDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePartyItemDropsToNewcomer(Character newcomer, List<MapleMapItem> partyItems) {
|
public void updatePartyItemDropsToNewcomer(Character newcomer, List<MapItem> partyItems) {
|
||||||
for (MapleMapItem mdrop : partyItems) {
|
for (MapItem mdrop : partyItems) {
|
||||||
mdrop.lockItem();
|
mdrop.lockItem();
|
||||||
try {
|
try {
|
||||||
if (mdrop.isPickedUp()) {
|
if (mdrop.isPickedUp()) {
|
||||||
@@ -1095,7 +1095,7 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spawnDrop(final Item idrop, final Point dropPos, final MapleMapObject dropper, final Character chr, final byte droptype, final short questid) {
|
private void spawnDrop(final Item idrop, final Point dropPos, final MapleMapObject dropper, final Character chr, final byte droptype, final short questid) {
|
||||||
final MapleMapItem mdrop = new MapleMapItem(idrop, dropPos, dropper, chr, chr.getClient(), droptype, false, questid);
|
final MapItem mdrop = new MapItem(idrop, dropPos, dropper, chr, chr.getClient(), droptype, false, questid);
|
||||||
mdrop.setDropTime(Server.getInstance().getCurrentTime());
|
mdrop.setDropTime(Server.getInstance().getCurrentTime());
|
||||||
spawnAndAddRangedMapObject(mdrop, c -> {
|
spawnAndAddRangedMapObject(mdrop, c -> {
|
||||||
Character chr1 = c.getPlayer();
|
Character chr1 = c.getPlayer();
|
||||||
@@ -1116,7 +1116,7 @@ public class MapleMap {
|
|||||||
|
|
||||||
public final void spawnMesoDrop(final int meso, final Point position, final MapleMapObject dropper, final Character owner, final boolean playerDrop, final byte droptype) {
|
public final void spawnMesoDrop(final int meso, final Point position, final MapleMapObject dropper, final Character owner, final boolean playerDrop, final byte droptype) {
|
||||||
final Point droppos = calcDropPos(position, position);
|
final Point droppos = calcDropPos(position, position);
|
||||||
final MapleMapItem mdrop = new MapleMapItem(meso, droppos, dropper, owner, owner.getClient(), droptype, playerDrop);
|
final MapItem mdrop = new MapItem(meso, droppos, dropper, owner, owner.getClient(), droptype, playerDrop);
|
||||||
mdrop.setDropTime(Server.getInstance().getCurrentTime());
|
mdrop.setDropTime(Server.getInstance().getCurrentTime());
|
||||||
|
|
||||||
spawnAndAddRangedMapObject(mdrop, c -> {
|
spawnAndAddRangedMapObject(mdrop, c -> {
|
||||||
@@ -1133,7 +1133,7 @@ public class MapleMap {
|
|||||||
|
|
||||||
public final void disappearingItemDrop(final MapleMapObject dropper, final Character owner, final Item item, final Point pos) {
|
public final void disappearingItemDrop(final MapleMapObject dropper, final Character owner, final Item item, final Point pos) {
|
||||||
final Point droppos = calcDropPos(pos, pos);
|
final Point droppos = calcDropPos(pos, pos);
|
||||||
final MapleMapItem mdrop = new MapleMapItem(item, droppos, dropper, owner, owner.getClient(), (byte) 1, false);
|
final MapItem mdrop = new MapItem(item, droppos, dropper, owner, owner.getClient(), (byte) 1, false);
|
||||||
|
|
||||||
mdrop.lockItem();
|
mdrop.lockItem();
|
||||||
try {
|
try {
|
||||||
@@ -1145,7 +1145,7 @@ public class MapleMap {
|
|||||||
|
|
||||||
public final void disappearingMesoDrop(final int meso, final MapleMapObject dropper, final Character owner, final Point pos) {
|
public final void disappearingMesoDrop(final int meso, final MapleMapObject dropper, final Character owner, final Point pos) {
|
||||||
final Point droppos = calcDropPos(pos, pos);
|
final Point droppos = calcDropPos(pos, pos);
|
||||||
final MapleMapItem mdrop = new MapleMapItem(meso, droppos, dropper, owner, owner.getClient(), (byte) 1, false);
|
final MapItem mdrop = new MapItem(meso, droppos, dropper, owner, owner.getClient(), (byte) 1, false);
|
||||||
|
|
||||||
mdrop.lockItem();
|
mdrop.lockItem();
|
||||||
try {
|
try {
|
||||||
@@ -2137,7 +2137,7 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Point droppos = calcDropPos(pos, pos);
|
final Point droppos = calcDropPos(pos, pos);
|
||||||
final MapleMapItem mdrop = new MapleMapItem(item, droppos, dropper, owner, owner.getClient(), dropType, playerDrop);
|
final MapItem mdrop = new MapItem(item, droppos, dropper, owner, owner.getClient(), dropType, playerDrop);
|
||||||
mdrop.setDropTime(Server.getInstance().getCurrentTime());
|
mdrop.setDropTime(Server.getInstance().getCurrentTime());
|
||||||
|
|
||||||
spawnAndAddRangedMapObject(mdrop, c -> {
|
spawnAndAddRangedMapObject(mdrop, c -> {
|
||||||
@@ -2208,7 +2208,7 @@ public class MapleMap {
|
|||||||
service.registerOverallAction(mapid, r, delay);
|
service.registerOverallAction(mapid, r, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void activateItemReactors(final MapleMapItem drop, final Client c) {
|
private void activateItemReactors(final MapItem drop, final Client c) {
|
||||||
final Item item = drop.getItem();
|
final Item item = drop.getItem();
|
||||||
|
|
||||||
for (final MapleMapObject o : getReactors()) {
|
for (final MapleMapObject o : getReactors()) {
|
||||||
@@ -2232,7 +2232,7 @@ public class MapleMap {
|
|||||||
int reactItem = reactProp.getLeft(), reactQty = reactProp.getRight();
|
int reactItem = reactProp.getLeft(), reactQty = reactProp.getRight();
|
||||||
Rectangle reactArea = react.getArea();
|
Rectangle reactArea = react.getArea();
|
||||||
|
|
||||||
List<MapleMapItem> list;
|
List<MapItem> list;
|
||||||
objectRLock.lock();
|
objectRLock.lock();
|
||||||
try {
|
try {
|
||||||
list = new ArrayList<>(droppedItems.keySet());
|
list = new ArrayList<>(droppedItems.keySet());
|
||||||
@@ -2240,7 +2240,7 @@ public class MapleMap {
|
|||||||
objectRLock.unlock();
|
objectRLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final MapleMapItem drop : list) {
|
for (final MapItem drop : list) {
|
||||||
drop.lockItem();
|
drop.lockItem();
|
||||||
try {
|
try {
|
||||||
if (!drop.isPickedUp()) {
|
if (!drop.isPickedUp()) {
|
||||||
@@ -2830,15 +2830,15 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastItemDropMessage(MapleMapItem mdrop, Point dropperPos, Point dropPos, byte mod, Point rangedFrom) {
|
private void broadcastItemDropMessage(MapItem mdrop, Point dropperPos, Point dropPos, byte mod, Point rangedFrom) {
|
||||||
broadcastItemDropMessage(mdrop, dropperPos, dropPos, mod, getRangedDistance(), rangedFrom);
|
broadcastItemDropMessage(mdrop, dropperPos, dropPos, mod, getRangedDistance(), rangedFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastItemDropMessage(MapleMapItem mdrop, Point dropperPos, Point dropPos, byte mod) {
|
private void broadcastItemDropMessage(MapItem mdrop, Point dropperPos, Point dropPos, byte mod) {
|
||||||
broadcastItemDropMessage(mdrop, dropperPos, dropPos, mod, Double.POSITIVE_INFINITY, null);
|
broadcastItemDropMessage(mdrop, dropperPos, dropPos, mod, Double.POSITIVE_INFINITY, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastItemDropMessage(MapleMapItem mdrop, Point dropperPos, Point dropPos, byte mod, double rangeSq, Point rangedFrom) {
|
private void broadcastItemDropMessage(MapItem mdrop, Point dropperPos, Point dropPos, byte mod, double rangeSq, Point rangedFrom) {
|
||||||
chrRLock.lock();
|
chrRLock.lock();
|
||||||
try {
|
try {
|
||||||
for (Character chr : characters) {
|
for (Character chr : characters) {
|
||||||
@@ -3343,14 +3343,14 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean makeDisappearItemFromMap(MapleMapObject mapobj) {
|
public boolean makeDisappearItemFromMap(MapleMapObject mapobj) {
|
||||||
if (mapobj instanceof MapleMapItem) {
|
if (mapobj instanceof MapItem) {
|
||||||
return makeDisappearItemFromMap((MapleMapItem) mapobj);
|
return makeDisappearItemFromMap((MapItem) mapobj);
|
||||||
} else {
|
} else {
|
||||||
return mapobj == null; // no drop to make disappear...
|
return mapobj == null; // no drop to make disappear...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean makeDisappearItemFromMap(MapleMapItem mapitem) {
|
public boolean makeDisappearItemFromMap(MapItem mapitem) {
|
||||||
if (mapitem != null && mapitem == getMapObject(mapitem.getObjectId())) {
|
if (mapitem != null && mapitem == getMapObject(mapitem.getObjectId())) {
|
||||||
mapitem.lockItem();
|
mapitem.lockItem();
|
||||||
try {
|
try {
|
||||||
@@ -3412,11 +3412,11 @@ public class MapleMap {
|
|||||||
|
|
||||||
private class ActivateItemReactor implements Runnable {
|
private class ActivateItemReactor implements Runnable {
|
||||||
|
|
||||||
private final MapleMapItem mapitem;
|
private final MapItem mapitem;
|
||||||
private final MapleReactor reactor;
|
private final MapleReactor reactor;
|
||||||
private final Client c;
|
private final Client c;
|
||||||
|
|
||||||
public ActivateItemReactor(MapleMapItem mapitem, MapleReactor reactor, Client c) {
|
public ActivateItemReactor(MapItem mapitem, MapleReactor reactor, Client c) {
|
||||||
this.mapitem = mapitem;
|
this.mapitem = mapitem;
|
||||||
this.reactor = reactor;
|
this.reactor = reactor;
|
||||||
this.c = c;
|
this.c = c;
|
||||||
|
|||||||
@@ -1748,7 +1748,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet updateMapItemObject(MapleMapItem drop, boolean giveOwnership) {
|
public static Packet updateMapItemObject(MapItem drop, boolean giveOwnership) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.DROP_ITEM_FROM_MAPOBJECT);
|
OutPacket p = OutPacket.create(SendOpcode.DROP_ITEM_FROM_MAPOBJECT);
|
||||||
p.writeByte(2);
|
p.writeByte(2);
|
||||||
p.writeInt(drop.getObjectId());
|
p.writeInt(drop.getObjectId());
|
||||||
@@ -1766,7 +1766,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet dropItemFromMapObject(Character player, MapleMapItem drop, Point dropfrom, Point dropto, byte mod) {
|
public static Packet dropItemFromMapObject(Character player, MapItem drop, Point dropfrom, Point dropto, byte mod) {
|
||||||
int dropType = drop.getDropType();
|
int dropType = drop.getDropType();
|
||||||
if (drop.hasClientsideOwnership(player) && dropType < 3) {
|
if (drop.hasClientsideOwnership(player) && dropType < 3) {
|
||||||
dropType = 2;
|
dropType = 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user