2011-04-23 02:43:27 +02:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
|
|
|
import com.earth2me.essentials.User;
|
2017-06-11 02:17:43 +02:00
|
|
|
import com.google.common.collect.Lists;
|
2011-04-23 02:43:27 +02:00
|
|
|
import org.bukkit.Server;
|
2011-04-26 14:13:39 +02:00
|
|
|
import org.bukkit.World;
|
|
|
|
|
2017-06-11 02:17:43 +02:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
|
|
|
|
|
|
|
public class Commandthunder extends EssentialsCommand {
|
|
|
|
public Commandthunder() {
|
|
|
|
super("thunder");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
2020-08-11 20:09:22 +02:00
|
|
|
if (args.length == 0) {
|
2015-04-15 06:06:16 +02:00
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
|
|
|
|
final World world = user.getWorld();
|
|
|
|
final boolean setThunder = args[0].equalsIgnoreCase("true");
|
2020-08-11 20:09:22 +02:00
|
|
|
if (args.length == 1) {
|
2015-06-03 22:11:56 +02:00
|
|
|
world.setThundering(setThunder);
|
2015-04-15 06:06:16 +02:00
|
|
|
user.sendMessage(tl("thunder", setThunder ? tl("enabled") : tl("disabled")));
|
2020-08-11 20:09:22 +02:00
|
|
|
return;
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
2020-08-11 20:09:22 +02:00
|
|
|
|
|
|
|
world.setThundering(setThunder);
|
|
|
|
world.setThunderDuration(Integer.parseInt(args[1]) * 20);
|
|
|
|
user.sendMessage(tl("thunderDuration", (setThunder ? tl("enabled") : tl("disabled")), Integer.parseInt(args[1])));
|
2017-06-11 02:17:43 +02:00
|
|
|
}
|
2011-04-23 02:43:27 +02:00
|
|
|
|
2017-06-11 02:17:43 +02:00
|
|
|
@Override
|
|
|
|
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
|
|
|
if (args.length == 1) {
|
|
|
|
return Lists.newArrayList("true", "false");
|
|
|
|
} else if (args.length == 2) {
|
|
|
|
return COMMON_DATE_DIFFS;
|
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
2011-04-23 02:43:27 +02:00
|
|
|
}
|