From 3c241c48bc7769c3c3600c11cdf2546a6ec6f4e8 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Mon, 27 Mar 2017 17:26:18 -0300 Subject: [PATCH] Changed rabbit morph to spawn holograms --- .../gadgets/morph/MorphAwkwardRabbit.java | 76 +++---------------- 1 file changed, 9 insertions(+), 67 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAwkwardRabbit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAwkwardRabbit.java index c636beaad..217d2513e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAwkwardRabbit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAwkwardRabbit.java @@ -1,24 +1,15 @@ package mineplex.core.gadget.gadgets.morph; -import java.util.HashMap; -import java.util.Map; - import org.bukkit.Material; -import org.bukkit.entity.Bat; import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.spigotmc.event.entity.EntityDismountEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; import com.mojang.authlib.GameProfile; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; @@ -29,10 +20,6 @@ import mineplex.core.utils.UtilGameProfile; public class MorphAwkwardRabbit extends MorphGadget { - private Map _skeletons = new HashMap<>(); - private Map _slimes = new HashMap<>(); - private Map _bats = new HashMap<>(); - public MorphAwkwardRabbit(GadgetManager manager) { super(manager, "Awkward Rabbit Morph", UtilText.splitLinesToArray(new String[]{C.cGray + "Dale was the most awkward of Rabbits."}, LineFormat.LORE), @@ -44,26 +31,6 @@ public class MorphAwkwardRabbit extends MorphGadget { applyArmor(player, message); - Manager.getPetManager().getCreatureModule().SetForce(true); - - Slime slime = player.getWorld().spawn(player.getLocation(), Slime.class); - UtilEnt.silence(slime, true); - slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false)); - slime.setSize(-2); - - Skeleton skeleton = player.getWorld().spawn(player.getLocation(), Skeleton.class); - UtilEnt.silence(skeleton, true); - skeleton.setCustomName("Dinnerbone"); - skeleton.setCustomNameVisible(false); - skeleton.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1, false, false)); - skeleton.getEquipment().setHelmet(SkinData.SLENDERMAN.getSkull()); - - Bat bat = player.getWorld().spawn(player.getLocation(), Bat.class); - UtilEnt.silence(bat, true); - bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false)); - - Manager.getPetManager().getCreatureModule().SetForce(false); - GameProfile gameProfile = UtilGameProfile.getGameProfile(player); gameProfile.getProperties().clear(); gameProfile.getProperties().put("textures", SkinData.BUGS_BUNNY.getProperty()); @@ -71,14 +38,6 @@ public class MorphAwkwardRabbit extends MorphGadget DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile); disguisePlayer.showInTabList(true, 0); UtilMorph.disguise(player, disguisePlayer, Manager); - - _skeletons.put(player, skeleton); - _slimes.put(player, slime); - _bats.put(player, bat); - - skeleton.setPassenger(bat); - slime.setPassenger(skeleton); - disguisePlayer.getEntity().getBukkitEntity().setPassenger(slime); } @Override @@ -86,35 +45,18 @@ public class MorphAwkwardRabbit extends MorphGadget { removeArmor(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); - _skeletons.get(player).remove(); - _slimes.get(player).remove(); - _bats.get(player).remove(); } @EventHandler - public void dismount(EntityDismountEvent event) + public void spawnHolograms(PlayerToggleSneakEvent event) { - if (event.getDismounted() instanceof Skeleton) - { - if (_skeletons.containsValue(event.getDismounted())) - { - event.setCancelled(true); - } - } - if (event.getDismounted() instanceof Slime) - { - if (_slimes.containsValue(event.getDismounted())) - { - event.setCancelled(true); - } - } - if (event.getDismounted() instanceof Bat) - { - if (_bats.containsValue(event.getDismounted())) - { - event.setCancelled(true); - } - } + if (!isActive(event.getPlayer())) + return; + + if (event.isSneaking()) + return; + + } }