Added HuskClaims antigrief support
Added HuskTowns antigrief support Added ItemBridge lookup support (`itembridge:key__id)
This commit is contained in:
@@ -244,6 +244,8 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
||||
IntegrationLoader("Kingdoms") { AntigriefManager.register(AntigriefKingdoms()) },
|
||||
IntegrationLoader("RPGHorses") { AntigriefManager.register(AntigriefRPGHorses()) },
|
||||
IntegrationLoader("CrashClaim") { AntigriefManager.register(AntigriefCrashClaim()) },
|
||||
IntegrationLoader("HuskTowns") { AntigriefManager.register(AntigriefHuskTowns()) },
|
||||
IntegrationLoader("HuskClaims") { AntigriefManager.register(AntigriefHuskClaims()) },
|
||||
IntegrationLoader("CombatLogX") {
|
||||
val pluginManager = Bukkit.getPluginManager()
|
||||
val combatLogXPlugin = pluginManager.getPlugin("CombatLogX") ?: return@IntegrationLoader
|
||||
@@ -283,6 +285,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
||||
IntegrationLoader("MythicMobs") { CustomItemsManager.register(CustomItemsMythicMobs(this)) },
|
||||
IntegrationLoader("Scyther") { CustomItemsManager.register(CustomItemsScyther()) },
|
||||
IntegrationLoader("Denizen") { CustomItemsManager.register(CustomItemsDenizen()) },
|
||||
IntegrationLoader("ItemBridge") { CustomItemsManager.register(CustomItemsItemBridge()) },
|
||||
|
||||
// Shop
|
||||
IntegrationLoader("ShopGUIPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.willfp.eco.internal.spigot.integrations.antigrief
|
||||
|
||||
import com.willfp.eco.core.integrations.antigrief.AntigriefIntegration
|
||||
import net.crashcraft.crashclaim.CrashClaim
|
||||
import net.crashcraft.crashclaim.permissions.PermissionRoute
|
||||
import net.william278.huskclaims.api.HuskClaimsAPI
|
||||
import net.william278.huskclaims.libraries.cloplib.operation.Operation
|
||||
import net.william278.huskclaims.libraries.cloplib.operation.OperationPosition
|
||||
import net.william278.huskclaims.libraries.cloplib.operation.OperationType
|
||||
import net.william278.huskclaims.position.Position
|
||||
import net.william278.huskclaims.position.World
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.block.Block
|
||||
import org.bukkit.entity.LivingEntity
|
||||
import org.bukkit.entity.Monster
|
||||
import org.bukkit.entity.Player
|
||||
import kotlin.jvm.optionals.getOrElse
|
||||
|
||||
class AntigriefHuskClaims : AntigriefIntegration {
|
||||
override fun canBreakBlock(
|
||||
player: Player,
|
||||
block: Block
|
||||
): Boolean {
|
||||
val api = HuskClaimsAPI.getInstance() ?: return true
|
||||
|
||||
val user = api.getOnlineUser(player.uniqueId) ?: return true
|
||||
|
||||
return api.isOperationAllowed(
|
||||
Operation.of(
|
||||
user,
|
||||
OperationType.BLOCK_BREAK,
|
||||
Position.at(
|
||||
block.x.toDouble(),
|
||||
block.y.toDouble(),
|
||||
block.z.toDouble(),
|
||||
api.getWorld(block.location.world.name)
|
||||
),
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun canCreateExplosion(
|
||||
player: Player,
|
||||
location: Location
|
||||
): Boolean {
|
||||
val api = HuskClaimsAPI.getInstance() ?: return true
|
||||
|
||||
val user = api.getOnlineUser(player.uniqueId) ?: return true
|
||||
|
||||
return api.isOperationAllowed(
|
||||
Operation.of(
|
||||
user,
|
||||
OperationType.EXPLOSION_DAMAGE_ENTITY,
|
||||
Position.at(
|
||||
location.x,
|
||||
location.y,
|
||||
location.z,
|
||||
api.getWorld(location.world.name)
|
||||
),
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun canPlaceBlock(
|
||||
player: Player,
|
||||
block: Block
|
||||
): Boolean {
|
||||
val api = HuskClaimsAPI.getInstance() ?: return true
|
||||
|
||||
val user = api.getOnlineUser(player.uniqueId) ?: return true
|
||||
|
||||
return api.isOperationAllowed(
|
||||
Operation.of(
|
||||
user,
|
||||
OperationType.BLOCK_PLACE,
|
||||
Position.at(
|
||||
block.x.toDouble(),
|
||||
block.y.toDouble(),
|
||||
block.z.toDouble(),
|
||||
api.getWorld(block.location.world.name)
|
||||
),
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun canInjure(
|
||||
player: Player,
|
||||
victim: LivingEntity
|
||||
): Boolean {
|
||||
val api = HuskClaimsAPI.getInstance() ?: return true
|
||||
|
||||
val user = api.getOnlineUser(player.uniqueId) ?: return true
|
||||
|
||||
return api.isOperationAllowed(
|
||||
Operation.of(
|
||||
user,
|
||||
when (victim) {
|
||||
is Monster -> OperationType.PLAYER_DAMAGE_MONSTER
|
||||
is Player -> OperationType.PLAYER_DAMAGE_PLAYER
|
||||
else -> OperationType.PLAYER_DAMAGE_ENTITY
|
||||
},
|
||||
Position.at(
|
||||
victim.x,
|
||||
victim.y,
|
||||
victim.z,
|
||||
api.getWorld(victim.location.world.name)
|
||||
),
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "HuskClaims"
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is AntigriefIntegration) {
|
||||
return false
|
||||
}
|
||||
|
||||
return other.pluginName == this.pluginName
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return this.pluginName.hashCode()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.willfp.eco.internal.spigot.integrations.antigrief
|
||||
|
||||
import com.willfp.eco.core.integrations.antigrief.AntigriefIntegration
|
||||
import net.william278.husktowns.api.HuskTownsAPI
|
||||
import net.william278.husktowns.claim.Position
|
||||
import net.william278.husktowns.listener.Operation
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.block.Block
|
||||
import org.bukkit.entity.LivingEntity
|
||||
import org.bukkit.entity.Monster
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class AntigriefHuskTowns : AntigriefIntegration {
|
||||
override fun canBreakBlock(
|
||||
player: Player,
|
||||
block: Block
|
||||
): Boolean {
|
||||
val api = HuskTownsAPI.getInstance() ?: return true
|
||||
|
||||
val user = api.getOnlineUser(player) ?: return true
|
||||
|
||||
return api.isOperationAllowed(
|
||||
Operation.of(
|
||||
user,
|
||||
Operation.Type.BLOCK_BREAK,
|
||||
Position.at(
|
||||
block.location.x,
|
||||
block.location.y,
|
||||
block.location.z,
|
||||
api.getWorld(block.world)
|
||||
),
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun canCreateExplosion(
|
||||
player: Player,
|
||||
location: Location
|
||||
): Boolean {
|
||||
val api = HuskTownsAPI.getInstance() ?: return true
|
||||
|
||||
val user = api.getOnlineUser(player) ?: return true
|
||||
|
||||
return api.isOperationAllowed(
|
||||
Operation.of(
|
||||
user,
|
||||
Operation.Type.EXPLOSION_DAMAGE_ENTITY,
|
||||
Position.at(
|
||||
location.x,
|
||||
location.y,
|
||||
location.z,
|
||||
api.getWorld(location.world)
|
||||
),
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun canPlaceBlock(
|
||||
player: Player,
|
||||
block: Block
|
||||
): Boolean {
|
||||
val api = HuskTownsAPI.getInstance() ?: return true
|
||||
|
||||
val user = api.getOnlineUser(player) ?: return true
|
||||
|
||||
return api.isOperationAllowed(
|
||||
Operation.of(
|
||||
user,
|
||||
Operation.Type.BLOCK_PLACE,
|
||||
Position.at(
|
||||
block.location.x,
|
||||
block.location.y,
|
||||
block.location.z,
|
||||
api.getWorld(block.world)
|
||||
),
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun canInjure(
|
||||
player: Player,
|
||||
victim: LivingEntity
|
||||
): Boolean {
|
||||
val api = HuskTownsAPI.getInstance() ?: return true
|
||||
|
||||
val user = api.getOnlineUser(player) ?: return true
|
||||
|
||||
return api.isOperationAllowed(
|
||||
Operation.of(
|
||||
user,
|
||||
when(victim) {
|
||||
is Monster -> Operation.Type.PLAYER_DAMAGE_MONSTER
|
||||
is Player -> Operation.Type.PLAYER_DAMAGE_PLAYER
|
||||
else -> Operation.Type.PLACE_HANGING_ENTITY
|
||||
},
|
||||
Position.at(
|
||||
player.location.x,
|
||||
player.location.y,
|
||||
player.location.z,
|
||||
api.getWorld(player.world)
|
||||
),
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "HuskTowns"
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is AntigriefIntegration) {
|
||||
return false
|
||||
}
|
||||
|
||||
return other.pluginName == this.pluginName
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return this.pluginName.hashCode()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.willfp.eco.internal.spigot.integrations.customitems
|
||||
|
||||
import com.jojodmo.itembridge.ItemBridge
|
||||
import com.willfp.eco.core.integrations.customitems.CustomItemsIntegration
|
||||
import com.willfp.eco.core.items.CustomItem
|
||||
import com.willfp.eco.core.items.Items
|
||||
import com.willfp.eco.core.items.TestableItem
|
||||
import com.willfp.eco.core.items.provider.ItemProvider
|
||||
import com.willfp.eco.util.namespacedKeyOf
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class CustomItemsItemBridge : CustomItemsIntegration {
|
||||
override fun registerProvider() {
|
||||
Items.registerItemProvider(ItemBridgeProvider())
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "ItemBridge"
|
||||
}
|
||||
|
||||
private class ItemBridgeProvider : ItemProvider("itembridge") {
|
||||
override fun provideForKey(key: String): TestableItem? {
|
||||
|
||||
val split = key.split(":").toMutableList()
|
||||
|
||||
if (split.size < 2) {
|
||||
return null
|
||||
}
|
||||
|
||||
val itemKey = split[0]
|
||||
|
||||
val item = split[1]
|
||||
|
||||
val stack = ItemBridge.getItemStack(itemKey, item) ?: kotlin.run {
|
||||
return null
|
||||
}
|
||||
|
||||
return CustomItem(
|
||||
namespacedKeyOf("eco:${key.lowercase().replace(":", "__")}"),
|
||||
{ test: ItemStack ->
|
||||
ItemBridge.isItemStack(test, itemKey, item)
|
||||
},
|
||||
stack
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,9 @@ loadbefore:
|
||||
- SCore
|
||||
- ExecutableItems
|
||||
softdepend:
|
||||
- ItemBridge
|
||||
- HuskClaims
|
||||
- HuskTowns
|
||||
- Terra
|
||||
- ProtocolLib
|
||||
- WorldGuard
|
||||
|
||||
Reference in New Issue
Block a user