Hi, im new at plugin develop. and i have a couple question: 1-) We can teleport to a player or a target block but how can we teleport on a arrow ? i mean after i shoot arrow when the arrow on air, if i click right with arrow item im gonna teleport to arrow's location. 2-)When i click right with xx item, world gonna create 3x3 dirt block in front of me. how can i do them ? thanks for answers and sorry for grammer
1: Listen for the PlayerInteractEvent and when you right click with the arrow launched, you will get teleported to it. 2: Get your location, and edit it until and loop through every block and then place some dirt on that location you're looping too.
1) You listen to a EntityShootBowEvent and store the arrow and the player. On a PlayerInteractEvent you then check if the players active slot is an arrow and if he is clicking it. If he is, you get the stored arrow and teleport the player to its location. 2) You check the rightclick like above(PlayerInteractEvent) , and when you get the players location, with location.getBlock() you can get Blocks and with block.getRelative(BlockFace) you can get the Blocks nearby. With block.setType(Typ/Material) you set the type (in your case block.setType(Material.DIRT)
Terradominik for the first question i did something like this: Code: @EventHandler public void onShoot(EntityShootBowEvent evt){ if(evt.getEntity() instanceof Arrow) { Arrow arrow = (Arrow) evt.getEntity(); if(arrow.getShooter() instanceof Player) { Player shooter = (Player) arrow.getShooter(); if(shooter.getItemInHand().getType() == Material.BOW) { evt.setCancelled(true); shooter.teleport(arrow.getLocation()); shooter.sendMessage("done"); } } } } and i tried something like that too Code: @SuppressWarnings("deprecation") public void onPlayerClick(PlayerInteractEvent event){ Player oyuncu = (Player)event.getPlayer(); oyuncu.sendMessage("done"); if(event.getPlayer().getItemInHand().getTypeId() == Material.ARROW.getId()){ oyuncu.shootArrow(); Block blok = oyuncu.getTargetBlock(null, 100); Location hedefblok = blok.getLocation(); oyuncu.teleport(hedefblok); oyuncu.sendMessage("done"); } } but nothing happened both of them
oh so you want to port the player instant when the arrow hit the ground like when throwing an enderpearl.. right?
Terradominik i want something like this 2:22 - 2:48 when i click left with arrow its gonna throw a arrow and when i click right with arrow im gonna teleport to arrow's location
that is way more complicated... because you have to shoot the arrow with the player pitch&yaw, it should be possible though.
Terradominik hmm what is the wrong of my codes on up ? why they didnt work :/ teunie75 Terradominik @and others im still need help Code: @EventHandler public void onShoot(EntityShootBowEvent evt){ if(evt.getEntity() instanceof Arrow) { Arrow arrow = (Arrow) evt.getEntity(); if(arrow.getShooter() instanceof Player) { Player shooter = (Player) arrow.getShooter(); if(shooter.getItemInHand().getType() == Material.BOW) { evt.setCancelled(true); shooter.teleport(arrow.getLocation()); shooter.sendMessage("done"); } } } } this and Code: @SuppressWarnings("deprecation") public void onPlayerClick(PlayerInteractEvent event){ Player oyuncu = (Player)event.getPlayer(); oyuncu.sendMessage("done"); if(event.getPlayer().getItemInHand().getTypeId() == Material.ARROW.getId()){ oyuncu.shootArrow(); Block blok = oyuncu.getTargetBlock(null, 100); Location hedefblok = blok.getLocation(); oyuncu.teleport(hedefblok); oyuncu.sendMessage("done"); } } this code not working even its not sending done message.. Malikk u can help me i think =P ++ =/ EDIT by Moderator: merged posts, please use the edit button instead of double posting.
i checked the arrow in the second code (onclick event) and i tried it with arrow. here is the full code: Code: package me.barisaraci.Naruto; import java.util.logging.Logger; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class NarutoPlugin extends JavaPlugin{ public static NarutoPlugin plugin; public final Logger logger = Logger.getLogger("Minecraft"); @Override public void onDisable(){ PluginDescriptionFile pdfFile = this.getDescription(); this.logger.info(pdfFile.getName() + " v. " + pdfFile.getVersion() + " deaktiflestirildi!"); } @Override public void onEnable(){ PluginDescriptionFile pdfFile = this.getDescription(); this.logger.info(pdfFile.getName() + " v. " + pdfFile.getVersion() + " aktiflestirildi!"); } @SuppressWarnings("deprecation") public boolean onCommand(CommandSender yollayici, Command komut, String komutsatiri, String args[]){ Player oyuncu = (Player)yollayici; if(komutsatiri.equalsIgnoreCase("tele")){ Block blok = oyuncu.getTargetBlock(null, 100); Location hedefblok = blok.getLocation(); oyuncu.teleport(hedefblok); } if(komutsatiri.equalsIgnoreCase("ok")){ oyuncu.shootArrow(); } return false; } @EventHandler public void onShoot(EntityShootBowEvent evt){ if(evt.getEntity() instanceof Arrow) { Arrow arrow = (Arrow) evt.getEntity(); if(arrow.getShooter() instanceof Player) { Player shooter = (Player) arrow.getShooter(); if(shooter.getItemInHand().getType() == Material.BOW) { evt.setCancelled(true); shooter.teleport(arrow.getLocation()); shooter.sendMessage("done"); } } } } @SuppressWarnings("deprecation") public void onPlayerClick(PlayerInteractEvent event){ Player oyuncu = (Player)event.getPlayer(); oyuncu.sendMessage("done"); if(event.getPlayer().getItemInHand().getTypeId() == Material.ARROW.getId()){ oyuncu.shootArrow(); Block blok = oyuncu.getTargetBlock(null, 100); Location hedefblok = blok.getLocation(); oyuncu.teleport(hedefblok); oyuncu.sendMessage("done"); } } } /tele and /ok functions are working but the others not working =/ i did it my problem was about listeners.. thanks for everyone for the help Terradominik Malikk teunie75 may u guys look this thread please ? http://forums.bukkit.org/threads/onshoot-event.140911/ EDIT by Moderator: merged posts, please use the edit button instead of double posting.