mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 20:00:46 +00:00
May death rain upon them
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1561 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
b83bb1faa3
commit
797dde94e1
5 changed files with 145 additions and 1 deletions
|
@ -30,7 +30,6 @@ import com.earth2me.essentials.register.payment.Methods;
|
|||
import java.math.BigInteger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
|
@ -50,6 +49,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||
private EssentialsBlockListener blockListener;
|
||||
private EssentialsEntityListener entityListener;
|
||||
private JailPlayerListener jailPlayerListener;
|
||||
private TNTExplodeListener tntListener;
|
||||
private static Essentials instance = null;
|
||||
private Spawn spawn;
|
||||
private Jail jail;
|
||||
|
@ -187,6 +187,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
|
||||
}
|
||||
|
||||
tntListener = new TNTExplodeListener(this);
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
|
||||
|
||||
timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
|
||||
if (enableErrorLogging)
|
||||
|
@ -730,6 +733,11 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||
return this.getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
}
|
||||
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, long delay, long period)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
|
@ -744,4 +752,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||
{
|
||||
return bannedIps;
|
||||
}
|
||||
|
||||
public TNTExplodeListener getTNTListener()
|
||||
{
|
||||
return tntListener;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,9 +60,13 @@ public interface IEssentials
|
|||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
|
||||
List<String> getBans();
|
||||
|
||||
List<String> getBannedIps();
|
||||
|
||||
TNTExplodeListener getTNTListener();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
|
||||
public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private boolean enabled = false;
|
||||
private int timer = -1;
|
||||
|
||||
public TNTExplodeListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void enable()
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
enabled = true;
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
return;
|
||||
}
|
||||
if (timer != -1) {
|
||||
ess.getScheduler().cancelTask(timer);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityExplode(final EntityExplodeEvent event)
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() instanceof LivingEntity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final Player[] players = ess.getServer().getOnlinePlayers();
|
||||
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
|
||||
final Location loc = event.getLocation();
|
||||
for (Player player : players)
|
||||
{
|
||||
if (player.getWorld().equals(loc.getWorld()))
|
||||
{
|
||||
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
|
||||
}
|
||||
}
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
|
||||
if (!blocksUnderPlayers.contains(cp))
|
||||
{
|
||||
set.add(cp);
|
||||
}
|
||||
}
|
||||
((CraftServer)ess.getServer()).getHandle().a(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import net.minecraft.server.EntityTNTPrimed;
|
||||
import net.minecraft.server.World;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandnuke extends EssentialsCommand
|
||||
{
|
||||
public Commandnuke()
|
||||
{
|
||||
super("nuke");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args)
|
||||
{
|
||||
Location loc;
|
||||
World world;
|
||||
server.broadcastMessage("May death rain upon them");
|
||||
ess.getTNTListener().enable();
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
loc = player.getLocation();
|
||||
world = ((CraftWorld)loc.getWorld()).getHandle();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -175,6 +175,10 @@ commands:
|
|||
description: Change your nickname or that of another player.
|
||||
usage: /<command> <player> [nickname|off]
|
||||
aliases: [enick]
|
||||
nuke:
|
||||
description: May death rain upon them.
|
||||
usage: /<command>
|
||||
aliases: [enuke]
|
||||
pay:
|
||||
description: Pays another player from your balance
|
||||
usage: /<command> [player] [amount]
|
||||
|
|
Loading…
Reference in a new issue