CommandWeather .java

net.minecraft.command.CommandWeather (class, 97 lines): members: addTabCompletionOptions, getRequiredPermissionLevel, getCommandUsage, getCommandName.

net.minecraft.commandclass97 linescommonextends CommandBase2.9 KB

API Surface (5)

String getCommandName()
int getRequiredPermissionLevel()
String getCommandUsage(ICommandSender sender)
void processCommand(ICommandSender sender, String[] args)
List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)

String literals (8)

"weather"
"commands.weather.usage"
"clear"
"commands.weather.clear"
"rain"
"commands.weather.rain"
"thunder"
"commands.weather.thunder"

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

CommandWeather.java97 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.command;
2
3
import java.util.List;
4
import java.util.Random;
5
import net.minecraft.server.MinecraftServer;
6
import net.minecraft.util.BlockPos;
7
import net.minecraft.world.World;
8
import net.minecraft.world.storage.WorldInfo;
9
10
public class CommandWeather extends CommandBase
11
{
12
    /**
13
     * Gets the name of the command
14
     */
15
    public String getCommandName()
16
    {
17
        return "weather";
18
    }
19
20
    /**
21
     * Return the required permission level for this command.
22
     */
23
    public int getRequiredPermissionLevel()
24
    {
25
        return 2;
26
    }
27
28
    /**
29
     * Gets the usage string for the command.
30
     */
31
    public String getCommandUsage(ICommandSender sender)
32
    {
33
        return "commands.weather.usage";
34
    }
35
36
    /**
37
     * Callback when the command is invoked
38
     */
39
    public void processCommand(ICommandSender sender, String[] args) throws CommandException
40
    {
41
        if (args.length >= 1 && args.length <= 2)
42
        {
43
            int i = (300 + (new Random()).nextInt(600)) * 20;
44
45
            if (args.length >= 2)
46
            {
47
                i = parseInt(args[1], 1, 1000000) * 20;
48
            }
49
50
            World world = MinecraftServer.getServer().worldServers[0];
51
            WorldInfo worldinfo = world.getWorldInfo();
52
53
            if ("clear".equalsIgnoreCase(args[0]))
54
            {
55
                worldinfo.setCleanWeatherTime(i);
56
                worldinfo.setRainTime(0);
57
                worldinfo.setThunderTime(0);
58
                worldinfo.setRaining(false);
59
                worldinfo.setThundering(false);
60
                notifyOperators(sender, this, "commands.weather.clear", new Object[0]);
61
            }
62
            else if ("rain".equalsIgnoreCase(args[0]))
63
            {
64
                worldinfo.setCleanWeatherTime(0);
65
                worldinfo.setRainTime(i);
66
                worldinfo.setThunderTime(i);
67
                worldinfo.setRaining(true);
68
                worldinfo.setThundering(false);
69
                notifyOperators(sender, this, "commands.weather.rain", new Object[0]);
70
            }
71
            else
72
            {
73
                if (!"thunder".equalsIgnoreCase(args[0]))
74
                {
75
                    throw new WrongUsageException("commands.weather.usage", new Object[0]);
76
                }
77
78
                worldinfo.setCleanWeatherTime(0);
79
                worldinfo.setRainTime(i);
80
                worldinfo.setThunderTime(i);
81
                worldinfo.setRaining(true);
82
                worldinfo.setThundering(true);
83
                notifyOperators(sender, this, "commands.weather.thunder", new Object[0]);
84
            }
85
        }
86
        else
87
        {
88
            throw new WrongUsageException("commands.weather.usage", new Object[0]);
89
        }
90
    }
91
92
    public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
93
    {
94
        return args.length == 1 ? getListOfStringsMatchingLastWord(args, new String[] {"clear", "rain", "thunder"}): null;
95
    }
96
}
97

Deobfuscated MCP 1.8.9 source of CommandWeather from Marcelektro/MavenMCP-1.8.9 (net/minecraft/command/CommandWeather.java), stored verbatim.