Added some extra checks to Blood
Should resolve possible NPE and Material.AIR issues along
This commit is contained in:
parent
2d5868657a
commit
10e89a228e
|
@ -54,22 +54,28 @@ public class Blood extends MiniPlugin
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void display(BloodEvent event)
|
public void display(BloodEvent event)
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < event.getParticles() ; i++)
|
if(event.isCancelled()) return;
|
||||||
|
|
||||||
|
if(event.getMaterial() != null && event.getMaterial() != Material.AIR)
|
||||||
{
|
{
|
||||||
Item item = event.getLocation().getWorld().dropItem(event.getLocation(),
|
for (int i = 0 ; i < event.getParticles() ; i++)
|
||||||
new ItemBuilder(event.getMaterial(), 1, event.getMaterialData()).setTitle("" + System.nanoTime()).build());
|
{
|
||||||
|
Item item = event.getLocation().getWorld().dropItem(event.getLocation(),
|
||||||
|
new ItemBuilder(event.getMaterial(), 1, event.getMaterialData()).setTitle("" + System.nanoTime()).build());
|
||||||
|
|
||||||
item.setVelocity(new Vector((Math.random() - 0.5)*event.getVelocityMult(),Math.random()*event.getVelocityMult(),(Math.random() - 0.5)*event.getVelocityMult()));
|
item.setVelocity(new Vector((Math.random() - 0.5)*event.getVelocityMult(),Math.random()*event.getVelocityMult(),(Math.random() - 0.5)*event.getVelocityMult()));
|
||||||
|
|
||||||
item.setPickupDelay(999999);
|
item.setPickupDelay(999999);
|
||||||
|
|
||||||
_blood.put(item, event.getTicks());
|
_blood.put(item, event.getTicks());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getBloodStep())
|
if (event.getBloodStep())
|
||||||
event.getLocation().getWorld().playEffect(event.getLocation(), Effect.STEP_SOUND, 55);
|
event.getLocation().getWorld().playEffect(event.getLocation(), Effect.STEP_SOUND, 55);
|
||||||
|
|
||||||
event.getLocation().getWorld().playSound(event.getLocation(), event.getSound(), event.getSoundVolume(), event.getSoundPitch());
|
if(event.getSound() != null)
|
||||||
|
event.getLocation().getWorld().playSound(event.getLocation(), event.getSound(), event.getSoundVolume(), event.getSoundPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
Loading…
Reference in New Issue