A couple of questions :)

Discussion in 'Plugin Development' started by Brexima, Apr 12, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Brexima

    xmarinusx
    if u mean onprojectilehit im just removing the arrow in this event.

    Code:
    Entity entiti;
    @EventHandler
        public void onLaunch(ProjectileLaunchEvent event)
    {
          if (event.getEntity().getShooter() instanceof Player)
          {
              //Player player = (Player)event.getEntity().getShooter();
              event.getEntity().getVelocity().multiply(20);
              entiti = event.getEntity();
          }
        }
    im taking the entity with this event and

    Code:
    @EventHandler
    public void onPlayerClick(PlayerInteractEvent event){
    if(event.getPlayer().getItemInHand().getTypeId() == 262 && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)){
    event.getPlayer().teleport(entiti.getLocation());
    }
    }
    im teleporting the player with this event. its working perfect in single player but when i try it with my friend, im shooting the arrow after it my friend shooting the arrow and when i click right im teleporting the my friend's arrow.. i think i have to connect arrow to player.. but i don't know how can i do that
     
  2. Offline

    xmarinusx

    Ah I see the problem! Use a HashMap. Of course this does only work if there's one player. HashMap should work. Brexima
     
  3. Offline

    Brexima

    xmarinusx
    i can use hashmap on command things etc.. but how can i use hashmap in this problem may u give an example please :)
     
  4. Offline

    xmarinusx

    Brexima
    I'll write an example when I'm on my pc tomorrow.
     
  5. Offline

    Brexima

  6. Offline

    xmarinusx

    Code:java
    1.  
    2. HashMap<String, Entity> entities = new HashMap<String, Entity>();
    3. @EventHandler
    4. public void onLaunch(ProjectileLaunchEvent event)
    5. {
    6. if (event.getEntity().getShooter() instanceof Player)
    7. {
    8. Player player = (Player)event.getEntity().getShooter();
    9. event.getEntity().getVelocity().multiply(20);
    10. locations.put(player.getName(), event.getEntity());
    11. }
    12. }

    and
    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerClick(PlayerInteractEvent event){
    4. if(event.getPlayer().getItemInHand().getTypeId() == 262 && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)){
    5. event.getPlayer().teleport(entities.get(event.getPlayer().getName());
    6. }
    7. }

    Try this, tell me if it still doesn't work.
     
  7. Offline

    Brexima

    xmarinusx likes this.
  8. Offline

    Brexima

    xmarinusx
    i hope im not bothering u too much, but i have two more question =(
    - how can i take target player ? we can take target block with Block asd = player.getTargetBlock(); but there isnt any function like getTargetPlayer()..
    - are there any events that can take the entity to bump into a player ( collision detection event )
     
  9. Offline

    kreashenz

    Brexima You should use (if its a command) Player target = Bukkit.getPlayer(args[0-9]);
     
  10. Offline

    Brexima

    kreashenz
    not command, i want to take the character in the crosshair..(center of screen)
     
  11. Offline

    kreashenz

    Brexima :/ Check the players yaw, ( or pitch, whichever one it is ) and check if their crosshair is aiming at a Player, I cannot give you a code, I am VERY VERY VERY busy right now.
     
  12. Offline

    xmarinusx

    Brexima
    I'm sorry, I can't help you with this either.
     
  13. Offline

    Brexima

    its np thanks :)
     
Thread Status:
Not open for further replies.

Share This Page