Wither Morph

Legend Particle
This commit is contained in:
Chiss 2014-12-16 16:18:09 +11:00
parent c43ee95c55
commit a433ad764d
11 changed files with 381 additions and 6 deletions

View File

@ -12,10 +12,11 @@ public enum Rank
DEVELOPER("Dev", ChatColor.RED),
ADMIN("Admin", ChatColor.RED),
SNR_MODERATOR("Sr.Mod", ChatColor.GOLD),
MODERATOR("Mod", ChatColor.DARK_GREEN),
HELPER("Helper", ChatColor.GREEN),
MODERATOR("Mod", ChatColor.GOLD),
HELPER("Helper", ChatColor.DARK_AQUA),
MAPDEV("Mapper", ChatColor.BLUE),
YOUTUBE("YouTube", ChatColor.RED),
LEGEND("Legend", ChatColor.GREEN),
HERO("Hero", ChatColor.LIGHT_PURPLE),
ULTRA("Ultra", ChatColor.AQUA),
ALL("", ChatColor.WHITE);

View File

@ -59,9 +59,14 @@ public class UtilFirework
firework.remove();
}
public static Firework launchFirework(Location loc, Type type, Color color, boolean flicker, boolean trail, Vector dir, int power)
{
return launchFirework(loc, FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build(), dir, power);
}
public static void playFirework(Location loc, Type type, Color color, boolean flicker, boolean trail)
{
playFirework(loc, FireworkEffect.builder().flicker(false).withColor(color).with(type).trail(false).build());
playFirework(loc, FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build());
}
}

View File

@ -118,6 +118,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphCreeper(this));
addGadget(new MorphBlaze(this));
//addGadget(new MorphGeno(this));
addGadget(new MorphWither(this));
// Particles
addGadget(new ParticleFoot(this));
@ -128,6 +129,8 @@ public class GadgetManager extends MiniPlugin
addGadget(new ParticleGreen(this));
addGadget(new ParticleHeart(this));
addGadget(new ParticleFairy(this));
addGadget(new ParticleLegend(this));
addGadget(new ParticleBlizzard(this));
// Music
addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000));

View File

@ -0,0 +1,208 @@
package mineplex.core.gadget.gadgets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.entity.WitherSkull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
public class MorphWither extends MorphGadget
{
private ArrayList<WitherSkull> _skulls = new ArrayList<WitherSkull>();
public MorphWither(GadgetManager manager)
{
super(manager, "Wither Morph", new String[]
{
C.cWhite + "Become a legendary Wither!",
" ",
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Wither Skull",
" ",
C.cPurple + "Unlocked with Legend Rank",
},
-1,
Material.SKULL_ITEM, (byte)1);
}
@Override
public void EnableCustom(final Player player)
{
this.ApplyArmor(player);
player.setMaxHealth(300);
player.setHealth(300);
DisguiseWither disguise = new DisguiseWither(player);
disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank());
//disguise.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
player.setMaxHealth(20);
player.setHealth(20);
}
@Override
public void DisableCustom(Player player)
{
this.RemoveArmor(player);
Manager.getDisguiseManager().undisguise(player);
player.setAllowFlight(false);
player.setFlying(false);
player.setMaxHealth(20);
player.setHealth(20);
}
@EventHandler
public void witherSkull(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!IsActive(player))
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 1600, false, false))
return;
Vector offset = player.getLocation().getDirection();
if (offset.getY() < 0)
offset.setY(0);
_skulls.add(player.launchProjectile(WitherSkull.class));
//Effect
player.getWorld().playSound(player.getLocation(), Sound.WITHER_SHOOT, 0.5f, 1f);
}
@EventHandler
public void explode(EntityExplodeEvent event)
{
if (!_skulls.contains(event.getEntity()))
return;
event.setCancelled(true);
WitherSkull skull = (WitherSkull)event.getEntity();
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, skull.getLocation(), 0, 0, 0, 0, 1);
skull.getWorld().playSound(skull.getLocation(), Sound.EXPLODE, 2f, 1f);
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(), 6);
for (Player player : players.keySet())
{
if (Manager.collideEvent(this, player))
continue;
double mult = players.get(player);
//Knockback
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 2 * mult, false, 0, 0.6 + 0.4 * mult, 2, true);
}
}
@EventHandler
public void clean(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
Iterator<WitherSkull> skullIterator = _skulls.iterator();
while (skullIterator.hasNext())
{
WitherSkull skull = skullIterator.next();
if (!skull.isValid())
{
skullIterator.remove();
skull.remove();
continue;
}
}
}
@EventHandler
public void flight(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetActive())
{
if (player.getGameMode() == GameMode.CREATIVE)
continue;
player.setAllowFlight(true);
player.setFlying(true);
if (UtilEnt.isGrounded(player))
player.setVelocity(new Vector(0,1,0));
}
}
@EventHandler
public void legendOwner(PlayerJoinEvent event)
{
if (Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.LEGEND ||
Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.ADMIN ||
Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.DEVELOPER ||
Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.OWNER)
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}
}
public void setWitherData(String text, double healthPercent)
{
Iterator<Player> activeIterator = GetActive().iterator();
while (activeIterator.hasNext())
{
Player player = activeIterator.next();
DisguiseBase disguise = Manager.getDisguiseManager().getDisguise(player);
if (disguise == null || !(disguise instanceof DisguiseWither))
{
DisableCustom(player);
activeIterator.remove();
continue;
}
((DisguiseWither)disguise).setName(text);
((DisguiseWither)disguise).setHealth((float) (healthPercent * 300));
Manager.getDisguiseManager().updateDisguise(disguise);
}
}
}

