From fd5a09e71ba08cb22f496c0bb670a89dbad11255 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 1 Oct 2017 05:01:34 +0100 Subject: [PATCH] Ghast Morph --- .../disguise/disguises/DisguiseGhast.java | 12 ++ .../mineplex/core/gadget/GadgetManager.java | 2 + .../core/gadget/gadgets/morph/MorphGhast.java | 159 ++++++++++++++++++ .../powerplayclub/PowerPlayClubRewards.java | 1 + 4 files changed, 174 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGhast.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGhast.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGhast.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGhast.java new file mode 100644 index 000000000..b1775af0a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGhast.java @@ -0,0 +1,12 @@ +package mineplex.core.disguise.disguises; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; + +public class DisguiseGhast extends DisguiseCreature +{ + public DisguiseGhast(Entity entity) + { + super(EntityType.GHAST, entity); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 13c7da270..b5911dd9e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -147,6 +147,7 @@ import mineplex.core.gadget.gadgets.morph.MorphCreeper; import mineplex.core.gadget.gadgets.morph.MorphDinnerbone; import mineplex.core.gadget.gadgets.morph.MorphEnderman; import mineplex.core.gadget.gadgets.morph.MorphFreedomFighter; +import mineplex.core.gadget.gadgets.morph.MorphGhast; import mineplex.core.gadget.gadgets.morph.MorphGoldPot; import mineplex.core.gadget.gadgets.morph.MorphGrimReaper; import mineplex.core.gadget.gadgets.morph.MorphLoveDoctor; @@ -566,6 +567,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphLarissa(this)); addGadget(new MorphBiff(this)); addGadget(new MorphIvy(this)); + addGadget(new MorphGhast(this)); // Mounts addGadget(new MountUndead(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGhast.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGhast.java new file mode 100644 index 000000000..4ee85246a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGhast.java @@ -0,0 +1,159 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.time.Month; +import java.time.YearMonth; +import java.util.HashSet; +import java.util.Set; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LargeFireball; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseGhast; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class MorphGhast extends MorphGadget +{ + + private static final Vector UP = new Vector(0, 1.5, 0); + + private final Set _fireballs = new HashSet<>(); + + public MorphGhast(GadgetManager manager) + { + super(manager, "Ghast Morph", UtilText.splitLinesToArray(new String[]{ + C.cGray + "A never before seen morph, the very spooky Ghast!", + "", + C.cGreen + "Left Click" + C.cWhite + " to shoot a fireball", + }, LineFormat.LORE), CostConstants.POWERPLAY_BONUS, Material.GLASS, (byte) 0); + + setPPCYearMonth(YearMonth.of(2017, Month.OCTOBER)); + setDisplayItem(new ItemBuilder(Material.SKULL_ITEM, (byte) 3) + .setPlayerHead("MHF_Ghast") + .build()); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + UtilMorph.disguise(player, new DisguiseGhast(player), Manager); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + player.setAllowFlight(false); + player.setFlying(false); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!UtilEvent.isAction(event, ActionType.L) || !isActive(event.getPlayer())) + { + return; + } + + event.setCancelled(true); + + if (!Recharge.Instance.use(player, "Fireball", 4000, true, true, "Cosmetics")) + { + return; + } + + Sound sound; + int random = UtilMath.r(3); + + if (random == 0) + { + sound = Sound.GHAST_SCREAM; + } + else if (random == 1) + { + sound = Sound.GHAST_SCREAM2; + } + else + { + sound = Sound.GHAST_FIREBALL; + } + + player.getWorld().playSound(player.getLocation(), sound, 1, (float) (0.7 + Math.random() / 2)); + + LargeFireball fireball = player.launchProjectile(LargeFireball.class); + _fireballs.add(fireball); + } + + @EventHandler + public void flight(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player player : getActive()) + { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + + player.setAllowFlight(true); + player.setFlying(true); + + if (UtilEnt.isGrounded(player)) + { + UtilAction.velocity(player, UP); + } + } + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + if (!_fireballs.contains(event.getEntity())) + { + return; + } + + for (Player player : UtilPlayer.getNearby(event.getEntity().getLocation(), 5)) + { + player.setVelocity(UP); + } + + UtilParticle.PlayParticleToAll(ParticleType.LAVA, event.getEntity().getLocation().add(0, 0.8, 0), 0.5F, 0.5F, 0.5F, 0.01F, 6, ViewDist.NORMAL); + event.getEntity().remove(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index e5023eeea..e800b8bda 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -42,6 +42,7 @@ public class PowerPlayClubRewards .put(YearMonth.of(2017, Month.JULY), new UnknownSalesPackageItem("Freedom Fighter")) .put(YearMonth.of(2017, Month.AUGUST), new UnknownSalesPackageItem("Melonhead Morph")) .put(YearMonth.of(2017, Month.SEPTEMBER), new UnknownSalesPackageItem("Tornado")) + .put(YearMonth.of(2017, Month.OCTOBER), new UnknownSalesPackageItem("Ghast Morph")) .build(); public interface PowerPlayClubItem