всем ку, столкнулся с проблемой
при спавне визера (пишу плагин для появления частиц при спавне) не появляются заданные эффекты (particlehandler, код сниз, после fractalwither.java)
в конфиге все включено, эффекты и частицы
частицы не появляются - вся проблема в этом
!!!!! FRACTALWITHER (MAIN.JAVA) !!!!!
package com.fractal.fractalwither;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class FractalWither extends JavaPlugin implements Listener {
private ParticleHandler particleHandler;
@Override
public void onEnable() {
saveDefaultConfig();
particleHandler = new ParticleHandler(this);
if (getCommand("fw") != null) {
getCommand("fw").setExecutor(new CommandFW(this));
}
getServer().getPluginManager().registerEvents(this, this);
}
@Override
public void onDisable() {
getLogger().info("FractalWither выключен");
}
@EventHandler
public void onWitherSpawn(CreatureSpawnEvent event) {
if (event.getEntity() instanceof Wither) {
Wither wither = (Wither) event.getEntity();
particleHandler.applyEffectsToPlayers(wither);
particleHandler.spawnParticles(wither);
}
}
}
=======================
=======================
=======================
!!!! PARTICLEHANDLER.JAVA !!!
package com.fractal.fractalwither;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.bukkit.Color;
import org.bukkit.Particle;
public class ParticleHandler {
private final FractalWither plugin;
public ParticleHandler(FractalWither plugin) {
this.plugin = plugin;
}
public void applyEffectsToPlayers(Wither wither) {
for (Player player : wither.getWorld().getPlayers()) {
if (player.getLocation().distance(wither.getLocation()) <= 10) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 100, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 100, 1));
}
}
}
public void spawnParticles(Wither wither) {
new BukkitRunnable() {
@Override
public void run() {
wither.getWorld().spawnParticle(
Particle.SMOKE_LARGE,
wither.getLocation(),
20,
0.5, 0.5, 0.5,
0.1
);
Color colorFrom = Color.RED;
Color colorTo = Color.BLACK;
Particle.DustTransition dustTransition = new Particle.DustTransition(colorFrom, colorTo, 1);
wither.getWorld().spawnParticle(
Particle.DUST_COLOR_TRANSITION,
wither.getLocation(),
10,
0.5, 0.5, 0.5,
0.1,
dustTransition
);
new BukkitRunnable() {
@Override
public void run() {
wither.getWorld().spawnParticle(
Particle.DUST_COLOR_TRANSITION,
wither.getLocation(),
5,
0.5, 0.5, 0.5,
0.1,
dustTransition
);
}
}.runTaskLater(plugin, 20);
}
}.runTask(plugin);
}
}