Made /stoplag handle TNT removal better.

This commit is contained in:
sk89q 2011-06-29 16:15:56 -07:00
parent d90b960597
commit bed6782a00
5 changed files with 20 additions and 14 deletions

View File

@ -24,7 +24,7 @@
import com.sk89q.worldedit.blocks.BlockType;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
@ -219,4 +219,18 @@ public static String replaceColorMacros(String str) {
return str;
}
/**
* Returns whether an entity should be removed for the halt activity mode.
*
* @param entity
* @return
*/
public static boolean isIntensiveEntity(Entity entity) {
return entity instanceof Item
|| entity instanceof TNTPrimed
|| (entity instanceof LivingEntity
&& !(entity instanceof Tameable)
&& !(entity instanceof Player));
}
}

View File

@ -486,6 +486,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
}
} else if (ent instanceof TNTPrimed) {
if (cfg.activityHaltToggle) {
ent.remove();
event.setCancelled(true);
return;
}

View File

@ -23,7 +23,6 @@
import java.util.Set;
import java.util.logging.Logger;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -145,10 +144,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
int removed = 0;
for (Entity entity : player.getWorld().getEntities()) {
if (entity instanceof Item
|| (entity instanceof LivingEntity
&& !(entity instanceof Tameable)
&& !(entity instanceof Player))) {
if (BukkitUtil.isIntensiveEntity(entity)) {
entity.remove();
removed++;
}

View File

@ -66,10 +66,7 @@ public void onChunkLoad(ChunkLoadEvent event) {
int removed = 0;
for (Entity entity : event.getChunk().getEntities()) {
if (entity instanceof Item
|| (entity instanceof LivingEntity
&& !(entity instanceof Tameable)
&& !(entity instanceof Player))) {
if (BukkitUtil.isIntensiveEntity(entity)) {
entity.remove();
removed++;
}

View File

@ -19,6 +19,7 @@
package com.sk89q.worldguard.bukkit.commands;
import com.sk89q.worldguard.bukkit.BukkitUtil;
import com.sk89q.worldguard.bukkit.ConfigurationManager;
import org.bukkit.ChatColor;
import org.bukkit.World;
@ -115,10 +116,7 @@ public static void stopLag(CommandContext args, WorldGuardPlugin plugin,
int removed = 0;
for (Entity entity : world.getEntities()) {
if (entity instanceof Item
|| (entity instanceof LivingEntity
&& !(entity instanceof Tameable)
&& !(entity instanceof Player))) {
if (BukkitUtil.isIntensiveEntity(entity)) {
entity.remove();
removed++;
}