get every sign in the world - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: get every sign in the world (/thread-2403.html) |
get every sign in the world - danny9484 - 03-15-2016 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 RE: get every sign in the world - xoft - 03-15-2016 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. RE: get every sign in the world - danny9484 - 03-15-2016 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 RE: get every sign in the world - danny9484 - 03-15-2016 ok I will just use a database instead RE: get every sign in the world - danny9484 - 03-15-2016 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 RE: get every sign in the world - danny9484 - 03-15-2016 nevermind via cRoot I don't know why I didn't came to it RE: get every sign in the world - xoft - 03-16-2016 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. RE: get every sign in the world - danny9484 - 03-16-2016 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. RE: get every sign in the world - xoft - 03-18-2016 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: ...++++ If this gets accepted as a garden, what will be protected? The fences, naturally, most likely the "-" area, but how about the "." area? RE: get every sign in the world - danny9484 - 03-18-2016 Code: ----------- 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? |