示例#1
0
 private void LevelOnBlockPlace(object sender, BlockPlaceEventArgs e)
 {
     if (e.ExistingBlock.Coordinates.DistanceTo((BlockCoordinates)e.Player.SpawnPosition) < 15)
     {
         e.Cancel = e.Player.GameMode != GameMode.Creative;
     }
 }
示例#2
0
 public void OnPlace(object o, BlockPlaceEventArgs e)
 {
     if (!Class1.lged.ContainsKey(e.Player.Username.ToLower()))
     {
         notlogin(e.Player);
         e.Cancel = true;
     }
 }
示例#3
0
 /// <summary>
 /// Raises the block placement event
 /// </summary>
 /// <param name="entity">entity who placed the block</param>
 /// <param name="block">block that has been placed</param>
 /// <returns>resulting event args</returns>
 protected virtual bool RaisePlaceEvent(IEntityBase entity, StructBlock block)
 {
     BlockPlaceEventArgs e = new BlockPlaceEventArgs(this, entity);
     block.World.Server.PluginManager.CallEvent(Event.BlockPlace, e);
     // Destruction made not by the living can not be interrupted?
     if (entity == null)
         return true;
     return !e.EventCanceled;
 }
示例#4
0
        public void BlockPlace(object sender, BlockPlaceEventArgs e)
        {
            xCoreLevel level = e.Level as xCoreLevel;

            if (!level.Started || e.Player.GameMode != GameMode.Survival)
            {
                e.Cancel = true;
                return;
            }
        }
示例#5
0
        public override bool OnBlockPlace(BlockPlaceEventArgs e)
        {
            if (e.Player == null)
            {
                return(true);
            }
            BlockPlaceEvent bb = new BlockPlaceEvent((OpenPlayer)e.Player, e.TargetBlock);

            EventDispatcher.DispatchEvent(bb);
            return(!bb.IsCancelled);
        }
示例#6
0
 private void OnPlace(BlockPlaceEventArgs e)
 {
     foreach (EventListener el in Plugins)
     {
         if (el.Event == Event.BlockPlace)
         {
             IBlockListener l = el.Listener as IBlockListener;
             l.OnPlace(e);
         }
     }
 }
示例#7
0
        private void LevelOnBlockPlace(object sender, BlockPlaceEventArgs e)
        {
            PlotCoordinates coords = (PlotCoordinates)e.TargetBlock.Coordinates;

            if (coords == null)
            {
                e.Cancel = true;
            }
            else
            {
                if (e.Player != null)
                {
                    e.Cancel = !_plotManager.CanBuild(coords, e.Player);
                }
            }
        }
示例#8
0
 public void OnPlaceEvent(object sender, BlockPlaceEventArgs e)
 {
     if (e.Player.Inventory.GetItemInHand().Id == 271)
     {
         pos1.Add(e.Player.Username, new BlockCoordinates(e.TargetBlock.Coordinates.X, e.TargetBlock.Coordinates.Y, e.TargetBlock.Coordinates.Z));
         //$this->Engine->sendInfo($event->getPlayer(), 'Точка 1 установлена ('.$x.', '.$y.', '.$z.')', 1);
         e.Cancel = true;
     }
     else
     {
         if (!getRegion(e.Player.Username, e.TargetBlock.Coordinates.X, e.TargetBlock.Coordinates.Y, e.TargetBlock.Coordinates.Z, e.Level.LevelName, "Place"))
         {
             //$this->Engine->sendInfo($event->getPlayer(), 'Вы не можете ломать блоки на этой территории', 2);
             e.Cancel = true;
         }
     }
 }
