1 |
package dk.thoerup.bukkit.hoeruputils; |
2 |
|
3 |
import org.bukkit.Location; |
4 |
import org.bukkit.World; |
5 |
import org.bukkit.command.Command; |
6 |
import org.bukkit.command.CommandExecutor; |
7 |
import org.bukkit.command.CommandSender; |
8 |
import org.bukkit.entity.Player; |
9 |
|
10 |
public class WeatherCommand implements CommandExecutor { |
11 |
|
12 |
|
13 |
@Override |
14 |
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) { |
15 |
|
16 |
if (!(sender instanceof Player)) { |
17 |
return false; |
18 |
} |
19 |
|
20 |
Player p = (Player) sender; |
21 |
|
22 |
if (args.length != 1 || !( args[0].equals("clear") || args[0].equals("rain") || args[0].equals("thunder") ) ) { |
23 |
p.sendMessage("Usage /weather <clear|rain|thunder>"); |
24 |
return true; |
25 |
} |
26 |
|
27 |
World w = p.getWorld(); |
28 |
if ( args[0].equals("clear") ) { |
29 |
w.setThundering( false ); |
30 |
w.setStorm( false ); |
31 |
p.getServer().broadcastMessage("A nice blue sky appears"); |
32 |
} else if (args[0].equals("rain") ) { |
33 |
w.setStorm( true ); |
34 |
w.setThundering( false ); |
35 |
p.getServer().broadcastMessage("Dark clouds are gathering"); |
36 |
} else if (args[0].equals("thunder") ) { |
37 |
w.setStorm( true ); |
38 |
w.setThundering( true ); |
39 |
p.getServer().broadcastMessage("looks like a thunderstorm is comming"); |
40 |
} |
41 |
|
42 |
|
43 |
return true; |
44 |
} |
45 |
} |