Pig Morph

Morphs have tags/
This commit is contained in:
Chiss 2014-08-09 14:57:01 +10:00
parent 3d909b7cbe
commit 91a79f0345
9 changed files with 208 additions and 11 deletions

View File

@ -79,6 +79,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphPumpkinKing(this));
addGadget(new MorphCreeper(this));
addGadget(new MorphChicken(this));
addGadget(new MorphPig(this));
// Particles
addGadget(new ParticleGreen(this));

View File

@ -1,5 +1,6 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -39,7 +40,7 @@ public class MorphBlaze extends MorphGadget
this.ApplyArmor(player);
DisguiseBlaze disguise = new DisguiseBlaze(player);
disguise.SetName(player.getName());
disguise.SetName(Manager.getClientManager().Get(player).GetRank().GetTag(true, true) + " " + ChatColor.RESET + player.getName());
disguise.SetCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
}

View File

@ -1,5 +1,7 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.ChatColor;
import org.bukkit.EntityEffect;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -7,6 +9,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
@ -47,7 +50,7 @@ public class MorphChicken extends MorphGadget
this.ApplyArmor(player);
DisguiseChicken disguise = new DisguiseChicken(player);
disguise.SetName(player.getName());
disguise.SetName(Manager.getClientManager().Get(player).GetRank().GetTag(true, true) + " " + ChatColor.RESET + player.getName());
disguise.SetCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
}
@ -114,7 +117,7 @@ public class MorphChicken extends MorphGadget
Recharge.Instance.use(player, GetName(), 80, false, false);
//Energy
player.setExp(Math.max(0f, player.getExp() - (1f/6f)));
player.setExp(Math.max(0f, player.getExp() - (1f/9f)));
}
@EventHandler
@ -139,4 +142,14 @@ public class MorphChicken extends MorphGadget
}
}
}
@EventHandler
public void FlapUpdate(EntityDamageByEntityEvent event)
{
if (event.getDamager() instanceof Egg)
{
event.getEntity().playEffect(EntityEffect.HURT);
event.getEntity().setVelocity(new Vector(0,0,0));
}
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.gadget.gadgets;
import java.util.HashMap;
import org.bukkit.ChatColor;
import org.bukkit.EntityEffect;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -48,7 +49,7 @@ public class MorphCreeper extends MorphGadget
this.ApplyArmor(player);
DisguiseCreeper disguise = new DisguiseCreeper(player);
disguise.SetName(player.getName());
disguise.SetName(Manager.getClientManager().Get(player).GetRank().GetTag(true, true) + " " + ChatColor.RESET + player.getName());
disguise.SetCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
}

View File

