Changed pets to Entities instead of Creatures

This commit is contained in:
LCastr0 2017-03-24 16:52:37 -03:00
parent 8a7f221bc6
commit 6875287b6d
4 changed files with 28 additions and 34 deletions

View File

@ -4,8 +4,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.pet.PetType;
import mineplex.core.shop.item.IButton;
public class ActivateCustomPetButton implements IButton
@ -20,8 +18,8 @@ public class ActivateCustomPetButton implements IButton
@Override
public void onClick(Player player, ClickType clickType)
{
_page.playAcceptSound(player);
/*_page.playAcceptSound(player);
_page.getPlugin().getPetManager().addPetOwner(player, PetType.CUSTOM, player.getLocation());
_page.getShop().openPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), player));
_page.getShop().openPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), player));*/
}
}

View File

@ -1,7 +1,7 @@
package mineplex.core.pet;
import org.bukkit.Location;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -17,13 +17,13 @@ public class FlyingPetManager
*/
private Player _player;
private Creature _pet;
private Entity _pet;
private Location _grimReaperLoc, _target;
private Vector _direction;
private double _speed;
private long _idleTime;
public FlyingPetManager(Player player, Creature pet)
public FlyingPetManager(Player player, Entity pet)
{
_player = player;
_pet = pet;

View File

@ -66,7 +66,6 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.disguise.disguises.DisguiseRabbit;
import mineplex.core.disguise.disguises.DisguiseVillager;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.disguise.disguises.DisguiseZombie;
@ -98,8 +97,8 @@ public class PetManager extends MiniClientPlugin<PetClient>
private CoreClientManager _clientManager;
private InventoryManager _inventoryManager;
private Map<Creature, FlyingPetManager> _flyingPets = new HashMap<>();
private Map<Creature, TrueLoveData> _trueLovePets = new HashMap<>();
private Map<Entity, FlyingPetManager> _flyingPets = new HashMap<>();
private Map<Entity, TrueLoveData> _trueLovePets = new HashMap<>();
private ShapeWings _grimReaperWings = new ShapeWings(ParticleType.RED_DUST.particleName, new org.bukkit.util.Vector(0.2, 0.2, 0.2), 1, 0, false, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN);
private ShapeWings _grimReaperWingsEdge = new ShapeWings(ParticleType.RED_DUST.particleName, new org.bukkit.util.Vector(0.1, 0.1, 0.1), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN);
@ -214,7 +213,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
return;
}
Creature pet;
Entity pet;
EntityType entityType = petType.getEntityType();
//Wither Spawn
@ -222,7 +221,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
{
_creatureModule.SetForce(true);
pet = (Creature) location.getWorld().spawnEntity(location, EntityType.SILVERFISH);
pet = location.getWorld().spawnEntity(location, EntityType.SILVERFISH);
UtilEnt.silence(pet, true);
DisguiseWither witherDisguise = new DisguiseWither(pet);
@ -259,12 +258,12 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
}
}
pet = (Creature)_creatureModule.SpawnEntity(location, petType.getEntityType());
pet = _creatureModule.SpawnEntity(location, petType.getEntityType());
}
//Default Spawn
else
{
pet = (Creature)_creatureModule.SpawnEntity(location, petType.getEntityType());
pet = _creatureModule.SpawnEntity(location, petType.getEntityType());
}
//Named Pet
@ -276,16 +275,18 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (petType.equals(PetType.ZOMBIE))
{
((Zombie) pet).setBaby(true);
pet.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
pet.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 0));
Zombie zombie = (Zombie) pet;
zombie.setBaby(true);
zombie.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
zombie.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 0));
UtilEnt.silence(pet, true);
}
if (pet instanceof PigZombie)
{
((PigZombie)pet).setBaby(true);
pet.getEquipment().setHelmet(new ItemStack(Material.SKULL_ITEM, 1, (short)0, (byte) 1));
pet.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 0));
PigZombie pigZombie = (PigZombie) pet;
pigZombie.setBaby(true);
pigZombie.getEquipment().setHelmet(new ItemStack(Material.SKULL_ITEM, 1, (short)0, (byte) 1));
pigZombie.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 0));
}
else if (pet instanceof Villager)
{
@ -294,10 +295,11 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
else if (pet instanceof Skeleton)
{
pet.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); //stop burning
Skeleton skeleton = (Skeleton) pet;
skeleton.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); //stop burning
UtilEnt.silence(pet, true);
DisguiseGuardian disguise = new DisguiseGuardian(pet);
DisguiseGuardian disguise = new DisguiseGuardian(skeleton);
if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0)
{
@ -413,14 +415,8 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
else if (petType.equals(PetType.KILLER_BUNNY))
{
Zombie zombie = (Zombie) pet;
UtilEnt.silence(zombie, true);
DisguiseRabbit disguiseRabbit = new DisguiseRabbit(zombie);
Rabbit rabbit = (Rabbit) disguiseRabbit.getEntity().getBukkitEntity();
Rabbit rabbit = (Rabbit) pet;
rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY);
_disguiseManager.disguise(disguiseRabbit);
}
_activePetOwnerTypes.put(player.getName(), petType);
@ -669,7 +665,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
@EventHandler
public void grimReaperFly(UpdateEvent event)
{
for (Entry<Creature, FlyingPetManager> entry : _flyingPets.entrySet())
for (Entry<Entity, FlyingPetManager> entry : _flyingPets.entrySet())
{
FlyingPetManager flyingPetManager = entry.getValue();
flyingPetManager.update();
@ -682,11 +678,11 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (event.getType() != UpdateType.FASTEST)
return;
Iterator<Entry<Creature, TrueLoveData>> iterator = _trueLovePets.entrySet().iterator();
Iterator<Entry<Entity, TrueLoveData>> iterator = _trueLovePets.entrySet().iterator();
while (iterator.hasNext())
{
Entry<Creature, TrueLoveData> entry = iterator.next();
Creature zombie = entry.getKey();
Entry<Entity, TrueLoveData> entry = iterator.next();
Entity zombie = entry.getKey();
UtilParticle.PlayParticle(ParticleType.HEART, zombie.getLocation().add(0, 0.25, 0), 0.25f, 0.25f, 0.25f, 0, 1, ViewDist.NORMAL);
TrueLoveData trueLoveData = entry.getValue();
trueLoveData.update();

View File

@ -34,7 +34,7 @@ public enum PetType
CUPID_PET("Cupid", EntityType.ZOMBIE, -17, "Sometimes you need a little extra help finding true Love. Why not have Cupid help you out?", Material.BOW, (byte) 0),
TRUE_LOVE_PET("True Love", EntityType.ZOMBIE, -14, "Sometimes love means chasing the person of your dreams until you catch them.", Material.APPLE, YearMonth.of(2017, Month.FEBRUARY)),
LEPRECHAUN("Leprechaun", EntityType.ZOMBIE, -18, "Apparently this little guy lost his Pot of Gold in the war.", SkinData.LEPRECHAUN.getSkull()),
KILLER_BUNNY("Killer Bunny", EntityType.ZOMBIE, -19, "Placeholder")
KILLER_BUNNY("Killer Bunny", EntityType.RABBIT, -19, "Placeholder")
// TODO CHECK IF LOBBY IS 1.9+
// Not in this update
//SHULKER("Shulker Pet", EntityType.BAT, 0, "Is it a turtle or an alien? Either way its shot can be really UPLIFTING.")