Skip to content

Commit 34bf473

Browse files
authored
Merge pull request #22 from Kawi16/main
Re-Add BentoBox hook
2 parents 26f483e + 917fa04 commit 34bf473

6 files changed

Lines changed: 35 additions & 1 deletion

File tree

core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies {
1212
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
1313
compileOnly 'su.nightexpress.coinsengine:CoinsEngine:2.5.0'
1414
compileOnly 'com.github.Gypopo:EconomyShopGUI-API:1.8.0'
15+
compileOnly 'world.bentobox:bentobox:3.7.4-SNAPSHOT'
1516
compileOnly 'su.nightexpress.excellentshop:Core:4.19.0'
1617
compileOnly("io.github.fabiozumbi12.RedProtect:RedProtect-Core:8.1.2") { exclude(group: "*") }
1718
compileOnly("io.github.fabiozumbi12.RedProtect:RedProtect-Spigot:8.1.2") { exclude(group: "*") }

core/src/main/java/github/nighter/smartspawner/hooks/IntegrationManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class IntegrationManager {
2727
private boolean hasWorldGuard = false;
2828
private boolean hasGriefPrevention = false;
2929
private boolean hasSuperiorSkyblock2 = false;
30+
private boolean hasBentoBox = false;
3031
private boolean hasSimpleClaimSystem = false;
3132
private boolean hasRedProtect = false;
3233
private boolean hasMinePlots = false;
@@ -88,6 +89,11 @@ private void checkProtectionPlugins() {
8889
return false;
8990
}, true);
9091

92+
hasBentoBox = checkPlugin("BentoBox", () -> {
93+
Plugin bentoPlugin = Bukkit.getPluginManager().getPlugin("BentoBox");
94+
return bentoPlugin != null && bentoPlugin.isEnabled();
95+
}, true);
96+
9197
hasSimpleClaimSystem = checkPlugin("SimpleClaimSystem", () -> {
9298
Plugin simpleClaimPlugin = Bukkit.getPluginManager().getPlugin("SimpleClaimSystem");
9399
if (simpleClaimPlugin == null || !simpleClaimPlugin.isEnabled()) {

core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckOpenMenu.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static boolean CanPlayerOpenMenu(@NotNull final Player player, @NotNull L
1919
if (integrationManager.isHasLands() && !Lands.CanPlayerInteractContainer(player, location)) return false;
2020
if (integrationManager.isHasTowny() && !Towny.canPlayerInteractSpawner(player, location)) return false;
2121
if (integrationManager.isHasSuperiorSkyblock2() && SuperiorSkyblock2.canPlayerOpenMenu(player, location)) return false;
22+
if (integrationManager.isHasBentoBox() && !BentoBoxAPI.canPlayerOpenMenu(player, location)) return false;
2223
if (integrationManager.isHasSimpleClaimSystem() && !SimpleClaimSystem.canPlayerOpenMenuOnClaim(player, location))
2324
return false;
2425
if (integrationManager.isHasMinePlots() && !MinePlots.canPlayerOpenMenu(player, location)) return false;

core/src/main/java/github/nighter/smartspawner/hooks/protections/CheckStackBlock.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static boolean CanPlayerPlaceBlock(@NotNull final Player player, @NotNull
1919
if (integrationManager.isHasLands() && !Lands.canPlayerStackClaimBlock(player, location)) return false;
2020
if (integrationManager.isHasTowny() && !Towny.canPlayerInteractSpawner(player, location)) return false;
2121
if (integrationManager.isHasSuperiorSkyblock2() && SuperiorSkyblock2.canPlayerStackBlock(player, location)) return false;
22+
if (integrationManager.isHasBentoBox() && !BentoBoxAPI.canPlayerStackBlock(player, location)) return false;
2223
if (integrationManager.isHasSimpleClaimSystem() && !SimpleClaimSystem.canPlayerStackClaimBlock(player, location))
2324
return false;
2425
if (integrationManager.isHasMinePlots() && !MinePlots.canPlayerStackBlock(player, location)) return false;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package github.nighter.smartspawner.hooks.protections.api;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.entity.Player;
5+
import org.jetbrains.annotations.NotNull;
6+
7+
import world.bentobox.bentobox.BentoBox;
8+
import world.bentobox.bentobox.api.user.User;
9+
import world.bentobox.bentobox.lists.Flags;
10+
11+
public class BentoBoxAPI {
12+
public static boolean canPlayerStackBlock(@NotNull Player player, @NotNull Location location) {
13+
if(BentoBox.getInstance().getIslandsManager().getIslandAt(location).isEmpty()) return true;
14+
return BentoBox.getInstance().getIslandsManager().getIslandAt(location).
15+
map(island -> island.isAllowed(User.getInstance(player.getUniqueId()), Flags.PLACE_BLOCKS)).
16+
orElse(Flags.PLACE_BLOCKS.isSetForWorld(location.getWorld()));
17+
}
18+
19+
public static boolean canPlayerOpenMenu(@NotNull Player player, @NotNull Location location) {
20+
if(BentoBox.getInstance().getIslandsManager().getIslandAt(location).isEmpty()) return true;
21+
return BentoBox.getInstance().getIslandsManager().getIslandAt(location).
22+
map(island -> island.isAllowed(User.getInstance(player.getUniqueId()), Flags.CONTAINER)).
23+
orElse(Flags.CONTAINER.isSetForWorld(location.getWorld()));
24+
}
25+
}

core/src/main/resources/paper-plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ dependencies:
103103
load: BEFORE
104104
required: false
105105
join-classpath: true
106-
Bentobox:
106+
BentoBox:
107107
load: BEFORE
108108
required: false
109109
join-classpath: true

0 commit comments

Comments
 (0)