Back again, with a Simple Repeating task question.

Discussion in 'Plugin Development' started by dxwarlock, Jun 6, 2012.

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

    dxwarlock

    I'm trying to apply a 2 second smoke trail to someone being launched by a player.setVelocity();

    Im assuming I'd need to use a scheduleSyncRepeatingTask to do this, by either getting the players location, (or player himself if I can apply smoke to a player)..but how to actually use scheduleSyncRepeatingTask Im at a loss for, nothing I try works.

    anyone mind tossing together a line for me to use to a player.getWorld().playEffect(location, Effect.SMOKE, 3); on that would work?
    (or how to do it on the player himself)
     
  2. Offline

    chenr1

    Last edited by a moderator: May 26, 2016
  3. Offline

    dxwarlock

    Kinda helps, but not sure how to implement it :p

    first time trying to execute a bukkit repeating command, so lost on even how to start out.
    the command I need to do I can handle, how to repeat it for 2 seconds (or 40 server ticks) I'm completely lost on.

    I gotten this far:

    Code:java
    1.  
    2. public void onPlayerMove(PlayerMoveEvent e) {
    3. final Player p = e.getPlayer();
    4. //------------------------
    5. if (!p.hasPermission("dx.road")) {
    6. return;
    7. }
    8. else {
    9. final Location tloc = p.getLocation();
    10. final CraftPlayer cp = (CraftPlayer)p;
    11. final World World = p.getWorld();
    12. Location location = new Location (p.getWorld(), p.getLocation().getX(), p.getLocation().getBlockY()-1, p.getLocation().getBlockZ());
    13. Block block = location.getBlock();
    14. if(block.getTypeId() == 121 && (!TownyUniverse.isWilderness(block) || true && World == Bukkit.getWorld("Travel"))) {
    15. cp.getHandle().addEffect(new MobEffect(1, 20, Main.Speed));
    16. cp.getHandle().addEffect(new MobEffect(8, 20, Main.Jump));
    17. cp.getWorld().playEffect(location, Effect.SMOKE, 2);
    18. }
    19. //------------------------
    20. if(block.getTypeId() == 110 && !TownyUniverse.isWilderness(block) == true) {
    21. cp.getHandle().addEffect(new MobEffect(9, 200, Main.Twist));
    22. }
    23. //------------------------
    24. if(block.getTypeId() == 19 && !TownyUniverse.isWilderness(block) == true) {
    25. Vector dir = p.getLocation().getDirection();
    26. Vector vec = new Vector(dir.getX() * Main.JumpBlock, Main.JumpBlock, dir.getZ() * Main.JumpBlock);
    27. cp.setVelocity(vec);
    28. cp.setFallDistance(-100.0F);
    29. cp.getWorld().playEffect(location, Effect.EXTINGUISH, 1);
    30. cp.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 1);
    31. cp.getHandle().addEffect(new MobEffect(1, 20, 4));
    32. plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
    33. public void run(){
    34. World.playEffect(tloc, Effect.GHAST_SHRIEK, 1);
    35. }
    36. },20L);
    37. }
    38. }
    39. }
    40.  


    but I get an exception of "Could not pass event PlayerMoveEvent to DXRoads"
    with relvant part, being: Caused by: java.lang.NullPointerException at me.dx.roads.plugin.Lis.onPlayerMove(Lis.java:67)

    which is where the scheduleSyncDelayedTask is (Line 31 in here) ..what am I doing wrong.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  4. line 31 in there is cp.getHandle().addEffect(new MobEffect(1, 20, 4));
     
Thread Status:
Not open for further replies.

Share This Page