Помогите Отравленные снежки

StrayDog31

Новичок
Пользователь
Баллы
6
Приветствую! Возникла такая (очередная) проблема: в моем плагине есть предмет, создающий снежки. Мне нужно присвоить им определенный эффект, скажем, отравление. Можно было бы сделать по аналогии с
, но при таком подходе все снежки взрываются, а не только созданные предметом. Сослаться на этот void с void'a предмета не получается. Значится как ошибка. Подскажите, пожалуйста, пути решения!
 
Присвой метадату снежкам и по ней ищи свои в hit ивенте.
 
Присвой метадату снежкам и по ней ищи свои в hit ивенте.

Похоже на правду?

public void use1(PlayerInteractEvent e) {
Player player = e.getPlayer();
ItemStack FrostBook = e.getPlayer().getInventory().getItemInMainHand();
ItemStack HoneyArmorC = e.getPlayer().getInventory().getChestplate();
if(e.getPlayer().getInventory().getItemInMainHand().getType() != Material.BOOK) return;
if(e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if(!FrostBook.getItemMeta().hasDisplayName()) return;
if(!FrostBook.getItemMeta().getDisplayName().equals(ChatColor.BLUE + "Стрела Льда")) return;
if(e.getPlayer().getExp() == 0) return;


player.launchProjectile(Snowball.class, player.getEyeLocation().getDirection());
Entity mobs = (Entity) player.getWorld().getNearbyEntities(player.getLocation(), 1, 1, 1);
mobs.setMetadata("PSB", null);

player.playSound(player.getLocation(), Sound.ENTITY_SNOW_GOLEM_SHOOT, 8, 1);
player.spawnParticle(Particle.SNOWBALL, player.getLocation().add(0.5D, 0.5D, 0.5D), 25 , 1.2F, 1.2F, 1.2F);
player.giveExp(-2);
if(e.getPlayer().getExp() == 0) return;
if(e.getPlayer().getInventory().getChestplate().getType() == Material.GOLDEN_CHESTPLATE && HoneyArmorC.getItemMeta().hasDisplayName() && HoneyArmorC.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Пчелиный нагрудник")) player.giveExp(+1);
prv1(null);
}

@EventHandler
public void prv1(ProjectileHitEvent e) {


if(e.getEntity().getShooter() instanceof Player) {
if(e.getEntityType().equals(EntityType.SNOWBALL)) {
if(e.getEntity().hasMetadata("PSB")) {
if(e.getHitBlock() == null) {
Location loc = e.getHitEntity().getLocation();
e.getHitEntity().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1, false, false);


}else if(e.getHitEntity() == null) {
Location loc = e.getHitBlock().getLocation();
e.getHitBlock().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1, false, false);
}
}
}
}
}
 
Ну, ты был близок.
Можете указать на ошибку(и)?

public void use1(PlayerInteractEvent e) {

Player player = e.getPlayer();
Plugin Plugin = (org.bukkit.plugin.Plugin) this;
ItemStack FrostBook = e.getPlayer().getInventory().getItemInMainHand();
ItemStack HoneyArmorC = e.getPlayer().getInventory().getChestplate();
if(e.getPlayer().getInventory().getItemInMainHand().getType() != Material.BOOK) return;
if(e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if(!FrostBook.getItemMeta().hasDisplayName()) return;
if(!FrostBook.getItemMeta().getDisplayName().equals(ChatColor.BLUE + "Стрела Льда")) return;
if(e.getPlayer().getExp() == 0) return;


player.launchProjectile(Snowball.class, player.getEyeLocation().getDirection());
Entity mobs = (Entity) player.getWorld().getNearbyEntities(player.getLocation(), 1, 1, 1);
mobs.setMetadata("PSB", new FixedMetadataValue(Plugin, true));
player.playSound(player.getLocation(), Sound.ENTITY_SNOW_GOLEM_SHOOT, 8, 1);
player.spawnParticle(Particle.SNOWBALL, player.getLocation().add(0.5D, 0.5D, 0.5D), 25 , 1.2F, 1.2F, 1.2F);
player.giveExp(-2);
if(e.getPlayer().getExp() == 0) return;
if(e.getPlayer().getInventory().getChestplate().getType() == Material.GOLDEN_CHESTPLATE && HoneyArmorC.getItemMeta().hasDisplayName() && HoneyArmorC.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Пчелиный нагрудник")) player.giveExp(+1);
}

@EventHandler
public void prv1(ProjectileHitEvent e) {


if(e.getEntity().getShooter() instanceof Player) {
if(e.getEntityType().equals(EntityType.SNOWBALL)) {
if(e.getEntity().hasMetadata("PSB")) {
if(e.getHitBlock() == null) {
Location loc = e.getHitEntity().getLocation();
e.getHitEntity().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1, false, false);


}else if(e.getHitEntity() == null) {
Location loc = e.getHitBlock().getLocation();
e.getHitBlock().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1, false, false);
}
}
}
}
}
 
