Ninja kit help?

Discussion in 'Plugin Development' started by iAmGuus, Jul 5, 2014.

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


    Hey guys,
    I got another question about a kit i was coding, the ninja kit.
    For the people who dont know what it does. If you hit a player, you will be able to teleport to him for 7 seconds if you sneak.
    So, i try coding it, but it didnt work out that fine.
    It just doesnt teleport me to the player i hit.
    Anyways, here is my code:

    1. ArrayList<String> ninjateleport = new ArrayList<String>();
    2. ArrayList<String> ninjacooldown = new ArrayList<String>();
    4. @EventHandler
    5. public void ninja(EntityDamageByEntityEvent e) {
    6. if(e.getEntity() instanceof Player && e.getDamager() instanceof Player) {
    7. Player p = (Player) e.getEntity();
    8. final Player dmger = (Player) e.getDamager();
    9. final String pName = dmger.getName();
    10. if(PvPKits.hasKit(pName)) {
    11. if(PvPKits.getKit(pName).equalsIgnoreCase("Ninja")) {
    12. ninjateleport.add(pName);
    13. if(dmger.isSneaking()) {
    14. if(!ninjacooldown.contains(pName)) {
    15. dmger.teleport(p);
    16. ninjateleport.remove(pName);
    17. ninjacooldown.add(pName);
    18. }
    19. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    21. public void run(){
    22. ninjacooldown.remove(pName);
    23. }
    25. }, 140L);
    27. if(ninjacooldown.contains(pName)) {
    28. p.sendMessage(ChatColor.RED + "You may not tp yet!");
    29. }
    30. }
    31. }
    32. }
    33. }
    34. }

    Thx, iAmGuus
  2. Offline


  3. Offline


    What do you mean
  4. Offline


    You need to definitely learn some java first.
    PogoStick29 and CynutsBR like this.
  5. Offline


    Yeah, but you could you even explain it then?

    Ok, iknow what a stack-trace is. But anyways will look further on to it tomorrow. Its 11:00 PM here
  6. Offline


    U have to do another event, onplayersneak and check if the player is on the arraylist and u have to store d player who was "punched" and when the player (ninja) sneak and if he is on arraylist get the punched location and teleport the ninja for that location, thats simple...
  7. Offline


    But how would i get the player which he will need to get teleported to?
  8. Offline


    Just put dmger.getName() in a ArrayList
Thread Status:
Not open for further replies.

Share This Page