Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ItemPriceManager {

@Getter
private ShopIntegrationManager shopIntegrationManager;
@Getter
private CurrencyManager currencyManager;

private double defaultPrice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<String, Boolean> flags = claimedResidence.getPermissions().getPlayerFlags(player.getUniqueId());
for (String flag : flags.keySet()) {
if (flag.equalsIgnoreCase(flagName) && flags.get(flag))
return true;
}
return false;
}
}
4 changes: 4 additions & 0 deletions core/src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ softdepend:
- RedProtect
- MinePlots
- PlotSquared
- Residence

# World Management Plugins
- Multiverse-Core
Expand Down
Loading