@ -0,0 +1,175 @@
package mineplex.core.gadget.gadgets;
import java.util.HashSet;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
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.UtilMath;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguisePig;
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 MorphPig extends MorphGadget
{
private HashSet<Player> _double = new HashSet<Player>();
public MorphPig(GadgetManager manager)
{
super(manager, "Pig Morph", new String[]
{
C.cWhite + "Oink. Oink. Oink.... Oink?",
" ",
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Oink",
C.cYellow + "Collide" + C.cGray + " to use " + C.cGreen + "Pig Bounce",
" ",
C.cPurple + "Unlocked with Ultra Rank",
},
-1,
ArmorSlot.Helmet, Material.PORK, (byte)0);
}
@Override
public void EnableCustom(final Player player)
{
this.ApplyArmor(player);
DisguisePig disguise = new DisguisePig(player);
disguise.SetName(Manager.getClientManager().Get(player).GetRank().GetTag(true, true) + " " + ChatColor.RESET + player.getName());
disguise.SetCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
}
@Override
public void DisableCustom(Player player)
{
this.RemoveArmor(player);
Manager.getDisguiseManager().undisguise(player);
}
@EventHandler
public void Snort(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!IsActive(player))
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 100, false, false))
return;
player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, (float)(3 + Math.random()), (float)(0.75 + Math.random() * 0.5));
}
@EventHandler
public void HeroOwner(PlayerJoinEvent event)
{
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.ULTRA))
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}
}
@EventHandler
public void Collide(PlayerToggleFlightEvent event)
{
_double.add(event.getPlayer());
Recharge.Instance.useForce(event.getPlayer(), GetName() + " Double Jump", 200);
}
@EventHandler
public void Collide(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetActive())
{
//Grounded
if (_double.contains(player))
if (UtilEnt.isGrounded(player))
if (Recharge.Instance.usable(player, GetName() + " Double Jump"))
_double.remove(player);
double range = 1;
if (_double.contains(player))
range += 0.5;
if (player.getVehicle() != null)
continue;
if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue;
for (Player other : UtilServer.getPlayers())
{
if (other.equals(player))
continue;
if (other.getVehicle() != null)
continue;
if (!Recharge.Instance.usable(other, GetName() + " Collide"))
continue;
if (UtilMath.offset(player, other) > range)
continue;
//Cooldown
Recharge.Instance.useForce(other, GetName() + " Collide", 200);
Recharge.Instance.useForce(player, GetName() + " Collide", 200);
double power = 0.4;
double height = 0.1;
if (player.isSprinting())
{
power = 0.6;
height = 0.2;
}
if (_double.contains(player))
{
power = 1;
height = 0.3;
}
//Velocity
UtilAction.velocity(player, UtilAlg.getTrajectory2d(other, player), power, false, 0, height, 1, true);
UtilAction.velocity(other, UtilAlg.getTrajectory2d(player, other), power, false, 0, height, 1, true);
//Sound
if (_double.contains(player))
{
player.getWorld().playSound(player.getLocation(), Sound.PIG_DEATH, (float)(0.8 + Math.random() * 0.4), (float)(0.8 + Math.random() * 0.4));
}
else
{
player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, (float)(3 + Math.random()), (float)(1.5 + Math.random() * 0.5));
}
}
}
}
}

View File

@ -1,6 +1,7 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
@ -35,7 +36,7 @@ public class MorphPumpkinKing extends MorphGadget
DisguiseSkeleton disguise = new DisguiseSkeleton(player);
disguise.showArmor();
disguise.SetName(player.getName());
disguise.SetName(Manager.getClientManager().Get(player).GetRank().GetTag(true, true) + " " + ChatColor.RESET + player.getName());
disguise.SetCustomNameVisible(true);
disguise.SetSkeletonType(SkeletonType.WITHER);
Manager.getDisguiseManager().disguise(disguise);

View File

@ -1,5 +1,6 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -31,7 +32,7 @@ public class MorphSnowman extends MorphGadget
this.ApplyArmor(player);
DisguiseSnowman disguise = new DisguiseSnowman(player);
disguise.SetName(player.getName());
disguise.SetName(Manager.getClientManager().Get(player).GetRank().GetTag(true, true) + " " + ChatColor.RESET + player.getName());
disguise.SetCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
}

View File

@ -107,7 +107,7 @@ public class ParkourManager extends MiniPlugin
_active.add(player);
UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("Parkour Mode") + "."));
Manager.GetGadget().DisableAll();
Manager.GetGadget().DisableAll(player);
}
else
{
@ -306,7 +306,10 @@ public class ParkourManager extends MiniPlugin
if (!ent.getCustomName().contains(data.Name))
continue;
setParkourMode(player, true);
if (isParkourMode(player))
setParkourMode(player, false);
else
setParkourMode(player, true);
}
}

View File

@ -23,22 +23,23 @@ public class KitFighter extends Kit
{
"HE LIKES TO FIGHT!",
" ",
C.cGreen + "Stone Sword",
C.cGreen + "Wood Sword",
C.cGreen + "5 Apples",
},
new Perk[]
{
new PerkIronSkin(0.5)
},
EntityType.ZOMBIE,
new ItemStack(Material.STONE_SWORD));
new ItemStack(Material.WOOD_SWORD));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.APPLE, 5));
}
}