2012-03-02 00:30:52 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
|
|
|
import com.earth2me.essentials.Mob;
|
|
|
|
import com.earth2me.essentials.User;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Server;
|
2019-05-08 22:29:28 +00:00
|
|
|
import org.bukkit.entity.Cat;
|
|
|
|
import org.bukkit.entity.Entity;
|
2012-03-02 00:30:52 +00:00
|
|
|
import org.bukkit.entity.Ocelot;
|
2019-05-08 22:29:28 +00:00
|
|
|
import org.bukkit.entity.Tameable;
|
2012-03-02 00:30:52 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
2012-10-06 02:31:34 +00:00
|
|
|
// This command is not documented on the wiki #EasterEgg
|
2015-04-15 04:06:16 +00:00
|
|
|
public class Commandkittycannon extends EssentialsCommand {
|
|
|
|
private static final Random random = new Random();
|
2012-03-02 00:30:52 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
public Commandkittycannon() {
|
|
|
|
super("kittycannon");
|
|
|
|
}
|
2012-03-02 00:30:52 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
2020-08-11 18:09:22 +00:00
|
|
|
final Entity ocelot = Mob.CAT.getType() == null ? spawnOcelot(server, user) : spawnCat(server, user);
|
|
|
|
ess.scheduleSyncDelayedTask(() -> {
|
|
|
|
final Location loc = ocelot.getLocation();
|
|
|
|
ocelot.remove();
|
|
|
|
loc.getWorld().createExplosion(loc, 0F);
|
|
|
|
}, 20);
|
2014-05-18 20:32:07 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
}
|
2019-05-08 22:29:28 +00:00
|
|
|
|
2020-08-11 18:09:22 +00:00
|
|
|
private static Ocelot spawnOcelot(Server server, User user) throws Mob.MobException {
|
2019-05-08 22:29:28 +00:00
|
|
|
final Ocelot ocelot = (Ocelot) Mob.OCELOT.spawn(user.getWorld(), server, user.getBase().getEyeLocation());
|
|
|
|
final int i = random.nextInt(Ocelot.Type.values().length);
|
|
|
|
ocelot.setCatType(Ocelot.Type.values()[i]);
|
|
|
|
((Tameable) ocelot).setTamed(true);
|
|
|
|
ocelot.setBaby();
|
|
|
|
ocelot.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));
|
|
|
|
return ocelot;
|
|
|
|
}
|
|
|
|
|
2020-08-11 18:09:22 +00:00
|
|
|
private static Entity spawnCat(Server server, User user) throws Mob.MobException {
|
2019-05-08 22:29:28 +00:00
|
|
|
final Cat cat = (Cat) Mob.CAT.spawn(user.getWorld(), server, user.getBase().getEyeLocation());
|
|
|
|
final int i = random.nextInt(Cat.Type.values().length);
|
|
|
|
cat.setCatType(Cat.Type.values()[i]);
|
|
|
|
cat.setTamed(true);
|
|
|
|
cat.setBaby();
|
|
|
|
cat.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));
|
|
|
|
return cat;
|
|
|
|
}
|
2012-03-02 00:30:52 +00:00
|
|
|
}
|