Revamp original Pumpkin King morph, add a new Christmas King Morph, and make the Christmas King morph the new reward for Christmas Chaos

This commit is contained in:
AlexTheCoder 2016-11-26 06:51:20 -05:00 committed by cnr
parent 58fe232520
commit df48369e70
5 changed files with 298 additions and 23 deletions

View File

@ -110,6 +110,7 @@ import mineplex.core.gadget.gadgets.morph.MorphBlaze;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.gadgets.morph.MorphBunny;
import mineplex.core.gadget.gadgets.morph.MorphChicken;
import mineplex.core.gadget.gadgets.morph.MorphChristmasKing;
import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphCreeper;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
@ -369,6 +370,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphGrimReaper(this));
addGadget(new MorphMetalMan(this));
addGadget(new MorphTurkey(this));
addGadget(new MorphChristmasKing(this));
// Not in this update
//addGadget(new MorphStray(this));
//addGadget(new MorphSanta(this));

View File

@ -0,0 +1,171 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.Map;
import java.util.WeakHashMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
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.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargeData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
public class MorphChristmasKing extends MorphGadget
{
private Map<Projectile, Player> _snowball = new WeakHashMap<Projectile, Player>();
public MorphChristmasKing(GadgetManager manager)
{
super(manager, "Christmas Kings Head", UtilText.splitLinesToArray(new String[]
{
C.cGray + "Transforms the wearer into the",
C.cGray + "Pumpkin King's not so jolly Winter Form!",
"",
C.cBlue + "Earned by defeating the Pumpkin King",
C.cBlue + "in the 2016 Christmas Chaos Event",
C.blankLine,
"#" + C.cWhite + "Sneak to use Snowstorm"
}, LineFormat.LORE),
-1,
Material.PUMPKIN, (byte)0);
}
@Override
public void enableCustom(final Player player, boolean message)
{
this.applyArmor(player, message);
DisguiseSkeleton disguise = new DisguiseSkeleton(player);
disguise.showArmor();
disguise.SetSkeletonType(SkeletonType.WITHER);
UtilMorph.disguise(player, disguise, Manager);
player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers());
VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers());
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.getInventory().setHelmet(null);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.FASTEST)
{
for (Player player : getActive())
{
NautHashMap<String, RechargeData> map = Recharge.Instance.Get(player);
if (map == null)
continue;
RechargeData data = map.get("Snowstorm");
if (data == null)
continue;
if (data.GetRemaining() < 25000)
continue;
for (int i = 0; i < 6; i++)
{
Snowball snow = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Snowball.class);
double x = 0.1 - (UtilMath.r(20)/100d);
double y = UtilMath.r(20)/100d;
double z = 0.1 - (UtilMath.r(20)/100d);
snow.setShooter(player);
snow.setVelocity(player.getLocation().getDirection().add(new Vector(x,y,z)).multiply(2));
_snowball.put(snow, player);
}
//Effect
player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 0.2f, 0.5f);
}
}
if (event.getType() == UpdateType.TICK)
{
for (Player player : getActive())
{
if (Manager.isMoving(player))
{
continue;
}
for (double y = 0; y < 5; y++)
{
double sin = Math.sin(y);
double cos = Math.cos(y);
Location loc1 = player.getLocation().add(sin, y, cos);
Location loc2 = player.getLocation().add(cos, y, sin);
UtilParticle.PlayParticleToAll(ParticleType.SNOWBALL_POOF, loc1, null, 0, 1, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.SNOWBALL_POOF, loc2, null, 0, 1, ViewDist.NORMAL);
}
}
}
}
@EventHandler
public void onSneak(PlayerToggleSneakEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (!event.isSneaking())
return;
if (Recharge.Instance.use(event.getPlayer(), "Snowstorm", 30000, true, true))
{
event.getPlayer().sendMessage(F.main("Recharge", "You used " + F.skill("Snowstorm") + "."));
}
}
@EventHandler
public void onSnowballHit(EntityDamageByEntityEvent event)
{
if (!(event.getDamager() instanceof Snowball))
return;
Snowball proj = (Snowball) event.getDamager();
if (!_snowball.containsKey(proj))
return;
if (Manager.collideEvent(_snowball.remove(proj), this, event.getEntity()))
return;
UtilAction.velocity(event.getEntity(), proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0)));
}
}

View File

