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 #42 from TheWylot/dev/v2.0.0
Browse files Browse the repository at this point in the history
DEV-2.0.9 // Lands Support
  • Loading branch information
TheWylot authored Feb 16, 2023
2 parents 19873ad + b1a046c commit ad04bf6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>ir.wy</groupId>
<artifactId>WyCore</artifactId>
<packaging>jar</packaging>
<version>2.0.8</version>
<version>2.0.9</version>


<properties>
Expand Down Expand Up @@ -210,6 +210,12 @@
<scope>system</scope>
<systemPath>${project.basedir}/libs/VulcanAPI.jar</systemPath>
</dependency>
<dependency>
<groupId>com.github.angeschossen</groupId>
<artifactId>LandsAPI</artifactId>
<version>6.28.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.jpx3.intave.access</groupId>
<artifactId>intave-access</artifactId>
Expand Down
65 changes: 65 additions & 0 deletions src/main/java/ir/wy/wycore/spigot/support/protection/Lands.kt
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit ad04bf6

Please sign in to comment.