add 1 to int every X ticks

Discussion in 'Plugin Development' started by Niv200, Aug 4, 2013.

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

    Niv200

    i tried to do that in alot of ways but cant get it to work :/
    i want that every time that player pull bow its will add 1 to some int every X ticks.. but cant :/
    any help?
     
  2. Niv200
    I'm not sure if you actually solved this already, but if not, use a repeating task.
    Code:
    final int i = 0;
    Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(MainClassInstance, new Runnable() {
        public void run() {
            i++;
        }
    }, 0L, ticks);
     
  3. Offline

    Niv200

    thx and its wannt solved :), now it is :p
    but - i have problem with my command... here is my code : anything wrong?
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    2. if(cmd.getName().equalsIgnoreCase("basic")){
    3. Player p = (Player)sender;
    4. Location loc = p.getLocation();
    5. ParticleEffect.CLOUD.play(loc, 0, 0, 0, 0.1F, 20);
    6.  
    7. return true;
    8. }
    9. return false;
    10. }
     
  4. Niv200
    Few things. You're casting player to sender without checking if sender is player. I don't think you can play particle effects that way, but I could be wrong. Don't return true if your command is "successful".

    What is the problem?
     
  5. Offline

    Niv200

    i have that particleEffect in some class.. so its work and play effects :p (checked that ...)
    the problem that it isnt detect the command... its only say "type /help for help..."
     
  6. Niv200
    Get rid of the return true. Did you add the command to your plugin.yml?

    If your onCommand method is not in your main class, then let the class that it's in implement CommandExecutor, and in your onEnable method inside main class, register the command using
    Code:
    getCommand("basic").setExecutor(new YourCommandExecutorClass());
    Make sure that's all done, and try again.
     
  7. Offline

    Niv200

    i read somewhere that im not must to add command to plugin yml... is that true?..
     
  8. No... you HAVE to add it to plugin.yml, where are you getting this dodgy information from xP
    Also, why do you guys say to remove return true? That'd mean it'll always say "Usage: /<commandusage>"?
     
  9. Offline

    Niv200

    ok ty :) will remove that ... now i have 1 last question... (i can open new theard but i dont want to open too much...)
    how can i play effect at player location? im using PlayerMoveEvent so its only play when i move.. but i want it to play even if im stand... how can i do that?
     
  10. Well you could use a repeating scheduler if you want it played every x seconds.
     
Thread Status:
Not open for further replies.

Share This Page