From 49d738dd985253fe5a99e0cb6566ad104ed63540 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 28 Mar 2018 17:02:28 +0100 Subject: [PATCH] Implement Mary Poppin's Umbrella cosmetic --- .../mineplex/core/common/util/UtilEnt.java | 5 + .../mineplex/core/gadget/GadgetManager.java | 2 + .../gadget/gadgets/item/ItemMaryPoppins.java | 128 ++++++++++++++++++ .../powerplayclub/PowerPlayClubRewards.java | 1 + 4 files changed, 136 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMaryPoppins.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 650f4ff3a..ec1d0571f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -1125,4 +1125,9 @@ public class UtilEnt return null; } } + + public static void setPosition(Entity entity, Location location) + { + ((CraftEntity) entity).getHandle().setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 67364b75f..9c359e05c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -146,6 +146,7 @@ import mineplex.core.gadget.gadgets.item.ItemFleshHook; import mineplex.core.gadget.gadgets.item.ItemFlowerGift; import mineplex.core.gadget.gadgets.item.ItemFreezeCannon; import mineplex.core.gadget.gadgets.item.ItemLovePotion; +import mineplex.core.gadget.gadgets.item.ItemMaryPoppins; import mineplex.core.gadget.gadgets.item.ItemMelonLauncher; import mineplex.core.gadget.gadgets.item.ItemMobBomb; import mineplex.core.gadget.gadgets.item.ItemOAndX; @@ -560,6 +561,7 @@ public class GadgetManager extends MiniPlugin addGadget(new ItemBallCatch(this)); addGadget(new ItemTrampoline(this)); addGadget(new ItemConnect4(this)); + addGadget(new ItemMaryPoppins(this)); // Costume addGadget(new OutfitRaveSuitHelmet(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMaryPoppins.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMaryPoppins.java new file mode 100644 index 000000000..85ab66367 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMaryPoppins.java @@ -0,0 +1,128 @@ +package mineplex.core.gadget.gadgets.item; + +import java.awt.*; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +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.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.gadget.util.CostConstants; + +public class ItemMaryPoppins extends ItemGadget +{ + + private static final DustSpellColor TOP = new DustSpellColor(Color.BLACK), BOTTOM = new DustSpellColor(new Color(90, 50, 31)); + + public ItemMaryPoppins(GadgetManager manager) + { + super(manager, "Umbrella", new String[] + { + + }, CostConstants.POWERPLAY_BONUS, Material.STICK, (byte) 0, TimeUnit.SECONDS.toMillis(20), null); + } + + @Override + public void ActivateCustom(Player player) + { + Location location = player.getLocation().add(0, 0.5, 0); + + UtilAction.velocity(player, new Vector(0, 3, 0)); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, location, 0.5F, 0, 0.5F, 0, 10, ViewDist.NORMAL); + location.getWorld().playSound(location, Sound.BAT_TAKEOFF, 1, 0.6F); + + Manager.runSyncTimer(new BukkitRunnable() + { + Chicken chicken; + int iterations = 0; + + @Override + public void run() + { + if (iterations == 0) + { + if (UtilEnt.isGrounded(player)) + { + cancel(); + } + else + { + Location location = player.getLocation(); + chicken = player.getWorld().spawn(location, Chicken.class); + chicken.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); + chicken.setPassenger(player); + UtilEnt.vegetate(chicken, true); + UtilEnt.ghost(chicken, true, false); + iterations++; + } + + return; + } + + Location location = player.getLocation().add(0, 0.9, 0); + location.setPitch(0); + + UtilEnt.setPosition(chicken, chicken.getLocation().add(location.getDirection().multiply(0.2))); + + if (iterations % 4 == 0) + { + displayUmbrella(location.add(UtilAlg.getRight(location.getDirection()).multiply(0.5))); + } + + if (chicken.getPassenger() == null || UtilEnt.isGrounded(chicken)) + { + chicken.eject(); + chicken.remove(); + cancel(); + } + + iterations++; + } + }, 20, 1); + } + + private void displayUmbrella(Location location) + { + for (double y = 0; y < 1.5; y += 0.1) + { + new ColoredParticle(ParticleType.RED_DUST, BOTTOM, location.clone().add(0, y, 0)) + .display(); + } + + location.add(0, 1.5, 0); + double deltaY = 0; + + for (double r = 0.1; r < 1; r += 0.2) + { + for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10) + { + double x = r * Math.cos(theta), z = r * Math.sin(theta); + + location.add(x, deltaY, z); + + new ColoredParticle(ParticleType.RED_DUST, TOP, location) + .display(); + + location.subtract(x, deltaY, z); + } + + deltaY -= 0.04; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 10dfbd23e..dfd484052 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -48,6 +48,7 @@ public class PowerPlayClubRewards .put(YearMonth.of(2018, Month.JANUARY), new UnknownSalesPackageItem("Mob Bomb")) .put(YearMonth.of(2018, Month.FEBRUARY), new UnknownSalesPackageItem("Play Catch")) .put(YearMonth.of(2018, Month.MARCH), new UnknownSalesPackageItem("Connect 4")) + .put(YearMonth.of(2018, Month.APRIL), new UnknownSalesPackageItem("Umbrella")) .build(); public interface PowerPlayClubItem