Make all admin checks use one table

This commit is contained in:
ShadowNinja 2014-07-12 19:10:26 -04:00
parent 65013863b2
commit 57c18fce95
3 changed files with 6 additions and 6 deletions

View File

@ -35,7 +35,7 @@ minetest.register_chatcommand("set_owner", {
description = "Protect an area beetween two positions and give" description = "Protect an area beetween two positions and give"
.." a player access to it without setting the parent of the" .." a player access to it without setting the parent of the"
.." area to any existing area", .." area to any existing area",
privs = {areas=true}, privs = areas.adminPrivs,
func = function(name, param) func = function(name, param)
local ownerName, areaName = param:match('^(%S+)%s(.+)$') local ownerName, areaName = param:match('^(%S+)%s(.+)$')
@ -175,7 +175,7 @@ minetest.register_chatcommand("find_areas", {
minetest.register_chatcommand("list_areas", { minetest.register_chatcommand("list_areas", {
description = "List your areas, or all areas if you are an admin.", description = "List your areas, or all areas if you are an admin.",
func = function(name, param) func = function(name, param)
local admin = minetest.check_player_privs(name, {areas=true}) local admin = minetest.check_player_privs(name, areas.adminPrivs)
local areaStrings = {} local areaStrings = {}
for id, area in pairs(areas.areas) do for id, area in pairs(areas.areas) do
if admin or areas:isAreaOwner(id, name) then if admin or areas:isAreaOwner(id, name) then

View File

@ -109,7 +109,7 @@ end
-- Also checks the size of the area and if the user already -- Also checks the size of the area and if the user already
-- has more than max_areas. -- has more than max_areas.
function areas:canPlayerAddArea(pos1, pos2, name) function areas:canPlayerAddArea(pos1, pos2, name)
if minetest.check_player_privs(name, {areas=true}) then if minetest.check_player_privs(name, self.adminPrivs) then
return true return true
end end
@ -188,7 +188,7 @@ end
-- Checks if a player owns an area or a parent of it -- Checks if a player owns an area or a parent of it
function areas:isAreaOwner(id, name) function areas:isAreaOwner(id, name)
local cur = self.areas[id] local cur = self.areas[id]
if cur and minetest.check_player_privs(name, {areas=true}) then if cur and minetest.check_player_privs(name, self.adminPrivs) then
return true return true
end end
while cur do while cur do

View File

@ -5,7 +5,7 @@ minetest.register_chatcommand("legacy_load_areas", {
params = "<version>", params = "<version>",
description = "Loads, converts, and saves the areas from" description = "Loads, converts, and saves the areas from"
.." a legacy save file.", .." a legacy save file.",
privs = {areas=true, server=true, privs=true}, privs = {areas=true, server=true},
func = function(name, param) func = function(name, param)
minetest.chat_send_player(name, "Converting areas...") minetest.chat_send_player(name, "Converting areas...")
local version = tonumber(param) local version = tonumber(param)
@ -86,7 +86,7 @@ end
-- Checks if a node is owned by you -- Checks if a node is owned by you
function areas.isNodeOwner(pos, name) function areas.isNodeOwner(pos, name)
if minetest.check_player_privs(name, {areas=true}) then if minetest.check_player_privs(name, areas.adminPrivs) then
return true return true
end end
for id, area in pairs(areas:getAreasAtPos(pos)) do for id, area in pairs(areas:getAreasAtPos(pos)) do