Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. package com.earth2me.essentials.commands;
  2.  
  3. import com.earth2me.essentials.CommandSource;
  4. import org.bukkit.Location;
  5. import org.bukkit.Server;
  6. import org.bukkit.World;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.entity.TNTPrimed;
  9.  
  10. import java.util.ArrayList;
  11. import java.util.Collection;
  12. import java.util.Collections;
  13. import java.util.List;
  14.  
  15. import static com.earth2me.essentials.I18n.tl;
  16.  
  17.  
  18. public class Commandnuke extends EssentialsCommand {
  19. public Commandnuke() {
  20. super("nuke");
  21. }
  22.  
  23. @Override
  24. protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException {
  25. Collection<Player> targets;
  26. if (args.length > 0) {
  27. targets = new ArrayList<>();
  28. int pos = 0;
  29. for (String arg : args) {
  30. targets.add(getPlayer(server, sender, args, pos).getBase());
  31. pos++;
  32. }
  33. } else {
  34. targets = ess.getOnlinePlayers();
  35. }
  36. ess.getTNTListener().enable();
  37. for (Player player : targets) {
  38. if (player == null) {
  39. continue;
  40. }
  41. player.sendMessage(tl("nuke"));
  42. final Location loc = player.getLocation();
  43. final World world = loc.getWorld();
  44. for (int x = -10; x <= 10; x += 5) {
  45. for (int z = -10; z <= 10; z += 5) {
  46. final Location tntloc = new Location(world, loc.getBlockX() + x, world.getHighestBlockYAt(loc) + 64, loc.getBlockZ() + z);
  47. final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
  48. }
  49. }
  50. }
  51. }
  52.  
  53. @Override
  54. protected List<String> getTabCompleteOptions(Server server, CommandSource sender, String commandLabel, String[] args) {
  55. if (args.length == 1) {
  56. return getPlayers(server, sender);
  57. } else {
  58. return Collections.emptyList();
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement