Rename and clean up MaplePet
This commit is contained in:
@@ -162,7 +162,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
private MapleRockPaperScissor rps;
|
||||
private MapleMount maplemount;
|
||||
private MapleParty party;
|
||||
private MaplePet[] pets = new MaplePet[3];
|
||||
private Pet[] pets = new Pet[3];
|
||||
private MaplePlayerShop playerShop = null;
|
||||
private MapleShop shop = null;
|
||||
private MapleSkinColor skinColor = MapleSkinColor.NORMAL;
|
||||
@@ -616,7 +616,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
this.mesosTraded += gain;
|
||||
}
|
||||
|
||||
public void addPet(MaplePet pet) {
|
||||
public void addPet(Pet pet) {
|
||||
petLock.lock();
|
||||
try {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -2962,7 +2962,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
deletedCoupon = true;
|
||||
}
|
||||
} else {
|
||||
MaplePet pet = item.getPet(); // thanks Lame for noticing pets not getting despawned after expiration time
|
||||
Pet pet = item.getPet(); // thanks Lame for noticing pets not getting despawned after expiration time
|
||||
if (pet != null) {
|
||||
unequipPet(pet, true);
|
||||
}
|
||||
@@ -5614,7 +5614,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
this.setMessengerPosition(4);
|
||||
}
|
||||
|
||||
public MaplePet[] getPets() {
|
||||
public Pet[] getPets() {
|
||||
petLock.lock();
|
||||
try {
|
||||
return Arrays.copyOf(pets, pets.length);
|
||||
@@ -5623,7 +5623,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
public MaplePet getPet(int index) {
|
||||
public Pet getPet(int index) {
|
||||
if (index < 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -5652,7 +5652,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
public byte getPetIndex(MaplePet pet) {
|
||||
public byte getPetIndex(Pet pet) {
|
||||
petLock.lock();
|
||||
try {
|
||||
for (byte i = 0; i < 3; i++) {
|
||||
@@ -7042,7 +7042,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
ret.getInventory(item.getRight()).addItemFromDB(item.getLeft());
|
||||
Item itemz = item.getLeft();
|
||||
if (itemz.getPetId() > -1) {
|
||||
MaplePet pet = itemz.getPet();
|
||||
Pet pet = itemz.getPet();
|
||||
if (pet != null && pet.isSummoned()) {
|
||||
ret.addPet(pet);
|
||||
}
|
||||
@@ -7973,7 +7973,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void removePet(MaplePet pet, boolean shift_left) {
|
||||
public void removePet(Pet pet, boolean shift_left) {
|
||||
petLock.lock();
|
||||
try {
|
||||
int slot = -1;
|
||||
@@ -8477,7 +8477,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
List<MaplePet> petList = new LinkedList<>();
|
||||
List<Pet> petList = new LinkedList<>();
|
||||
petLock.lock();
|
||||
try {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -8489,7 +8489,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
petLock.unlock();
|
||||
}
|
||||
|
||||
for (MaplePet pet : petList) {
|
||||
for (Pet pet : petList) {
|
||||
pet.saveToDb();
|
||||
}
|
||||
|
||||
@@ -9708,7 +9708,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
|
||||
public void runFullnessSchedule(int petSlot) {
|
||||
MaplePet pet = getPet(petSlot);
|
||||
Pet pet = getPet(petSlot);
|
||||
if (pet == null) {
|
||||
return;
|
||||
}
|
||||
@@ -9762,20 +9762,20 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
|
||||
public void unequipAllPets() {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
MaplePet pet = getPet(i);
|
||||
Pet pet = getPet(i);
|
||||
if (pet != null) {
|
||||
unequipPet(pet, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unequipPet(MaplePet pet, boolean shift_left) {
|
||||
public void unequipPet(Pet pet, boolean shift_left) {
|
||||
unequipPet(pet, shift_left, false);
|
||||
}
|
||||
|
||||
public void unequipPet(MaplePet pet, boolean shift_left, boolean hunger) {
|
||||
public void unequipPet(Pet pet, boolean shift_left, boolean hunger) {
|
||||
byte petIdx = this.getPetIndex(pet);
|
||||
MaplePet chrPet = this.getPet(petIdx);
|
||||
Pet chrPet = this.getPet(petIdx);
|
||||
|
||||
if (chrPet != null) {
|
||||
chrPet.setSummoned(false);
|
||||
|
||||
@@ -26,7 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import client.command.Command;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import config.YamlConfig;
|
||||
import constants.inventory.ItemConstants;
|
||||
@@ -67,7 +67,7 @@ public class ItemCommand extends Command {
|
||||
quantity = 1;
|
||||
long days = Math.max(1, Integer.parseInt(params[1]));
|
||||
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
|
||||
int petid = MaplePet.createPet(itemId);
|
||||
int petid = Pet.createPet(itemId);
|
||||
|
||||
MapleInventoryManipulator.addById(c, itemId, quantity, player.getName(), petid, expiration);
|
||||
return;
|
||||
|
||||
@@ -28,7 +28,7 @@ import client.MapleClient;
|
||||
import client.command.Command;
|
||||
import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import config.YamlConfig;
|
||||
import constants.inventory.ItemConstants;
|
||||
import server.MapleItemInformationProvider;
|
||||
@@ -68,7 +68,7 @@ public class ItemDropCommand extends Command {
|
||||
quantity = 1;
|
||||
long days = Math.max(1, Integer.parseInt(params[1]));
|
||||
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
|
||||
int petid = MaplePet.createPet(itemId);
|
||||
int petid = Pet.createPet(itemId);
|
||||
|
||||
Item toDrop = new Item(itemId, (short) 0, quantity, petid);
|
||||
toDrop.setExpiration(expiration);
|
||||
|
||||
@@ -26,7 +26,7 @@ package client.command.commands.gm4;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import client.command.Command;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import server.maps.MapleMapItem;
|
||||
import server.maps.MapleMapObject;
|
||||
@@ -59,7 +59,7 @@ public class ForceVacCommand extends Command {
|
||||
// Add NX to account, show effect and make item disappear
|
||||
player.getCashShop().gainCash(1, mapItem.getItemId() == 4031865 ? 100 : 250);
|
||||
} else if (mapItem.getItem().getItemId() >= 5000000 && mapItem.getItem().getItemId() <= 5000100) {
|
||||
int petId = MaplePet.createPet(mapItem.getItem().getItemId());
|
||||
int petId = Pet.createPet(mapItem.getItem().getItemId());
|
||||
if (petId == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Item implements Comparable<Item> {
|
||||
private short position;
|
||||
private short quantity;
|
||||
private int petid = -1;
|
||||
private MaplePet pet = null;
|
||||
private Pet pet = null;
|
||||
private String owner = "";
|
||||
protected List<String> log;
|
||||
private short flag;
|
||||
@@ -58,7 +58,7 @@ public class Item implements Comparable<Item> {
|
||||
this.position = position;
|
||||
this.quantity = quantity;
|
||||
if (petid > -1) { // issue with null "pet" having petid > -1 found thanks to MedicOP
|
||||
this.pet = MaplePet.loadFromDb(id, position, petid);
|
||||
this.pet = Pet.loadFromDb(id, position, petid);
|
||||
if (this.pet == null) {
|
||||
petid = -1;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class Item implements Comparable<Item> {
|
||||
this.giftFrom = giftFrom;
|
||||
}
|
||||
|
||||
public MaplePet getPet() {
|
||||
public Pet getPet() {
|
||||
return pet;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,9 @@ import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Matze
|
||||
*/
|
||||
public class MaplePet extends Item {
|
||||
public class Pet extends Item {
|
||||
private String name;
|
||||
private int uniqueid;
|
||||
private int closeness = 0;
|
||||
@@ -54,13 +53,13 @@ public class MaplePet extends Item {
|
||||
private int stance;
|
||||
private boolean summoned;
|
||||
private int petFlag = 0;
|
||||
|
||||
|
||||
public enum PetFlag {
|
||||
OWNER_SPEED(0x01);
|
||||
|
||||
private int i;
|
||||
|
||||
private PetFlag(int i) {
|
||||
private final int i;
|
||||
|
||||
PetFlag(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
@@ -69,14 +68,14 @@ public class MaplePet extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
private MaplePet(int id, short position, int uniqueid) {
|
||||
private Pet(int id, short position, int uniqueid) {
|
||||
super(id, position, (short) 1);
|
||||
this.uniqueid = uniqueid;
|
||||
this.pos = new Point(0, 0);
|
||||
}
|
||||
|
||||
public static MaplePet loadFromDb(int itemid, short position, int petid) {
|
||||
MaplePet ret = new MaplePet(itemid, position, petid);
|
||||
public static Pet loadFromDb(int itemid, short position, int petid) {
|
||||
Pet ret = new Pet(itemid, position, petid);
|
||||
try (Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT name, level, closeness, fullness, summoned, flag FROM pets WHERE petid = ?")) { // Get the pet details...
|
||||
ps.setInt(1, petid);
|
||||
@@ -96,7 +95,7 @@ public class MaplePet extends Item {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void deleteFromDb(MapleCharacter owner, int petid) {
|
||||
try (Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE `petid` = ?")) {
|
||||
@@ -109,7 +108,7 @@ public class MaplePet extends Item {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void saveToDb() {
|
||||
try (Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE pets SET name = ?, level = ?, closeness = ?, fullness = ?, summoned = ?, flag = ? WHERE petid = ?")) {
|
||||
@@ -184,48 +183,55 @@ public class MaplePet extends Item {
|
||||
public byte getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
public void gainClosenessFullness(MapleCharacter owner, int incCloseness, int incFullness, int type) {
|
||||
byte slot = owner.getPetIndex(this);
|
||||
boolean enjoyed;
|
||||
|
||||
|
||||
//will NOT increase pet's closeness if tried to feed pet with 100% fullness
|
||||
if (fullness < 100 || incFullness == 0) { //incFullness == 0: command given
|
||||
int newFullness = fullness + incFullness;
|
||||
if (newFullness > 100) newFullness = 100;
|
||||
if (newFullness > 100) {
|
||||
newFullness = 100;
|
||||
}
|
||||
fullness = newFullness;
|
||||
|
||||
|
||||
if (incCloseness > 0 && closeness < 30000) {
|
||||
int newCloseness = closeness + incCloseness;
|
||||
if (newCloseness > 30000) newCloseness = 30000;
|
||||
|
||||
if (newCloseness > 30000) {
|
||||
newCloseness = 30000;
|
||||
}
|
||||
|
||||
closeness = newCloseness;
|
||||
while(newCloseness >= ExpTable.getClosenessNeededForLevel(level)) {
|
||||
while (newCloseness >= ExpTable.getClosenessNeededForLevel(level)) {
|
||||
level += 1;
|
||||
owner.sendPacket(PacketCreator.showOwnPetLevelUp(slot));
|
||||
owner.getMap().broadcastMessage(PacketCreator.showPetLevelUp(owner, slot));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enjoyed = true;
|
||||
} else {
|
||||
int newCloseness = closeness - 1;
|
||||
if (newCloseness < 0) newCloseness = 0;
|
||||
if (newCloseness < 0) {
|
||||
newCloseness = 0;
|
||||
}
|
||||
|
||||
closeness = newCloseness;
|
||||
if (level > 1 && newCloseness < ExpTable.getClosenessNeededForLevel(level - 1)) {
|
||||
level -= 1;
|
||||
}
|
||||
|
||||
|
||||
enjoyed = false;
|
||||
}
|
||||
|
||||
|
||||
owner.getMap().broadcastMessage(PacketCreator.petFoodResponse(owner.getId(), slot, enjoyed, false));
|
||||
saveToDb();
|
||||
|
||||
|
||||
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
||||
if (petz != null)
|
||||
if (petz != null) {
|
||||
owner.forceUpdateItem(petz);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLevel(byte level) {
|
||||
@@ -271,31 +277,33 @@ public class MaplePet extends Item {
|
||||
public void setSummoned(boolean yes) {
|
||||
this.summoned = yes;
|
||||
}
|
||||
|
||||
|
||||
public int getPetFlag() {
|
||||
return this.petFlag;
|
||||
}
|
||||
|
||||
|
||||
private void setPetFlag(int flag) {
|
||||
this.petFlag = flag;
|
||||
}
|
||||
|
||||
|
||||
public void addPetFlag(MapleCharacter owner, PetFlag flag) {
|
||||
this.petFlag |= flag.getValue();
|
||||
saveToDb();
|
||||
|
||||
|
||||
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
||||
if (petz != null)
|
||||
if (petz != null) {
|
||||
owner.forceUpdateItem(petz);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void removePetFlag(MapleCharacter owner, PetFlag flag) {
|
||||
this.petFlag &= 0xFFFFFFFF ^ flag.getValue();
|
||||
saveToDb();
|
||||
|
||||
|
||||
Item petz = owner.getInventory(InventoryType.CASH).getItem(getPosition());
|
||||
if (petz != null)
|
||||
if (petz != null) {
|
||||
owner.forceUpdateItem(petz);
|
||||
}
|
||||
}
|
||||
|
||||
public Pair<Integer, Boolean> canConsume(int itemId) {
|
||||
@@ -408,7 +408,7 @@ public class MapleInventoryManipulator {
|
||||
if (petid > -1) { // thanks Vcoc for finding a d/c issue with equipped pets and pets remaining on DB here
|
||||
int petIdx = chr.getPetIndex(petid);
|
||||
if(petIdx > -1) {
|
||||
MaplePet pet = chr.getPet(petIdx);
|
||||
Pet pet = chr.getPet(petIdx);
|
||||
chr.unequipPet(pet, true);
|
||||
}
|
||||
|
||||
@@ -702,7 +702,7 @@ public class MapleInventoryManipulator {
|
||||
if (petid > -1) {
|
||||
int petIdx = chr.getPetIndex(petid);
|
||||
if(petIdx > -1) {
|
||||
MaplePet pet = chr.getPet(petIdx);
|
||||
Pet pet = chr.getPet(petIdx);
|
||||
chr.unequipPet(pet, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import client.SkillFactory;
|
||||
import client.inventory.InventoryType;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import provider.MapleDataProvider;
|
||||
import provider.MapleDataProviderFactory;
|
||||
@@ -44,7 +44,7 @@ public class SpawnPetProcessor {
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MaplePet pet = chr.getInventory(InventoryType.CASH).getItem(slot).getPet();
|
||||
Pet pet = chr.getInventory(InventoryType.CASH).getItem(slot).getPet();
|
||||
if (pet == null) return;
|
||||
|
||||
int petid = pet.getItemId();
|
||||
@@ -56,7 +56,7 @@ public class SpawnPetProcessor {
|
||||
return;
|
||||
} else {
|
||||
int evolveid = MapleDataTool.getInt("info/evol1", dataRoot.getData("Pet/" + petid + ".img"));
|
||||
int petId = MaplePet.createPet(evolveid);
|
||||
int petId = Pet.createPet(evolveid);
|
||||
if (petId == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ package net.server.channel.handlers;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import client.inventory.PetCommand;
|
||||
import client.inventory.PetDataFactory;
|
||||
import net.AbstractPacketHandler;
|
||||
@@ -38,7 +38,7 @@ public final class PetCommandHandler extends AbstractPacketHandler {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
int petId = p.readInt();
|
||||
byte petIndex = chr.getPetIndex(petId);
|
||||
MaplePet pet;
|
||||
Pet pet;
|
||||
if (petIndex == -1) {
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@ package net.server.channel.handlers;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import client.autoban.AutobanFactory;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class PetExcludeItemsHandler extends AbstractPacketHandler {
|
||||
byte petIndex = chr.getPetIndex(petId);
|
||||
if (petIndex < 0) return;
|
||||
|
||||
final MaplePet pet = chr.getPet(petIndex);
|
||||
final Pet pet = chr.getPet(petIndex);
|
||||
if (pet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import client.autoban.AutobanManager;
|
||||
import client.inventory.Inventory;
|
||||
import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
@@ -53,7 +53,7 @@ public final class PetFoodHandler extends AbstractPacketHandler {
|
||||
}
|
||||
int previousFullness = 100;
|
||||
byte slot = 0;
|
||||
MaplePet[] pets = chr.getPets();
|
||||
Pet[] pets = chr.getPets();
|
||||
for (byte i = 0; i < 3; i++) {
|
||||
if (pets[i] != null) {
|
||||
if (pets[i].getFullness() < previousFullness) {
|
||||
@@ -63,7 +63,7 @@ public final class PetFoodHandler extends AbstractPacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
MaplePet pet = chr.getPet(slot);
|
||||
Pet pet = chr.getPet(slot);
|
||||
if(pet == null) return;
|
||||
|
||||
short pos = p.readShort();
|
||||
|
||||
@@ -23,7 +23,7 @@ package net.server.channel.handlers;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import server.maps.MapleMapItem;
|
||||
@@ -42,7 +42,7 @@ public final class PetLootHandler extends AbstractPacketHandler {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
|
||||
int petIndex = chr.getPetIndex(p.readInt());
|
||||
MaplePet pet = chr.getPet(petIndex);
|
||||
Pet pet = chr.getPet(petIndex);
|
||||
if (pet == null || !pet.isSummoned()) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
|
||||
@@ -338,7 +338,7 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
|
||||
player.checkBerserk(player.isHidden());
|
||||
|
||||
if (newcomer) {
|
||||
for (MaplePet pet : player.getPets()) {
|
||||
for (Pet pet : player.getPets()) {
|
||||
if (pet != null) {
|
||||
wserv.registerPetHunger(player, player.getPetIndex(pet));
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
|
||||
player.getMap().startMapEffect(ii.getMsg(itemId).replaceFirst("%s", player.getName()).replaceFirst("%s", p.readString()), itemId);
|
||||
remove(c, position, itemId);
|
||||
} else if (itemType == 517) {
|
||||
MaplePet pet = player.getPet(0);
|
||||
Pet pet = player.getPet(0);
|
||||
if (pet == null) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
@@ -405,7 +405,7 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
|
||||
|
||||
} else if (itemType == 524) {
|
||||
for (byte i = 0; i < 3; i++) {
|
||||
MaplePet pet = player.getPet(i);
|
||||
Pet pet = player.getPet(i);
|
||||
if (pet != null) {
|
||||
Pair<Integer, Boolean> pair = pet.canConsume(itemId);
|
||||
|
||||
|
||||
@@ -498,8 +498,8 @@ public class AbstractPlayerInteraction {
|
||||
}
|
||||
|
||||
public Item evolvePet(byte slot, int afterId) {
|
||||
MaplePet evolved = null;
|
||||
MaplePet target;
|
||||
Pet evolved = null;
|
||||
Pet target;
|
||||
|
||||
long period = (long) 90 * 24 * 60 * 60 * 1000; //refreshes expiration date: 90 days
|
||||
|
||||
@@ -512,7 +512,7 @@ public class AbstractPlayerInteraction {
|
||||
Item tmp = gainItem(afterId, (short) 1, false, true, period, target);
|
||||
|
||||
/*
|
||||
evolved = MaplePet.loadFromDb(tmp.getItemId(), tmp.getPosition(), tmp.getPetId());
|
||||
evolved = Pet.loadFromDb(tmp.getItemId(), tmp.getPosition(), tmp.getPetId());
|
||||
|
||||
evolved = tmp.getPet();
|
||||
if(evolved == null) {
|
||||
@@ -561,17 +561,17 @@ public class AbstractPlayerInteraction {
|
||||
return gainItem(id, quantity, randomStats, showMessage, expires, null);
|
||||
}
|
||||
|
||||
public Item gainItem(int id, short quantity, boolean randomStats, boolean showMessage, long expires, MaplePet from) {
|
||||
public Item gainItem(int id, short quantity, boolean randomStats, boolean showMessage, long expires, Pet from) {
|
||||
Item item = null;
|
||||
MaplePet evolved;
|
||||
Pet evolved;
|
||||
int petId = -1;
|
||||
|
||||
if (quantity >= 0) {
|
||||
if (ItemConstants.isPet(id)) {
|
||||
petId = MaplePet.createPet(id);
|
||||
petId = Pet.createPet(id);
|
||||
|
||||
if(from != null) {
|
||||
evolved = MaplePet.loadFromDb(id, (short) 0, petId);
|
||||
evolved = Pet.loadFromDb(id, (short) 0, petId);
|
||||
|
||||
Point pos = getPlayer().getPosition();
|
||||
pos.y -= 12;
|
||||
@@ -1113,13 +1113,13 @@ public class AbstractPlayerInteraction {
|
||||
return getPlayer().getJailExpirationTimeLeft();
|
||||
}
|
||||
|
||||
public List<MaplePet> getDriedPets() {
|
||||
List<MaplePet> list = new LinkedList<>();
|
||||
public List<Pet> getDriedPets() {
|
||||
List<Pet> list = new LinkedList<>();
|
||||
|
||||
long curTime = System.currentTimeMillis();
|
||||
for(Item it : getPlayer().getInventory(InventoryType.CASH).list()) {
|
||||
if(ItemConstants.isPet(it.getItemId()) && it.getExpiration() < curTime) {
|
||||
MaplePet pet = it.getPet();
|
||||
Pet pet = it.getPet();
|
||||
if (pet != null) {
|
||||
list.add(pet);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ package scripting.npc;
|
||||
import client.*;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.ItemFactory;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import config.YamlConfig;
|
||||
import constants.game.GameConstants;
|
||||
import constants.inventory.ItemConstants;
|
||||
@@ -336,7 +336,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
}
|
||||
|
||||
public void gainCloseness(int closeness) {
|
||||
for (MaplePet pet : getPlayer().getPets()) {
|
||||
for (Pet pet : getPlayer().getPets()) {
|
||||
if(pet != null) {
|
||||
pet.gainClosenessFullness(getPlayer(), closeness, 0, 0);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class CashShop {
|
||||
|
||||
int petid = -1;
|
||||
if (ItemConstants.isPet(itemId)) {
|
||||
petid = MaplePet.createPet(itemId);
|
||||
petid = Pet.createPet(itemId);
|
||||
}
|
||||
|
||||
if (ItemConstants.getInventoryType(itemId).equals(InventoryType.EQUIP)) {
|
||||
|
||||
@@ -24,7 +24,7 @@ package server;
|
||||
import client.MapleClient;
|
||||
import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import constants.inventory.ItemConstants;
|
||||
import tools.DatabaseConnection;
|
||||
@@ -138,7 +138,7 @@ public class MapleShop {
|
||||
int diff = cardreduce + c.getPlayer().getMeso();
|
||||
if (MapleInventoryManipulator.checkSpace(c, itemId, quantity, "")) {
|
||||
if (ItemConstants.isPet(itemId)) {
|
||||
int petid = MaplePet.createPet(itemId);
|
||||
int petid = Pet.createPet(itemId);
|
||||
MapleInventoryManipulator.addById(c, itemId, quantity, "", petid, -1);
|
||||
} else {
|
||||
MapleInventoryManipulator.addById(c, itemId, quantity, "", -1, -1);
|
||||
|
||||
@@ -28,7 +28,7 @@ import client.autoban.AutobanFactory;
|
||||
import client.inventory.Equip;
|
||||
import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import client.status.MonsterStatus;
|
||||
import client.status.MonsterStatusEffect;
|
||||
import config.YamlConfig;
|
||||
@@ -2452,8 +2452,8 @@ public class MapleMap {
|
||||
chr.sendPacket(PacketCreator.getClock(pqTimer / 1000));
|
||||
}
|
||||
|
||||
MaplePet[] pets = chr.getPets();
|
||||
for (MaplePet pet : pets) {
|
||||
Pet[] pets = chr.getPets();
|
||||
for (Pet pet : pets) {
|
||||
if (pet != null) {
|
||||
pet.setPos(getGroundBelow(chr.getPosition()));
|
||||
chr.sendPacket(PacketCreator.showPet(chr, pet, false, false));
|
||||
|
||||
@@ -19,11 +19,10 @@
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.MaplePet;
|
||||
import client.MapleClient;
|
||||
import client.inventory.Pet;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
@@ -46,12 +45,12 @@ public class PetSpeedAction extends MapleQuestAction {
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleClient c = chr.getClient();
|
||||
|
||||
MaplePet pet = chr.getPet(0); // assuming here only the pet leader will gain owner speed
|
||||
Pet pet = chr.getPet(0); // assuming here only the pet leader will gain owner speed
|
||||
if(pet == null) return;
|
||||
|
||||
c.lockClient();
|
||||
try {
|
||||
pet.addPetFlag(c.getPlayer(), MaplePet.PetFlag.OWNER_SPEED);
|
||||
pet.addPetFlag(c.getPlayer(), Pet.PetFlag.OWNER_SPEED);
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.MaplePet;
|
||||
import client.MapleClient;
|
||||
import client.inventory.Pet;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
@@ -50,7 +50,7 @@ public class PetTamenessAction extends MapleQuestAction {
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleClient c = chr.getClient();
|
||||
|
||||
MaplePet pet = chr.getPet(0); // assuming here only the pet leader will gain tameness
|
||||
Pet pet = chr.getPet(0); // assuming here only the pet leader will gain tameness
|
||||
if(pet == null) return;
|
||||
|
||||
c.lockClient();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.Pet;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
@@ -55,7 +55,7 @@ public class MinTamenessRequirement extends MapleQuestRequirement {
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
int curCloseness = 0;
|
||||
|
||||
for(MaplePet pet : chr.getPets()) {
|
||||
for(Pet pet : chr.getPets()) {
|
||||
if(pet == null) continue;
|
||||
|
||||
if(pet.getCloseness() > curCloseness)
|
||||
|
||||
@@ -22,14 +22,15 @@
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.MaplePet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import client.inventory.Pet;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
@@ -54,7 +55,7 @@ public class PetRequirement extends MapleQuestRequirement {
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
for(MaplePet pet : chr.getPets()) {
|
||||
for(Pet pet : chr.getPets()) {
|
||||
if(pet == null) continue; // thanks Arufonsu for showing a NPE occurring here
|
||||
|
||||
if(petIDs.contains(pet.getItemId()))
|
||||
|
||||
@@ -137,7 +137,7 @@ public class PacketCreator {
|
||||
p.writeInt(chr.getHair()); // hair
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
MaplePet pet = chr.getPet(i);
|
||||
Pet pet = chr.getPet(i);
|
||||
if (pet != null) //Checked GMS.. and your pets stay when going into the cash shop.
|
||||
{
|
||||
p.writeLong(pet.getUniqueId());
|
||||
@@ -375,7 +375,7 @@ public class PacketCreator {
|
||||
}
|
||||
addExpirationTime(p, item.getExpiration());
|
||||
if (isPet) {
|
||||
MaplePet pet = item.getPet();
|
||||
Pet pet = item.getPet();
|
||||
p.writeFixedString(StringUtil.getRightPaddedStr(pet.getName(), '\0', 13));
|
||||
p.writeByte(pet.getLevel());
|
||||
p.writeShort(pet.getCloseness());
|
||||
@@ -1937,7 +1937,7 @@ public class PacketCreator {
|
||||
|
||||
p.writeShort(0);//chr.getFh()
|
||||
p.writeByte(0);
|
||||
MaplePet[] pet = chr.getPets();
|
||||
Pet[] pet = chr.getPets();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (pet[i] != null) {
|
||||
addPetInfo(p, pet[i], false);
|
||||
@@ -2693,7 +2693,7 @@ public class PacketCreator {
|
||||
p.writeString(allianceName); // does not seem to work
|
||||
p.writeByte(0); // pMedalInfo, thanks to Arnah (Vertisy)
|
||||
|
||||
MaplePet[] pets = chr.getPets();
|
||||
Pet[] pets = chr.getPets();
|
||||
Item inv = chr.getInventory(InventoryType.EQUIPPED).getItem((short) -114);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (pets[i] != null) {
|
||||
@@ -4361,7 +4361,7 @@ public class PacketCreator {
|
||||
return p;
|
||||
}
|
||||
|
||||
private static void addPetInfo(final OutPacket p, MaplePet pet, boolean showpet) {
|
||||
private static void addPetInfo(final OutPacket p, Pet pet, boolean showpet) {
|
||||
p.writeByte(1);
|
||||
if (showpet) {
|
||||
p.writeByte(0);
|
||||
@@ -4375,7 +4375,7 @@ public class PacketCreator {
|
||||
p.writeInt(pet.getFh());
|
||||
}
|
||||
|
||||
public static Packet showPet(MapleCharacter chr, MaplePet pet, boolean remove, boolean hunger) {
|
||||
public static Packet showPet(MapleCharacter chr, Pet pet, boolean remove, boolean hunger) {
|
||||
OutPacket p = OutPacket.create(SendOpcode.SPAWN_PET);
|
||||
p.writeInt(chr.getId());
|
||||
p.writeByte(chr.getPetIndex(pet));
|
||||
@@ -4475,7 +4475,7 @@ public class PacketCreator {
|
||||
mask |= MapleStat.PET.getValue();
|
||||
p.writeByte(0);
|
||||
p.writeInt(mask);
|
||||
MaplePet[] pets = chr.getPets();
|
||||
Pet[] pets = chr.getPets();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (pets[i] != null) {
|
||||
p.writeLong(pets[i].getUniqueId());
|
||||
|
||||
Reference in New Issue
Block a user