A few advanced plugin questions.

Discussion in 'Plugin Development' started by RangerNuk, Feb 1, 2013.

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

    RangerNuk

    So, im making a plugin (obviously) but ive hit some bumps,

    1. how to schedule a delayed task, i know u put this,
    Code:
     [/COLOR][COLOR=#000000]int [/COLOR][URL='http://jd.bukkit.org/apidocs/src-html/org/bukkit/scheduler/BukkitScheduler.html#line.19'][B]scheduleSyncDelayedTask[/B][/URL][COLOR=#000000]([/COLOR][URL='http://jd.bukkit.org/apidocs/org/bukkit/plugin/Plugin.html']Plugin[/URL][COLOR=#000000] plugin,[/COLOR]
    [COLOR=#000000]                            [URL='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runnable.html?is-external=true']Runnable[/URL] task,
                                long delay)[/COLOR]
    
    But it just throws errors, i know i need to replace stuff inside it but im not sure what.
    2. Arguments affection variables
    I need to make a command that spawns abunch of zombies, ive used a for loop but i want the ammount to be configurable (ie, /command [playername] [number here determines spawn amount]
    3. Arguments, what code do i put to add arguments to a command?
    4. How do i make things determined or difined in a config.yml file, i know how to make one generate, but not how to define variables inside of it, and not how to define something in a command that will be determined by the variable. for example, /blowup [player] the explosion size is defined by the float variable, how do i make the float variable customizble in the config.
    like this...
    #config headline
    explosion_size = 5
    would create an explosion equal to float size 5.
    like this...
    explosionPower = 5.0F;


    If anyone can help, that would be really nice.
    Thank you in advance[/code]
     
  2. Offline

    CubixCoders

    1.
    Code:java
    1.  
    2. new BukkitRunnable(){
    3. public void run(){
    4.  
    5. }
    6. }.runTaskLater(plugin, (seconds*20));
    7.  

    2.
    Code:java
    1.  
    2. for(int i = 0; i < getConfig().getInt("MyPlugin.SpawnZombie.Amount")){
    3. world.spawnEntity(player.getLocation(), EntityType.ZOMBIE);
    4. }
    5.  

    3.
    Code:java
    1.  
    2. if(args.length == 1){
    3. if(args[0].equalsIgnoreCase("first arg")){}
    4. }
    5.  

    4.
    Code:java
    1.  
    2. //In the onEnable method
    3. getConfig().addDefault("MyPlugin.SpawnZombie.Amount", 1);
    4. saveConfig();
    5.  

    These honestly weren't advanced.
     
  3. Offline

    RealDope

    hahahahah i lol'd hard reading CubixCoders post.

    1. is wrong
    2. is wrong
    3. is wrong

    and then he said they weren't advanced in a condescending way. Oh man, too much.
     
  4. Offline

    CubixCoders

  5. Offline

    RealDope

    1.
    Code:JAVA
    1.  
    2. getServer().getScheduler().runTaskTimer(this, new BukkitRunnable() {
    3. public void run() {
    4.  
    5. }
    6. }, 20, 20);
    7.  


    2. you never did i++ so i will always be 0, permanently less than the max and will forever spawn zombies

    3. an arg is a single word. args[0].equalsIgnoreCase("first arg") will always return false
     
  6. Offline

    CubixCoders

    RealDope
    1. is another way of doing that
    2. was a dumb mistake
    3. was an example for him to change "first arg" to his first arg.
     
    Darq likes this.
  7. Offline

    Sagacious_Zed Bukkit Docs

    Honestly any new plugin should probably use Bukkit Runnables just because it will keep you out of trouble.
     
  8. Offline

    TnT

Thread Status:
Not open for further replies.

Share This Page