From a34c63161dc94d6386356daf0b5640c818c00d3e Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Wed, 27 Oct 2021 22:44:45 +0300 Subject: [PATCH] Added SuperiorSkyblock2 Antigrief integration --- build.gradle | 3 ++ eco-core/core-plugin/build.gradle | 1 + .../com/willfp/eco/spigot/EcoSpigotPlugin.kt | 1 + .../antigrief/AntigriefSuperiorSkyblock2.kt | 49 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/antigrief/AntigriefSuperiorSkyblock2.kt diff --git a/build.gradle b/build.gradle index 7ae2641e..491e94c0 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,9 @@ allprojects { mavenLocal() maven { url 'https://jitpack.io' } + // SuperiorSkyblock2 + maven { url 'https://repo.bg-software.com/repository/api/' } + // NMS (for jitpack compilation) maven { url 'https://repo.codemc.org/repository/nms/' } diff --git a/eco-core/core-plugin/build.gradle b/eco-core/core-plugin/build.gradle index 87cdaa93..4f2aa889 100644 --- a/eco-core/core-plugin/build.gradle +++ b/eco-core/core-plugin/build.gradle @@ -30,6 +30,7 @@ dependencies { compileOnly 'com.github.brcdev-minecraft:shopgui-api:2.2.0' compileOnly 'com.github.LoneDev6:API-ItemsAdder:2.4.7' compileOnly 'com.arcaniax:HeadDatabase-API:1.3.0' + compileOnly 'com.bgsoftware:SuperiorSkyblockAPI:latest' // CombatLogX V10 + NewbieHelper Expansion compileOnly 'com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT' diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt index eb9ba56d..ff60c03b 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt @@ -123,6 +123,7 @@ abstract class EcoSpigotPlugin : EcoPlugin( override fun loadIntegrationLoaders(): List { return listOf( // AntiGrief + IntegrationLoader("SuperiorSkyblock2") { AntigriefManager.register(AntigriefSuperiorSkyblock2()) }, IntegrationLoader("WorldGuard") { AntigriefManager.register(AntigriefWorldGuard()) }, IntegrationLoader("GriefPrevention") { AntigriefManager.register(AntigriefGriefPrevention()) }, IntegrationLoader("FactionsUUID") { AntigriefManager.register(AntigriefFactionsUUID()) }, diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/antigrief/AntigriefSuperiorSkyblock2.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/antigrief/AntigriefSuperiorSkyblock2.kt new file mode 100644 index 00000000..1d7c0d34 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/antigrief/AntigriefSuperiorSkyblock2.kt @@ -0,0 +1,49 @@ +package com.willfp.eco.spigot.integrations.antigrief + +import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI +import com.bgsoftware.superiorskyblock.api.enums.HitActionResult +import com.bgsoftware.superiorskyblock.api.island.IslandPrivilege +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 + +class AntigriefSuperiorSkyblock2 : AntigriefWrapper { + override fun getPluginName(): String { + return "SuperiorSkyblock2" + } + + override fun canBreakBlock(player: Player, block: Block): Boolean { + if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) return true + return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("Break")) + || SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("BREAK")) + } + + override fun canCreateExplosion(player: Player, location: Location): Boolean { + if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) return true + return SuperiorSkyblockAPI.getIslandAt(location)?.isMember(SuperiorSkyblockAPI.getPlayer(player)) ?: true + } + + override fun canPlaceBlock(player: Player, block: Block): Boolean { + if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) return true + return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("Place")) + || SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("PLACE")) + } + + override fun canInjure(player: Player, victim: LivingEntity): Boolean { + if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) return true + return when { + victim is Player -> SuperiorSkyblockAPI.getPlayer(player).canHit(SuperiorSkyblockAPI.getPlayer(victim)).equals(HitActionResult.SUCCESS) + victim is Animals -> { + return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("ANIMAL_DAMAGE")) + } + victim is Monster -> { + return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("MONSTER_DAMAGE")) + } + else -> true + } + } +} \ No newline at end of file