mirror of
https://github.com/essentials/Essentials.git
synced 2025-01-17 21:39:26 +01:00
Fix fake explosions.
This commit is contained in:
parent
09fdd20de3
commit
3aadff48bf
@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.FakeExplosion;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -46,8 +45,12 @@ public class TNTExplodeListener implements Listener, Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
|
||||
if (event.blockList().size() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,51 +0,0 @@
|
||||
package com.earth2me.essentials.craftbukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
|
||||
public class FakeExplosion
|
||||
{
|
||||
public static void createExplosion(final EntityExplodeEvent event, final Server server, final Player[] players)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
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)server).getHandle().sendPacketNearby(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));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ package com.earth2me.essentials.protect;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.FakeExplosion;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -204,11 +203,11 @@ public class EssentialsProtectEntityListener implements Listener
|
||||
if (event.getEntity() instanceof EnderDragon
|
||||
&& prot.getSettingBool(ProtectConfig.prevent_enderdragon_blockdmg))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
if (prot.getSettingBool(ProtectConfig.enderdragon_fakeexplosions))
|
||||
{
|
||||
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
|
||||
event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
else if (event.getEntity() instanceof Creeper
|
||||
@ -217,8 +216,8 @@ public class EssentialsProtectEntityListener implements Listener
|
||||
|| (maxHeight >= 0 && event.getLocation().getBlockY() > maxHeight)))
|
||||
{
|
||||
//Nicccccccccce plaaacccccccccce..
|
||||
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
|
||||
event.setCancelled(true);
|
||||
event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
|
||||
return;
|
||||
}
|
||||
else if (event.getEntity() instanceof TNTPrimed
|
||||
|
Loading…
x
Reference in New Issue
Block a user