{"action":"created","issue":{"url":"https://api.github.com/repos/benbaptist/minecraft-wrapper/issues/175","labels_url":"https://api.github.com/repos/benbaptist/minecraft-wrapper/issues/175/labels{/name}","comments_url":"https://api.github.com/repos/benbaptist/minecraft-wrapper/issues/175/comments","events_url":"https://api.github.com/repos/benbaptist/minecraft-wrapper/issues/175/events","html_url":"https://github.com/benbaptist/minecraft-wrapper/issues/175","id":66651697,"number":175,"title":"protection plugin","user":{"login":"Cougar","id":60040,"avatar_url":"https://avatars.githubusercontent.com/u/60040?v=3","gravatar_id":"","url":"https://api.github.com/users/Cougar","html_url":"https://github.com/Cougar","followers_url":"https://api.github.com/users/Cougar/followers","following_url":"https://api.github.com/users/Cougar/following{/other_user}","gists_url":"https://api.github.com/users/Cougar/gists{/gist_id}","starred_url":"https://api.github.com/users/Cougar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cougar/subscriptions","organizations_url":"https://api.github.com/users/Cougar/orgs","repos_url":"https://api.github.com/users/Cougar/repos","events_url":"https://api.github.com/users/Cougar/events{/privacy}","received_events_url":"https://api.github.com/users/Cougar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-04-06T16:51:58Z","updated_at":"2015-04-06T18:16:49Z","closed_at":null,"body":"I'm developing plugin to manage world protection for spawns and warps. This could  also be used for players (and teams) to give them protected areas for building.\r\n\r\nIt basically works but due no block visibility in proxy, it needs different workarounds and not all things can be done. For example I can get area information when clicking area (with stick for example) but I can't make area visible like Bukkit plugins can do.\r\n\r\nOne thing I'm stuck a little bit is the performance of the code. I haven't found any good library for fast coordinate lookup. Just having array of (x1, z1, x2, z2) duples and doing linear lookup doesn't scale well. Especially if every \"dig\", \"place\" and \"interact\" events needs to be processed. Every new protected area adds search time. I already have some ideas how to optimize it but I'm sure that this kind of problems are solved before.\r\n\r\nDoes anyone know any good python library for such lookups?"},"comment":{"url":"https://api.github.com/repos/benbaptist/minecraft-wrapper/issues/comments/90181715","html_url":"https://github.com/benbaptist/minecraft-wrapper/issues/175#issuecomment-90181715","issue_url":"https://api.github.com/repos/benbaptist/minecraft-wrapper/issues/175","id":90181715,"user":{"login":"Cougar","id":60040,"avatar_url":"https://avatars.githubusercontent.com/u/60040?v=3","gravatar_id":"","url":"https://api.github.com/users/Cougar","html_url":"https://github.com/Cougar","followers_url":"https://api.github.com/users/Cougar/followers","following_url":"https://api.github.com/users/Cougar/following{/other_user}","gists_url":"https://api.github.com/users/Cougar/gists{/gist_id}","starred_url":"https://api.github.com/users/Cougar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cougar/subscriptions","organizations_url":"https://api.github.com/users/Cougar/orgs","repos_url":"https://api.github.com/users/Cougar/repos","events_url":"https://api.github.com/users/Cougar/events{/privacy}","received_events_url":"https://api.github.com/users/Cougar/received_events","type":"User","site_admin":false},"created_at":"2015-04-06T18:16:49Z","updated_at":"2015-04-06T18:16:49Z","body":"Yes, I see. In action_rightclick() you just go through all regions\r\n```\r\nfor name in self.regions[\"regions\"]:  #see if block break occurs in a region.\r\n…\r\n```\r\nThis is exactly what I think is too slow. Of course could be that tens or even hundreds of regions doesn't matter much but if you do it for every client action then it will be quite a big overhead.\r\n\r\nI have two ideas here.\r\n\r\n1. Create \"free land\" regions so that all coordinates are covered by region. Then every lookup find a match (in next point why it is important). Of course any change in regions will cause recalculation of these free regions. It is doable but here I would like to find a existing library instead of doing it from scratch.\r\n\r\n2. Cache last region or small number of regions for every user. This way you always start searching from the same region you last matched. This will make searching very fast because you usually don't cycle between multiple regions too often. For edge cases multiple regions can be cached and ordered. For instance in case of 100 protected regions the 1-5 region cache makes search even 20-100 times faster.\r\n\r\nDo you have your plugins anywhere in Github? I see that \"guarddog\" plugin needs some \"global\" plugin to work. This sis something I haven't used yet (plugin dependencies) ;-)"}}