/// <summary> /// Raises the block destruction event /// </summary> /// <param name="entity">entity who destroyed the block</param> /// <param name="block">block that has been destroyed</param> /// <returns>resulting event args</returns> protected virtual BlockDestroyEventArgs RaiseDestroyEvent(IEntityBase entity, StructBlock block) { BlockDestroyEventArgs e = new BlockDestroyEventArgs(this, entity); block.World.Server.PluginManager.CallEvent(Event.BlockDestroy, e); return(e); }
/// <summary> /// Destroy the block /// </summary> /// <param name="entity">entity who destroyed the block</param> /// <param name="block">block that has been destroyed</param> public virtual void Destroy(IEntityBase entity, IStructBlock iBlock) { StructBlock block = (StructBlock)iBlock; BlockDestroyEventArgs eventArgs = RaiseDestroyEvent(entity, block); if (eventArgs.EventCanceled) { return; } PlaySoundOnDestroy(entity, block); UpdateWorld(block, true); // Check if the entity is a player if ((entity != null) && (entity is Player)) { // Check if the player is not in creative mode // Don't drop any items if the player is in creative mode if (((Player)entity).GameMode == GameMode.Normal) { DropItems(entity as EntityBase, block); } } NotifyNearbyBlocks((EntityBase)entity, block); }
/// <summary> /// Destroy the block /// </summary> /// <param name="entity">entity who destroyed the block</param> /// <param name="block">block that has been destroyed</param> public virtual void Destroy(IEntityBase entity, IStructBlock iBlock) { StructBlock block = (StructBlock)iBlock; BlockDestroyEventArgs eventArgs = RaiseDestroyEvent(entity, block); if (eventArgs.EventCanceled) return; PlaySoundOnDestroy(entity, block); UpdateWorld(block, true); // Check if the entity is a player if ((entity != null) && (entity.GetType() == typeof(Player))) { // Check if the player is in creative mode if (((Player)entity).GameMode == System.Convert.ToByte(1)) { // Don't drop any items as the player is in creative mode goto skipDrop; } } DropItems(entity as EntityBase, block); skipDrop: DamageItem(entity); NotifyNearbyBlocks((EntityBase)entity, block); }
private void OnDestroy(BlockDestroyEventArgs e) { foreach (EventListener el in Plugins) { if (el.Event == Event.BlockDestroy) { IBlockListener l = el.Listener as IBlockListener; l.OnDestroy(e); } } }