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, int


    scheduleSyncDelayedTask(Plugin plugin,
    Runnable task,
    long delay)


    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
     
  2. Offline

    RangerNuk

    yes i saw that, i dont really get javadocs (probably looking at it wrong) sorry about the other stuff
     
  3. Offline

    RealDope

    Code:JAVA
    1.  
    2. getServer().getScheduler().runTaskTimer(this, new BukkitRunnable() {
    3. public void run() {
    4.  
    5. }
    6. }, 20, 20); // Waits 1 second, then fires every second until cancelled
    7.  
     
  4. Offline

    RangerNuk

    thanks, I forgot one other thing, how to make something random or a specific chance,

    like making a potion effect a 50/50 chance

    or making catching on fire random chance
     
  5. RangerNuk
    Use a random number generator.

    Code:java
    1.  
    2. Random r = new Random();
    3. double maxVal = 100;
    4. double chance = (double)r.nextInt(maxVal);
    5. doulbe percentChance = chance/maxVal;
    6.  
     
  6. Offline

    Lolmewn

    RangerNuk use the Random class. Give it a google, lots of examples are available.
     
  7. Offline

    RangerNuk

    thanks, and a set value?
     
  8. RangerNuk
    What do you mean a 'set' value?
     
  9. Offline

    RangerNuk

    umm, like a 50% chance to get a potion effect and 50% chance to get blown up
     
  10. Offline

    Tirelessly

    if(new Random().nextInt(2) == 1){
    world.createExplosion(...)
    }else{
    player.addPotionEffect(...)
    }
     
Thread Status:
Not open for further replies.

Share This Page