mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
fix: economy checks being used even if no hook loaded
This commit is contained in:
4 files changed
+17
-4
No files matched your search
@@ -163,7 +163,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
|||||||
() -> getSettings().getDatabase().getType().getDisplayName())
|
() -> getSettings().getDatabase().getType().getDisplayName())
|
||||||
);
|
);
|
||||||
metrics.addCustomChart(new SimplePie("using_economy",
|
metrics.addCustomChart(new SimplePie("using_economy",
|
||||||
() -> Boolean.toString(getSettings().getEconomy().isEnabled()))
|
() -> Boolean.toString(isUsingEconomy()))
|
||||||
);
|
);
|
||||||
metrics.addCustomChart(new SimplePie("using_map",
|
metrics.addCustomChart(new SimplePie("using_map",
|
||||||
() -> Boolean.toString(getSettings().getMapHook().isEnabled()))
|
() -> Boolean.toString(getSettings().getMapHook().isEnabled()))
|
||||||
|
|||||||
@@ -221,9 +221,9 @@ public class HomesManager {
|
|||||||
final SavedUser savedOwner = plugin.getSavedUser(owner)
|
final SavedUser savedOwner = plugin.getSavedUser(owner)
|
||||||
.or(() -> plugin.getDatabase().getUser(owner.getUuid()))
|
.or(() -> plugin.getDatabase().getUser(owner.getUuid()))
|
||||||
.orElseThrow(() -> new IllegalStateException("User data not found for " + owner.getUuid()));
|
.orElseThrow(() -> new IllegalStateException("User data not found for " + owner.getUuid()));
|
||||||
if (!ignoreHomeSlots && plugin.getSettings().getEconomy().isEnabled()
|
if (plugin.isUsingEconomy() && !ignoreHomeSlots && homes > getFreeHomes(owner)
|
||||||
&& homes > getFreeHomes(owner) && homes > savedOwner.getHomeSlots()) {
|
&& homes > savedOwner.getHomeSlots()) {
|
||||||
if (!buyAdditionalSlots || plugin.getEconomyHook().isEmpty() || !(owner instanceof OnlineUser online)) {
|
if (!buyAdditionalSlots || !(owner instanceof OnlineUser online)) {
|
||||||
throw new ValidationException(ValidationException.Type.NOT_ENOUGH_HOME_SLOTS);
|
throw new ValidationException(ValidationException.Type.NOT_ENOUGH_HOME_SLOTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,6 +168,15 @@ public interface TransactionResolver {
|
|||||||
return getPlugin().getHook(EconomyHook.class);
|
return getPlugin().getHook(EconomyHook.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether to use the economy hook
|
||||||
|
*
|
||||||
|
* @return {@code true} if the economy hook is in use
|
||||||
|
*/
|
||||||
|
default boolean isUsingEconomy() {
|
||||||
|
return getPlugin().getSettings().getEconomy().isEnabled() && getEconomyHook().isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
HuskHomes getPlugin();
|
HuskHomes getPlugin();
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
@PluginHook(
|
||||||
|
name = "Impactor Economy",
|
||||||
|
register = PluginHook.Register.ON_LOAD
|
||||||
|
)
|
||||||
public class FabricImpactorEconomyHook extends EconomyHook {
|
public class FabricImpactorEconomyHook extends EconomyHook {
|
||||||
private EconomyService economyService;
|
private EconomyService economyService;
|
||||||
private Currency currency;
|
private Currency currency;
|
||||||
|
|||||||
Reference in new issue
Block a user