Fire a few extra entities from /fireball

This commit is contained in:
KHobbits 2013-01-09 00:58:29 +00:00
parent 6c48e02c14
commit c210e8730b

View File

@ -2,8 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.SmallFireball;
import org.bukkit.entity.*;
import org.bukkit.util.Vector;
@ -18,12 +17,31 @@ public class Commandfireball extends EssentialsCommand
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
boolean small = false;
if (args.length > 0 && args[0].equalsIgnoreCase("small"))
Class<? extends Entity> type = Fireball.class;
Projectile projectile;
int speed = 2;
if (args.length > 0)
{
small = true;
if (args[0].equalsIgnoreCase("small"))
{
type = SmallFireball.class;
}
else if (args[0].equalsIgnoreCase("arrow"))
{
type = Arrow.class;
}
else if (args[0].equalsIgnoreCase("skull"))
{
type = WitherSkull.class;
}
else if (args[0].equalsIgnoreCase("egg"))
{
type = Egg.class;
}
}
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
Fireball fireball = user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
fireball.setShooter(user.getBase());
final Vector direction = user.getEyeLocation().getDirection().multiply(speed);
projectile = (Projectile)user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), type);
projectile.setShooter(user.getBase());
projectile.setVelocity(direction);
}
}