mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Merge pull request #2697 from SilverCory/master
Monitor falling blocks.
This commit is contained in:
commit
982ee13631
@ -11,6 +11,7 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.BrewingStand;
|
import org.bukkit.block.BrewingStand;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -20,6 +21,7 @@ import org.bukkit.event.block.BlockDamageEvent;
|
|||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -49,6 +51,8 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
|
||||||
public class BlockListener implements Listener {
|
public class BlockListener implements Listener {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
@ -124,6 +128,34 @@ public class BlockListener implements Listener {
|
|||||||
//new StickyPistonTrackerTask(direction, event.getBlock(), movedBlock).runTaskLater(plugin, 2);
|
//new StickyPistonTrackerTask(direction, event.getBlock(), movedBlock).runTaskLater(plugin, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Monitor falling blocks.
|
||||||
|
*
|
||||||
|
* @param event The event to watch
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onFallingBlock(EntityChangeBlockEvent event) {
|
||||||
|
|
||||||
|
if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
|
||||||
|
if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) {
|
||||||
|
event.getEntity().setMetadata("mcMMOBlockFall", new FixedMetadataValue( plugin, event.getBlock().getLocation()));
|
||||||
|
} else {
|
||||||
|
List<MetadataValue> values = event.getEntity().getMetadata( "mcMMOBlockFall" );
|
||||||
|
|
||||||
|
if (!values.isEmpty()) {
|
||||||
|
|
||||||
|
if (values.get(0).value() == null) return;
|
||||||
|
Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock();
|
||||||
|
|
||||||
|
|
||||||
|
mcMMO.getPlaceStore().setTrue( event.getBlock() );
|
||||||
|
mcMMO.getPlaceStore().setFalse( spawn );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor BlockPlace events.
|
* Monitor BlockPlace events.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user