Gadget Paintball: Add particles on impact, change block break effect to stone break sound.
This commit is contained in:
parent
18843c2cc6
commit
72adf21bff
@ -18,9 +18,15 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
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.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||
import mineplex.core.gadget.types.ItemGadget;
|
||||
@ -30,16 +36,17 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
public class ItemPaintballGun extends ItemGadget
|
||||
{
|
||||
private HashSet<Projectile> _balls = new HashSet<Projectile>();
|
||||
|
||||
public ItemPaintballGun(GadgetManager manager)
|
||||
|
||||
public ItemPaintballGun(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Paintball Gun", new String[]
|
||||
{
|
||||
super(manager, "Paintball Gun", new String[]
|
||||
{
|
||||
C.cWhite + "PEW PEW PEW PEW!",
|
||||
},
|
||||
-1,
|
||||
Material.GOLD_BARDING, (byte)0,
|
||||
200, new Ammo("Paintball Gun", "100 Paintballs", Material.GOLD_BARDING, (byte)0, new String[] { C.cWhite + "100 Paintballs for you to shoot!" }, 500, 100));
|
||||
}, -1, Material.GOLD_BARDING, (byte) 0, 200, new Ammo("Paintball Gun", "100 Paintballs", Material.GOLD_BARDING,
|
||||
(byte) 0, new String[]
|
||||
{
|
||||
C.cWhite + "100 Paintballs for you to shoot!"
|
||||
}, 500, 100));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,38 +55,56 @@ public class ItemPaintballGun extends ItemGadget
|
||||
Projectile proj = player.launchProjectile(EnderPearl.class);
|
||||
proj.setVelocity(proj.getVelocity().multiply(2));
|
||||
_balls.add(proj);
|
||||
|
||||
//Sound
|
||||
|
||||
// Sound
|
||||
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5f, 1.2f);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void Paint(ProjectileHitEvent event)
|
||||
{
|
||||
if (!_balls.remove(event.getEntity()))
|
||||
return;
|
||||
|
||||
Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity());
|
||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 49);
|
||||
|
||||
Location loc = event.getEntity().getLocation();
|
||||
|
||||
Vector vec = event.getEntity().getVelocity().normalize().multiply(0.05);
|
||||
|
||||
if (vec.length() > 0)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (UtilBlock.airFoliage(loc.getBlock()))
|
||||
{
|
||||
loc.add(vec);
|
||||
|
||||
if (i++ > 50)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
loc.getWorld().playSound(loc, Sound.DIG_STONE, 1.3F, 1.3F);
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.RED_DUST, loc, 0.2F, 0.2F, 0.2F, 1, 70, ViewDist.LONG, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void Teleport(PlayerTeleportEvent event)
|
||||
{
|
||||
if (event.getCause() == TeleportCause.ENDER_PEARL)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void cleanupBalls(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
|
||||
for (Iterator<Projectile> ballIterator = _balls.iterator(); ballIterator.hasNext();)
|
||||
{
|
||||
Projectile ball = ballIterator.next();
|
||||
|
||||
|
||||
if (ball.isDead() || !ball.isValid())
|
||||
ballIterator.remove();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user