[{"data":1,"prerenderedAt":159},["ShallowReactive",2],{"project--15-04-2024-dev-blog-2-build-a-skyblock-plugin":3},{"id":4,"title":5,"body":6,"description":141,"extension":142,"meta":143,"navigation":154,"path":155,"seo":156,"stem":157,"__hash__":158},"blog\u002Fblog\u002F15-04-2024-dev-blog-2-build-a-skyblock-plugin.md","Build a Skyblock Plugin (part 2): Island System",{"type":7,"value":8,"toc":132},"minimark",[9,14,22,27,33,44,48,54,57,63,66,75,79,88,91,94,98,101,104,107,110,113,119,122,126,129],[10,11,13],"h1",{"id":12},"dev-blog-2-build-a-skyblock-plugin-island-system","Dev Blog #2: Build a Skyblock Plugin: Island System",[15,16,17,18,21],"p",{},"In the last article, we have created the basic structure of our plugin.",[19,20],"br",{},"\nIn this article, we will create the island system that is the core of the Skyblock plugin.",[23,24,26],"h2",{"id":25},"considerations-requirements","Considerations \u002F Requirements",[15,28,29,30,32],{},"For the cross-server support, I choose to use a cache system. I will use Redis for now with the Jedis client.",[19,31],{},"\nThe cache system will permit reducing the number of requests to the database, share data between servers, improve the\nperformance of the plugin, and allow using a message broker like Redis Pub\u002FSub for cross-server communication.",[15,34,35,36,43],{},"Also, I will use ",[37,38,42],"a",{"href":39,"rel":40},"https:\u002F\u002Fwww.spigotmc.org\u002Fresources\u002Fadvanced-slimeworldmanager.87209\u002F",[41],"nofollow","Advanced Slimeworldmanager"," for\nworld management. This plugin will allow creating, managing, and storing islands in the MySQL database.",[23,45,47],{"id":46},"island-world-system","Island World System",[15,49,50,51,53],{},"Thanks to Advanced Slimeworldmanager, we can easily set up the island system.",[19,52],{},"\nWe just need to create a generic island world, save it in the database as read-only, and then clone it when a player\ncreates an island.",[15,55,56],{},"With this approach, we can have multiple types of islands, such as desert or jungle islands, without struggling with\nFAWE (FastAsyncWorldEdit) or the WorldEdit API, which is not very easy to use. I have already created a Skyblock plugin\nwith this method and got accustomed to it.",[15,58,59,60,62],{},"Another benefit of ASWM (Advanced Slimeworldmanager) is that we can store our worlds in the database. This is very\nuseful for cross-server support.",[19,61],{},"\nWith its API, we can easily load, clone, save, and unload worlds like a normal world but much faster since it was\ndesigned for small worlds.",[15,64,65],{},"I decided to name my worlds \"islands_\" followed by the UUID of the island. A clear name that is unique and easy to find\nin the database.",[15,67,68,69,71,72,74],{},"The downside of ASWM is that it doesn't allow storing huge worlds like a survival world by default, as it wasn't\ndesigned for that.",[19,70],{},"\nHowever, for small worlds like islands, it's perfect. Also, MySQL servers by default don't allow storing huge blobs (\n16MB by default), but we can change that in the configuration.",[19,73],{},"\nFor example, an island world with dimensions 250x250x320 has little chance of exceeding 16MB (though it's possible).",[23,76,78],{"id":77},"island-cross-server-system","Island Cross Server System",[15,80,81,82,84,85,87],{},"First, each island server sends a Pub\u002FSub message every 3 to 5 seconds. This allows the plugin to monitor the server\nload.",[19,83],{},"\nThen, on all servers, the plugin receives the message and stores it locally. The plugin will choose the server with the\nlowest load to create the island.",[19,86],{},"\nThis approach allows distributing the load of islands across all servers and easily adding or removing servers.",[15,89,90],{},"Once a server is selected, it will send a Pub\u002FSub message to the chosen server to create or load the island. When\nloaded, the remote server sends a confirmation message to the selected server, indicating the island is loaded, and the\nplayer can join.",[15,92,93],{},"The next step is to implement a similar system for teleportation. We send the player to another server, and at the same\ntime, we send a Pub\u002FSub message to the server to teleport the player to the island or elsewhere.",[23,95,97],{"id":96},"island-functionalities","Island Functionalities",[15,99,100],{},"As you may know, you can invite, kick, ban, expel, promote, demote, etc., players on your island in any Skyblock plugin.",[15,102,103],{},"I implemented all these functionalities in my plugin. BUT, there's a small constraint: the player must be on the server\nwhere the island is loaded to perform these actions (other servers have read-only data). This is to prevent data\nconflicts.",[15,105,106],{},"I could have implemented it cross-server, but it would require a very large Pub\u002FSub system, making it very complex. I\nopted to keep it simple and efficient.",[15,108,109],{},"So, when on the server where the island is loaded, you can perform all actions on your island. Then, a Pub\u002FSub message\ntells the other servers to update the island data (which is read-only).",[15,111,112],{},"For example, if you change a player's rank, the other servers will know about it in under 3 seconds.",[15,114,115,116,118],{},"This leads to the issue of cooldowns. Imagine if players spam commands to change the rank of a player.",[19,117],{},"\nTo address this, I implemented a cooldown system and a queue system. For example, if a player changes another player's\nrank, the plugin will wait a bit before sending the Pub\u002FSub message to allow for other changes. But critical changes (\nlike money, kick) are sent immediately, overriding whatever is in the queue.",[15,120,121],{},"With cross-server systems, we can encounter many problems like this, so we need to be very careful. You can easily make\nmistakes without realizing it.",[23,123,125],{"id":124},"conclusion","Conclusion",[15,127,128],{},"I’ve discussed the main concepts of the island system. I won’t go into the code details here because for complex systems\nlike this, it’s better to first understand the overall structure before diving into the code. If you’re interested in\nthe code, I can write a more detailed article about it—just reach out to me via Discord (Farmeurimmo), contact form, or\nemail.",[15,130,131],{},"Next time, I’ll cover the Inventory Sync System for cross-server support.",{"title":133,"searchDepth":134,"depth":134,"links":135},"",2,[136,137,138,139,140],{"id":25,"depth":134,"text":26},{"id":46,"depth":134,"text":47},{"id":77,"depth":134,"text":78},{"id":96,"depth":134,"text":97},{"id":124,"depth":134,"text":125},"This article delves into the Skyblock plugin's island system, focusing on cross-server compatibility, island distribution, and data management.","md",{"image":144,"date":145,"tags":146,"author":151},"https:\u002F\u002Fcdn.farmeurimmo.fr\u002Fimg\u002Fblog\u002F15-04-2024-dev-blog-2-build-a-skyblock-plugin.jpeg","2024-04-15T11:28:00.000Z",[147,148,149,150],"Minecraft","Spigot","Plugin Development","Skyblock",{"name":152,"picture":153},"Farmeurimmo","https:\u002F\u002Fcdn.farmeurimmo.fr\u002Fimg\u002Flogo.png",true,"\u002Fblog\u002F15-04-2024-dev-blog-2-build-a-skyblock-plugin",{"title":5,"description":141},"blog\u002F15-04-2024-dev-blog-2-build-a-skyblock-plugin","7v1COuY7d1CqPqap5I25FbDlOYMvc4wYWX_N861nlX0",1794558958059]