Пример #1
0
        /// <summary>
        /// Deletes the world protection
        /// </summary>
        public override RestResponse OnDelete(Query query)
        {
            //get the manager
            var manager = GetWhitelistManager();

            if (manager == null)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "Could not find the protection manager!"));
            }

            //Get the protection
            var task = Task.Run(async() =>
            {
                //Get the protection
                ProtectedWorld protection = await manager.GetProtectionAsync(World);
                if (protection == null)
                {
                    return(new RestResponse(RestStatus.ResourceNotFound, msg: "Protection does not exist."));
                }

                //Get hte account
                var result = await protection.RemoveAccountAsync(Account);
                return(new RestResponse(RestStatus.OK, result));
            });

            if (query.GetBool(Query.AsyncKey, false))
            {
                return(RestResponse.Async);
            }
            return(task.Result);
        }
Пример #2
0
        public OptionalProtectedWorld(ProtectedWorld pw)
        {
            Name     = pw.Name;
            Whereami = pw.World.Whereami;

            AllowAnonymous = pw.AllowAnonymous;
            Mode           = pw.Mode;

            //TODO: Fix the account listing
            AccountList = null;
        }
Пример #3
0
        /// <summary>
        /// Gets the world protection
        /// </summary>
        public override RestResponse OnGet(Query query)
        {
            //get the manager
            var manager = GetWhitelistManager();

            if (manager == null)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "Could not find the protection manager!"));
            }

            //Get the protection
            ProtectedWorld protection = manager.GetProtectionAsync(World).Result;

            if (protection == null)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "The world does not have any protection."));
            }

            //return the world
            return(new RestResponse(RestStatus.OK, res: new OptionalProtectedWorld(protection)));
        }