Unsummon previous existing pet, return null if template does not exist.

This commit is contained in:
MobiusDevelopment
2021-05-28 23:48:11 +00:00
parent 4055965fa9
commit 24e82859ca
23 changed files with 90 additions and 46 deletions

View File

@@ -216,10 +216,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -216,10 +216,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -216,10 +216,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -216,10 +216,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -180,9 +180,10 @@ public class PetInstance extends Summon
*/ */
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);

View File

@@ -181,9 +181,10 @@ public class PetInstance extends Summon
*/ */
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);

View File

@@ -231,10 +231,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -231,10 +231,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -216,10 +216,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -216,10 +216,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -217,10 +217,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -216,10 +216,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetData data = PetDataTable.getInstance().getPetData(template.getId()); final PetData data = PetDataTable.getInstance().getPetData(template.getId());
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world

View File

@@ -327,10 +327,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world
if (pet != null) if (pet != null)

View File

@@ -327,10 +327,12 @@ public class PetInstance extends Summon
public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control) public static synchronized PetInstance spawnPet(NpcTemplate template, PlayerInstance owner, ItemInstance control)
{ {
if (World.getInstance().getPet(owner.getObjectId()) != null) final PetInstance existingPet = World.getInstance().getPet(owner.getObjectId());
if (existingPet != null) // owner has a pet listed in world
{ {
return null; // owner has a pet listed in world existingPet.unSummon(owner);
} }
final PetInstance pet = restore(control, template, owner); final PetInstance pet = restore(control, template, owner);
// add the pet instance to world // add the pet instance to world
if (pet != null) if (pet != null)