diff --git a/bukkit/src/main/java/net/william278/huskhomes/importer/EssentialsXImporter.java b/bukkit/src/main/java/net/william278/huskhomes/importer/EssentialsXImporter.java index 975ec509..9907d264 100644 --- a/bukkit/src/main/java/net/william278/huskhomes/importer/EssentialsXImporter.java +++ b/bukkit/src/main/java/net/william278/huskhomes/importer/EssentialsXImporter.java @@ -69,6 +69,7 @@ private int importHomes() { this.normalizeName(homeName), BukkitHuskHomes.Adapter.adapt(essentialsUser.getHome(homeName), plugin.getServerName()), true, + false, true, true ); diff --git a/common/src/main/java/net/william278/huskhomes/api/BaseHuskHomesAPI.java b/common/src/main/java/net/william278/huskhomes/api/BaseHuskHomesAPI.java index a35e3e1f..178186df 100644 --- a/common/src/main/java/net/william278/huskhomes/api/BaseHuskHomesAPI.java +++ b/common/src/main/java/net/william278/huskhomes/api/BaseHuskHomesAPI.java @@ -370,7 +370,30 @@ public CompletableFuture createHome(@NotNull User owner, @NotNull String n public CompletableFuture createHome(@NotNull User owner, @NotNull String name, @NotNull Position position, boolean overwrite, boolean buyAdditionalSlots, boolean ignoreMaxHomes) { return plugin.supplyAsync(() -> plugin.getManager().homes().createHome( - owner, name, position, overwrite, buyAdditionalSlots, ignoreMaxHomes + owner, name, position, overwrite, buyAdditionalSlots, ignoreMaxHomes, false + )); + } + + /** + * Create a home for a given user with the specified name and position. + * The returned future may complete exceptionally with a {@link net.william278.huskhomes.util.ValidationException} + * if the home could not be created. + * + * @param owner The {@link User} to create the home for + * @param name The name of the home + * @param position The {@link Position} of the home + * @param overwrite Whether to overwrite an existing home with the same name + * @param buyAdditionalSlots Whether to buy additional home slots if the user has reached their maximum + * @param ignoreMaxHomes Whether to ignore the maximum number of homes a user can have + * @param ignoreHomeSlots Whether to ignore the number of home slots a user has + * @return a {@link CompletableFuture} that will complete with the created {@link Home}. + * @since 4.8 + */ + public CompletableFuture createHome(@NotNull User owner, @NotNull String name, @NotNull Position position, + boolean overwrite, boolean buyAdditionalSlots, boolean ignoreMaxHomes, + boolean ignoreHomeSlots) { + return plugin.supplyAsync(() -> plugin.getManager().homes().createHome( + owner, name, position, overwrite, buyAdditionalSlots, ignoreMaxHomes, ignoreHomeSlots )); } @@ -786,7 +809,7 @@ public final TeleportBuilder teleportBuilder() { public final void randomlyTeleportPlayer(@NotNull OnlineUser user, boolean timedTeleport, @NotNull String... rtpArgs) { if (plugin.getSettings().getRtp().isCrossServer() && (plugin.getSettings().getCrossServer().isEnabled() && - plugin.getSettings().getCrossServer().getBrokerType() == Broker.Type.REDIS)) { + plugin.getSettings().getCrossServer().getBrokerType() == Broker.Type.REDIS)) { List allowedServers = plugin.getSettings().getRtp().getRandomTargetServers(); String randomServer = allowedServers.get(random.nextInt(allowedServers.size())); if (randomServer.equals(plugin.getServerName())) { diff --git a/common/src/main/java/net/william278/huskhomes/manager/HomesManager.java b/common/src/main/java/net/william278/huskhomes/manager/HomesManager.java index 2ded7e3b..1f955516 100644 --- a/common/src/main/java/net/william278/huskhomes/manager/HomesManager.java +++ b/common/src/main/java/net/william278/huskhomes/manager/HomesManager.java @@ -200,7 +200,8 @@ public void removeUserHomes(@NotNull User user) { @NotNull public Home createHome(@NotNull User owner, @NotNull String name, @NotNull Position position, - boolean overwrite, boolean buyAdditionalSlots, boolean ignoreMaxHomes) + boolean overwrite, boolean buyAdditionalSlots, boolean ignoreMaxHomes, + boolean ignoreHomeSlots) throws ValidationException { final Optional existingHome = plugin.getDatabase().getHome(owner, name); if (existingHome.isPresent() && !overwrite) { @@ -220,7 +221,7 @@ public Home createHome(@NotNull User owner, @NotNull String name, @NotNull Posit final SavedUser savedOwner = plugin.getSavedUser(owner) .or(() -> plugin.getDatabase().getUser(owner.getUuid())) .orElseThrow(() -> new IllegalStateException("User data not found for " + owner.getUuid())); - if (plugin.getSettings().getEconomy().isEnabled() + if (!ignoreHomeSlots && plugin.getSettings().getEconomy().isEnabled() && homes > getFreeHomes(owner) && homes > savedOwner.getHomeSlots()) { if (!buyAdditionalSlots || plugin.getEconomyHook().isEmpty() || !(owner instanceof OnlineUser online)) { throw new ValidationException(ValidationException.Type.NOT_ENOUGH_HOME_SLOTS); @@ -250,7 +251,7 @@ public void createHome(@NotNull OnlineUser owner, @NotNull String name, @NotNull throws ValidationException { this.createHome( owner, name, position, plugin.getSettings().getGeneral().getNames().isOverwriteExisting(), - true, false + true, false, false ); }