mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-24 11:36:11 +01:00
Made /stoplag handle TNT removal better.
This commit is contained in:
parent
d90b960597
commit
bed6782a00
@ -24,7 +24,7 @@
|
|||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
@ -219,4 +219,18 @@ public static String replaceColorMacros(String str) {
|
|||||||
|
|
||||||
return 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -486,6 +486,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
}
|
}
|
||||||
} else if (ent instanceof TNTPrimed) {
|
} else if (ent instanceof TNTPrimed) {
|
||||||
if (cfg.activityHaltToggle) {
|
if (cfg.activityHaltToggle) {
|
||||||
|
ent.remove();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
|
||||||
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -145,10 +144,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
|
|||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
|
||||||
for (Entity entity : player.getWorld().getEntities()) {
|
for (Entity entity : player.getWorld().getEntities()) {
|
||||||
if (entity instanceof Item
|
if (BukkitUtil.isIntensiveEntity(entity)) {
|
||||||
|| (entity instanceof LivingEntity
|
|
||||||
&& !(entity instanceof Tameable)
|
|
||||||
&& !(entity instanceof Player))) {
|
|
||||||
entity.remove();
|
entity.remove();
|
||||||
removed++;
|
removed++;
|
||||||
}
|
}
|
||||||
|
@ -66,10 +66,7 @@ public void onChunkLoad(ChunkLoadEvent event) {
|
|||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
|
||||||
for (Entity entity : event.getChunk().getEntities()) {
|
for (Entity entity : event.getChunk().getEntities()) {
|
||||||
if (entity instanceof Item
|
if (BukkitUtil.isIntensiveEntity(entity)) {
|
||||||
|| (entity instanceof LivingEntity
|
|
||||||
&& !(entity instanceof Tameable)
|
|
||||||
&& !(entity instanceof Player))) {
|
|
||||||
entity.remove();
|
entity.remove();
|
||||||
removed++;
|
removed++;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||||
import com.sk89q.worldguard.bukkit.ConfigurationManager;
|
import com.sk89q.worldguard.bukkit.ConfigurationManager;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -115,10 +116,7 @@ public static void stopLag(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
|
||||||
for (Entity entity : world.getEntities()) {
|
for (Entity entity : world.getEntities()) {
|
||||||
if (entity instanceof Item
|
if (BukkitUtil.isIntensiveEntity(entity)) {
|
||||||
|| (entity instanceof LivingEntity
|
|
||||||
&& !(entity instanceof Tameable)
|
|
||||||
&& !(entity instanceof Player))) {
|
|
||||||
entity.remove();
|
entity.remove();
|
||||||
removed++;
|
removed++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user