1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-18 12:31:26 +02:00

Fire a few extra entities from /fireball

c210e8730b
This commit is contained in:
Chris Ward
2013-01-10 00:41:32 +11:00
parent 4bcbd7350a
commit 0d0c007c85

View File

@@ -1,8 +1,6 @@
package net.ess3.commands;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Player;
import org.bukkit.entity.SmallFireball;
import org.bukkit.entity.*;
import org.bukkit.util.Vector;
import net.ess3.api.IUser;
@@ -12,17 +10,32 @@ public class Commandfireball extends EssentialsCommand
@Override
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
boolean small = false;
if (args.length > 0 && args[0].equalsIgnoreCase("small"))
Class<? extends Entity> clazz = Fireball.class;
if (args.length > 0)
{
small = true;
if(args[0].equalsIgnoreCase("small"))
{
clazz = SmallFireball.class;
}
else if(args[0].equalsIgnoreCase("arrow"))
{
clazz = Arrow.class;
}
else if(args[0].equalsIgnoreCase("skull"))
{
clazz = WitherSkull.class;
}
else if(args[0].equalsIgnoreCase("egg"))
{
clazz = Egg.class;
}
}
final Player player = user.getPlayer();
final Vector direction = player.getEyeLocation().getDirection().multiply(2);
final Fireball fireball = player.getWorld().spawn(
player.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
fireball.setShooter(player);
Projectile projectile = (Projectile)user.getPlayer().getWorld().spawn(user.getPlayer().getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), clazz);
projectile.setShooter(user.getPlayer());
projectile.setVelocity(direction);
}
}