Solved Turning off rain?

Discussion in 'Plugin Development' started by gamemster2468, Jun 28, 2014.

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

    gamemster2468

    Hi,

    I know this is possible, as I have seen it on other servers, and I was wondering how I could turn off rain?

    And yes, I have done some site searching and I didn't find anything.

    Any help would be great!
    Thanks <3
     
  2. Offline

    Gerov

    Erm

    Is this what you mean?

    if(world.hasStorm()){
    world.setWeatherDuration(0);
    }

    gamemster2468 Or you could do a WeatherChangeEvent and then check if it is a storm and set the duration to 0.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  3. Offline

    gamemster2468

    Had no clue there was an event for this! Thanks <3
     
  4. Offline

    Gerov

    This site might help you then; jd.bukkit.org

    But, after you go through that site, he is the code you would need IN a listener class;

    Code:java
    1. public void onWeather(WeatherChangeEvent e){
    2. World ew = e.getWorld();
    3. if(ew.hasStorm()){
    4. ew.setWeatherDuration(0);
    5. }
    6. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    Traks

    Gerov Can be much shorter
    Code:java
    1. @EventHandler
    2. public void onWeatherChange(WeatherChangeEvent e){
    3. e.setCancelled(event.toWeatherState());
    4. }

    WeatherChangeEvent#toWeatherState() returns true when the weather is set to rain and false otherwise
     
    Gerov likes this.
  6. Offline

    gamemster2468

    Thank you all so much! Really helped! Also thanks for that helpful site! <3
     
Thread Status:
Not open for further replies.

Share This Page