Added AntigriefManager#canPickupItem and created and implemented DropQueuePushEvent event
This commit is contained in:
@@ -48,6 +48,10 @@ class AntigriefCrashClaim : AntigriefWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "CrashClaim"
|
||||
}
|
||||
|
||||
@@ -31,4 +31,8 @@ class AntigriefDeluxeCombat: AntigriefWrapper {
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,10 @@ class AntigriefFactionsUUID : AntigriefWrapper {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "FactionsUUID"
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ class AntigriefGriefPrevention : AntigriefWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "GriefPrevention"
|
||||
}
|
||||
|
||||
@@ -48,6 +48,11 @@ class AntigriefIridiumSkyblock : AntigriefWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
val api = IridiumSkyblockAPI.getInstance() ?: return true
|
||||
return api.getIslandPermission(api.getIslandViaLocation(location).orElse(null) ?: return true, api.getUser(player), PermissionType.PICKUP_ITEMS)
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "IridiumSkyblock"
|
||||
}
|
||||
|
||||
@@ -65,6 +65,10 @@ class AntigriefKingdoms : AntigriefWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "Kingdoms"
|
||||
}
|
||||
|
||||
@@ -52,6 +52,11 @@ class AntigriefLands(private val plugin: EcoPlugin) : AntigriefWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
val area = landsIntegration.getAreaByLoc(location) ?: return true
|
||||
return area.hasFlag(player, Flags.ITEM_PICKUP, false)
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "Lands"
|
||||
}
|
||||
|
||||
@@ -2,14 +2,13 @@ package com.willfp.eco.internal.spigot.integrations.antigrief
|
||||
|
||||
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI
|
||||
import com.bgsoftware.superiorskyblock.api.enums.HitActionResult
|
||||
import com.bgsoftware.superiorskyblock.api.island.Island
|
||||
import com.bgsoftware.superiorskyblock.api.island.IslandPrivilege
|
||||
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer
|
||||
import com.willfp.eco.core.integrations.antigrief.AntigriefWrapper
|
||||
import org.bukkit.Location
|
||||
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
|
||||
import org.bukkit.entity.*
|
||||
|
||||
class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
||||
override fun getPluginName(): String {
|
||||
@@ -17,11 +16,29 @@ class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
||||
}
|
||||
|
||||
override fun canBreakBlock(player: Player, block: Block): Boolean {
|
||||
if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) {
|
||||
val island: Island? =
|
||||
SuperiorSkyblockAPI.getIslandAt(block.location)
|
||||
val superiorPlayer: SuperiorPlayer =
|
||||
SuperiorSkyblockAPI.getPlayer(player)
|
||||
|
||||
if (island == null) {
|
||||
if (!superiorPlayer.hasBypassModeEnabled() && SuperiorSkyblockAPI.getSuperiorSkyblock().grid
|
||||
.isIslandsWorld(superiorPlayer.world)
|
||||
) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("Break"))
|
||||
|| SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("BREAK"))
|
||||
|
||||
if (!island.hasPermission(superiorPlayer, IslandPrivilege.getByName("BREAK"))) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!island.isInsideRange(block.location)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canCreateExplosion(player: Player, location: Location): Boolean {
|
||||
@@ -32,26 +49,60 @@ class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
||||
}
|
||||
|
||||
override fun canPlaceBlock(player: Player, block: Block): Boolean {
|
||||
if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) {
|
||||
val island: Island? =
|
||||
SuperiorSkyblockAPI.getIslandAt(block.location)
|
||||
val superiorPlayer: SuperiorPlayer =
|
||||
SuperiorSkyblockAPI.getPlayer(player)
|
||||
|
||||
if (island == null) {
|
||||
if (!superiorPlayer.hasBypassModeEnabled() && SuperiorSkyblockAPI.getSuperiorSkyblock().grid
|
||||
.isIslandsWorld(superiorPlayer.world)
|
||||
) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("Place"))
|
||||
|| SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("PLACE"))
|
||||
|
||||
if (!island.hasPermission(superiorPlayer, IslandPrivilege.getByName("BUILD"))) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!island.isInsideRange(block.location)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canInjure(player: Player, victim: LivingEntity): Boolean {
|
||||
if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) {
|
||||
return true
|
||||
|
||||
val island: Island? = SuperiorSkyblockAPI.getSuperiorSkyblock().grid.getIslandAt(victim.location)
|
||||
|
||||
if (victim is Player) return SuperiorSkyblockAPI.getPlayer(player).canHit(SuperiorSkyblockAPI.getPlayer(victim)).equals(HitActionResult.SUCCESS)
|
||||
|
||||
val islandPermission = when (victim) {
|
||||
is Monster -> IslandPrivilege.getByName("MONSTER_DAMAGE")
|
||||
else -> IslandPrivilege.getByName("ANIMAL_DAMAGE")
|
||||
}
|
||||
return when (victim) {
|
||||
is Player -> SuperiorSkyblockAPI.getPlayer(player).canHit(SuperiorSkyblockAPI.getPlayer(victim)).equals(HitActionResult.SUCCESS)
|
||||
is Animals -> {
|
||||
return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("ANIMAL_DAMAGE"))
|
||||
}
|
||||
is Monster -> {
|
||||
return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("MONSTER_DAMAGE"))
|
||||
}
|
||||
else -> true
|
||||
|
||||
if (island != null && !island.hasPermission(player, islandPermission)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
val superiorPlayer: SuperiorPlayer =
|
||||
SuperiorSkyblockAPI.getPlayer(player)
|
||||
val island: Island? =
|
||||
SuperiorSkyblockAPI.getSuperiorSkyblock().grid.getIslandAt(location)
|
||||
if (island != null &&
|
||||
!island.hasPermission(superiorPlayer, IslandPrivilege.getByName("PICKUP_DROPS"))
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,10 @@ class AntigriefTowny : AntigriefWrapper {
|
||||
return townBlock.permissions.pvp
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "Towny"
|
||||
}
|
||||
|
||||
@@ -98,6 +98,13 @@ class AntigriefWorldGuard : AntigriefWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
val localPlayer: LocalPlayer = WorldGuardPlugin.inst().wrapPlayer(player)
|
||||
val container: RegionContainer = WorldGuard.getInstance().platform.regionContainer
|
||||
val query: RegionQuery = container.createQuery()
|
||||
return query.testState(BukkitAdapter.adapt(location), localPlayer, Flags.ITEM_PICKUP)
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "WorldGuard"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user