public String doCmd(ICommandSender sender, World world, String[] args)
{
if (args.length == 0)
{
throw new CommandException("Improper syntax. Please try this instead: [dimID, none for all] <freeze|lock|set|add> <time (number)|day|night>");
}
switch (args[0]) {
case "set":
{
if (args[1].equalsIgnoreCase("day")) {
CommandsEventHandler.makeWorldTimeHours(world, WeatherTimeData.dayTimeStart);
} else if (args[1].equalsIgnoreCase("night")) {
CommandsEventHandler.makeWorldTimeHours(world, WeatherTimeData.nightTimeStart);
} else {
world.setWorldTime(parseInt(sender, args[1]));
}
WeatherTimeData wt = CommandDataManager.WTmap.get(world.provider.dimensionId);
wt.freezeTime = world.getWorldTime();
return String.format("Set time to %s.", args[1]);
}
case "add":
{
if (args.length == 1) {
throw new CommandException("Improper syntax. Please try this instead: [dimID, none for all] <freeze|lock|set|add> <time (number)|day|night>");
}
world.setWorldTime(world.getWorldTime() + parseInt(sender, args[1]));
WeatherTimeData wt = CommandDataManager.WTmap.get(world.provider.dimensionId);
wt.freezeTime = world.getWorldTime();
return String.format("Added %d to the current time.", args[1]);
}
case "freeze":
{
WeatherTimeData wt = CommandDataManager.WTmap.get(world.provider.dimensionId);
wt.freezeTime = world.getWorldTime();
wt.timeFreeze = !wt.timeFreeze;
return "Time freeze" + (wt.timeFreeze ? "on" : "off");
}
case "lock":
{
WeatherTimeData wt = CommandDataManager.WTmap.get(world.provider.dimensionId);
if (args.length == 1) {
wt.timeSpecified = !wt.timeSpecified;
} else {
wt.timeSpecified = true;
if (args[1].equalsIgnoreCase("day")) {
wt.day = true;
} else if (args[1].equalsIgnoreCase("night")) {
wt.day = false;
} else {
throw new CommandException("Improper syntax. Please try this instead: [dimID, none for all] <freeze|lock|set|add> <time (number)|day|night>");
}
}
return String.format("Locked time to %s.", args[1]);
}
default:
{
throw new CommandException("Improper syntax. Please try this instead: [dimID, none for all] <freeze|lock|set|add> <time (number)|day|night>");
}
}
}