Kangaroo Help

Discussion in 'Plugin Development' started by fls1234, Oct 7, 2013.

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

    fls1234

    Hey guys,

    I need help with a kangaroo kit, like in mcpvp's hardcore games.
    Code:java
    1. @EventHandler
    2. public void PlayerInteractEvent(PlayerInteractEvent event) {
    3. int jumps = 0;
    4. Entity entity = event.getPlayer();
    5. if (event.getItem().getType() == Material.FIREWORK && (event.getAction() == Action.RIGHT_CLICK_AIR ||
    6. event.getAction() == Action.RIGHT_CLICK_BLOCK)){
    7. event.setCancelled(true);
    8. if (jumps != 2){
    9. jumps++;
    10. Vector v = entity.getLocation().getDirection();
    11. v.multiply(1);
    12. v.setY(1);
    13. v.normalize();
    14. entity.setVelocity(v);
    15. }
    16. else if (entity.isOnGround()==true){
    17. jumps=0;
    18. }
    19. else if(jumps == 2){
    20.  
    21. jumps=0;
    22. }
    23. }
    24. }
     
  2. Offline

    chasechocolate

    Your "jumps" variable is in the method, so it will be 0 every time a player interacts. Put it outside the method. Also, it would be better to use a HashMap<String, Integer> so one player's jumps does not affect another player's.
     
  3. Offline

    fls1234

  4. Offline

    sgavster

    This is what I did, it's much more simple, but yours is probably more efficient (if it worked)
    Code:java
    1. @EventHandler
    2. public void onOrangeClick(PlayerInteractEvent e)
    3. {
    4. final Player p = e.getPlayer();
    5. Location l = p.getLocation();
    6. Vector v = p.getVelocity();
    7. if(QuadularPVP.getInstance().orange.contains(p.getName()))
    8. {
    9. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)
    10. {
    11. if(p.getItemInHand().getType() == Material.PUMPKIN_PIE)
    12. {
    13. if(p.getItemInHand().getItemMeta().hasDisplayName())
    14. {
    15. if(p.getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Orange Slice"))
    16. {
    17. if(!(cd.contains(p.getName())))
    18. {
    19. p.setVelocity(l.getDirection().multiply(0.5));
    20. p.setVelocity(new Vector(v.getX(), 1.0D, v.getZ()));
    21. cd.add(p.getName());
    22. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
    23. {
    24. public void run()
    25. {
    26. cd.remove(p.getName());
    27. }
    28. }, 40L);
    29. }
    30. }
    31. }
    32. }
    33. }
    34. }
    35. }


    (cd is an ArrayList<String>)
     
  5. Offline

    fls1234

    @T3h Cr33p3r I'm not the best with HashMaps.
     
  6. Offline

    MrSnare

    Learn how to use them
     
  7. Offline

    BungeeTheCookie

    That's why we have bukkit forums
     
  8. Offline

    fls1234

    So....... can some one help me with the hashmaps?
     
  9. Offline

    MrSnare

    This forum is for help with the bukkit api. There are many resources online dedicated to teaching Java. I would suggest youtube or StackOverflow
     
Thread Status:
Not open for further replies.

Share This Page