Последнее редактирование:
Можете указать на ошибку(и)?

public void use1(PlayerInteractEvent e) {

Player player = e.getPlayer();
Plugin Plugin = (org.bukkit.plugin.Plugin) this;
ItemStack FrostBook = e.getPlayer().getInventory().getItemInMainHand();
ItemStack HoneyArmorC = e.getPlayer().getInventory().getChestplate();
if(e.getPlayer().getInventory().getItemInMainHand().getType() != Material.BOOK) return;
if(e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if(!FrostBook.getItemMeta().hasDisplayName()) return;
if(!FrostBook.getItemMeta().getDisplayName().equals(ChatColor.BLUE + "Стрела Льда")) return;
if(e.getPlayer().getExp() == 0) return;


player.launchProjectile(Snowball.class, player.getEyeLocation().getDirection());
Entity mobs = (Entity) player.getWorld().getNearbyEntities(player.getLocation(), 1, 1, 1);
mobs.setMetadata("PSB", new FixedMetadataValue(Plugin, true));
player.playSound(player.getLocation(), Sound.ENTITY_SNOW_GOLEM_SHOOT, 8, 1);
player.spawnParticle(Particle.SNOWBALL, player.getLocation().add(0.5D, 0.5D, 0.5D), 25 , 1.2F, 1.2F, 1.2F);
player.giveExp(-2);
if(e.getPlayer().getExp() == 0) return;
if(e.getPlayer().getInventory().getChestplate().getType() == Material.GOLDEN_CHESTPLATE && HoneyArmorC.getItemMeta().hasDisplayName() && HoneyArmorC.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Пчелиный нагрудник")) player.giveExp(+1);
}

@EventHandler
public void prv1(ProjectileHitEvent e) {


if(e.getEntity().getShooter() instanceof Player) {
if(e.getEntityType().equals(EntityType.SNOWBALL)) {
if(e.getEntity().hasMetadata("PSB")) {
if(e.getHitBlock() == null) {
Location loc = e.getHitEntity().getLocation();
e.getHitEntity().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1, false, false);


}else if(e.getHitEntity() == null) {
Location loc = e.getHitBlock().getLocation();
e.getHitBlock().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1, false, false);
}
}
}
}
}
Читать невозможно. Вставляй код в блок:
Код:
[PHP]Тут код[/PHP]
 
Читать невозможно. Вставляй код в блок:
Код:
[PHP]Тут код[/PHP]

PHP:
public void use1(PlayerInteractEvent e) {

Player player = e.getPlayer();
Plugin Plugin = (org.bukkit.plugin.Plugin) this;
ItemStack FrostBook = e.getPlayer().getInventory().getItemInMainHand();
ItemStack HoneyArmorC = e.getPlayer().getInventory().getChestplate();
if(e.getPlayer().getInventory().getItemInMainHand().getType() != Material.BOOK) return;
if(e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if(!FrostBook.getItemMeta().hasDisplayName()) return;
if(!FrostBook.getItemMeta().getDisplayName().equals(ChatColor.BLUE + "Стрела Льда")) return;
if(e.getPlayer().getExp() == 0) return;


player.launchProjectile(Snowball.class, player.getEyeLocation().getDirection());
Entity mobs = (Entity) player.getWorld().getNearbyEntities(player.getLocation(), 1, 1, 1);
mobs.setMetadata("PSB", new FixedMetadataValue(Plugin, true));
player.playSound(player.getLocation(), Sound.ENTITY_SNOW_GOLEM_SHOOT, 8, 1);
player.spawnParticle(Particle.SNOWBALL, player.getLocation().add(0.5D, 0.5D, 0.5D), 25 , 1.2F, 1.2F, 1.2F);
player.giveExp(-2);
if(e.getPlayer().getExp() == 0) return;
if(e.getPlayer().getInventory().getChestplate().getType() == Material.GOLDEN_CHESTPLATE && HoneyArmorC.getItemMeta().hasDisplayName() && HoneyArmorC.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Пчелиный нагрудник")) player.giveExp(+1);
}

@EventHandler
public void prv1(ProjectileHitEvent e) {


if(e.getEntity().getShooter() instanceof Player) {
if(e.getEntityType().equals(EntityType.SNOWBALL)) {
if(e.getEntity().hasMetadata("PSB")) {
if(e.getHitBlock() == null) {
Location loc = e.getHitEntity().getLocation();
e.getHitEntity().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1, false, false);


}else if(e.getHitEntity() == null) {
Location loc = e.getHitBlock().getLocation();
e.getHitBlock().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1, false, false);
}
}
}
}
}
 
Назад
Верх