Ghast Morph

This commit is contained in:
Sam 2017-10-01 05:01:34 +01:00 committed by cnr
parent 2dd42805ef
commit fd5a09e71b
4 changed files with 174 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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));

View File

@ -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<LargeFireball> _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();
}
}

View File

@ -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