diff --git a/README.md b/README.md index 850b42a9..a6a2e77a 100644 --- a/README.md +++ b/README.md @@ -579,6 +579,6 @@ The game includes the mods from the default [minetest_game](https://github.com/m [patch.trash_can]: https://github.com/AntumMT/mod-trash_can/tree/5a92bf4 [patch.unifieddyes]: https://github.com/AntumMT/mod-unifieddyes/tree/9c2f740 [patch.walking_light]: https://github.com/AntumMT/mod-walking_light/tree/e602515 -[patch.whitelist]: https://github.com/AntumMT/mod-whitelist/tree/d0e1f48 +[patch.whitelist]: https://github.com/AntumMT/mod-whitelist/tree/13e8686 [patch.windmill]: https://github.com/AntumMT/mod-windmill/tree/7756ab4 [patch.workbench]: https://github.com/AntumMT/mod-workbench/tree/b964323 diff --git a/minetest.conf.example b/minetest.conf.example index b1db0a24..a0ea49ed 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1619,6 +1619,24 @@ inventory = sfinv +########### +## ADMIN ## +########### + +# *** whitelist *** + +## Enables/Disables whitelist feature. +# type: bool +# default: false +#whitelist.enable = false + +## Sets a custom message to display when access to server is denied. +# type: string +# default: This server is whitelisted and you are not on the whitelist. +#whitelist.message = This server is whitelisted and you are not on the whitelist. + + + ##################### ## TOOLS / WEAPONS ## ##################### diff --git a/mods/admin/whitelist/README.md b/mods/admin/whitelist/README.md new file mode 100644 index 00000000..ed1358d2 --- /dev/null +++ b/mods/admin/whitelist/README.md @@ -0,0 +1,28 @@ +## Whitelist Mod for [Minetest][] + + +--- +### **Description:** + +This is a simple Minetest mod that adds a player whitelist. Any player names not found in the whitelist are denied access to the server. + +- Commands: + - ***/whitelist add *** + - Adds a username to whitelist & allows access to server. + - ***/whitelist remove *** + - Removes a username from whitelist & denies access to server. +- Settings: + - ***whitelist.enable*** + - Enables/Disables denying access to users not on the whitelist. + - Disabled by default. + - ***whitelist.message*** + - Changes the default message *"This server is whitelisted and you are not on the whitelist."* + + +--- +### **Licensing:** + +CC0 + + +[Minetest]: http://www.minetest.net/ diff --git a/mods/admin/whitelist/init.lua b/mods/admin/whitelist/init.lua index 3a5385c9..56a71d93 100644 --- a/mods/admin/whitelist/init.lua +++ b/mods/admin/whitelist/init.lua @@ -7,6 +7,10 @@ local world_path = minetest.get_worldpath() local admin = minetest.settings:get("name") local whitelist = {} +-- Disabled by default +local enabled = minetest.settings:get_bool("whitelist.enable") == true +local deny_message = minetest.settings:get("whitelist.message") or "This server is whitelisted and you are not on the whitelist." + local function load_whitelist() local file, err = io.open(world_path.."/whitelist.txt", "r") if err then @@ -31,12 +35,14 @@ end load_whitelist() -minetest.register_on_prejoinplayer(function(name, ip) - if name == "singleplayer" or name == admin or whitelist[name] then - return - end - return "This server is whitelisted and you are not on the whitelist." -end) +if enabled then + minetest.register_on_prejoinplayer(function(name, ip) + if name == "singleplayer" or name == admin or whitelist[name] then + return + end + return deny_message + end) +end minetest.register_chatcommand("whitelist", { params = "{add|remove} ", diff --git a/mods/admin/whitelist/settingtypes.txt b/mods/admin/whitelist/settingtypes.txt new file mode 100644 index 00000000..877f2b40 --- /dev/null +++ b/mods/admin/whitelist/settingtypes.txt @@ -0,0 +1,6 @@ + +# Enables/Disables whitelist feature. +whitelist.enable (Enable whitelist) bool false + +# Sets a custom message to display when access to server is denied. +whitelist.message (Whitelist message) string This server is whitelisted and you are not on the whitelist. diff --git a/settingtypes.txt b/settingtypes.txt index 3ed6b618..c3cb5673 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -426,6 +426,15 @@ spawneggs.grass_chance (Grass chance) int 3000 spawneggs.enable_node_spawn (Enable node spawn) bool true +[*whitelist] + +# Enables/Disables whitelist feature. +whitelist.enable (Enable whitelist) bool false + +# Sets a custom message to display when access to server is denied. +whitelist.message (Whitelist message) string This server is whitelisted and you are not on the whitelist. + + # --------------------------------------------------------------------------------- [Modpacks]