Следуйте инструкциям в видео ниже, чтобы узнать, как установить наш сайт как веб-приложение на главный экран вашего устройства.
Примечание: Эта функция может быть недоступна в некоторых браузерах.
Смотри ссорцы ThrowSwords, там такое есть). Иветы юзай только тогда когда на арморстенд пытаются повесить броню или поджечь.Получилось! И последний вопрос, какие надо использовать эвенты, когда армор стенд рядом с живым объектом и блоками?
List<Entity> ne = (List<Entity>)ArmorStand.getLocation().getWorld().getNearbyEntities(frontlocation, 0.05, 0.05, 0.05);
for (Entity e : ne) {
if (e instanceof Player && e.equals((Object)p) || e instanceof ArmorStand || e instanceof Item || !(e instanceof LivingEntity)) continue;
p.damage((double)5, (LivingEntity)e);
}
Не работает(Смотри ссорцы ThrowSwords, там такое есть). Иветы юзай только тогда когда на арморстенд пытаются повесить броню или поджечь.
Код:List<Entity> ne = (List<Entity>)ArmorStand.getLocation().getWorld().getNearbyEntities(frontlocation, 0.05, 0.05, 0.05); for (Entity e : ne) { if (e instanceof Player && e.equals((Object)p) || e instanceof ArmorStand || e instanceof Item || !(e instanceof LivingEntity)) continue; p.damage((double)5, (LivingEntity)e); }
@EventHandler
public void onIntercat(PlayerInteractEvent e) {
Player player = e.getPlayer();
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(player.getItemInHand() != null && player.getItemInHand().getType() == Material.DIAMOND_SWORD) {
Location loc = player.getLocation();
ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class);
stand.setVisible(false);
stand.setGravity(true);
stand.setArms(true);
stand.setItemInHand(new ItemStack(Material.DIAMOND_SWORD));
int animate = Bukkit.getScheduler().scheduleAsyncRepeatingTask(Main.getInstance(), new Animate(stand), 0, 1);
player.playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1, 1);
BukkitRunnable runnable = new BukkitRunnable() {
private int i = 0;
@Override
public void run() {
stand.setVelocity(player.getLocation().getDirection());
List<Entity> ne = (List<Entity>)stand.getLocation().getWorld().getNearbyEntities(loc, 0.05, 0.05, 0.05);
for (Entity all : ne) {
if (all instanceof Player && all.equals((Object)player) || all instanceof ArmorStand || all instanceof Item || !(all instanceof LivingEntity)) continue;
player.damage((double)5, (LivingEntity)all);
}
i++;
if(i >= 30) {
this.cancel();
stand.remove();
}
}
};
runnable.runTaskTimer(Main.getInstance(), 0L, 0L);
new EventUtil(Main.getInstance()) {
@EventHandler
public void onQuit(PlayerQuitEvent e) {
runnable.cancel();
}
};
new BukkitRunnable() {
@Override
public void run() {
Bukkit.getScheduler().cancelTask(animate);
stand.remove();
}
}.runTaskLater(Main.getInstance(), 100);
}
}
}
public class TestListener implements Listener {
@EventHandler
public void onIntercat(PlayerInteractEvent e) {
Player player = e.getPlayer();
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(player.getItemInHand() != null && player.getItemInHand().getType() == Material.DIAMOND_SWORD) {
Location loc = player.getLocation();
ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class);
stand.setVisible(false);
stand.setArms(true);
stand.setGravity(true);
stand.setItemInHand(new ItemStack(Material.DIAMOND_SWORD));
int animate = Bukkit.getScheduler().scheduleAsyncRepeatingTask(Main.getInstance(), new Animate(stand), 0, 1);
player.playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1, 1);
BukkitRunnable runnable = new BukkitRunnable() {
private int i = 0;
@Override
public void run() {
stand.setVelocity(player.getLocation().getDirection());
List<Entity> ne = (List<Entity>)stand.getLocation().getWorld().getNearbyEntities(stand.getLocation(), 1, 1, 1);
for (Entity all : ne) {
if (all instanceof Player && all.equals((Object)player) || all instanceof ArmorStand || all instanceof Item || !(all instanceof LivingEntity)) continue;
((LivingEntity) all).setHealth(0.0D);
stand.remove();
stand.playEffect(EntityEffect.DEATH);
}
stand.playEffect(EntityEffect.DEATH);
i++;
if(i >= 100) {
this.cancel();
stand.remove();
}
}
};
runnable.runTaskTimer(Main.getInstance(), 0L, 0L);
new EventUtil(Main.getInstance()) {
@EventHandler
public void onQuit(PlayerQuitEvent e) {
runnable.cancel();
}
};
new BukkitRunnable() {
@Override
public void run() {
Bukkit.getScheduler().cancelTask(animate);
stand.remove();
}
}.runTaskLater(Main.getInstance(), 100);
}
}
}
}