mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-07-04 19:53:49 +00:00
f6cb9ff470
Co-authored-by: MD <1917406+md678685@users.noreply.github.com> Fixes #3579 (async `/skull` command) Fixes #3336 (improve codestyle of commands) Partially addresses #3339 (`/spawn` and `/setspawn` are now hidden from tabcomplete) Closes #3087 (`/paytoggle` is now a loop command)
53 lines
2 KiB
Java
53 lines
2 KiB
Java
package com.earth2me.essentials.commands;
|
|
|
|
import com.earth2me.essentials.Mob;
|
|
import com.earth2me.essentials.User;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.Server;
|
|
import org.bukkit.entity.Cat;
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.entity.Ocelot;
|
|
import org.bukkit.entity.Tameable;
|
|
|
|
import java.util.Random;
|
|
|
|
// This command is not documented on the wiki #EasterEgg
|
|
public class Commandkittycannon extends EssentialsCommand {
|
|
private static final Random random = new Random();
|
|
|
|
public Commandkittycannon() {
|
|
super("kittycannon");
|
|
}
|
|
|
|
@Override
|
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
|
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);
|
|
|
|
}
|
|
|
|
private static Ocelot spawnOcelot(Server server, User user) throws Mob.MobException {
|
|
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;
|
|
}
|
|
|
|
private static Entity spawnCat(Server server, User user) throws Mob.MobException {
|
|
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;
|
|
}
|
|
}
|