Example #1
0
	/**
	 * Used to cancel the land of falling blocks in bowspleef games
	 */
	@EventHandler
	public void onEntityChangeBlock(EntityChangeBlockEvent e) {
		if (!(e.getEntity() instanceof FallingBlock)) {
			return;
		}

		boolean bowspleefEntity = false;

		List<MetadataValue> metadatas = e.getEntity().getMetadata("bowspleef");
		for (MetadataValue metadata : metadatas) {
			if (metadata.getOwningPlugin() != HeavySpleef.getInstance())
				continue;

			if (metadata.asBoolean()) {
				bowspleefEntity = true;
				break;
			}
		}

		if (!bowspleefEntity) {
			return;
		}

		e.setCancelled(true);
		e.getEntity().remove();
	}
 @EventHandler
 public void onBlockLand(EntityChangeBlockEvent e) {
   if (Variables.blocks.contains(e.getEntity().getUniqueId())) {
     e.setCancelled(true);
     e.getEntity().remove();
   }
 }
Example #3
0
 @SuppressWarnings(value = "unused")
 @EventHandler
 public void onBlockLand(EntityChangeBlockEvent event) {
   if (event.getEntity() instanceof FallingBlock) {
     FallingBlock fallingBlock = (FallingBlock) event.getEntity();
     if (event.getBlock().getType() == Material.AIR) {
       new BukkitRunnable() {
         @Override
         public void run() {
           fallingBlock.getLocation().getBlock().setType(Material.AIR);
           // Effect effect = new ItemLaunchEffect(new ItemStack(fallingBlock.getMaterial()),
           //        fallingBlock.getLocation(),2D);
           // effect.perform();
         }
       }.runTaskLater(Minigames.getMinigames().getPlugin(), 1L);
     }
   }
 }
  // when an entity picks up an item
  @EventHandler(priority = EventPriority.LOWEST)
  public void onEntityPickup(EntityChangeBlockEvent event) {
    // FEATURE: endermen don't steal claimed blocks

    // if its an enderman
    if (event.getEntity() instanceof Enderman) {
      // and the block is claimed
      if (this.dataStore.getClaimAt(event.getBlock().getLocation(), false, null) != null) {
        // he doesn't get to steal it
        event.setCancelled(true);
      }
    }
  }
  /**
   * Monitor EntityChangeBlock events.
   *
   * @param event The event to watch
   */
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onEntityChangeBlock(EntityChangeBlockEvent event) {
    Entity entity = event.getEntity();

    if (!(entity instanceof FallingBlock)) {
      return;
    }

    Block block = event.getBlock();
    boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);

    if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
      mcMMO.getPlaceStore().setFalse(block);
      entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
    } else if (isTracked) {
      mcMMO.getPlaceStore().setTrue(block);
    }
  }