Merge pull request #207 from ammaraskar/more_breaks

Handle more relative breaking scenarios
This commit is contained in:
md-5
2012-08-21 22:54:10 -07:00
2 changed files with 36 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import static de.diddiz.LogBlock.config.Config.getWorldConfig;
import static de.diddiz.LogBlock.config.Config.isLogging;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -25,14 +26,20 @@ public class BlockBreakLogging extends LoggingListener
final WorldConfig wcfg = getWorldConfig(event.getBlock().getWorld());
if (wcfg != null && wcfg.isLogging(Logging.BLOCKBREAK)) {
final int type = event.getBlock().getTypeId();
if (wcfg.isLogging(Logging.SIGNTEXT) && (type == 63 || type == 68))
if (wcfg.isLogging(Logging.SIGNTEXT) && (type == 63 || type == 68)) {
consumer.queueSignBreak(event.getPlayer().getName(), (Sign)event.getBlock().getState());
else if (wcfg.isLogging(Logging.CHESTACCESS) && (type == 23 || type == 54 || type == 61))
}
else if (wcfg.isLogging(Logging.CHESTACCESS) && (type == 23 || type == 54 || type == 61)) {
consumer.queueContainerBreak(event.getPlayer().getName(), event.getBlock().getState());
else if (type == 79)
}
else if (type == 79) {
consumer.queueBlockReplace(event.getPlayer().getName(), event.getBlock().getState(), 9, (byte)0);
}
else {
consumer.queueBlockBreak(event.getPlayer().getName(), event.getBlock().getState());
if (BukkitUtils.getRelativeTopBreakabls().contains(event.getBlock().getRelative(BlockFace.UP).getTypeId())) {
consumer.queueBlockBreak(event.getPlayer().getName(), event.getBlock().getRelative(BlockFace.UP).getState());
}
List<Location> nearbySigns = BukkitUtils.getBlocksNearby(event.getBlock(), BukkitUtils.getRelativeBreakables());
if(nearbySigns.size() != 0) {
for(Location location : nearbySigns) {

View File

@@ -27,6 +27,7 @@ public class BukkitUtils
{
private static final Set<Set<Integer>> blockEquivalents;
private static final Set<Integer> relativeBreakable;
private static final Set<Integer> relativeTopBreakable;
static {
blockEquivalents = new HashSet<Set<Integer>>(7);
@@ -43,6 +44,27 @@ public class BukkitUtils
relativeBreakable.add(68); // Sign
relativeBreakable.add(65); // Ladder
relativeBreakable.add(77); // Button
relativeTopBreakable = new HashSet<Integer>(19);
relativeTopBreakable.add(6); ////Vegetation start////
relativeTopBreakable.add(31); //
relativeTopBreakable.add(32); //
relativeTopBreakable.add(37); //
relativeTopBreakable.add(38); //
relativeTopBreakable.add(39); //
relativeTopBreakable.add(40); //
relativeTopBreakable.add(59); //
relativeTopBreakable.add(81); //
relativeTopBreakable.add(83); ////Vegetation end////
relativeTopBreakable.add(27); // Powered rail
relativeTopBreakable.add(28); // Detector rail
relativeTopBreakable.add(66); // Rails
relativeTopBreakable.add(55); // Redstone
relativeTopBreakable.add(70); // Stone pressure plate
relativeTopBreakable.add(72); // Wood pressure plate
relativeTopBreakable.add(78); // Snow
relativeTopBreakable.add(93); // Redstone repeater
relativeTopBreakable.add(94); // Redstone repeater
}
/**
@@ -165,6 +187,10 @@ public class BukkitUtils
public static Set<Integer> getRelativeBreakables() {
return relativeBreakable;
}
public static Set<Integer> getRelativeTopBreakabls() {
return relativeTopBreakable;
}
public static String entityName(Entity entity) {
if (entity instanceof Player)