Delete more copied code

This commit is contained in:
Starbeamrainbowlabs 2022-05-16 22:37:10 +01:00
parent 10f350c967
commit d3119ee54a
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
2 changed files with 0 additions and 66 deletions

@ -1,26 +0,0 @@
function worldeditadditions_core.check_command(name, def)
if not (name and #name > 0) then
return false, "Error: No command name."
end
if not def.privs then
return false, "Error: privs is nill. Expected table."
end
def.require_pos = def.require_pos or 0
if not (def.require_pos >= 0 and def.require_pos < 3) then
return false, "Error: require_pos must be greater than -1 and less than 3."
end
if not def.parse then
if def.params == "" then
def.parse = function(params_text) return true end
else
return false, "Error: parse function is invalid."
end
end
if not (def.nodes_needed == nil or type(def.nodes_needed) == "function") then
return false, "Error: nodes_needed must be nil or function."
end
if not def.func then
return false, "Error: main function is invalid."
end
return true
end

@ -1,40 +0,0 @@
function worldeditadditions_core.chatcommand_handler(cmd_name, name, param)
local def = assert(worldedit.registered_commands[cmd_name], "Error: Failed to locate worldedit command definition for command '"..name.."' (this is probably a bug).")
if def.require_pos == 2 then
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 == nil or pos2 == nil then
worldedit.player_notify(name, "no region selected")
return
end
elseif def.require_pos == 1 then
local pos1 = worldedit.pos1[name]
if pos1 == nil then
worldedit.player_notify(name, "no position 1 selected")
return
end
end
local parsed = {def.parse(param)}
local success = table.remove(parsed, 1)
if not success then
worldedit.player_notify(name, parsed[1] or "invalid usage")
return
end
if def.nodes_needed then
local count = def.nodes_needed(name, unpack(parsed))
safe_region(name, count, function()
local success, msg = def.func(name, unpack(parsed))
if msg then
minetest.chat_send_player(name, msg)
end
end)
else
-- no "safe region" check
local success, msg = def.func(name, unpack(parsed))
if msg then
minetest.chat_send_player(name, msg)
end
end
end