Hey guys, I need help with a kangaroo kit, like in mcpvp's hardcore games. Code:java @EventHandler public void PlayerInteractEvent(PlayerInteractEvent event) { int jumps = 0; Entity entity = event.getPlayer(); if (event.getItem().getType() == Material.FIREWORK && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)){ event.setCancelled(true); if (jumps != 2){ jumps++; Vector v = entity.getLocation().getDirection(); v.multiply(1); v.setY(1); v.normalize(); entity.setVelocity(v); } else if (entity.isOnGround()==true){ jumps=0; } else if(jumps == 2){ jumps=0; } } }
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.
This is what I did, it's much more simple, but yours is probably more efficient (if it worked) Code:java @EventHandler public void onOrangeClick(PlayerInteractEvent e) { final Player p = e.getPlayer(); Location l = p.getLocation(); Vector v = p.getVelocity(); if(QuadularPVP.getInstance().orange.contains(p.getName())) { if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) { if(p.getItemInHand().getType() == Material.PUMPKIN_PIE) { if(p.getItemInHand().getItemMeta().hasDisplayName()) { if(p.getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Orange Slice")) { if(!(cd.contains(p.getName()))) { p.setVelocity(l.getDirection().multiply(0.5)); p.setVelocity(new Vector(v.getX(), 1.0D, v.getZ())); cd.add(p.getName()); Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { cd.remove(p.getName()); } }, 40L); } } } } } } } (cd is an ArrayList<String>)
This forum is for help with the bukkit api. There are many resources online dedicated to teaching Java. I would suggest youtube or StackOverflow