New PlayerTimer?

Discussion in 'Plugin Development' started by horse2950, Jul 11, 2012.

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

    horse2950

    okay so yes i have been trying to recreate a blockey and ran into a bug with the PlayerTimer...

    http://pastie.org/4238737

    This is the red underlined part:

    http://pastie.org/4238735

    Plz help

    lol can u help me again Digi Sence your so good at it lolz ill also be sure to give u creditz

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  2. Offline

    stelar7

    do you have a class named PlayerTime?
     
  3. Offline

    horse2950

    no... derp

    stelar7 okay now i do but what do i put in that class file? lol im new to all this

    is it just

    package me.horse2950.Blockey;

    public class PlayerTime implements Runnable {

    @Override
    public void run() {
    // TODO Auto-generated method stub

    }

    }

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  4. You put whatever you want to run after 200 ticks... what did the original plugin do after 10 seconds since a player got a ball ?
    Also, change async to sync... scheduleSyncDelayedTask() !

    And also, you don't need a new class for a small task, you can use new Runnable() inside that and place the code right in...

    Code:
    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
    {
        public void run()
        {
             // whatever code
        }
    }, 200);
    The advantage of this is that you can set "final" to variables defined before the task was created to use them inside that task.
     
    ferrybig likes this.
  5. Offline

    horse2950

    Tyvm!

    Digi So like this?
    Code:
        @EventHandler
        public void PlayerPickupItem(PlayerPickupItemEvent event){
            Player player = event.getPlayer();
            if(plugin.registered(player) && event.getItem().getItemStack().getTypeId()==Material.SLIME_BALL.getId()){
                player.sendMessage(ChatColor.BLUE + "You Have The Ball!");
                tasknumber = plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(), 200);
                plugin.setCarrier(player);
                player.setDisplayName("The Carrier");
            }
        }
    }
        
    Runnable is underlined in red....

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  6. No, like my provided example... replace that entire line with the lines what I provided... but I have no clue what you want in that task since you didn't say anything about the goal of the plugin... and I have no clue what "blockey" was :}
     
  7. Offline

    horse2950

    Digi
    Code:
    package me.horse2950.Blockey;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerPickupItemEvent;
     
    public class BlockeyPlayerListenerPick implements Listener{
        public static Blockey plugin;
        public int tasknumber;
       
        public BlockeyPlayerListenerPick(Blockey instance){
            plugin = instance;
        }
       
       
        @EventHandler
        public void PlayerPickupItem(PlayerPickupItemEvent event){
            Player player = event.getPlayer();
            if(plugin.registered(player) && event.getItem().getItemStack().getTypeId()==Material.SLIME_BALL.getId()){
                player.sendMessage(ChatColor.BLUE + "You Have The Ball!");
                tasknumber = plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(), 200);
                plugin.setCarrier(player);
                player.setDisplayName("The Carrier");
            }
        }
    }
        
    This is The PlayerBlockPickUp Class when they pick up the slimeball... they can only have it for 10secs then it goes to the PlayerBlockDrop

    lol i still need help

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  8. You seem to refuse to understand that in-line task... just use new PlayerTimer() instead of new Runnable() like you had before and in that class, remove the slimeball from the player that has it and spawn it at the PlayerBlockDrop whatever location :}
     
  9. Offline

    horse2950

    Last edited by a moderator: May 26, 2016
Thread Status:
Not open for further replies.

Share This Page