[mod] Land Claim [0.7.1] [0gb_us]

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

[mod] Land Claim [0.7.1] [0gb_us]

by 0gb.us » Fri Nov 09, 2012 15:18

Development of 0gb_us as a single plugin will no longer continue. If anyone is still interested in this, it is still being developed as part of 0gb.us_game, the game used at 0gb.us:30000.

Topic: http://forum.minetest.net/viewtopic.php?id=3808
Github: https://github.com/0gb-us/0gb.us_game/tree/master/0gb.us_game

Note: In the game directory, it is not called 0gb_us, but landclaim_0gb_us




[mod] Land Claim [0.7.1] [0gb_us]

Code license: GNU LGPL version 2
Image license: CC Attribution-ShareAlike 3.0

Plugin dependencies: none (bucket, default, and fire are supported, however)

With version 0.2 and beyond, worlds that used the first two versions of this plugin cannot have the plugin just upgraded, as the code that makes them work runs in a radically different way. If you upgrade, all currently protected areas will loose their protection. Not a good idea.

The recipe for a single Land Claim block is:

Cobblestone, Cobblestone, Cobblestone
Cobblestone, Mese, Cobblestone
Cobblestone, Cobblestone, Cobblestone

If you want to own a lot of land, you will need to do a lot of digging. Once you find a decent mese mine though, your set.

To provide a cost to land ownership , as well as provide an easy way to allow users to stake their claims, land claim blocks may be crafted. Once placed on the map, they immediately disappear, but the placer now owns that map chunk (assuming it isn't claimed already). If the land has already been claimed (even by the block's placer) they will not be able to place the block, so they won't loose it for nothing. Once you have staked your claim, you will be the only player able to dig blocks, place blocks, and use buckets within that area, unless you share the area with others. Only the owner can add or remove more users to the list of users able to edit the area.

Map chunks were chosen, instead of protection ranges, to avoid having to look up the meta data of 11^3 nodes every time a block is placed or removed, and avoid having to check each protected area for collisions during protect block placement, and again when any block is dug or placed. Instead, a small amount of arithmetic is applied to the coordinates of the node, and the map chunk is immediately identified. This does have the disadvantage that protected ranges are harder to see, but hopefully the /landowner chat command will help with that.

Commands: (All require the interact privilege)

/landowner: Tells the player who's map chunk they are standing in. This can be helpful for making sure the edges of your constructions are within your property lines, or finding out who built that cool tower across the way.

/unclaim: If used in an area you actually own, you loose ownership of the map chunk, and your land claim block is returned to you.

/sharearea <name>: Adds <name> to the list of players who can edit the current map chunk, after checking to see if <name> is a valid player. This command only works if you own the map chunk. I'm not sure whether it is a bug or an optimization, but Minetest does not consider users who are not logged in to be valid users. So you can only add someone to the share list if they are currently online. I'll try to find a better way of implementing this, where invalid names are not accepted, but uses don't have to be logged in to be added.

/unsharearea <name>: Stops sharing the current map chunk with <name>, if you own the map chunk. Unlike /sharearea, this command accepts invalid arguments without flinching, and can remove someone from a share list even if they are not logged in.

/mayedit: Asked for by people on my server, this command lists all the users who may edit the current map chunk. Due to the way it is implemented, the first name listed will always be the owner. I may remove the /landowner command in the future, as this command makes it redundant.

/showarea: Puts a visual box around a map chunk, so you can see where the protection boundaries are. The box disappears in 16 seconds, and cannot be placed in an area you cannot edit.

Support for other plugins:

bucket:
If bucket is installed, buckets (full or empty) will not be usable in protected areas that you don't have permission to edit.

doors:
Prevents wooden and steel doors from being placed in protected areas, even though they are craft items before they are placed, not nodes. Also provides an API for protecting against other doors defined using PilzAdam'a doors definition API.

default:
If default is installed, sign text will be protected, if the sign is in a protected area. More importantly, default provides the ingredients for the Land Claim block's crafting recipe. If default is not installed, you will need to define a crafting recipe in another plugin, or use /give and /giveme to obtain them. Please note that Land Claim blocks DO NOT show up in the creative inventory unless default is installed. In addition,

fire:
Flammable objects within a claimed area will not catch fire. This was made possible by changes made in the fire plugin by PilzAdam recently, and is not compatible with 0.4.3's fire plugin. While this plugin will function without any fire plugin at all, it will stop the server from starting if the 0.4.3 version of fire is installed, without using one of several workarounds.

