package me.twx.twx_vape;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.*********ventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
public class TwX_Vape extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (player.getItemInHand().getType() == Material.SPYGLASS && player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase("Вейп")) {
new BukkitRunnable() {
int ticks = 0;
@Override
public void run() {
// Создание белого дыма возле головы игрока
Location smokeLocation = player.getEyeLocation();
Particle.DustTransition dustTransition = new Particle.DustTransition(Color.WHITE, Color.fromRGB(255, 255, 255), 4);
player.playSound(player.getLocation(), Sound.BLOCK_BUBBLE_COLUMN_BUBBLE_POP, 5, 1);
ticks++;
if (ticks >= 100) { // 60 тиков = 3 секунды (20 тиков в секунде)
this.cancel();
} else if (ticks >= 40) {
player.getWorld().spawnParticle(Particle.REDSTONE, smokeLocation, 1, 0, 0, 0, 0, dustTransition);
}
}
}.runTaskTimer(this, 0, 1); // Запускаем таймер с интервалом 1 тик (1/20 секунды)
} else if (player.getItemInHand().getType() == Material.SPYGLASS && player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase("Сигарета")) {
new BukkitRunnable() {
int ticks = 0;
@Override
public void run() {
Location smokeLocation = player.getEyeLocation().add(0, 0, 0);
Particle.DustTransition dustTransition1 = new Particle.DustTransition(Color.GRAY, Color.fromRGB(33, 33, 33), 3);
player.playSound(player.getLocation(), Sound.BLOCK_BUBBLE_COLUMN_BUBBLE_POP, 5, 1);
ticks++;
if (ticks >= 100) {
this.cancel();
} else if (ticks >= 40) {
player.getWorld().spawnParticle(Particle.REDSTONE, smokeLocation, 1, 0, 0, 0, 0, dustTransition1);
}
}
}.runTaskTimer(this, 0, 1);
} else if (player.getItemInHand().getType() == Material.SPYGLASS && player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase("Вейп Виноград" )) {
new BukkitRunnable() {
int ticks = 0;
@Override
public void run() {
Location smokeLocation = player.getEyeLocation().add(0, 0, 0);
Particle.DustTransition dustTransition2 = new Particle.DustTransition(Color.PURPLE, Color.fromRGB(99, 53, 99), 4);
player.playSound(player.getLocation(), Sound.BLOCK_BUBBLE_COLUMN_BUBBLE_POP, 5, 1);
ticks++;
if (ticks >= 100) {
this.cancel();
} else if (ticks >= 40) {
player.getWorld().spawnParticle(Particle.REDSTONE, smokeLocation, 1, 0, 0, 0, 0, dustTransition2);
}
}
} .runTaskTimer(this, 0, 1);
}
}
}
А это код (я знаю что писать все в 1 классе плохо но все же