Skip to content

Commit

Permalink
Add BentoBox hook
Browse files Browse the repository at this point in the history
  • Loading branch information
weaves7 committed Mar 11, 2020
1 parent 24c55df commit 0901199
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.makershaven</groupId>
<artifactId>SignShop</artifactId>
<version>3.3.1</version>
<version>3.3.2</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down Expand Up @@ -69,6 +69,12 @@
<version>0.95.1.0-1.13.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
<version>1.11.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bekvon.bukkit</groupId>
<artifactId>residence</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ private static void setupHooks() {
HookManager.addHook("WorldGuard");
HookManager.addHook("GriefPrevention");
HookManager.addHook("Towny");
HookManager.addHook("BentoBox");

}

Expand Down
37 changes: 37 additions & 0 deletions src/main/java/org/wargamer2010/signshop/hooks/BentoBoxHook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.wargamer2010.signshop.hooks;

import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.managers.IslandsManager;

import java.util.Optional;


public class BentoBoxHook implements Hook {
@Override
public String getName() {
return "BentoBox";
}

@Override
public Boolean canBuild(Player player, Block block) {
if(HookManager.getHook("BentoBox") == null)
return true;
BentoBox bentoBox = BentoBox.getInstance();
User user = User.getInstance(player);
IslandsManager islandsManager = bentoBox.getIslands();
Optional<Island> island = islandsManager.getIslandAt(block.getLocation());
if (island.isPresent() && island.get().getMembers().containsKey(user.getUniqueId())){
return island.get().getMembers().get(user.getUniqueId()) >= 500;
}
return false;
}

@Override
public Boolean protectBlock(Player player, Block block) {
return false;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ api-version: "1.13"
version: "${project.version}"
dev-url: http://dev.bukkit.org/server-mods/signshop
authors: [Wargamer2010, Devinish, Weaves]
softdepend: [Vault, Towny, GriefPrevention, WorldGuard, Essentials, CMI]
softdepend: [Vault, Towny, GriefPrevention, WorldGuard, Essentials, CMI, BentoBox]
commands:
signshop:
description: Admin commands for SignShop
Expand Down

0 comments on commit 0901199

Please sign in to comment.