diff --git a/build.gradle.kts b/build.gradle.kts index 2bd6aca22..83717d598 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -89,6 +89,9 @@ allprojects { // IridiumSkyblock maven("https://nexus.iridiumdevelopment.net/repository/maven-releases/") + + // HuskPlugins + maven("https://repo.william278.net/releases") } dependencies { diff --git a/eco-core/core-plugin/build.gradle.kts b/eco-core/core-plugin/build.gradle.kts index 827c788bb..66e7bc1b8 100644 --- a/eco-core/core-plugin/build.gradle.kts +++ b/eco-core/core-plugin/build.gradle.kts @@ -62,6 +62,9 @@ dependencies { exclude(group = "*", module = "*") } compileOnly("com.iridium:IridiumSkyblock:4.0.8") + compileOnly("net.william278.huskclaims:huskclaims-bukkit:1.0.1") + compileOnly("net.william278:husktowns:2.6.1") + compileOnly("com.github.jojodmo:ItemBridge:b0054538c1") compileOnly(fileTree("../../lib") { include("*.jar") diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt index e5eb6706b..fc215bf3a 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt @@ -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()) }, diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/antigrief/AntigriefHuskClaims.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/antigrief/AntigriefHuskClaims.kt new file mode 100644 index 000000000..91ff92114 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/antigrief/AntigriefHuskClaims.kt @@ -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() + } +} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/antigrief/AntigriefHuskTowns.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/antigrief/AntigriefHuskTowns.kt new file mode 100644 index 000000000..d94456fd6 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/antigrief/AntigriefHuskTowns.kt @@ -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() + } +} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/customitems/CustomItemsItemBridge.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/customitems/CustomItemsItemBridge.kt new file mode 100644 index 000000000..f34d42073 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/customitems/CustomItemsItemBridge.kt @@ -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 + ) + } + } +} diff --git a/eco-core/core-plugin/src/main/resources/plugin.yml b/eco-core/core-plugin/src/main/resources/plugin.yml index 54ed00105..9791b46a1 100644 --- a/eco-core/core-plugin/src/main/resources/plugin.yml +++ b/eco-core/core-plugin/src/main/resources/plugin.yml @@ -18,6 +18,9 @@ loadbefore: - SCore - ExecutableItems softdepend: + - ItemBridge + - HuskClaims + - HuskTowns - Terra - ProtocolLib - WorldGuard