View File

@ -0,0 +1,80 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.gadget.GadgetManager;
public class ParticleBlizzard extends ParticleGadget
{
public ParticleBlizzard(GadgetManager manager)
{
super(manager, "Test", new String[]
{
C.cWhite + "",
},
1,
Material.FIREWORK, (byte)0);
}
@EventHandler
public void playParticle(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetActive())
{
if (!shouldDisplay(player))
continue;
if (Manager.isMoving(player))
{
for (int i=0 ; i<2 ; i++)
player.getWorld().playEffect(player.getLocation().add(r(1), Math.random() + 0.5, r(1)), Effect.COLOURED_DUST, 0);
}
else
{
for (int i=0 ; i<2 ; i++)
player.getWorld().playEffect(player.getLocation().add(r(2), Math.random() + 0.5, r(2)), Effect.COLOURED_DUST, 0);
if (Math.random() > 0.95)
{
UtilFirework.launchFirework(player.getEyeLocation(), Type.BALL, color(), true, true, new Vector(r(0.1),r(0.1),r(0.1)), 1);
}
}
}
}
private Color color()
{
double r = Math.random();
if (r > 0.8) return Color.RED;
if (r > 0.6) return Color.YELLOW;
if (r > 0.4) return Color.LIME;
if (r > 0.2) return Color.AQUA;
else return Color.FUCHSIA;
}
public double r(double mult)
{
return (Math.random() - 0.5)*mult;
}
}

View File

@ -0,0 +1,43 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.gadget.GadgetManager;
public class ParticleLegend extends ParticleGadget
{
public ParticleLegend(GadgetManager manager)
{
super(manager, "Legendary Aura", new String[]
{
C.cWhite + "These mystic particle attach to",
C.cWhite + "only the most legendary of players!",
" ",
C.cPurple + "Unlocked with Legend Rank",
},
-2,
Material.ENDER_PORTAL, (byte)0);
}
@EventHandler
public void playParticle(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetActive())
{
if (!shouldDisplay(player))
continue;
player.getWorld().playEffect(player.getLocation().add(0, 1, 0), Effect.ENDER_SIGNAL, 0);
}
}
}

View File

@ -5,9 +5,11 @@ import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
@ -50,6 +52,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
@ -513,7 +516,15 @@ public class HubManager extends MiniClientPlugin<HubClient>
UtilTabTitle.setHeaderAndFooter(player, " ", "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop");
//Public Message
event.setJoinMessage(null);
if (_clientManager.Get(player).GetRank() != Rank.OWNER)
event.setJoinMessage(null);
else
{
event.setJoinMessage(C.cGreen + C.Bold + "Legend " + player.getName() + " has joined!");
UtilFirework.playFirework(player.getEyeLocation(), org.bukkit.FireworkEffect.Type.BALL_LARGE, Color.LIME, true, true);
player.getWorld().playSound(player.getEyeLocation(), Sound.WITHER_SPAWN, 2f, 1f);
}
//Teleport
player.teleport(GetSpawn().add(0, 10, 0));

View File

@ -20,6 +20,7 @@ import mineplex.core.disguise.disguises.DisguiseBat;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.disguise.disguises.DisguiseCreeper;
import mineplex.core.disguise.disguises.DisguiseEnderman;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
@ -45,7 +46,8 @@ public class JumpManager extends MiniPlugin
//Chicken Cancel
DisguiseBase disguise = Manager.GetDisguise().getDisguise(player);
if (disguise != null && ((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman))
if (disguise != null &&
((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman || disguise instanceof DisguiseWither))
return;
event.setCancelled(true);

View File

@ -20,6 +20,9 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.gadget.gadgets.MorphWither;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.Mount;
import mineplex.core.mount.types.MountDragon;
import mineplex.core.updater.UpdateType;
@ -264,6 +267,14 @@ public class NewsManager extends MiniPlugin
((MountDragon)mount).setHealthPercent(healthPercent);
}
}
for (Gadget gadget : Manager.GetGadget().getGadgets(GadgetType.Morph))
{
if (gadget instanceof MorphWither)
{
((MorphWither)gadget).setWitherData(text, healthPercent);
}
}
}
@EventHandler

View File

@ -56,7 +56,7 @@ public enum GameType
String _name;
String _lobbyName;
Material _mat;
Material _mat;
byte _data;
GameType(String name, Material mat, byte data)

View File

@ -13,6 +13,9 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import mineplex.core.gadget.gadgets.MorphWither;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.core.mount.Mount;
import mineplex.core.mount.types.MountDragon;
@ -93,6 +96,14 @@ public class GameManager implements Listener
((MountDragon) mount).setHealthPercent(health);
}
}
for (Gadget gadget : Manager.getCosmeticManager().getGadgetManager().getGadgets(GadgetType.Morph))
{
if (gadget instanceof MorphWither)
{
((MorphWither)gadget).setWitherData(text, health);
}
}
}
}