Blow a kiss taunt

This commit is contained in:
LCastr0 2017-01-16 19:43:49 -02:00
parent ddc098649f
commit a70c8eccc6
6 changed files with 170 additions and 19 deletions

View File

@ -173,6 +173,7 @@ import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot;
import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan;
import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood;
import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant;
import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt;
import mineplex.core.gadget.gadgets.taunts.EternalTaunt;
import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken;
import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames;
@ -552,6 +553,7 @@ public class GadgetManager extends MiniPlugin
// TAUNTS!!!
addGadget(new EternalTaunt(this));
addGadget(new BlowAKissTaunt(this));
for (GadgetType gadgetType : GadgetType.values())
{

View File

@ -0,0 +1,74 @@
package mineplex.core.gadget.gadgets.taunts;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.types.TauntGadget;
import mineplex.core.particleeffects.BlowAKissEffect;
import mineplex.core.recharge.Recharge;
public class BlowAKissTaunt extends TauntGadget
{
private static final int COOLDOWN = 30000;
private static final int PVP_COOLDOWN = 10000;
public BlowAKissTaunt(GadgetManager manager)
{
super(manager, "Blow A Kiss", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE),
-17, Material.GLASS, (byte) 0);
setCanPlayWithPvp(false);
setPvpCooldown(PVP_COOLDOWN);
setShouldPlay(false);
}
@Override
public void onStart(Player player)
{
if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics"))
return;
HashSet<Material> ignore = new HashSet<Material>();
ignore.add(Material.AIR);
Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5);
GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(player, this, loc);
Bukkit.getServer().getPluginManager().callEvent(gadgetSelectLocationEvent);
// Checks to see if it's a valid location
if (gadgetSelectLocationEvent.isCancelled())
{
if (gadgetSelectLocationEvent.canShowMessage())
{
UtilPlayer.message(player, F.main("Gadget", "You cannot use the laser on this area!"));
}
return;
}
BlowAKissEffect blowAKissEffect = new BlowAKissEffect(player, loc, this);
blowAKissEffect.start();
}
@Override
public void onPlay(Player player)
{
}
@Override
public void onFinish(Player player)
{
}
}

View File

@ -56,12 +56,6 @@ public class EternalTaunt extends TauntGadget
addDisabledGames(GameType.SMASH, GameType.SMASHTEAMS, GameType.SMASHDOMINATION);
}
@Override
public void disableCustom(Player player, boolean message)
{
finish(player);
}
@Override
public void onStart(Player player)
{

View File

@ -67,6 +67,12 @@ public abstract class TauntGadget extends Gadget
super(manager, GadgetType.TAUNT, name, desc, cost, mat, data, yearMonth, 1, alternativeSalesPackageNames);
}
@Override
public void disableCustom(Player player, boolean message)
{
finish(player);
}
public void start(Player player)
{
onStart(player);

View File

@ -0,0 +1,87 @@
package mineplex.core.particleeffects;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.types.Gadget;
public class BlowAKissEffect extends Effect
{
private int _particles = 100;
private int _count = 0;
private Vector _vector;
private Location _fixedLoc;
private Gadget _gadget;
private Player _player;
private boolean _forceStop = false;
public BlowAKissEffect(Player player, Location target, Gadget gadget)
{
super(-1, new EffectLocation(player), gadget.Manager.getPlugin());
_gadget = gadget;
_player = player;
setTargetLocation(new EffectLocation(target));
}
@Override
public void onStart()
{
_player.getWorld().playSound(_player.getLocation(), Sound.PISTON_RETRACT, 1f, 1f);
}
@Override
public void runEffect()
{
Location location = _effectLocation.getFixedLocation().clone().add(0, 1, 0);
if (_vector == null)
{
Location targetLoc = getTargetLocation().getFixedLocation().clone();
Vector link = targetLoc.toVector().subtract(location.toVector());
float length = (float) link.length();
link.normalize();
_vector = link.multiply(length / _particles);
_fixedLoc = location.clone().subtract(_vector);
}
for (int i = 0; i < 5; i++){
_fixedLoc.add(_vector);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, _fixedLoc, 0, 0, 0, 0, 2, UtilParticle.ViewDist.LONG);
}
if (checkPlayer())
{
stop();
return;
}
if (_fixedLoc.getBlock().getType() != Material.AIR )
{
stop();
}
else if (_count >= 1000)
{
_forceStop = true;
stop();
}
_count += 5;
}
private boolean checkPlayer()
{
for (Player player : UtilServer.getPlayers())
{
if (player.getLocation().distanceSquared(_fixedLoc) <= 2.25)
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, player.getLocation(), 0.25f, 0.25f, 0.25f, 0.5f, 7, UtilParticle.ViewDist.NORMAL);
UtilServer.broadcast(F.main("Blow A Kiss", F.name(_player.getName()) + " blows a kiss at " + F.name(player.getName()) + "!"));
return true;
}
}
return false;
}
}

View File

@ -1,7 +1,6 @@
package mineplex.core.particleeffects;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.Location;
import org.bukkit.Material;
@ -51,8 +50,7 @@ public class LoveDoctorEffect extends Effect
Vector link = targetLoc.toVector().subtract(location.toVector());
float length = (float) link.length();
link.normalize();
Vector vector = link.multiply(length / _particles);
_vector = vector;
_vector = link.multiply(length / _particles);
_fixedLoc = location.clone().subtract(_vector);
}
for (int i = 0; i < 5; i++){
@ -74,16 +72,6 @@ public class LoveDoctorEffect extends Effect
@Override
public void onStop()
{
if (!_forceStop)
{
_count = 0;
_vector = null;
HashSet<Material> ignore = new HashSet<Material>();
ignore.add(Material.AIR);
Location loc = _player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5);
_effectLocation = new EffectLocation(_player);
setTargetLocation(new EffectLocation(loc));
}
// Creates the explosion and knockback players
Location loc = _fixedLoc;
loc.getWorld().createExplosion(loc, 0f);