mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-20 15:11:39 +01:00
Avoid using metadata storage if possible (#2150)
* Avoid using metadata storage if possible * Fix cause detection, use always on paper * Fix fat fingers Co-authored-by: aurora <21148213+aurorasmiles@users.noreply.github.com>
This commit is contained in:
parent
d9716a5bd8
commit
3b9ab47a97
@ -32,8 +32,10 @@
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -326,15 +328,21 @@ private void addAll(@Nullable Object... element) {
|
||||
addAll(player.getPlayer()); // player object if online, else null
|
||||
}
|
||||
}
|
||||
} else if (o instanceof Creature && ((Creature) o).getTarget() != null) {
|
||||
} else if (o instanceof Creeper c) {
|
||||
indirect = true;
|
||||
addAll(((Creature) o).getTarget());
|
||||
addAll(c.getTarget(), c.getIgniter());
|
||||
} else if (o instanceof Creature c) {
|
||||
indirect = true;
|
||||
addAll(c.getTarget());
|
||||
} else if (o instanceof BlockProjectileSource) {
|
||||
addAll(((BlockProjectileSource) o).getBlock());
|
||||
} else if (o instanceof LightningStrike && PaperLib.isPaper() &&
|
||||
((LightningStrike) o).getCausingEntity() != null) {
|
||||
indirect = true;
|
||||
addAll(((LightningStrike) o).getCausingEntity());
|
||||
} else if (o instanceof FallingBlock f && PaperLib.isPaper() && f.getOrigin() != null) {
|
||||
indirect = true;
|
||||
addAll(f.getOrigin().getBlock());
|
||||
}
|
||||
|
||||
// Add manually tracked parent causes
|
||||
|
@ -347,7 +347,10 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
} else if (toType == Material.AIR) {
|
||||
// Track the source so later we can create a proper chain of causes
|
||||
if (entity instanceof FallingBlock) {
|
||||
Cause.trackParentCause(entity, block);
|
||||
if (!PaperLib.isPaper()) {
|
||||
// On paper we use FallingBlock#getOrigin to get the origin location, on spigot we store it.
|
||||
Cause.trackParentCause(entity, block);
|
||||
}
|
||||
|
||||
// Switch around the event
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, create(block), entity));
|
||||
@ -864,12 +867,7 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (matchingItem != null && hasInteractBypass(world, matchingItem)) {
|
||||
useEntityEvent.setAllowed(true);
|
||||
}
|
||||
if (!Events.fireToCancel(event, useEntityEvent)) {
|
||||
// so this is a hack but CreeperIgniteEvent doesn't actually tell us who, so we need to do it here
|
||||
if (item.getType() == Material.FLINT_AND_STEEL && entity.getType() == EntityType.CREEPER) {
|
||||
Cause.trackParentCause(entity, player);
|
||||
}
|
||||
}
|
||||
Events.fireToCancel(event, useEntityEvent);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
|
Loading…
Reference in New Issue
Block a user