From a3e43cc09a78b33016657fe32b5f310c0719217e Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sun, 10 Nov 2019 23:15:22 +0200 Subject: [PATCH] oops i broke it --- ess/tools.lua | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/ess/tools.lua b/ess/tools.lua index 15b9c60..9fab806 100644 --- a/ess/tools.lua +++ b/ess/tools.lua @@ -8,31 +8,34 @@ local function cmd_repair(name, params, splitparams) splitparams[1] = "all" end - if splitparams[1] == "all" then - if not ess.priv_match(name, "ess.tools.repairall") then - return ess.reject_permission() + if #splitparams > 0 then + if splitparams[1] == "all" then + if not ess.priv_match(name, "ess.tools.repairall") then + return ess.reject_permission() + end + -- Repair all tools + commit = 2 + elseif splitparams[2] == "all" and minetest.get_player_by_name(splitparams[1]) then + if not ess.priv_match(name, "ess.tools.repairall.other") then + return ess.reject_permission() + end + player = minetest.get_player_by_name(splitparams[1]) + -- Repair all of a player's tools + commit = 2 + elseif splitparams[1] ~= name and minetest.get_player_by_name(splitparams[1]) then + if not ess.priv_match(name, "ess.tools.repair.other") then + return ess.reject_permission() + end + player = minetest.get_player_by_name(splitparams[1]) + -- Repair a player's held tool + commit = 1 end - -- Repair all tools - commit = 2 - elseif splitparams[2] == "all" and minetest.get_player_by_name(splitparams[1]) then - if not ess.priv_match(name, "ess.tools.repairall.other") then - return ess.reject_permission() - end - player = minetest.get_player_by_name(splitparams[1]) - -- Repair all of a player's tools - commit = 2 - elseif splitparams[1] ~= name and minetest.get_player_by_name(splitparams[1]) then - if not ess.priv_match(name, "ess.tools.repair.other") then - return ess.reject_permission() - end - player = minetest.get_player_by_name(splitparams[1]) - -- Repair a player's held tool - commit = 1 else -- Repair my own tool commit = 1 end + if commit == 1 and player then local held = player:get_wielded_item() if held:get_wear() > 0 then