forked from wargamer/SignShop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/org/wargamer2010/signshop/hooks/BentoBoxHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters