Skyblock islands grid

Discussion in 'Plugin Development' started by jarnoboy404, Jul 26, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    jarnoboy404

    Hello, i am making a skyblock plugin.

    I would have that when you create a island, its going to be in a square. I know you don't understand what i mean. So i have a screenshot right below. As you see, there are 4 islands. When you create a new island it needs to be next to the other island and when you create ANOTHER island. That island needs to be next to the previous island. So that you get always a square of islands. But my question is, how can i make that?

    I have this code right now:
    Code (open)

    Code:
        public static void createIsland(Player p, IslandType type) {
            nextLocation = Methods.getLocationFromString(s.getYAML().getString("NextLocation"));
           
            UUID eigenaar = p.getUniqueId();
            Integer id = Methods.getID(c.getYAML().getConfigurationSection("Islands").getKeys(false)) + 1;
            List<UUID> leden = new ArrayList<UUID>();
            Location center = nextLocation;
            Location home = center.clone();
           
            List<String> ex = u.getYAML().getStringList("Users." + eigenaar + ".OwnedIslands");
            ex.add(id + "");
            u.getYAML().set("Users." + eigenaar + ".OwnedIslands", ex);
            u.saveFile();
           
            c.getYAML().set("Islands." + id + ".Eigenaar", eigenaar.toString());
            List<String> ex2 = u.getYAML().getStringList("Islands." + id + ".Leden");
            c.getYAML().set("Islands." + id + ".Leden", ex2);
            c.getYAML().set("Islands." + id + ".Center", nextLocation.getWorld().getName() + "," + nextLocation.getX() + "," + nextLocation.getY() + "," + nextLocation.getZ());
            c.getYAML().set("Islands." + id + ".Home", nextLocation.getWorld().getName() + "," + nextLocation.getX() + "," + nextLocation.getY() + "," + nextLocation.getZ());
            c.saveFile();
           
            String islandPath = "/schematics/speler_ISLAND.schematic";
            if(type == IslandType.MEMBER) {
                islandPath = "/schematics/member_ISLAND.schematic";
            }else if(type == IslandType.SUPPORTER) {
                islandPath = "/schematics/supporter_ISLAND.schematic";
            }else if(type == IslandType.DONATOR) {
                islandPath = "/schematics/donator_ISLAND.schematic";
            }else if(type == IslandType.ELITE) {
                islandPath = "/schematics/elite_ISLAND.schematic";
            }
            Methods.loadSchematic(GetAPI.getWorldEdit().getDataFolder() + File.separator + islandPath, nextLocation, 0);
           
            RegionContainer container = GetAPI.getWorldGuard().getRegionContainer();
            RegionManager regions = container.get(nextLocation.getWorld());
            BlockVector v1 = new BlockVector(nextLocation.getX() -200, 0, nextLocation.getZ() -200);
            BlockVector v2 = new BlockVector(nextLocation.getX() +200, nextLocation.getWorld().getMaxHeight(), nextLocation.getZ() +200);
            ProtectedCuboidRegion region = new ProtectedCuboidRegion(id + "", v2, v1);
            DefaultDomain owners = new DefaultDomain();
            owners.addPlayer(GetAPI.getWorldGuard().wrapPlayer(Bukkit.getPlayer(eigenaar)));
            region.setOwners(owners);
            region.setFlag(DefaultFlag.USE.getRegionGroupFlag(), RegionGroup.MEMBERS);
           
            regions.addRegion(region);
           
            Location l = nextLocation.clone();
            l.add(0.5, 1, 0.5);
            Bukkit.getPlayer(eigenaar).teleport(l);
           
            SkyblockIsland sb = new SkyblockIsland(id, eigenaar, leden, center, home);
            islands.add(sb);
           
            double x = nextLocation.getX() + 10;
            s.getYAML().set("NextLocation", nextLocation.getWorld().getName() + "," + x + "," + nextLocation.getY() + "," + nextLocation.getZ());
            s.saveFile();
           
            p.sendMessage(Methods.COLOR("&3SkyBlock &1&l> &aSuccesvol SkyBlock eiland aangemaakt."));
        }
     

    Attached Files:

  2. Offline

    jarnoboy404

    Can anyone please help me? I don't know how to make it :(
     
  3. Offline

    bennie3211

    Get the origin of the world (0,0,0) for example and add a certain space for the number of islands you have. Lets say your island is 10x10 blocks, then the first island can be created centered around the start location. Then you need to start the other island at least 2 times 5 (half of the size) to a selected direction. Don't forget to add some space to build/explore.

    Pseudo code:

    Code:
    //Init code at startup
    int numIslands = 0; //Or read from config the number of islands :) Maybe start at -1 to make it center around the 0,0,64 coordinate?
    int islandSize = 10; //Default size of island or read from schematic ;)
    int islandSpace = 50; //Be crazy and give them room to play :D
    
    //Creating island
    numIslands++;
    Location center = New Location(0, numIslands*islandSize + islandSpace, 64)
    This only works in a X or Y direction, you can also create a 2D XY grid and select a random one and multiply it with the number of islands + spacing between the islands
     
Thread Status:
Not open for further replies.

Share This Page