Download: http://0gb.us/minetest/download.php?plugin=0gb_us-0.7.1 (version 0.7.1)

Old downloads:
http://0gb.us/minetest/download.php?plugin=0gb_us-0.7 (version 0.7.0)
http://0gb.us/minetest/download.php?plugin=0gb_us-0.6 (version 0.6)
http://0gb.us/minetest/download.php?plugin=0gb_us-0.5 (version 0.5)
http://0gb.us/minetest/download.php?plugin=0gb_us-0.4 (version 0.4)
http://0gb.us/minetest/download.php?plugin=0gb_us-0.3 (version 0.3)
http://0gb.us/minetest/download.php?plugin=0gb_us-0.2 (version 0.2)
http://0gb.us/minetest/download.php?plugin=0gb_us-0.1 (version 0.1)
http://0gb.us/minetest/download.php?plugin=0gb_us-0.0 (version 0.0)

Change log:
- Version 0.0: Original version. Based heavily on Glomie's protector plugin, borrowing much of its code. However, this plugin protects against bucket-based attacks, and does not depend on the moreores plugin.
- Version 0.1: Due to abuse, I had to release this as a bug fix, before I could finish implementing my new idea. This version doesn't actually “fix a bug”, per se, but adds a failsafe, shutting off the protection field around blocks that have lost their meta data (due to influence from other plugins). In addition, the generic “area protected” message was replaced with a more specific message, telling you exactly who owns the area.
- Version 0.2: This should have been released as version 0.1, but that didn't happen. Land claim blocks now act nothing like Glomie's, and leave no visible trace on the map. In addition, I fixed two bugs in the modified bucket, one that I introduced, and one that is present in the default bucket.
- Version 0.3: Owned areas are now shareable, fire protection added, and all dependencies have been removed. Sign text is also protected.
- Version 0.4: Altered the code to restore compatibility with farming_plus, as well as split the code into multiple files to ease debugging. Most non-standard bucket definitions should work now.
- Version 0.5: Fixed a bug where doors can be placed in protected areas.
- Version 0.6: Fixed a bug introduced in version 0.5, which prevented doors from being placed in any claimed area, including your own. Also fixed an error introduced in version 0.4, which causes the server to crash if a player attempt to attack another player with a full bucket. This bug did not effect empty buckets.
- Version 0.7: Added /showarea, an API for defining custom land claims, and experimental support for the new crystal mese system. Said support will be stabilized when crystal mese itself has been stabilized. If you try to unclaim an area, but there is no room in your inventory to replace the claim item, the area will no longer be unclaimed anyway.
- Version 0.7.1: Zeg9 fixed the entity generated by /showarea. Now, it can be seen from the INSIDE, as well as the outside. Thank you Zeg9!

TO DO:
- Contemplate ways to defend against people planting trees under your house. Trees no longer eat blocks when they grow (my very favorite new feature in Minetest 0.4.4), but attackers can still put leaves on your floor this way. Admittedly, this is a minimal threat, but I've always been paranoid.
- Find other vulnerabilities to fix
- Add support for more plugins, in a separate extended support pack
- Celebrate out victory over the vandals
Last edited by 0gb.us on Sat Feb 23, 2013 19:29, edited 1 time in total.
 

sky
Member
 
Posts: 152
Joined: Tue Oct 16, 2012 11:59
Location: SKY

by sky » Fri Nov 09, 2012 16:19

can you tell people what this mod adds but in like 5 sentences because it is too booring to read 50 sentences
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Fri Nov 09, 2012 17:08

Okay. It adds a protection block. If you know Glomie's, this does the same thing, but also protects against buckets. Nodes within a five node radius can only be modified by the block's placer. This plugin also, unlike Glomie's, only depends on plugins from the default set (default and bucket).
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Thu Nov 15, 2012 22:47

Okay, I had decided to take this plugin in a completely different direction, and had been trying to figure out how to rewrite the code. We found a glitch in mesecons_pistons that, when combined with this block, creates a cloning machine. However, someone on my server decided to abuse a glitch to clone land claim blocks, even after I warned them that it would create ownerless protect block, also creating areas where NO ONE can edit. What a mess. So I had to spend a sleepless night trying to fix the mess.

Anyway, I couldn't fix the cloning from my end, but the uneditable areas are now fixed. Any land claim block without an owner effectively is not a land claim block anymore. In addition, for debugging, I changed the "area protected" line the server responds with to "Area claimed by <player name>" . It seems useful, so I left it when I was done.

