Skip to content

Commit 2ef2370

Browse files
committed
Fixed home setting on island creation warning.
1 parent 4f04a82 commit 2ef2370

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/main/java/world/bentobox/bentobox/database/objects/Island.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ public void setSpawnPoint(Environment islandType, Location l) {
14011401
spawnPoint.compute(islandType, (key, value) -> {
14021402
if (value == null || !value.equals(l)) {
14031403
setChanged(); // Call setChanged only if the value is updated.
1404-
return l;
1404+
return l; // clone??
14051405
}
14061406
return value;
14071407
});

src/main/java/world/bentobox/bentobox/managers/IslandsManager.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1829,14 +1829,25 @@ public Island getPrimaryIsland(World world, UUID uuid) {
18291829
}
18301830

18311831
public CompletableFuture<Void> homeTeleportAsync(Island island, User user) {
1832+
return homeTeleportAsync(island, user, false);
1833+
}
1834+
1835+
/**
1836+
* Teleport the user home
1837+
* @param island island
1838+
* @param user user
1839+
* @param newIsland true if this is a new island first time teleport
1840+
* @return future when it is done
1841+
*/
1842+
public CompletableFuture<Void> homeTeleportAsync(Island island, User user, boolean newIsland) {
18321843
Location loc = island.getHome("");
18331844
user.sendMessage("commands.island.go.teleport");
18341845
goingHome.add(user.getUniqueId());
18351846
readyPlayer(user.getPlayer());
18361847
return Util.teleportAsync(Objects.requireNonNull(user.getPlayer()), loc).thenAccept(b -> {
18371848
// Only run the commands if the player is successfully teleported
18381849
if (Boolean.TRUE.equals(b)) {
1839-
teleported(island.getWorld(), user, "", false, island);
1850+
teleported(island.getWorld(), user, "", newIsland, island);
18401851
this.setPrimaryIsland(user.getUniqueId(), island);
18411852
} else {
18421853
// Remove from mid-teleport set

src/main/java/world/bentobox/bentobox/managers/island/NewIsland.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ public void newIsland(Island oldIsland) throws IOException {
267267
private void postCreationTask(Island oldIsland) {
268268
// Set initial spawn point if one exists
269269
if (island.getSpawnPoint(Environment.NORMAL) != null) {
270-
plugin.getIslands().setHomeLocation(user, island.getSpawnPoint(Environment.NORMAL));
270+
plugin.getIslands().setHomeLocation(island, island.getSpawnPoint(Environment.NORMAL), "");
271+
plugin.getIslands().setPrimaryIsland(user.getUniqueId(), island);
271272
}
272273
// If player is online, handle teleportation and movement
273274
if (user.isOnline()) {
@@ -277,7 +278,7 @@ private void postCreationTask(Island oldIsland) {
277278
user.getPlayer().setVelocity(new Vector(0, 0, 0));
278279
user.getPlayer().setFallDistance(0F);
279280
// Teleport player after island is built, then tidy up
280-
plugin.getIslands().homeTeleportAsync(world, user.getPlayer(), true).thenRun(() -> tidyUp(oldIsland));
281+
plugin.getIslands().homeTeleportAsync(island, user, true).thenRun(() -> tidyUp(oldIsland));
281282
return;
282283
} else {
283284
// Notify player they can teleport to their island

0 commit comments

Comments
 (0)