@ -1,22 +1,48 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
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.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
public class MorphPumpkinKing extends MorphGadget
{
private static final int CROWN_POINTS = 12;
private List<JackOBomb> _bombs = Lists.newArrayList();
public MorphPumpkinKing(GadgetManager manager)
{
super(manager, "Pumpkin Kings Head", UtilText.splitLinesToArray(new String[]
@ -24,7 +50,9 @@ public class MorphPumpkinKing extends MorphGadget
C.cGray + "Transforms the wearer into the dreaded Pumpkin King!",
"",
C.cBlue + "Earned by defeating the Pumpkin King",
C.cBlue + "in the 2013 Halloween Horror Event"
C.cBlue + "in the 2013 Halloween Horror Event",
C.blankLine,
"#" + C.cWhite + "Sneak to use Jack O Bomb"
}, LineFormat.LORE),
-1,
Material.PUMPKIN, (byte)0);
@ -54,6 +82,95 @@ public class MorphPumpkinKing extends MorphGadget
UtilMorph.undisguise(player, Manager.getDisguiseManager());
player.getInventory().setHelmet(null);
}
}
@EventHandler
public void onSneak(PlayerToggleSneakEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (!event.isSneaking())
return;
if (Recharge.Instance.use(event.getPlayer(), "Jack O Bomb", 30000, true, true))
{
event.getPlayer().sendMessage(F.main("Recharge", "You used " + F.skill("Jack O Bomb") + "."));
_bombs.add(new JackOBomb(event.getPlayer(), event.getPlayer().getLocation().add(event.getPlayer().getEyeLocation().getDirection().normalize())));
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
{
for (Player player : getActive())
{
if (Manager.isMoving(player))
{
continue;
}
for (int i = 0; i < 360; i += 360/CROWN_POINTS)
{
double angle = (i * Math.PI / 180);
double x = 0.5 * Math.cos(angle);
double z = 0.5 * Math.sin(angle);
Location loc = player.getEyeLocation().add(x, 1.4, z);
UtilParticle.PlayParticleToAll(ParticleType.FLAME, loc, null, 0, 1, ViewDist.NORMAL);
}
}
_bombs.removeIf(bomb -> bomb.update());
}
}
private class JackOBomb
{
private Player _user;
private Item _ent;
private DisguiseBlock _disguise;
private long _detonation;
private boolean _done;
public JackOBomb(Player user, Location spawnLocation)
{
_user = user;
_ent = spawnLocation.getWorld().dropItem(spawnLocation, new ItemBuilder(Material.APPLE).setTitle(new Random().nextDouble() + "").build());
_ent.setPickupDelay(Integer.MAX_VALUE);
_disguise = new DisguiseBlock(_ent, Material.JACK_O_LANTERN.getId(), 0);
Manager.getDisguiseManager().disguise(_disguise);
_detonation = System.currentTimeMillis() + 7000;
_done = false;
}
public boolean update()
{
if (_done)
{
return true;
}
if (System.currentTimeMillis() >= _detonation)
{
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _ent.getLocation(), null, 0, 1, ViewDist.NORMAL);
Map<Player, Double> players = UtilPlayer.getInRadius(_ent.getLocation(), 8);
for (Player player : players.keySet())
{
if (Manager.collideEvent(_user, MorphPumpkinKing.this, player))
continue;
double mult = players.get(player);
//Knockback
UtilAction.velocity(player, UtilAlg.getTrajectory(_ent.getLocation(), player.getLocation()), 1 * mult, false, 0, 0.5 + 0.5 * mult, 10, true);
}
Manager.getDisguiseManager().undisguise(_disguise);
_ent.remove();
_done = true;
}
return false;
}
}
}

View File

@ -23,9 +23,8 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
@ -477,29 +476,15 @@ public class Christmas extends SoloGame
if (!player.isOnline())
continue;
if (Manager.GetTaskManager().hasCompletedTask(player, "CC Reward 2015"))
if (Manager.GetDonation().Get(player).OwnsUnknownPackage("Christmas Kings Head"))
{
SetCustomWinMessage(player, "You already earned your reward");
}
else
{
SetCustomWinMessage(player, "You earned " + C.cYellow + "2x Winter Holiday Treasure");
SetCustomWinMessage(player, "You earned " + C.cYellow + "Christmas King Morph");
Manager.GetTaskManager().completedTask(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
if (data)
{
Manager.getInventoryManager().addItemToInventory(player, "Winter Chest", 2);
}
else
{
UtilPlayer.message(player, F.main("Inventory", "An error occured while giving you " + C.cRed + "2x Winter Holiday Treasure" + C.cGray + "."));
}
}
}, player, "CC Reward 2015");
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), Manager.GetClients().Get(player).getAccountId(), "Christmas Kings Head", GlobalCurrency.TREASURE_SHARD, 0, true);
}
}

View File

@ -353,7 +353,7 @@ public class Part5 extends Part
public void Skip(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().equals("/boss"))
if (event.getPlayer().getName().equals("Chiss"))
if (event.getPlayer().isOp())
{
event.setCancelled(true);