getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
List<ArmorStand> stands = new ArrayList<>();
List<Entity> entities = Bukkit.getWorld("world").getEntities();
for (Entity entity : entities) {
if (entity.getType().equals(EntityType.ARMOR_STAND)) {
stands.add((ArmorStand) entity);
}
}
for (ArmorStand armorStand : stands) {
if (armorStand.getScoreboardTags().contains(player.getName())) {
armorStand.teleport(armorStand.getLocation().add(armorStand.getLocation().getDirection().multiply(1)));
}
for (Entity entity : entities) {
if (entity.getLocation().distance(armorStand.getLocation()) < 1) {
if (entity instanceof LivingEntity) {
((org.bukkit.entity.LivingEntity) entity).damage(5);
}
}
}
}
}
}, 0, 0);
}
listener부분
@EventHandler
public void interact(PlayerInteractEvent event) {
if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
Player player = event.getPlayer();
World world = event.getPlayer().getWorld();
ArmorStand stand = world.spawn(player.getLocation(), ArmorStand.class);
stand.addScoreboardTag(player.getName());
stand.setItem(EquipmentSlot.HAND, player.getInventory().getItemInMainHand());
player.getInventory().setItemInMainHand(null);
}
}
윈초
2021.01.24아머스텐드로 하면 가능할거같은데요?
던지면 반복한다음 근처에 엔티티가 있으면 뎀지 주게..?
neinerror
2021.01.24예시 구문 있나요?
윈초
2021.01.25onEnable부분
listener부분
neinerror
2021.01.25감사합니다