コード例 #1
0
ファイル: Protected.cs プロジェクト: Comner-git/MineSharp
        public static bool ProtectBlockPlace(VanillaSession session, WorldRegion region, PlayerBlockPlacement bp)
        {
            if (IsBlockProtected(session, region) == false)
            {
                return(false);
            }

            if (FilterFire(session, bp))
            {
                string i = "";
                if (session.ActiveItem != null)
                {
                    i += "(server)" + session.ActiveItem.ItemID;
                }
                if (bp.Item != null)
                {
                    i += "(client)" + bp.Item.ItemID;
                }

                Chatting.Parser.TellAdmin(Permissions.Ban, session.Player.Name + " tried to use " + i + " in " + region.Name + " at " + session.Position);
                //session.Player.Kick("Arson");
                return(true);
            }

            //If adventure protection is active, allow all actions
            if (session.Mode == GameMode.Adventure) //buggy but best bet so far
            {
                return(false);                      //ok, only activate levers and chests
            }
            //Block all placements, non resident must be inside the region
            session.TellSystem(Chat.Aqua, "move inside the region before you open a door or chest");

            //New method, works - no longer works

            /*
             * PlayerDigging pd = new PlayerDigging();
             * pd.Position = bp.BlockPosition.Offset(bp.FaceDirection);
             * pd.Face = Face.Down;
             * pd.Status = PlayerDigging.StatusEnum.CheckBlock;
             * session.FromClient(pd);
             */

            //Old method - not perfect, disabling:

            /*BlockChange bc = new BlockChange(bp.BlockPosition.Offset(bp.FaceDirection), BlockID.Air);
             * session.Player.SendToClient(bc);*/
            return(true);
        }
コード例 #2
0
ファイル: Protected.cs プロジェクト: Comner-git/MineSharp
        /// <summary>
        /// Return true to block
        /// </summary>
        public static bool ProtectChestsClick(VanillaSession rs, WindowClick wc)
        {
            if (wc.WindowID == 0) //player inventory, allow
            {
                return(false);
            }

            if (rs.Player.Admin(Permissions.AnyAdmin) && rs.Mode == GameMode.Creative)
            {
                return(false);
            }

            if (rs.OpenWindows.ContainsKey(wc.WindowID) == false)
            {
                rs.TellSystem(Chat.Red, "Window not open");
                return(BlockClick(rs.Player, wc));
            }
            var w = rs.OpenWindows [wc.WindowID];

            if (w.Region == null)
            {
                return(false); //not in a region, allow
            }
            switch (w.Region.Type)
            {
            case Protected.Type:
            case Honeypot.Type:
                break;

            default:
                return(false);
            }

            if (w.Region.IsResident(rs.Player))
            {
                return(false); //residents allow
            }
            //Allow some open types
            if (w.Window.InventoryType == "CraftingTable")
            {
                return(false);
            }
            if (w.Window.InventoryType == "Enchant")
            {
                return(false);
            }
            if (w.Window.InventoryType == "Anvil")
            {
                return(false);
            }
            if (w.Window.WindowTitle == "container.enderchest")
            {
                return(false);
            }

            if (w.Region.Type == Protected.Type)
            {
                return(BlockClick(rs.Player, wc));
            }

            if (w.Region.Type == Honeypot.Type)
            {
                if (wc.Slot == 11 || wc.Slot == 13 || wc.Slot == 15)
                {
                    if (rs.Player.Admin(Permissions.AnyAdmin))
                    {
                        rs.TellSystem(Chat.White, "This spot is protected");
                        return(false);
                    }
                    Honeypot.Trigger(rs.Player, w.Region);
                    return(true);
                }
            }

            return(true);
        }