mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
refactor: add bypass for home slot validation, fix #706
This commit is contained in:
3 files changed
+30
-5
No files matched your search
@@ -69,6 +69,7 @@ public class EssentialsXImporter extends Importer {
|
||||
this.normalizeName(homeName),
|
||||
BukkitHuskHomes.Adapter.adapt(essentialsUser.getHome(homeName), plugin.getServerName()),
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
@@ -370,7 +370,30 @@ public class BaseHuskHomesAPI {
|
||||
public CompletableFuture<Home> 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<Home> 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 class BaseHuskHomesAPI {
|
||||
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<String> allowedServers = plugin.getSettings().getRtp().getRandomTargetServers();
|
||||
String randomServer = allowedServers.get(random.nextInt(allowedServers.size()));
|
||||
if (randomServer.equals(plugin.getServerName())) {
|
||||
|
||||
@@ -200,7 +200,8 @@ public class HomesManager {
|
||||
|
||||
@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<Home> existingHome = plugin.getDatabase().getHome(owner, name);
|
||||
if (existingHome.isPresent() && !overwrite) {
|
||||
@@ -220,7 +221,7 @@ public class HomesManager {
|
||||
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 class HomesManager {
|
||||
throws ValidationException {
|
||||
this.createHome(
|
||||
owner, name, position, plugin.getSettings().getGeneral().getNames().isOverwriteExisting(),
|
||||
true, false
|
||||
true, false, false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user