diff --git a/core/build.gradle b/core/build.gradle index 84d7e283..fecd78b7 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -26,7 +26,10 @@ dependencies { compileOnly("com.iridium:IridiumSkyblock:4.1.0") implementation(platform("com.intellectualsites.bom:bom-newest:1.55")) compileOnly("com.intellectualsites.plotsquared:plotsquared-core") - + implementation("com.github.Zrips:Residence:6.0.0.1") { + exclude group: "org.bukkit" + } + // Lombok compileOnly("org.projectlombok:lombok:1.18.42") annotationProcessor("org.projectlombok:lombok:1.18.42") diff --git a/core/src/main/java/github/nighter/smartspawner/hooks/IntegrationManager.java b/core/src/main/java/github/nighter/smartspawner/hooks/IntegrationManager.java index 5bdd226f..f0e8c344 100644 --- a/core/src/main/java/github/nighter/smartspawner/hooks/IntegrationManager.java +++ b/core/src/main/java/github/nighter/smartspawner/hooks/IntegrationManager.java @@ -35,6 +35,7 @@ public class IntegrationManager { private boolean hasMythicMobs = false; private boolean hasIridiumSkyblock = false; private boolean hasPlotSquared = false; + private boolean hasResidence = false; // Integration plugin flags private boolean hasAuraSkills = false; @@ -146,6 +147,11 @@ private void checkProtectionPlugins() { } return false; }, true); + + hasResidence = checkPlugin("Residence", () -> { + Plugin residence = Bukkit.getPluginManager().getPlugin("Residence"); + return residence != null && residence.isEnabled(); + }, true); } private void checkIntegrationPlugins() { diff --git a/core/src/main/java/github/nighter/smartspawner/hooks/economy/ItemPriceManager.java b/core/src/main/java/github/nighter/smartspawner/hooks/economy/ItemPriceManager.java index e5ecda4a..0dfbd93a 100644 --- a/core/src/main/java/github/nighter/smartspawner/hooks/economy/ItemPriceManager.java +++ b/core/src/main/java/github/nighter/smartspawner/hooks/economy/ItemPriceManager.java @@ -26,6 +26,7 @@ public class ItemPriceManager { @Getter private ShopIntegrationManager shopIntegrationManager; + @Getter private CurrencyManager currencyManager; private double defaultPrice; diff --git a/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckBreakBlock.java b/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckBreakBlock.java index 12fa678e..5e00b521 100644 --- a/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckBreakBlock.java +++ b/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckBreakBlock.java @@ -20,6 +20,7 @@ public static boolean CanPlayerBreakBlock(@NotNull final Player player, @NotNull if (integrationManager.isHasTowny() && !Towny.canPlayerInteractSpawner(player, location)) return false; if (integrationManager.isHasSimpleClaimSystem() && !SimpleClaimSystem.canPlayerBreakClaimBlock(player, location)) return false; if (integrationManager.isHasPlotSquared() && !PlotSquared.canInteract(player, location)) return false; + if (integrationManager.isHasResidence() && !Residence.canPlayerBreakBlock(player, location)) return false; return true; } } diff --git a/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckOpenMenu.java b/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckOpenMenu.java index 37021ba0..9fd51567 100644 --- a/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckOpenMenu.java +++ b/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckOpenMenu.java @@ -25,6 +25,7 @@ public static boolean CanPlayerOpenMenu(@NotNull final Player player, @NotNull L if (integrationManager.isHasMinePlots() && !MinePlots.canPlayerOpenMenu(player, location)) return false; if (integrationManager.isHasIridiumSkyblock() && !IridiumSkyblock.canPlayerOpenMenu(player, location)) return false; if (integrationManager.isHasPlotSquared() && !PlotSquared.canInteract(player, location)) return false; + if (integrationManager.isHasResidence() && !Residence.canInteract(player, location)) return false; return !integrationManager.isHasRedProtect() || RedProtectAPI.canPlayerOpenMenuOnClaim(player, location); } } \ No newline at end of file diff --git a/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckStackBlock.java b/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckStackBlock.java index f31e74fb..836a14c9 100644 --- a/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckStackBlock.java +++ b/core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckStackBlock.java @@ -25,6 +25,7 @@ public static boolean CanPlayerPlaceBlock(@NotNull final Player player, @NotNull if (integrationManager.isHasMinePlots() && !MinePlots.canPlayerStackBlock(player, location)) return false; if (integrationManager.isHasIridiumSkyblock() && !IridiumSkyblock.canPlayerStackBlock(player, location)) return false; if (integrationManager.isHasPlotSquared() && !PlotSquared.canInteract(player, location)) return false; + if (integrationManager.isHasResidence() && !Residence.canStack(player, location)) return false; return !integrationManager.isHasRedProtect() || RedProtectAPI.canPlayerStackClaimBlock(player, location); } } \ No newline at end of file diff --git a/core/src/main/java/github/nighter/smartspawner/hooks/protections/api/Residence.java b/core/src/main/java/github/nighter/smartspawner/hooks/protections/api/Residence.java new file mode 100644 index 00000000..095d3e9e --- /dev/null +++ b/core/src/main/java/github/nighter/smartspawner/hooks/protections/api/Residence.java @@ -0,0 +1,33 @@ +package github.nighter.smartspawner.hooks.protections.api; + +import com.bekvon.bukkit.residence.api.ResidenceApi; +import com.bekvon.bukkit.residence.protection.ClaimedResidence; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; + +public class Residence { + public static boolean canPlayerBreakBlock(@NotNull Player player, @NotNull Location location) { + return check(player, location, "build"); + } + + public static boolean canInteract(@NotNull Player player, @NotNull Location location) { + return check(player, location, "use"); + } + + public static boolean canStack(@NotNull Player player, @NotNull Location location) { + return check(player, location, "build"); + } + + private static boolean check(Player player, Location location, String flagName) { + ClaimedResidence claimedResidence = ResidenceApi.getResidenceManager().getByLoc(location); + Map flags = claimedResidence.getPermissions().getPlayerFlags(player.getUniqueId()); + for (String flag : flags.keySet()) { + if (flag.equalsIgnoreCase(flagName) && flags.get(flag)) + return true; + } + return false; + } +} diff --git a/core/src/main/resources/paper-plugin.yml b/core/src/main/resources/paper-plugin.yml index 41e3bccd..ee6cbf40 100644 --- a/core/src/main/resources/paper-plugin.yml +++ b/core/src/main/resources/paper-plugin.yml @@ -90,6 +90,10 @@ dependencies: load: BEFORE required: false join-classpath: true + Residence: + load: BEFORE + required: false + join-classpath: true # World Management Plugins Multiverse-Core: diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml index 3564e3d6..f2cf3522 100644 --- a/core/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -29,6 +29,7 @@ softdepend: - RedProtect - MinePlots - PlotSquared + - Residence # World Management Plugins - Multiverse-Core