2019-12-21 18:32:58 +00:00
|
|
|
package pw.kaboom.extras.commands;
|
|
|
|
|
2022-05-21 19:28:42 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
2019-12-21 18:32:58 +00:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
2022-05-21 19:28:42 +00:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
|
2019-12-21 18:32:58 +00:00
|
|
|
public final class CommandKaboom implements CommandExecutor {
|
|
|
|
|
2022-05-21 19:28:42 +00:00
|
|
|
public boolean onCommand(final @Nonnull CommandSender sender,
|
|
|
|
final @Nonnull Command command,
|
|
|
|
final @Nonnull String label,
|
2022-05-20 03:07:38 +00:00
|
|
|
final String[] args) {
|
2022-05-20 02:35:48 +00:00
|
|
|
final Player player = (Player) sender;
|
|
|
|
boolean explode = ThreadLocalRandom.current().nextBoolean();
|
|
|
|
|
|
|
|
if (explode) {
|
|
|
|
final Location location = player.getLocation();
|
|
|
|
final World world = player.getWorld();
|
|
|
|
final int explosionCount = 20;
|
|
|
|
final int power = 8;
|
|
|
|
|
|
|
|
world.createExplosion(location, power, true, true);
|
|
|
|
|
|
|
|
for (int i = 0; i < explosionCount; i++) {
|
|
|
|
final double posX = location.getX() + ThreadLocalRandom.current().nextInt(-15, 15);
|
|
|
|
final double posY = location.getY() + ThreadLocalRandom.current().nextInt(-6, 6);
|
|
|
|
final double posZ = location.getZ() + ThreadLocalRandom.current().nextInt(-15, 15);
|
|
|
|
|
|
|
|
final Location explodeLocation = new Location(world, posX, posY, posZ);
|
|
|
|
final int power2 = 4;
|
|
|
|
|
|
|
|
world.createExplosion(explodeLocation, power2, true, true);
|
|
|
|
explodeLocation.getBlock().setType(Material.LAVA);
|
|
|
|
}
|
|
|
|
|
2022-05-21 19:28:42 +00:00
|
|
|
player.sendMessage(Component.text("Forgive me :c"));
|
2022-05-20 02:35:48 +00:00
|
|
|
} else {
|
|
|
|
player.getInventory().setItemInMainHand(new ItemStack(Material.CAKE));
|
2022-05-21 19:28:42 +00:00
|
|
|
player.sendMessage(Component.text("Have a nice day :)"));
|
2022-05-20 02:35:48 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2022-05-19 22:44:22 +00:00
|
|
|
}
|