If you are using version 0.0 of this plugin, but not using mesecons_piston, there is no real reason to upgrade. Version 0.0 is, to the best of my knowledge, bug free. If you ARE using mesecons_piston, do a search and replace on mesecons_piston/init.lua. Replace all occurrences of "dig_node" with "remove_node". In addition, if anyone created ownerless land claim blocks, upgrade to make them removable.
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Sat Nov 17, 2012 15:23

As I said a couple days ago, I was rebuilding this plugin from the ground up. And the result is version 0.2. [s]I'll have another update in a couple days, to add a working API[/s], but after that, this thing's basically finished, unless someone finds some bugs for me to fix.

I've now removed all traces of Glomie's code. It made a great place to start when I couldn't figure out how to protect things, and I really appreciate it, but his style of protection has already been used (by him). I don't think my added bucket protection was really enough to justify my building a clone of his plugin.

I'm not sure if anyone's actually using this though, with more popular protection plugins available. Oh well, I'm building this for my own personal use anyway, and I'm still getting what I need out of it.

EDIT: It turns out I only need one extra function for the API. For convenience, I added two. I'm just going to reupload, and call it part of 0.2.
Last edited by 0gb.us on Sat Nov 17, 2012 18:12, edited 1 time in total.
 

babyface1031
Member
 
Posts: 51
Joined: Sat Sep 29, 2012 20:20

by babyface1031 » Sat Nov 24, 2012 00:53

is the land owned the same size as gloomie protect block?
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Sun Nov 25, 2012 14:58

No, these blocks protect a 16^3 area. However, unlike Glomie's, the protected area is not centred on the block, but rather it protects the map chunk it it placed in. It makes block placing a little harder to plan, but it also should be faster, because Glomie's has to check 11^3 blocks to see if they are protect blocks, and this only has to perform a little math, then check a single table entry.
 

Nubelite
Member
 
Posts: 161
Joined: Mon Jul 16, 2012 23:10

by Nubelite » Sun Nov 25, 2012 18:08

Can this let multiple users own the same land? So its protected but more them one can build.
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Mon Nov 26, 2012 03:05

The version that's uploaded? No. The beta version on my server? Yes. Before I can release the next version though, I need to build an /unshare option. Currently, to unshare previously shared land, you must unclaim and reclaim the land, which removes ALL players from the list of people being shared with, and gives trolls half a second to claim your land. I also need to make it so you cannot share land with yourself, as that wouldn't make any sense, and just bloats up the file. A /sharedwith command would be nice as well, so you wouldn't have to remember who could access your land.

The next version also defends against fire, so lava being poured just outside your area by trolls will be less of a problem for wooden objects.

To come: I want to make locked chests shareable. But maybe that should be a separate plugin. I might want to add a boolean as well, that decides if signs and furnaces in a particular protected area are protected as well. But perhaps that should be left for other existing plugins, such as locked_sign and locked_furnace.
Last edited by 0gb.us on Mon Nov 26, 2012 03:10, edited 1 time in total.
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Fri Dec 07, 2012 20:33

Sharing areas is now possible. I would have had this out sooner, but I already had to throw in an anti-fire hack. Until 0.4.4's release, I couldn't create proper fire protection. Before creating proper fire protection, I couldn't safely remove the hack. And of course,before removing the hack, I couldn't feel good about releasing this.

Sharing locked chests has been deemed impossible without either loosing this plugin's minimal footprint policy (removing this plugin will leave no trace that it was ever installed, besides the single unknown item), creating arbitrarily large and cumbersome data structures, or hooking it into the map chunk protection (so ALL locked chests in a map chunk would be shared, even if you want to share only one). Shared locked chests are outside the scope of this plugin anyway, and should probably be handled by defining a new node, or something. The same applies to protected furnaces.

I was reluctant to add fire protection, as it would create a dependency on fire, which most server owners seem to remove. Besides, as long as you protect you home with this plugin and build the outside of your home out of non-flamable materials, everything inside would be safe, because this no one can dump lava in protected areas. But wood seems to be a popular building material, and there was an arsonist loose on my server, so something had to be done.

So I found a way to depend on fire while also not depending on fire, if that makes any sense. But why stop there? This plugin no longer has any “hard dependencies”.

