Skip to content

Commit

Permalink
1.2: Added /island setspawn subcommand with permissions,
Browse files Browse the repository at this point in the history
Improved islands.bypass.home
Changed permission nodes
/give command can now be used without name to remove owners
(requires islands.bypass.give)
Added possibility for a default spawn island.
Fixed island and home naming
  • Loading branch information
aleksilassila committed Oct 1, 2020
1 parent 867209b commit 5631864
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
24 changes: 21 additions & 3 deletions src/me/aleksilassila/islands/generation/IslandGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void nameIsland(String islandId, String name){
}

public void giveIsland(String islandId, Player player) {
getIslandsConfig().set("islands." + islandId + ".home", String.valueOf(getNumberOfIslands(player.getUniqueId()) + 1));
getIslandsConfig().set("islands." + islandId + ".home", getNewHomeId(player.getUniqueId()));
getIslandsConfig().set("islands." + islandId + ".UUID", player.getUniqueId().toString());
islands.plugin.saveIslandsConfig();
}
Expand Down Expand Up @@ -165,7 +165,7 @@ private String addIslandToConfig(int xIndex, int zIndex, int islandSize, UUID uu
int realY = getIslandY(xIndex, zIndex);
int realZ = zIndex * islandSpacing + islandSpacing / 2 - islandSize / 2;

String home = String.valueOf(getNumberOfIslands(uuid) + 1);
String home = getNewHomeId(uuid);

String islandId = xIndex + "x" + zIndex;

Expand Down Expand Up @@ -212,7 +212,7 @@ public String createIsland(UUID uuid, int islandSize) {
}
}

return addIslandToConfig(x, z, islandSize, uuid, String.valueOf(getNumberOfIslands(uuid) + 1));
return addIslandToConfig(x, z, islandSize, uuid, getNewHomeId(uuid));
}
}

Expand Down Expand Up @@ -291,6 +291,24 @@ public void setSpawnPoint(String islandId, int x, int y) {
getIslandsConfig().set("islands." + islandId + ".spawnPoint.y", y);
}

public String getNewHomeId(UUID uuid) {
List<String> ids = getAllIslandIds(uuid);
List<String> homeIds = new ArrayList<>();

for (String islandId : ids) {
String homeNumber = getIslandsConfig().getString("islands." + islandId + ".home");
homeIds.add(homeNumber);
}

String home = String.valueOf(getNumberOfIslands(uuid) + 1);

for (int i = 1; i <= getNumberOfIslands(uuid) + 1; i++) {
if (!homeIds.contains(String.valueOf(i))) home = String.valueOf(i);
}

return home;
}

// deleteIsland
// moveIsland
}
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Islands
version: 1.1.1
version: 1.2.0
author: Aleksi Lassila
main: me.aleksilassila.islands.Main
api-version: 1.16
Expand Down

0 comments on commit 5631864

Please sign in to comment.