mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
We only care about blocks that award XP.
Also, this fixes a possible issue where blocks changed by entities other than falling blocks could have been left as tracked even after they were destroyed.
This commit is contained in:
parent
9c925d3327
commit
aa59348a94
@ -96,7 +96,7 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
Block movedBlock = event.getRetractLocation().getBlock();
|
Block movedBlock = event.getRetractLocation().getBlock();
|
||||||
|
|
||||||
if (movedBlock.getPistonMoveReaction() != PistonMoveReaction.MOVE || !mcMMO.getPlaceStore().isTrue(movedBlock)) {
|
if (!BlockUtils.shouldBeWatched(movedBlock.getState()) || movedBlock.getPistonMoveReaction() != PistonMoveReaction.MOVE || !mcMMO.getPlaceStore().isTrue(movedBlock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,11 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
||||||
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.AnimalTamer;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.Arrow;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.FallingBlock;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.entity.Tameable;
|
|
||||||
import org.bukkit.entity.Wolf;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -100,13 +92,15 @@ public class EntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
if (!(entity instanceof FallingBlock)) {
|
if (!BlockUtils.shouldBeWatched(block.getState())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = event.getBlock();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
|
if (entity instanceof FallingBlock || entity instanceof Enderman) {
|
||||||
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
|
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
|
||||||
|
|
||||||
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
||||||
@ -117,6 +111,12 @@ public class EntityListener implements Listener {
|
|||||||
mcMMO.getPlaceStore().setTrue(block);
|
mcMMO.getPlaceStore().setTrue(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (mcMMO.getPlaceStore().isTrue(block)) {
|
||||||
|
mcMMO.getPlaceStore().setFalse(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle EntityDamageByEntity events that involve modifying the event.
|
* Handle EntityDamageByEntity events that involve modifying the event.
|
||||||
|
Loading…
Reference in New Issue
Block a user