Automatic light won't work

Discussion in 'Plugin Development' started by Rsdragonboy, May 9, 2012.

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

    Rsdragonboy

    Hi,
    I am working on a plugin.
    When it is daytime the lights go off and when it is night the lights go on but it won't work here is my code:


    Code:
        @EventHandler
        public void Worldevent (WorldEvent event) {
                if(event.getWorld().getTime() >= 18000 &&  event.getWorld().getTime() <= 1) {
                    placeblocks.lighton();
                }
                if(event.getWorld().getTime() <= 17999 &&  event.getWorld().getTime() >= 0) {
                    placeblocks.lightoff();
                }
        }
     
  2. Offline

    pers2981

    Are you using the right event? Why not make a schedule that checks if its night every 30 seconds?
     
  3. Offline

    the_merciless

    Also i think u included 0 in both checks i would use:

    Code:
    if(event.getWorld().getTime() > 17999 &&  event.getWorld().getTime() < 0) {
                    placeblocks.lighton();
                }else{
                    placeblocks.lightoff();
                }
    
     
  4. Offline

    dsmyth1915

    Merciless, you can't have time set <0 because the time goes from 0-24000(measured in ticks). Once it hits 24000 it resets to 0(dawn)

    Some help, sunrise/sunset lasts 1.5min==1800 ticks. day lasts 10min==12000 ticks. And night lasts 7min==8400 ticks.
     
  5. Offline

    the_merciless

    Correct, my bad. so realy what i should of put is:

    Code:
    if(event.getWorld().getTime() > 17999) {
                    placeblocks.lighton();
                }else{
                    placeblocks.lightoff();
                }
    
     
Thread Status:
Not open for further replies.

Share This Page