diff --git a/pom.xml b/pom.xml index 8de661c..7bcc055 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ ir.wy WyCore jar - 2.0.8 + 2.0.9 @@ -210,6 +210,12 @@ system ${project.basedir}/libs/VulcanAPI.jar + + com.github.angeschossen + LandsAPI + 6.28.10 + provided + de.jpx3.intave.access intave-access diff --git a/src/main/java/ir/wy/wycore/spigot/support/protection/Lands.kt b/src/main/java/ir/wy/wycore/spigot/support/protection/Lands.kt new file mode 100644 index 0000000..25a6b73 --- /dev/null +++ b/src/main/java/ir/wy/wycore/spigot/support/protection/Lands.kt @@ -0,0 +1,65 @@ +package ir.wy.wycore.spigot.support.protection + +import ir.wy.wycore.WyCore +import ir.wy.wycore.behind.support.protection.ProtectionSupport +import me.angeschossen.lands.api.LandsIntegration +import me.angeschossen.lands.api.flags.type.Flags +import org.bukkit.Location +import org.bukkit.Material +import org.bukkit.block.Block +import org.bukkit.entity.Animals +import org.bukkit.entity.LivingEntity +import org.bukkit.entity.Monster +import org.bukkit.entity.Player + + +class Lands(private val plugin: WyCore) : ProtectionSupport { + private val landsIntegration = LandsIntegration.of(this.plugin) + override fun canBreakBlock(player: Player, block: Block): Boolean { + val area = landsIntegration.getArea(block.location) ?: return true + return area.hasRoleFlag(player, Flags.BLOCK_BREAK, block.type, false) + } + + override fun canCreateExplosion(player: Player, location: Location): Boolean { + val area = landsIntegration.getArea(location) ?: return true + return area.hasRoleFlag(player, Flags.ATTACK_PLAYER, Material.AIR, false) + && area.hasRoleFlag(player, Flags.ATTACK_ANIMAL, Material.AIR, false) + } + + override fun canPlaceBlock(player: Player, block: Block): Boolean { + val area = landsIntegration.getArea(block.location) ?: return true + return area.hasRoleFlag(player, Flags.BLOCK_PLACE, Material.AIR, false) + } + + override fun canInjure(player: Player, victim: LivingEntity): Boolean { + val area = landsIntegration.getArea(victim.location) ?: return true + + return when(victim) { + is Player -> area.hasRoleFlag(player, Flags.ATTACK_PLAYER, Material.AIR, false) + is Monster -> area.hasRoleFlag(player, Flags.ATTACK_MONSTER, Material.AIR, false) + is Animals -> area.hasRoleFlag(player, Flags.ATTACK_ANIMAL, Material.AIR, false) + else -> area.isTrusted(player.uniqueId) + } + } + + override fun getPluginName(): String { + return "Lands" + } + + override fun canPickupItem(player: Player, location: Location): Boolean { + val area = landsIntegration.getArea(location) ?: return true + return area.hasRoleFlag(player, Flags.ITEM_PICKUP, Material.AIR, false) + } + + override fun equals(other: Any?): Boolean { + if (other !is ProtectionSupport) { + return false + } + + return other.pluginName == this.pluginName + } + + override fun hashCode(): Int { + return this.pluginName.hashCode() + } +} \ No newline at end of file