get every sign in the world
#1
Hi again,
Im working on a Protection Plugin that should be used by players not only admins

It works like this, you build an area with a fence and a fence_gate, place a sign in front of the fence_gate with [garden] on top line. My Plugin follows the fence and protects it for the Player who placed the sign.

I want this Plugin to be without database so I have to read every Sign in the World to know if it is a "Garden". currently im using the generating chunk hook to read every block and see if there is a sign. but that doesn't work for the spawn area or on reloads. so does someone has a idea how to archieve that?

current code -> https://github.com/danny9484/Gardens
Reply
Thanks given by:
#2
Believe me, it would be much better to use some kind of storage for the gardens, rather than inspecting chunk contents.

Problems with your approach:
- gardens across chunk borders - if only one half of the garden is present in a chunk currently being loaded, your plugin won't be able to trace the fences around it
- placement - if two gardens are placed next to each other, sharing a fence, your plugin will have trouble deciding what to trace
- placement - if a sign is placed in between two fence gates, your plugin will have trouble deciding which of the fence gates are the garden.
- reload - there's currently no way to enumerate all loaded chunks, so there's no way to enumerate sign entities in those; therefore no protection.
- performance - tracing the fences might produce TPS drops if not implemented carefully, especially when larger gardens are allowed.
Reply
Thanks given by:
#3
1. I could make sure the chunk is loaded/ load it if not while checking the fence
2. it also protects 1 block around each fence so that shouldn't happen, if 2 friends mess around with it well it could throw a broken garden or it's ont protected correctly but I don't think it's a big problem
3. nope fence_gates are handled like fences it would just follow them, you only need a fence_gate at start and it tries to get back to it following the fence or fence_gates.
4. thats were I see the real problem
5. I had the Idea to make a maximum fences counter which you can set in a ini file
Reply
Thanks given by:
#4
ok I will just use a database instead
Reply
Thanks given by:
#5
now a question I have created a Database now and saved the coordinates of a sign and the name of the world where it's placed

but how can I get a cWorld object from that world name?
I tried World = tolua.cast(World_name, "cWorld") but that doesn't seem to work
Reply
Thanks given by:
#6
nevermind via cRoot

I don't know why I didn't came to it
Reply
Thanks given by:
#7
I think you should instead store the coordinates of the entire garden, rather than just the sign, because otherwise you still have a problem on chunk boundaries - when a chunk is loaded that contains your sign, but not the entire garden, there's no way for the plugin to know what to protect at that point.

Oh, and by the way, you definitely don't want to load the entire DB into memory. Instead, you should keep, for each player, a table of gardens they are near to, and update that list whenever the player moves away. If you had everything in memory, it would slowly bring the server to its knees once there were many gardens.
Reply
Thanks given by:
#8
for the chunk problem couldn't I use GenerateChunk() while checking the fences (if i get blocktype = 0 (I think that means air or no chunk)) to force load the chunk? sure it's not the best performance wise but still it should work.

and about the db im not sure how big it could grow I will just say that im gonna try that out until I face a problem with that. I mean It's just a bunch of coordinates but I don't know.
Reply
Thanks given by:
#9
GenerateChunk() will only queue the chunk to be loaded at a later time, there's no immediate result for that.

Question: can your gardens be non-rectangular? If I put the fences down like in the following diagram, would this be accepted as a garden and what exactly will be protected?
Code:
...++++
...+--+
++++--+
G-----+
+++++++
(top-down view, "+" means fence, "G" is fencegate)
If this gets accepted as a garden, what will be protected? The fences, naturally, most likely the "-" area, but how about the "." area?
Reply
Thanks given by:
#10
Code:
     -----------
 ----++++++++++-
 -++++--------+-
 -+----      -+-
 -+-    ------+-
S-G-    -++++++-
 -+-    -+------
 -+------+-
 -++++++++-
 ----------

S is the sign
G gate
+ is the fence
- is the protection

yes they can be non-rectangular
it protects the fence and one block around each fence
the idea is that players could build a wall or something but im still not sure what I do against players who built over it and jump in the not protected field maybe teleporting them back if the gate is closed? would be a nice idea

but I faced another problem I started to write the fence coordinates in the database while tracing but it takes a little bit long and I think big fences will cause a deadlock. is there anyway to tell the deadlock protection that the process is still living?
Reply
Thanks given by:




Users browsing this thread: 3 Guest(s)