How do I get the weather?

Discussion in 'Plugin Development' started by Fiddy_percent, Aug 18, 2012.

  1. Offline

    Fiddy_percent

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    how can I call the current weather and the weather durration. I see it in there the methods anyways
    but I cant seem to get them to work
    can anyone show me how to set up the
    getWeatherDuration() and how to get what weather is currently going on.
  2. Offline

    Courier

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    hasStorm() and isThundering()
  3. Offline

    Fiddy_percent

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I mean HasStorm and is Thundering are in the same boat I do World and getWorld() and I still cant seem to get to those methods for use
  4. Offline

    Courier

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    If you want to get the overworld, do:
    Code:java
    1. //this will be true iff the overworld is raining/snowing
    2. Bukkit.getWorlds().get(0).hasStorm();
  5. Offline

    Fiddy_percent

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    ok I got that and actually I needed to do it from the players perspective or so I thought. But it doesnt seem accurate
    even on clear sky's it still says there is a storm and for like 97 min.


    Code:
                else if(cmd.getName().equalsIgnoreCase("Weather")){
                    if(p.getTargetBlock(null, 10).getType() == Material.DIAMOND_BLOCK) {
                        weather = p.getWorld().hasStorm();
                        int wtime = p.getWorld().getWeatherDuration();
                        int weathertime = wtime / 20 / 60;
                        if(weather = false){
                            sender.sendMessage(ChatColor.DARK_AQUA+"Today we have clear skys hope you enjoy that sunny weather!");
                           
                        }
                        else if(weather = true){
                            sender.sendMessage(ChatColor.DARK_AQUA+ "Looks Like there is a storm today for the next " + weathertime + " minute(s)");
                        }
                    } else {
                        sender.sendMessage(ChatColor.DARK_RED+ "You need to be looking at a TV.");
                    }


    it always says there is a storm even if there isnt one where the player is at.
  6. Offline

    Courier

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You mean to use the comparison operator, ==
    = is the assignment operator.

    However, in your case, you don't need either.
    Code:java
    1. if(weather) {
    2. //it is raining
    3. } else {
    4. //it is not raining
    5. }

Share This Page