1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-14 18:44:48 +02:00

[trunk] Prevent explosions near protected objects

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1091 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
snowleo
2011-04-02 02:43:58 +00:00
parent 348cb29469
commit 3496a85228
3 changed files with 66 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials.protect;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.EssentialsBlockListener;
import com.earth2me.essentials.User;
import java.util.ArrayList;
import java.util.HashSet;
@@ -8,7 +9,9 @@ import java.util.List;
import net.minecraft.server.ChunkPosition;
import net.minecraft.server.Packet60Explosion;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Creeper;
@@ -187,6 +190,33 @@ public class EssentialsProtectEntityListener extends EntityListener
return;
}
}
// This code will prevent explosions near protected rails, signs or protected chests
// TODO: Use protect db instead of this code
for (Block block : event.blockList())
{
if ((block.getType() == Material.RAILS || block.getFace(BlockFace.UP).getType() == Material.RAILS) && EssentialsProtect.genSettings.get("protect.protect.rails"))
{
event.setCancelled(true);
return;
}
if (( block.getType() == Material.WALL_SIGN ||
block.getFace(BlockFace.NORTH).getType() == Material.WALL_SIGN ||
block.getFace(BlockFace.EAST).getType() == Material.WALL_SIGN ||
block.getFace(BlockFace.SOUTH).getType() == Material.WALL_SIGN ||
block.getFace(BlockFace.WEST).getType() == Material.WALL_SIGN ||
block.getType() == Material.SIGN_POST ||
block.getFace(BlockFace.UP).getType() == Material.SIGN_POST) &&
EssentialsProtect.genSettings.get("protect.protect.signs"))
{
event.setCancelled(true);
return;
}
if ( EssentialsBlockListener.protectedBlocks.contains(block.getType()) &&
EssentialsBlockListener.isBlockProtected(block)) {
event.setCancelled(true);
return;
}
}
}
@Override