Armor stands no longer get removed by /stoplag.

Also restored MC1.7 compatibility to pistons.
This commit is contained in:
wizjany 2015-09-27 20:38:56 -04:00
parent 0fcd42fdd5
commit 32341393fe
2 changed files with 17 additions and 2 deletions

View File

@ -29,6 +29,7 @@
import com.sk89q.worldguard.blacklist.target.Target; import com.sk89q.worldguard.blacklist.target.Target;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.util.Enums;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.*; import org.bukkit.entity.*;
@ -276,6 +277,9 @@ public static String replaceColorMacros(String str) {
return str; return str;
} }
private static final org.bukkit.entity.EntityType armorStandType =
Enums.findByValue(org.bukkit.entity.EntityType.class, "ARMOR_STAND");
/** /**
* Returns whether an entity should be removed for the halt activity mode. * Returns whether an entity should be removed for the halt activity mode.
* *
@ -289,7 +293,8 @@ public static boolean isIntensiveEntity(Entity entity) {
|| entity instanceof FallingBlock || entity instanceof FallingBlock
|| (entity instanceof LivingEntity || (entity instanceof LivingEntity
&& !(entity instanceof Tameable) && !(entity instanceof Tameable)
&& !(entity instanceof Player)); && !(entity instanceof Player)
&& !(entity.getType() == armorStandType));
} }
/** /**
@ -299,7 +304,9 @@ public static boolean isIntensiveEntity(Entity entity) {
* @param enumType enum class * @param enumType enum class
* @param values values to test * @param values values to test
* @return a value in the enum or null * @return a value in the enum or null
* @deprecated use {@link Enums#findByValue(Class, String...)}
*/ */
@Deprecated
public static <T extends Enum<T>> T tryEnum(Class<T> enumType, String ... values) { public static <T extends Enum<T>> T tryEnum(Class<T> enumType, String ... values) {
for (String val : values) { for (String val : values) {
try { try {

View File

@ -253,7 +253,15 @@ public void onBlockPistonRetract(BlockPistonRetractEvent event) {
BlockFace direction = event.getDirection(); BlockFace direction = event.getDirection();
ArrayList<Block> blocks = new ArrayList<Block>(event.getBlocks()); ArrayList<Block> blocks;
try {
blocks = new ArrayList<Block>(event.getBlocks());
} catch (NoSuchMethodError e) {
blocks = Lists.newArrayList(event.getRetractLocation().getBlock());
if (piston.getType() == Material.PISTON_MOVING_PIECE) {
direction = new PistonExtensionMaterial(Material.PISTON_STICKY_BASE.getId(), piston.getData()).getFacing();
}
}
int originalSize = blocks.size(); int originalSize = blocks.size();
Events.fireBulkEventToCancel(event, new BreakBlockEvent(event, cause, event.getBlock().getWorld(), blocks, Material.AIR)); Events.fireBulkEventToCancel(event, new BreakBlockEvent(event, cause, event.getBlock().getWorld(), blocks, Material.AIR));
if (originalSize != blocks.size()) { if (originalSize != blocks.size()) {