Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1074 thank(s) in 852 post(s)
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.
Posts: 29
Threads: 3
Joined: Dec 2014
Thanks: 0
Given 0 thank(s) in 0 post(s)
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
Posts: 29
Threads: 3
Joined: Dec 2014
Thanks: 0
Given 0 thank(s) in 0 post(s)
ok I will just use a database instead
Posts: 29
Threads: 3
Joined: Dec 2014
Thanks: 0
Given 0 thank(s) in 0 post(s)
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
Posts: 29
Threads: 3
Joined: Dec 2014
Thanks: 0
Given 0 thank(s) in 0 post(s)
nevermind via cRoot
I don't know why I didn't came to it
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1074 thank(s) in 852 post(s)
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.
Posts: 29
Threads: 3
Joined: Dec 2014
Thanks: 0
Given 0 thank(s) in 0 post(s)
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.