mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-14 13:13:24 +00:00
Better /nuke command, now accepts playernames as argument
This commit is contained in:
parent
efaed85188
commit
2ea5e6c03b
2 changed files with 32 additions and 15 deletions
|
@ -1,12 +1,14 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import net.minecraft.server.EntityTNTPrimed;
|
||||
import net.minecraft.server.World;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
public class Commandnuke extends EssentialsCommand
|
||||
|
@ -17,23 +19,38 @@ public class Commandnuke extends EssentialsCommand
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args)
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
|
||||
{
|
||||
Location loc;
|
||||
World world;
|
||||
server.broadcastMessage("May death rain upon them");
|
||||
ess.getTNTListener().enable();
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
List<Player> targets;
|
||||
if (args.length > 0)
|
||||
{
|
||||
loc = player.getLocation();
|
||||
world = ((CraftWorld)loc.getWorld()).getHandle();
|
||||
targets = new ArrayList<Player>();
|
||||
int pos = 0;
|
||||
for (String arg : args)
|
||||
{
|
||||
targets.add(getPlayer(server, args, pos));
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targets = Arrays.asList(server.getOnlinePlayers());
|
||||
}
|
||||
ess.getTNTListener().enable();
|
||||
for (Player player : targets)
|
||||
{
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
player.sendMessage("May death rain upon them");
|
||||
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)
|
||||
{
|
||||
final EntityTNTPrimed tnt = new EntityTNTPrimed(world, loc.getBlockX() + x, 120, loc.getBlockZ() + z);
|
||||
world.addEntity(tnt);
|
||||
world.makeSound(tnt, "random.fuse", 1.0F, 1.0F);
|
||||
final Location tntloc = new Location(world, loc.getBlockX() + x, 127, loc.getBlockZ() + z);
|
||||
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ commands:
|
|||
aliases: [enick]
|
||||
nuke:
|
||||
description: May death rain upon them.
|
||||
usage: /<command>
|
||||
usage: /<command> <player>
|
||||
aliases: [enuke]
|
||||
pay:
|
||||
description: Pays another player from your balance
|
||||
|
|
Loading…
Reference in a new issue