-
Notifications
You must be signed in to change notification settings - Fork 18
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
72 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pluginVersion=1.3.6 | ||
pluginVersion=1.4.0 |
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
64 changes: 64 additions & 0 deletions
64
src/main/java/io/th0rgal/protectionlib/compatibilities/HuskClaimCompat.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,64 @@ | ||
package io.th0rgal.protectionlib.compatibilities; | ||
|
||
import io.th0rgal.protectionlib.ProtectionCompatibility; | ||
import net.william278.cloplib.operation.OperationType; | ||
import net.william278.huskclaims.api.BukkitHuskClaimsAPI; | ||
import net.william278.huskclaims.api.HuskClaimsAPI; | ||
import net.william278.huskclaims.position.Position; | ||
import net.william278.huskclaims.trust.TrustLevel; | ||
import net.william278.huskclaims.user.OnlineUser; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.Optional; | ||
|
||
public class HuskClaimCompat extends ProtectionCompatibility { | ||
|
||
private final HuskClaimsAPI huskClaimsCommon; | ||
private final BukkitHuskClaimsAPI huskClaimsBukkit; | ||
|
||
public HuskClaimCompat(JavaPlugin mainPlugin, Plugin plugin) { | ||
super(mainPlugin, plugin); | ||
huskClaimsCommon = HuskClaimsAPI.getInstance(); | ||
huskClaimsBukkit = BukkitHuskClaimsAPI.getInstance(); | ||
} | ||
|
||
@Override | ||
public boolean canBuild(Player player, Location target) { | ||
OnlineUser onlineUser = huskClaimsCommon.getOnlineUser(player.getUniqueId()); | ||
Position position = huskClaimsBukkit.getPosition(target); | ||
|
||
Optional<TrustLevel> trustLevel = huskClaimsBukkit.getTrustLevelAt(position, onlineUser); | ||
return trustLevel.isPresent() && trustLevel.get().getFlags().contains(OperationType.BLOCK_PLACE); | ||
} | ||
|
||
@Override | ||
public boolean canBreak(Player player, Location target) { | ||
OnlineUser onlineUser = huskClaimsCommon.getOnlineUser(player.getUniqueId()); | ||
Position position = huskClaimsBukkit.getPosition(target); | ||
|
||
Optional<TrustLevel> trustLevel = huskClaimsBukkit.getTrustLevelAt(position, onlineUser); | ||
return trustLevel.isPresent() && trustLevel.get().getFlags().contains(OperationType.BLOCK_BREAK); | ||
} | ||
|
||
@Override | ||
public boolean canInteract(Player player, Location target) { | ||
OnlineUser onlineUser = huskClaimsCommon.getOnlineUser(player.getUniqueId()); | ||
Position position = huskClaimsBukkit.getPosition(target); | ||
|
||
OperationType operationType = target.getBlock().getType().isBlock() ? OperationType.BLOCK_INTERACT : OperationType.ENTITY_INTERACT; | ||
Optional<TrustLevel> trustLevel = huskClaimsBukkit.getTrustLevelAt(position, onlineUser); | ||
return trustLevel.isPresent() && trustLevel.get().getFlags().contains(operationType); | ||
} | ||
|
||
@Override | ||
public boolean canUse(Player player, Location target) { | ||
OnlineUser onlineUser = huskClaimsCommon.getOnlineUser(player.getUniqueId()); | ||
Position position = huskClaimsBukkit.getPosition(target); | ||
|
||
Optional<TrustLevel> trustLevel = huskClaimsBukkit.getTrustLevelAt(position, onlineUser); | ||
return trustLevel.isPresent() && trustLevel.get().getFlags().contains(OperationType.BLOCK_INTERACT); | ||
} | ||
} |