Duration of Ticks from Config of auto broadcaster.

Discussion in 'Plugin Development' started by AdityaTD, Jul 11, 2015.

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

    AdityaTD

    Hey there, so I am making a Announcer and I want to make so players can set in how many ticks any other message should be broadcasted. Anyone know how?
     
  2. @AdityaTD Just have an int in the config?
     
  3. Offline

    benjfb1

    You could get the int number of secs in the config and use:
    Code:
    try{ // just in case it isn't a int
    int num = this.getConfig().getInt("Path")
    num = num * 20; // converting secs to int
    }catch(Exception e){
    }
    
    you could also do this with mins instead with:
    Code:
    num = (num * 60) * 20;  //converting mins to ticks
    
    then use a Repeating Scheduler to display the message after the num amount of ticks
    Code:
                        Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
                             
                            @Override
                            public void run() {
    
    Long long = new Long(num);
    
    }
    }, long, 0);
    
     
  4. Make a command to store the ticks in the config.
    In onEnable, make a new repeating task and get those ticks:
    Code:
    new BukkitRunnable() {
    public void run() {
    //Display messages
    }
    }.runTaskTimer(this, 0, getConfig().getInt("tick-period");
     
  5. Offline

    mythbusterma

    @benjfb1

    Again, why are you using try-catch blocks when they aren't necessary and are too broad?
     
    bwfcwalshy likes this.
  6. Offline

    benjfb1

    If the config path isn't a int it'll catch the exception.. Could use a if statement i guess. But i was on my phone and that's what came to mind.
     
  7. If it's not an int.
     
  8. Offline

    mythbusterma

    @benjfb1

    Use ConfigurationSection#getInt(String, int)

    That provides a default value that and will never throw an Exception. Besides, an exception like that should be fatal anyway.

    That's not an appropriate response. If it's not an int, your plugin should fail to load because it would be in an undesirable state.
     
  9. Offline

    AdityaTD

    ON Topic: Well I want to know on how I can get 1 line every period of time as I don't want to limit on how much messages people can put in config.

    OFF Topic: Hey Walshy! Long time no see!!
     
  10. @AdityaTD On topic: I did a multi line config thing today with a wait time. It is a pain but you need to go through and when you hit a wait then get the wait time and run a scheduled task and then continue with the rest of the messages.

    Off topic: Hello! Yeah it's been a while, how have you been?
     
  11. Offline

    AdityaTD

    ON Topic: I am thinking to Abandon this project as I am creating a new kind of essentials plugin which is pretty light weight and 100% Customization. I am facing a problem on saving each and every "# HELP TEXT" when the plugin loads for the first time. No "# HELP TEXT" loads. ;( Any help?
     
  12. @AdityaTD How are you saving it? If you want you can look at my SOS plugin that saves like it should and works well.
     
  13. Offline

    AdityaTD

    ON Topic: Alright I'll just decode it if you allow me! :D
    OFF Topic: I sen't you a request on skype!
     
  14. @AdityaTD On topic: Sure, decompile it.
    Off topic: I bet you added the wrong one :D Not that many people know my Skype except those that guess it. Did you add bwfcwalshy because that is my old account, I can't even load that account anymore :D
     
  15. Offline

    AdityaTD

    ON Topic: Ok!
    OFF Topic: I added your old account... xD Though I'll know your new account... :d
     
Thread Status:
Not open for further replies.

Share This Page