2011-06-02 11:43:25 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 19:59:39 +00:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2011-06-02 11:43:25 +00:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Server;
|
2011-06-23 12:58:26 +00:00
|
|
|
import org.bukkit.World;
|
2011-06-02 11:43:25 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2011-06-23 12:58:26 +00:00
|
|
|
import org.bukkit.entity.TNTPrimed;
|
2011-06-02 11:43:25 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
2017-06-11 00:17:43 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2015-04-15 04:06:16 +00:00
|
|
|
|
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
|
|
|
public class Commandnuke extends EssentialsCommand {
|
|
|
|
public Commandnuke() {
|
|
|
|
super("nuke");
|
|
|
|
}
|
2011-06-02 11:43:25 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException {
|
2020-10-03 17:46:05 +00:00
|
|
|
final Collection<Player> targets;
|
2015-04-15 04:06:16 +00:00
|
|
|
if (args.length > 0) {
|
2015-06-03 20:11:56 +00:00
|
|
|
targets = new ArrayList<>();
|
2020-08-11 18:09:22 +00:00
|
|
|
for (int i = 0; i < args.length; ++i) {
|
|
|
|
targets.add(getPlayer(server, sender, args, i).getBase());
|
2015-04-15 04:06:16 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
targets = ess.getOnlinePlayers();
|
|
|
|
}
|
|
|
|
ess.getTNTListener().enable();
|
2020-10-03 17:46:05 +00:00
|
|
|
for (final Player player : targets) {
|
2015-04-15 04:06:16 +00:00
|
|
|
if (player == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
player.sendMessage(tl("nuke"));
|
|
|
|
final Location loc = player.getLocation();
|
|
|
|
final World world = loc.getWorld();
|
|
|
|
for (int x = -10; x <= 10; x += 5) {
|
|
|
|
for (int z = -10; z <= 10; z += 5) {
|
2020-08-11 18:09:22 +00:00
|
|
|
world.spawn(new Location(world, loc.getBlockX() + x, world.getHighestBlockYAt(loc) + 64, loc.getBlockZ() + z), TNTPrimed.class);
|
2015-04-15 04:06:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-11 00:17:43 +00:00
|
|
|
|
|
|
|
@Override
|
2020-10-03 17:46:05 +00:00
|
|
|
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
2017-06-11 00:17:43 +00:00
|
|
|
if (args.length == 1) {
|
|
|
|
return getPlayers(server, sender);
|
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
2011-06-02 11:43:25 +00:00
|
|
|
}
|