示例#9
0
        public void UseItem(Vector3 pos, Item item, BlockFace blockFace, Vector3 clickPos, Player player)
        {
            Block clicked = this.GetBlock(pos);
            Block replace = clicked.GetSideBlock(blockFace);

            if (clicked.Y > 255 || clicked.Y < 0 || clicked.ID == BlockFactory.AIR)
            {
                return;
            }

            PlayerInteractEventArgs playerInteractEvent = new PlayerInteractEventArgs(player, item, clicked, blockFace);

            if (player.IsAdventure)
            {
                playerInteractEvent.IsCancel = true;
            }

            if (Server.ServerConfig.SpawnProtection > 0 || player.Op)
            {
                //TODO
            }

            PlayerEvents.OnPlayerInteract(playerInteractEvent);
            if (playerInteractEvent.IsCancel)
            {
                return;
            }

            clicked.Update(World.BLOCK_UPDATE_TOUCH);
            if (!player.Sneaking && clicked.CanBeActivated && clicked.Activate(player, item))
            {
                return;
            }

            if (!player.Sneaking && item.CanBeActivate && item.Activate(player, this, clicked, blockFace, clickPos))
            {
                if (item.Count <= 0)
                {
                    return;
                }
            }

            if (!item.CanBePlace)
            {
                return;
            }
            Block hand = item.Block;

            hand.Position = replace.Position;

            if (clicked.CanBeReplaced)
            {
                replace       = clicked;
                hand.Position = replace.Position;
            }

            //TODO : near by entity check

            //TODO : check can place on

            BlockPlaceEventArgs blockPlaceEvent = new BlockPlaceEventArgs(player, hand, replace, clicked, item);

            //TODO : check spawn protection

            BlockEvents.OnBlockPlace(blockPlaceEvent);
            if (blockPlaceEvent.IsCancel)
            {
                return;
            }
            hand.Place(clicked, replace, blockFace, clickPos, player, item);

            LevelSoundEventPacket pk = new LevelSoundEventPacket();

            pk.Position  = (Vector3)hand.Position;
            pk.Sound     = LevelSoundEventPacket.SOUND_PLACE;
            pk.ExtraData = hand.RuntimeId;
            pk.Pitch     = 1;
            player.SendPacket(pk); //TODO : near players
        }
示例#10
0
 private void LevelOnBlockPlace(object sender, BlockPlaceEventArgs e)
 {
     e.Cancel = true;
 }
示例#11
0
 private void LevelOnBlockPlace(object sender, BlockPlaceEventArgs e)
 {
     e.Cancel = e.Player.GameMode != GameMode.Creative;
 }
示例#12
0
 protected virtual void HandleBlockPlace(object sender, BlockPlaceEventArgs e)
 {
     e.Cancel = CurrentState.HandleBlockPlace(this, e.Player as SkyPlayer, e.ExistingBlock, e.TargetBlock);
 }
示例#13
0
 private void OnPlace(object sender, BlockPlaceEventArgs e)
 {
     e.Cancel = !isAuthenticated(e.Player);
 }
 public static void OnBlockPlace(BlockPlaceEventArgs args)
 {
     BlockPlace?.Invoke(args);
 }
示例#15
0
        public void UseItem(Vector3 pos, Item item, BlockFace blockFace, Vector3 clickPos, Player player)
        {
            Block clicked = this.GetBlock(pos);
            Block replace = clicked.GetSideBlock(blockFace);

            if (clicked.Y > 255 || clicked.Y < 0 || clicked.ID == BlockIDs.AIR)
            {
                return;
            }

            PlayerInteractEventArgs args = new PlayerInteractEventArgs(player, item, clicked, blockFace);

            if (player.IsAdventure)
            {
                args.IsCancel = true;
            }

            /*if (Server.ServerConfig.SpawnProtection > 0 || player.Op)
             * {
             *  //TODO
             * }*/

            Server.Instance.Event.Player.OnPlayerInteract(this, args);
            if (args.IsCancel)
            {
                return;
            }

            clicked.OnTouchUpdate();
            if (!player.Sneaking && clicked.CanBeActivated && clicked.Activate(player, item))
            {
                return;
            }

            if (!player.Sneaking && item.Activate(player, this, clicked, blockFace, clickPos))
            {
                if (item.Count <= 0)
                {
                    return;
                }
            }

            Block hand = item.Block;

            if (hand.ID == BlockIDs.AIR)
            {
                return;
            }

            hand.Damage = item.Damage;
            hand.SetPosition(replace.GetPosition());

            if (clicked.CanBeReplaced)
            {
                replace = clicked;
                hand.SetPosition(replace.GetPosition());
            }

            //TODO : near by entity check

            //TODO : check can place on

            BlockPlaceEventArgs args1 = new BlockPlaceEventArgs(player, hand, replace, clicked, item);

            //TODO : check spawn protection

            Server.Instance.Event.Block.OnBlockPlace(this, args1);
            if (args1.IsCancel)
            {
                this.SendBlocks(Server.Instance.GetOnlinePlayers(), new Vector3[] { hand.ToVector3() });
                return;
            }

            hand.Place(clicked, replace, blockFace, clickPos, player, item);

            LevelSoundEventPacket pk = new LevelSoundEventPacket
            {
                Position  = hand.ToVector3(),
                Sound     = LevelSoundEventPacket.SOUND_PLACE,
                ExtraData = hand.RuntimeId
            };

            Server.Instance.BroadcastSendPacket(pk); //TODO : near players
        }