Add server privs restriction to mcl_villages build tool #4043

Merged
chmodsayshello merged 10 commits from Eliy21/MineClone2:restrict_villages_tool_privs into master 2023-12-05 13:49:51 +01:00
Contributor

Fixes #4022

Testing

-Make a new world, check host server and go into creative mode
-Since you're the server you have the server privs so get the mcl_villages build tool item in creative inventory and use it to see if it works
-Have someone join your server and give them the same item to use and see if they are restricted from using it

<!-- Please follow our contributing guidelines first: https://git.minetest.land/MineClone2/MineClone2/src/branch/master/CONTRIBUTING.md#how-you-can-help-as-a-programmer By submitting this pull request, you agree to follow our Code of Conduct: https://git.minetest.land/MineClone2/MineClone2/src/branch/master/CODE_OF_CONDUCT.md --> Fixes #4022 ### Testing -Make a new world, check host server and go into creative mode -Since you're the server you have the server privs so get the mcl_villages build tool item in creative inventory and use it to see if it works -Have someone join your server and give them the same item to use and see if they are restricted from using it
Eliy21 force-pushed restrict_villages_tool_privs from e7704fc9bc to f14cff4649 2023-12-02 15:23:12 +01:00 Compare
chmodsayshello requested changes 2023-12-02 19:51:56 +01:00
@ -130,1 +130,4 @@
if not pointed_thing.under then return end
local name = placer:get_player_name()
local privs = minetest.get_player_privs(name)
if not privs.server then
Member

why are you getting the name of the player, then all their privileges, just to finally check if the resulting table contains a single value?

I suggest the use of minetest.check_player_privs(placer, "server")
For reference: https://github.com/minetest/minetest/blob/master/doc/lua_api.md#authentication

why are you getting the name of the player, then all their privileges, just to finally check if the resulting table contains a single value? I suggest the use of `minetest.check_player_privs(placer, "server")` For reference: https://github.com/minetest/minetest/blob/master/doc/lua_api.md#authentication
Author
Contributor

I just copied the placing barriers code. Now edited the code to your suggestion.

I just copied the placing barriers code. Now edited the code to your suggestion.
chmodsayshello marked this conversation as resolved
@ -131,0 +131,4 @@
local name = placer:get_player_name()
local privs = minetest.get_player_privs(name)
if not privs.server then
minetest.chat_send_player(name, "Placement denied. You need the “server” privilege to place villages.")
Member

Please use minetest's translation functionality for messages sent to the player, and update the template.
Oh, and, while ofc you don't have to update all languages, in german, it'd be

Platzierung verweigert. Sie benötigen das "server" Privileg, um Dörfer zu platzieren.

Please use minetest's translation functionality for messages sent to the player, and update the template. Oh, and, while ofc you don't have to update all languages, in german, it'd be > Platzierung verweigert. Sie benötigen das "server" Privileg, um Dörfer zu platzieren.
Author
Contributor

There's no German translation file so I made one and placed your suggested translation there while using DeepL translation on the rest.

There's no German translation file so I made one and placed your suggested translation there while using DeepL translation on the rest.
Member

Oops, sorry, didn't notice, anyways, thanks for updating the template

Oops, sorry, didn't notice, anyways, thanks for updating the template
chmodsayshello marked this conversation as resolved
@ -131,0 +132,4 @@
local privs = minetest.get_player_privs(name)
if not privs.server then
minetest.chat_send_player(name, "Placement denied. You need the “server” privilege to place villages.")
return itemstack
Member

I don't quite get why you return the itemstack, that technically modifies the inventory.

on_place = function(itemstack, placer, pointed_thing),
-- When the 'place' key was pressed with the item in hand
-- and a node was pointed at.
-- Shall place item and return the leftover itemstack
-- or nil to not modify the inventory.
-- The placer may be any ObjectRef or nil.
-- default: minetest.item_place

Might be better just to return without any values

I don't quite get why you return the itemstack, that technically modifies the inventory. > on_place = function(itemstack, placer, pointed_thing), > -- When the 'place' key was pressed with the item in hand > -- and a node was pointed at. > -- Shall place item and return the leftover itemstack > -- or nil to not modify the inventory. > -- The placer may be any ObjectRef or nil. > -- default: minetest.item_place Might be better just to return without any values
Author
Contributor

Just copied the code and tested that it works and just left it there. Now itemstack is removed per your suggestion.

Just copied the code and tested that it works and just left it there. Now itemstack is removed per your suggestion.
chmodsayshello marked this conversation as resolved
chmodsayshello added the
#P6: low
items
creative mode
multiplayer
labels 2023-12-02 19:53:20 +01:00
Eliy21 requested review from chmodsayshello 2023-12-04 10:03:58 +01:00
chmodsayshello reviewed 2023-12-04 20:00:53 +01:00
@ -0,0 +1,4 @@
# textdomain: mcl_villages
Chiseled Stone Village Bricks=Dorfziegel aus gemeißeltem Stein
mcl_villages build tool=mcl_villages Werkzeug erstellen
Member

There's a grammar mistake in here, should just "mcl_villages Konstruktionswerkzeug"… anyways, I don't want to further bother you with the German language, wouldn't have raised the point if I knew there wasn't a translation before.

I cannot push to your branch, but, in case the PR isn't merged already when you are reading this, here is a patch you can just apply (it's basically like handing you a (or multiple) git commits in file form).

You could apply it by placing the file below in your git repository and running git am < 0001-fix-german-grammar-mistake-in-mcl_villages.patch, simply push afterwards...

Looks like you can actually do it in the GUI, though I don't recommend doing git stuff using it that much

There's a grammar mistake in here, should just "mcl_villages Konstruktionswerkzeug"… anyways, I don't want to further bother you with the German language, wouldn't have raised the point if I knew there wasn't a translation before. I cannot push to your branch, but, in case the PR isn't merged already when you are reading this, here is a patch you can just apply (it's basically like handing you a (or multiple) git commits in file form). You could apply it by placing the file below in your git repository and running `git am < 0001-fix-german-grammar-mistake-in-mcl_villages.patch`, simply push afterwards... Looks like you can actually do it in the GUI, though I don't recommend doing git stuff using it that much ![](https://git.minetest.land/attachments/21a6aba2-c875-4119-966f-505e2cc5a3ca)

FYI I don't see any patch attachment in this comment.

FYI I don't see any patch attachment in this comment.
chmodsayshello approved these changes 2023-12-04 20:14:54 +01:00
Dismissed
Eliy21 dismissed chmodsayshello’s review 2023-12-05 00:21:16 +01:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

Author
Contributor

Oops I thought I could just commit the changes myself sorry. Next time I'll check the "allow edit" for my PRs in the future.

Oops I thought I could just commit the changes myself sorry. Next time I'll check the "allow edit" for my PRs in the future.
Eliy21 force-pushed restrict_villages_tool_privs from fad2c892b9 to d53e819a47 2023-12-05 00:25:38 +01:00 Compare
Eliy21 added 1 commit 2023-12-05 00:47:59 +01:00
chmodsayshello approved these changes 2023-12-05 13:49:10 +01:00
chmodsayshello merged commit 4127d120d2 into master 2023-12-05 13:49:51 +01:00
Member

Merged a squashed version of your PR as I thought having 10 commits for this might be a bit overkill ;)

Merged a squashed version of your PR as I thought having 10 commits for this might be a bit overkill ;)
the-real-herowl added this to the 0.85.0 - Fire and Stone milestone 2023-12-05 15:18:59 +01:00
Sign in to join this conversation.
No reviewers
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#4043
No description provided.