Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #65 from TheWylot/dev/v2.0.0
Browse files Browse the repository at this point in the history
DEV-2.0.15 // Lands Support Update
  • Loading branch information
TheWylot authored Mar 8, 2023
2 parents 3c6a8ae + 5e083fc commit 906903c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 38 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@
<scope>system</scope>
<systemPath>${project.basedir}/libs/lands-api-6.28.11.jar</systemPath>
</dependency>
<dependency>
<groupId>com.github.angeschossen</groupId>
<artifactId>PluginFrameworkAPI</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/PluginFrameworkAPI.jar</systemPath>
</dependency>
<dependency>
<groupId>de.jpx3.intave.access</groupId>
<artifactId>intave-access</artifactId>
Expand Down
89 changes: 51 additions & 38 deletions src/main/java/ir/wy/wycore/spigot/support/protection/Lands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,65 @@ 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)
}
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 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 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
override fun canInjure(
player: Player,
victim: LivingEntity
): Boolean {

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)
}
}
val area = landsIntegration.getArea(victim.location) ?: return true

override fun getPluginName(): String {
return "Lands"
}
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 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 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
override fun getPluginName(): String {
return "Lands"
}

return other.pluginName == this.pluginName
}
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()
}
override fun hashCode(): Int {
return this.pluginName.hashCode()
}
}

0 comments on commit 906903c

Please sign in to comment.