In addition, we had someone writing colorful words on other people's signs. Signs are now protected. Doors and chests will not be protected, because you can just use locked chests and steel doors if you need them protected. I don't know what to do about sharing locked chests, but sharing a locked room couldn't be simpler. Each user can place their own locked door on the wall.
 

Sokomine
Member
 
Posts: 3616
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

by Sokomine » Sat Dec 08, 2012 06:29

For shared locked chests, just use my locks mod. It also provides shared locked signs and doors (can be disabled by deleting one line).

Your landclaim mod looks intresting. I wonder in which situations which approach of protection might be the best. How well does lua handle large tables?
A list of my mods can be found here.
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Sat Dec 08, 2012 08:24

Sorry in advance for the overly long post. It's just that I REALLY care about block protection, and spend a lot of time thinking about it. Obsessed? Maybe. But I do what it takes to minimize threats on my server.

Sokomine wrote:For shared locked chests, just use my locks mod. It also provides shared locked signs and doors (can be disabled by deleting one line).

Your landclaim mod looks intresting. I wonder in which situations which approach of protection might be the best. How well does lua handle large tables?


Oh cool, your plugin looks great! I do have one concern with it though. I defines a /set command, which overrides the default /set command used by people with the server privilege to change the server's settings. Is there any chance you'll change the name of that command to fix that?

I don't know how well Lua handles large tables, but if it doesn't handle them well, I could switch the data structure format to use smaller nested tables, indexed as claims[x][y][z]. My main fear is that the whole table stays in RAM while the server is up. Too much data in RAM could slow the server causing lag. I could break the file into several pieces, and have each piece load and unload as needed, but it would require more loading from the hard drive, which I hear is slow.

I want to use "map chunk meta data" to handle this (in fact, that was my initial plan), but I don't think Minetest has that. If it did, performance issues would be minimized. (It seems that there is some sort of map chunk meta data used in the C++ for something, but there doesn't seem to be a way of using this in Lua.)

I think my plugin works better on computers with lower processing power, and Glomie's portector works better on computers with less RAM. And for computers where processing power is even less of a concern, there's also Aqua's protectorplus, if you want to add variance to the protection ranges.

Ignoring performance and focusing on users, my plugin has had to evolve into a protection plugin for a hostile world. Most servers remove fire, and I think many disable lava above ground. My implementation provides protection for worlds that don't take these precautions. protector and protectorplus on the other hand, do not provide this protection, but do provide better customization of protect range locations. If you place one of my blocks, it locks the current map chunk, but if you place one from protector or protectorplus, it locks an area centred on the block. In addition, the block remains on the map, providing a point to measure from, to see if all your stuff is protected. In addition, protector (and I believe protectorpluss, but it has been a while since I read its source code) automatically protects any block below y=-999. This probably helps in reducing the size of your map.sqlite file, but prevents users from digging arbitrarily deep, creating a big flat spot at that depth, where most mining tunnels gather and fan out.

Long story short, which plugin is "best" depends on what your needs are.

To be honest, I like all three, but Glomie's will always have a special place in my heart, as it was the first protection plugin I had ever seen. I would have used protector and just built a plugin that depends on it to protect against fire and buckets, but I didn't want to satisfy protector's dependency on moreores in my minimalistic world. I would have done the same with protectorplus, but by the time that was released, mine was almost ready to be released itself. I like how mine turned out best (if I didn't, I'd just modify it some more), but I think all three are a great way to put protection in the hands of your users, as opposed to making users ask an administrator for a protected area.
 

tux_peng
Member
 
Posts: 99
Joined: Thu Dec 06, 2012 18:21

by tux_peng » Mon Dec 10, 2012 03:59

With protector+, areas can overlap- no one can build then. If someone puts a protection block right on the edge of another protected area, then no one can build in between the protection blocks. Can anything like that happen with this?
Servers now up (Economy, no PvP) Forum up already! http://tuxcraft.info
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Mon Dec 10, 2012 08:25

Short answer: No. That can never happen, as long as this is the only block protection in place.

Using any two types of block protection at once risks creating these uneditable areas though.

Long answer: All protect-able areas are predefined, so even two of the same person's protected areas cannot overlap. A protect block placed anywhere in one of these areas will protect the whole area, and will not allow another protect block to be placed there.

EDIT: By "types of block protection", I mean block protection plugins. For example, you should never use Aqua's protect blocks together with Glomie's protect blocks, or this protection with node_ownership, or any other combination.
Last edited by 0gb.us on Mon Dec 10, 2012 08:28, edited 1 time in total.
 

