Bugfix: don't error out on //flora → //bonemeal alias if bonemeal mod isn't installed

Also add worldeditadditions_core.command_exists to check both WEA and WEW for whether a command exists or not
This commit is contained in:
Starbeamrainbowlabs 2023-12-13 22:15:27 +00:00
parent 74a8996afc
commit 873ff4bef8
No known key found for this signature in database
GPG Key ID: C1C6C0BB001E1725
5 changed files with 32 additions and 2 deletions

@ -11,6 +11,9 @@ Note to self: See the bottom of this file for the release template text.
- Added [`//nodeapply`](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply), a generalisation of [`//airapply`](https://worldeditadditions.mooncarrot.space/Reference/#airapply) that works with a defined list of nodes. Check out [the reference](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply) - it has some cool tricks to it! (thanks for suggesting, @kliv91 from the Discord server!)
- Added [`//ngroups`](https://worldeditadditions.mooncarrot.space/Reference/#ngroups), which lists the groups that a given node is a member of. Useful when paired with [`//nodeapply`](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply)!
### Bugfixes and changes
- Don't warn on failed registration of `//flora` → [`//bonemeal`](https://worldeditadditions.mooncarrot.space/Reference/#bonemeal) if the `bonemeal` mod isn't installed (e.g. in MineClone2) - thanks @VorTechnix in #106
## v1.14.5: The multipoint update, hotfix 5 (1st August 2023)
- Fix a bug where creative players in survival couldn't punch out position markers

@ -7,7 +7,10 @@ wea_c.register_alias("conv", "convolve")
wea_c.register_alias("naturalise", "layers")
wea_c.register_alias("naturalize", "layers")
wea_c.register_alias("flora", "bonemeal")
if wea_c.command_exists("/bonemeal") then
-- No need to log here, since we notify the server admin in the server logs in the dofile() for the main //bonemeal command
wea_c.register_alias("flora", "bonemeal")
end
-- Measure Tools
wea_c.register_alias("mcount", "count")

@ -0,0 +1,23 @@
--- WorldEditAdditions chat command registration
-- @namespace worldeditadditions_core
local wea_c = worldeditadditions_core
--- Returns whether a WorldEditAdditions (or WorldEdit) command exists with the given name.
-- Note that this does NOT check for general Minetest chat commands - only commands registered through WorldEditAdditions or WorldEdit, if WorldEdit is currently loaded - the eventual plan is to make it an optional dependency.
-- @param cmdname string The name of the command to check for. Remember to remove the first forward slash! In other words if you would normally type `//layers` in-game, then you'd call `worldeditadditions.command_exists("/layers")`.
-- @param only_wea bool If true, then only check for WorldEditAdditions commands and not commands from related compatible mods such as WorldEdit.
-- @returns bool Whether a WorldEdit/WorldEditAdditions command exists with the given name.
local function command_exists(cmdname, only_wea)
if only_wea == nil then only_wea = false end
if wea_c.registered_commands[cmdname] ~= nil then
return true
end
if only_wea == true then return false end
if worldedit.registered_commands[cmdname] ~= nil then
return true
end
return false
end
return command_exists

@ -5,7 +5,7 @@
-- ██ ██ ███████ ██████ ██ ███████ ██ ███████ ██ ██
--- WorldEditAdditions chat command registration
-- @module worldeditadditions_core
-- @namespace worldeditadditions_core
local wea_c = worldeditadditions_core
local run_command = dofile(wea_c.modpath.."/core/run_command.lua")

@ -61,6 +61,7 @@ wea_c.setting_handler = dofile(wea_c.modpath.."/utils/setting_handler.lua") -- A
wea_c.pos = dofile(modpath.."/core/pos.lua") -- AFTER EventEmitter
wea_c.register_command = dofile(modpath.."/core/register_command.lua")
wea_c.command_exists = dofile(modpath.."/core/command_exists.lua")
wea_c.fetch_command_def = dofile(modpath.."/core/fetch_command_def.lua")
wea_c.register_alias = dofile(modpath.."/core/register_alias.lua")
wea_c.entities = dofile(modpath.."/core/entities/init.lua") -- AFTER pos