diff --git a/README.md b/README.md index 3f2b359..c9523c4 100644 --- a/README.md +++ b/README.md @@ -96,12 +96,19 @@ Commands * `/area_pos2 [X,Y,Z|X Y Z]` -- Sets area position two to your position or the one supplied. + * `/areas_cleanup` -- Removes all ownerless areas. + Useful for cleaning after user deletion, for example using /remove_player. + + * `/area_open ` -- Toggle open/closed the specified area for everyone. + License ------- -Copyright (C) 2013 ShadowNinja +Copyright (C) 2013-2017 ShadowNinja -Copyright (C) 2019-2020 MultiCraft Development Team +Copyright (C) 2015-2020 various contributors + +Copyright (C) 2019-2021 MultiCraft Development Team Licensed under the GNU LGPL version 3.0 or later. See https://www.gnu.org/licenses/lgpl-3.0.txt diff --git a/chatcommands.lua b/chatcommands.lua index e88b57c..3107fab 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -1,4 +1,4 @@ -local S = intllib.make_gettext_pair() +local S = areas.S minetest.register_chatcommand("protect", { params = S(""), @@ -79,8 +79,7 @@ minetest.register_chatcommand("add_owner", { .." positions that have already been protected," .." Use set_owner if you don't want the parent to be set."), func = function(name, param) - local pid, ownerName, areaName - = param:match('^(%d+) ([^ ]+) (.+)$') + local pid, ownerName, areaName = param:match('^(%d+) ([^ ]+) (.+)$') if not pid then minetest.chat_send_player(name, S("Invalid usage, see /help @1.", "add_owner")) @@ -120,7 +119,7 @@ minetest.register_chatcommand("add_owner", { minetest.register_chatcommand("rename_area", { - params = S("").." "..S(""), + params = S("").." "..S(""), description = S("Rename an area that you own"), func = function(name, param) local id, newName = param:match("^(%d+)%s(.+)$") @@ -199,8 +198,8 @@ minetest.register_chatcommand("list_areas", { if #areaStrings == 0 then return true, S("No visible areas.") elseif #areaStrings > 100 then - return true, S("Too many areas to list.") - end + return true, S("Too many areas to list.") + end return true, table.concat(areaStrings, "\n") end @@ -381,7 +380,6 @@ minetest.register_chatcommand("area_info", { area_num = area_num + 1 end end - table.insert(lines, S("You have @1 areas.", area_num)) -- Area limit @@ -417,8 +415,7 @@ minetest.register_chatcommand("area_info", { minetest.register_chatcommand("areas_cleanup", { - params = "", - description = "Removes all ownerless areas", + description = S("Removes all ownerless areas"), privs = areas.adminPrivs, func = function() local total, count = 0, 0 @@ -436,6 +433,7 @@ minetest.register_chatcommand("areas_cleanup", { end areas:save() - return true, "Total areas: " .. total .. ", Removed: " .. count .. " areas! New count: " .. total - count + return true, "Total areas: " .. total .. ", Removed: " .. + count .. " areas. New count: " .. (total - count) end }) diff --git a/hud.lua b/hud.lua index 124ab24..3b28ed5 100644 --- a/hud.lua +++ b/hud.lua @@ -1,9 +1,12 @@ -- This is inspired by the landrush mod by Bremaweb -local S = intllib.make_gettext_pair() +local S = areas.S areas.hud = {} +local vround = vector.round +local tconcat = table.concat + hud.register("areas", { hud_elem_type = "text", position = {x = 0, y = 1}, @@ -18,7 +21,7 @@ minetest.register_playerstep(function(_, playernames) for _, name in pairs(playernames) do local player = minetest.get_player_by_name(name) if not player or not player:is_player() then return end - local pos = vector.round(player:get_pos()) + local pos = vround(player:get_pos()) if minetest.is_valid_pos(pos) then local areaStrings = {} @@ -40,7 +43,7 @@ minetest.register_playerstep(function(_, playernames) if #areaStrings > 0 then areaString = S("Areas:") areaString = areaString .. "\n" .. - table.concat(areaStrings, "\n") + tconcat(areaStrings, "\n") end local phud = areas.hud[name] or {} diff --git a/init.lua b/init.lua index 32cbb34..aa681e9 100644 --- a/init.lua +++ b/init.lua @@ -4,7 +4,9 @@ areas = {} -areas.adminPrivs = {areas=true} +areas.S = intllib.make_gettext_pair() + +areas.adminPrivs = {areas = true} areas.startTime = os.clock() areas.modpath = minetest.get_modpath("areas") @@ -19,16 +21,20 @@ dofile(areas.modpath.."/protector.lua") areas:load() +local S = areas.S + minetest.register_privilege("areas", { - description = "Can administer areas." + description = S("Can administer areas."), + give_to_singleplayer = false }) minetest.register_privilege("areas_high_limit", { - description = "Can protect more, bigger areas." + description = S("Can protect more, bigger areas."), + give_to_singleplayer = false }) if not minetest.registered_privileges[areas.config.self_protection_privilege] then minetest.register_privilege(areas.config.self_protection_privilege, { - description = "Can protect areas.", + description = S("Can protect areas."), }) end diff --git a/interact.lua b/interact.lua index aa50b9a..ce06560 100644 --- a/interact.lua +++ b/interact.lua @@ -1,4 +1,4 @@ -local S = intllib.make_gettext_pair() +local S = areas.S local old_is_protected = minetest.is_protected @@ -52,7 +52,7 @@ minetest.register_on_protection_violation(function(pos, name) local player = minetest.get_player_by_name(name) if player and player:is_player() then local hp = player:get_hp() - if hp and hp > 1 then + if hp and hp > 2 then player:set_hp(hp - 1) end end diff --git a/internal.lua b/internal.lua index 4f313de..37516e0 100644 --- a/internal.lua +++ b/internal.lua @@ -1,4 +1,4 @@ -local S = intllib.make_gettext_pair() +local S = areas.S function areas:player_exists(name) return minetest.get_auth_handler().get_auth(name) ~= nil @@ -159,7 +159,6 @@ function areas:move(id, area, pos1, pos2) area.pos1 = pos1 area.pos2 = pos2 - for i=1, #areas.registered_on_moves do areas.registered_on_moves[i](id, area, pos1, pos2) end diff --git a/locale/areas.ru.tr b/locale/areas.ru.tr index 21ac6e7..1aa19e0 100644 --- a/locale/areas.ru.tr +++ b/locale/areas.ru.tr @@ -7,7 +7,7 @@ =<НовыйВладелец> =<РодственныйID> =<ИмяИгрока> -=<НовоеИмя> +=<НовоеИмя> @1 has given you control over the area "@2" (ID @3).=@1 дал вам контроль над областью "@2" (ID @3). @1 spanning up to @2x@3x@4.=@1 охватывает до @2x@3x@4. A regular expression is required.=Требуется регулярное выражение. @@ -43,6 +43,7 @@ Recursively remove areas using an ID=Рекурсивно удаляет зон Remove an area using an ID=Удаляет зону используя её ID Removed area @1=Удалена зона @1 Removed area @1 and it's sub areas.=Удалена зона @1 и её подзоны. +Removes all ownerless areas=Удаляет все бесхозные зоны Rename an area that you own=Переименовывает зону которой вы владеете Self protection is disabled.=Защита отключена. Self protection is enabled.=Защита включена. @@ -114,5 +115,5 @@ Unknown subcommand: @1=Неизвестная подкоманда: @1 Protector Block=Защитный Блок You are not allowed to protect that area: @1=Вам не разрешено защищать эту область: @1 You have already protected this area.=Вы уже защитили эту область. -The area from @1 to @1 has been protected as ID @1=Зона от @1 до @1 была защищена, ID @1 -Protected area @1, Owned by @1=Защищённая зона @1, Владелец: @1 +The area from @1 to @2 has been protected as ID @3=Зона от @1 до @2 была защищена, ID @3 +Protected area @1, Owned by @2=Защищённая зона @1, Владелец: @2 diff --git a/pos.lua b/pos.lua index afebb43..37d790a 100644 --- a/pos.lua +++ b/pos.lua @@ -1,4 +1,4 @@ -local S = intllib.make_gettext_pair() +local S = areas.S -- I could depend on WorldEdit for this, but you need to have the 'worldedit' -- permission to use those commands and you don't have diff --git a/protector.lua b/protector.lua index 97b048f..ed54017 100644 --- a/protector.lua +++ b/protector.lua @@ -1,4 +1,4 @@ -local S = intllib.make_gettext_pair() +local S = areas.S local radius = minetest.settings:get("areasprotector_radius") or 8 @@ -43,11 +43,11 @@ minetest.register_node("areas:protector", { local id = areas:add(name, S("Protector Block"), pos1, pos2) areas:save() minetest.chat_send_player(name, - (S("The area from @1 to @1 has been protected as ID @1", + (S("The area from @1 to @2 has been protected as ID @3", cyan(minetest.pos_to_string(pos1)), cyan(minetest.pos_to_string(pos2)), cyan(id)))) minetest.set_node(pos, {name = "areas:protector"}) local meta = minetest.get_meta(pos) - meta:set_string("infotext", (S("Protected area @1, Owned by @1", id, name))) + meta:set_string("infotext", S("Protected area @1, Owned by @2", id, name)) meta:set_int("area_id", id) meta:set_string("owner", name) itemstack:take_item()