Kryuko
Member
 
Posts: 76
Joined: Tue Dec 11, 2012 20:26

by Kryuko » Thu Dec 13, 2012 13:24

how can I set the blocks to claim only 3 ^ 3 blocks?
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Thu Dec 13, 2012 22:30

I hadn't thought about making the size adjustable, so I had to look at the code again. It's actually a lot easier than I thought. Find this function in init.lua:

Code: Select all
function us_0gb.get_chunk(pos)
    local x = math.floor(pos.x/16)
    local y = math.floor(pos.y/16)
    local z = math.floor(pos.z/16)
    return x..","..y..","..z
end


Change the "16"s int "3"s, so it looks like this (or just copy and paste this version):
Code: Select all
function us_0gb.get_chunk(pos)
    local x = math.floor(pos.x/3)
    local y = math.floor(pos.y/3)
    local z = math.floor(pos.z/3)
    return x..","..y..","..z
end


Keep in mind though, that the smaller the area protected, the bigger the data structure created will be. So setting the area size to 32^3 will use less RAM and disk space, but setting it to 8^3 will use more RAM and disk space.
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Fri Dec 14, 2012 11:12

It was brought to my attention that when this plugin is used with farming_plus, the game won't start. When redefining the buckets to not work in other people's protected areas, this plugin assumed the buckets had been defined in the standard way, with bucket.register_liquid(). However, farming_plus uses buckets in an unusual way, such that calling that function wouldn't have worked.

It was difficult to find a workaround without using an item-specific hack, but 0gb_us is now compatible with farming_plus, as well as most other non-standard bucket use. In addition, I was able to remove the code I copied from bucket/init.lua, so any changes made to the main bucket plugin will not require this plugin to be updated.

Now, I want to build an extended support pack, for servers that use a lot of plugins. If you know of a plugin that vandals can use to deface your property, post it here, and I will try to add support for it. I'm only adding support for plugins that are included in minetest_game or that are specifically requested, so if you want support, speak up.
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Fri Dec 14, 2012 11:15

I just posted the bug fix. Download the new version, and the bug will trouble you no more.
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11
Location: Earth

by jojoa1997 » Fri Dec 14, 2012 11:16

Yah i had posted on what i saw before you added it. Thanks
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

Kryuko
Member
 
Posts: 76
Joined: Tue Dec 11, 2012 20:26

by Kryuko » Fri Dec 14, 2012 22:51

Why the claim is not centered?
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Fri Dec 14, 2012 23:05

For efficiency, this plugin uses predefined regions to protect. That way, it doesn't have to check 11^3 (1331) nodes for protection like protector does, and doesn't have to check EVERY defined protected area, the way node_ownership does.

The down side is that it is a little less intuitive to use. You need to make sure your whole building is protected by trying to place a land claim block at all four corners, instead of counting the distance from where you placed the block.
 

User avatar
BrandonReese
Member
 
Posts: 839
Joined: Wed Sep 12, 2012 00:44
Location: USA
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

by BrandonReese » Sat Dec 15, 2012 02:26

0gb.us wrote:For efficiency, this plugin uses predefined regions to protect. That way, it doesn't have to check 11^3 (1331) nodes for protection like protector does, and doesn't have to check EVERY defined protected area, the way node_ownership does.

The down side is that it is a little less intuitive to use. You need to make sure your whole building is protected by trying to place a land claim block at all four corners, instead of counting the distance from where you placed the block.


That makes sense now. I couldn't understand why I would drop a land claim block, and the block right next it it wouldn't be owned by me.
 

Kryuko
Member
 
Posts: 76
Joined: Tue Dec 11, 2012 20:26

by Kryuko » Sun Dec 16, 2012 20:05

How can i able the claim blocks for only admins?
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Mon Dec 17, 2012 02:29

You would need to claim the area, then use /sharearea to share it whit each admin. Due to a bug in Minetest, you can only share an area with someone who is currently online though. I'm looking for a workaround to that.
 

Kryuko
Member
 
Posts: 76
Joined: Tue Dec 11, 2012 20:26

by Kryuko » Mon Dec 17, 2012 10:22

Ok, but i want to make the "claim land" craftable/usable by only admins.
It's possible?

And it's possible create a special claim land block, to use only in the spawn areas?
 

Next

Return to Old Mods



Who is online

Users browsing this forum: No registered users and 1 guest