summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
blob: 07ea07699f03a03c8d41e63f3ed69b4e09bb447c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.earth2me.essentials.commands;

import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.World;


public class Commandweather extends EssentialsCommand
{
	public Commandweather()
	{
		super("weather");
	}

	@Override
	public void run(Server server, User user, String commandLabel, String[] args) throws Exception
	{
		if (args.length < 1)
		{
			throw new NotEnoughArgumentsException();
		}

		boolean isStorm = args[0].equalsIgnoreCase("storm");
		World world = user.getWorld();
		user.charge(this);
		if (args.length > 1)
		{

			world.setStorm(isStorm ? true : false);
			world.setWeatherDuration(Integer.parseInt(args[1]) * 20);
			user.sendMessage("§7You set the weather to  " + (isStorm ? "storm" : "sun") + " in your world for " + args[1] + " seconds");
			return;
		}
		else
		{
			world.setStorm(isStorm ? true : false);
			user.sendMessage("§7You set the weather to  " + (isStorm ? "storm" : "sun") + " in your world");
			return;
		}
	}
}