mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-15 05:33:40 +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;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import net.minecraft.server.EntityTNTPrimed;
|
import java.util.ArrayList;
|
||||||
import net.minecraft.server.World;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
|
||||||
|
|
||||||
public class Commandnuke extends EssentialsCommand
|
public class Commandnuke extends EssentialsCommand
|
||||||
|
@ -17,23 +19,38 @@ public class Commandnuke extends EssentialsCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
List<Player> targets;
|
||||||
World world;
|
if (args.length > 0)
|
||||||
server.broadcastMessage("May death rain upon them");
|
{
|
||||||
|
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();
|
ess.getTNTListener().enable();
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : targets)
|
||||||
{
|
{
|
||||||
loc = player.getLocation();
|
if (player == null) {
|
||||||
world = ((CraftWorld)loc.getWorld()).getHandle();
|
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 x = -10; x <= 10; x += 5)
|
||||||
{
|
{
|
||||||
for (int z = -10; z <= 10; z += 5)
|
for (int z = -10; z <= 10; z += 5)
|
||||||
{
|
{
|
||||||
final EntityTNTPrimed tnt = new EntityTNTPrimed(world, loc.getBlockX() + x, 120, loc.getBlockZ() + z);
|
final Location tntloc = new Location(world, loc.getBlockX() + x, 127, loc.getBlockZ() + z);
|
||||||
world.addEntity(tnt);
|
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
|
||||||
world.makeSound(tnt, "random.fuse", 1.0F, 1.0F);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ commands:
|
||||||
aliases: [enick]
|
aliases: [enick]
|
||||||
nuke:
|
nuke:
|
||||||
description: May death rain upon them.
|
description: May death rain upon them.
|
||||||
usage: /<command>
|
usage: /<command> <player>
|
||||||
aliases: [enuke]
|
aliases: [enuke]
|
||||||
pay:
|
pay:
|
||||||
description: Pays another player from your balance
|
description: Pays another player from your balance
|
||||||
|
|
Loading…
Reference in a new issue