All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.CommandWeather Maven / Gradle / Ivy

package net.minecraft.server;

import java.util.List;
import java.util.Random;

public class CommandWeather extends CommandAbstract {
	
	public CommandWeather() {
	}
	
	public String getCommand() {
		return "weather";
	}
	
	public int a() {
		return 2;
	}
	
	public String getUsage(ICommandListener icommandlistener) {
		return "commands.weather.usage";
	}
	
	public void execute(ICommandListener icommandlistener, String[] astring) throws CommandException {
		if (astring.length >= 1 && astring.length <= 2) {
			int i = (300 + (new Random()).nextInt(600)) * 20;
			
			if (astring.length >= 2) {
				i = a(astring[1], 1, 1000000) * 20;
			}
			
			WorldServer worldserver = MinecraftServer.getServer().worldServer[0];
			WorldData worlddata = worldserver.getWorldData();
			
			if ("clear".equalsIgnoreCase(astring[0])) {
				worlddata.i(i);
				worlddata.setWeatherDuration(0);
				worlddata.setThunderDuration(0);
				worlddata.setStorm(false);
				worlddata.setThundering(false);
				a(icommandlistener, this, "commands.weather.clear");
			} else if ("rain".equalsIgnoreCase(astring[0])) {
				worlddata.i(0);
				worlddata.setWeatherDuration(i);
				worlddata.setThunderDuration(i);
				worlddata.setStorm(true);
				worlddata.setThundering(false);
				a(icommandlistener, this, "commands.weather.rain");
			} else {
				if (!"thunder".equalsIgnoreCase(astring[0])) {
					throw new ExceptionUsage("commands.weather.usage");
				}
				
				worlddata.i(0);
				worlddata.setWeatherDuration(i);
				worlddata.setThunderDuration(i);
				worlddata.setStorm(true);
				worlddata.setThundering(true);
				a(icommandlistener, this, "commands.weather.thunder");
			}
			
		} else {
			throw new ExceptionUsage("commands.weather.usage");
		}
	}
	
	public List tabComplete(ICommandListener icommandlistener, String[] astring, BlockPosition blockposition) {
		return astring.length == 1 ? a(astring, "clear", "rain", "thunder") : null;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy