From d2c6cc0d2ee5ed4f3855bac06273872c13814f29 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Fri, 19 Nov 2021 23:22:15 +0300 Subject: [PATCH 1/3] Added more flexible constructors to ConfigYml.java --- .../eco/core/config/base/ConfigYml.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/eco-api/src/main/java/com/willfp/eco/core/config/base/ConfigYml.java b/eco-api/src/main/java/com/willfp/eco/core/config/base/ConfigYml.java index e974e6eb..01380673 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/config/base/ConfigYml.java +++ b/eco-api/src/main/java/com/willfp/eco/core/config/base/ConfigYml.java @@ -16,4 +16,36 @@ public class ConfigYml extends YamlBaseConfig { public ConfigYml(@NotNull final EcoPlugin plugin) { super("config", true, plugin); } + + /** + * Config.yml. + * + * @param plugin The plugin. + * @param removeUnused Remove unused. + */ + public ConfigYml(@NotNull final EcoPlugin plugin, boolean removeUnused) { + super("config", removeUnused, plugin); + } + + /** + * Config.yml. + * + * @param plugin The plugin. + * @param name The config name. + */ + public ConfigYml(@NotNull final EcoPlugin plugin, String name) { + super(name, true, plugin); + } + + /** + * Config.yml. + * + * @param plugin The plugin. + * @param name The config name. + * @param removeUnused Remove unused. + */ + public ConfigYml(@NotNull final EcoPlugin plugin, String name, boolean removeUnused) { + super(name, removeUnused, plugin); + } + } From f2760269720a69ae263e1bd8c1bffad1a8fad192 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Fri, 19 Nov 2021 23:22:15 +0300 Subject: [PATCH 2/3] Added more flexible constructors to ConfigYml.java --- .../eco/core/config/base/ConfigYml.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/eco-api/src/main/java/com/willfp/eco/core/config/base/ConfigYml.java b/eco-api/src/main/java/com/willfp/eco/core/config/base/ConfigYml.java index e974e6eb..01380673 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/config/base/ConfigYml.java +++ b/eco-api/src/main/java/com/willfp/eco/core/config/base/ConfigYml.java @@ -16,4 +16,36 @@ public class ConfigYml extends YamlBaseConfig { public ConfigYml(@NotNull final EcoPlugin plugin) { super("config", true, plugin); } + + /** + * Config.yml. + * + * @param plugin The plugin. + * @param removeUnused Remove unused. + */ + public ConfigYml(@NotNull final EcoPlugin plugin, boolean removeUnused) { + super("config", removeUnused, plugin); + } + + /** + * Config.yml. + * + * @param plugin The plugin. + * @param name The config name. + */ + public ConfigYml(@NotNull final EcoPlugin plugin, String name) { + super(name, true, plugin); + } + + /** + * Config.yml. + * + * @param plugin The plugin. + * @param name The config name. + * @param removeUnused Remove unused. + */ + public ConfigYml(@NotNull final EcoPlugin plugin, String name, boolean removeUnused) { + super(name, removeUnused, plugin); + } + } From 95cecc2b2acb3bc690ec108360d481b8687c9341 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sat, 27 Nov 2021 22:20:32 +0300 Subject: [PATCH 3/3] Remade SuperiorSkyblock2 antigrief integration --- .../antigrief/AntigriefSuperiorSkyblock2.kt | 83 +++++++++++++++---- 1 file changed, 67 insertions(+), 16 deletions(-) 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 index 9e87018d..a88e56b7 100644 --- 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 @@ -2,14 +2,15 @@ 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.Island import com.bgsoftware.superiorskyblock.api.island.IslandPrivilege +import com.bgsoftware.superiorskyblock.api.key.Key +import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer import com.willfp.eco.core.integrations.antigrief.AntigriefWrapper 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 +import org.bukkit.entity.* class AntigriefSuperiorSkyblock2 : AntigriefWrapper { override fun getPluginName(): String { @@ -17,11 +18,42 @@ 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(player.world) + ) { + return false + } return true } - return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("Break")) - || SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("BREAK")) + + val blockType = block.type + + val islandPermission: IslandPrivilege = + if (blockType == Material.SPAWNER) IslandPrivilege.getByName("SPAWNER_BREAK") else IslandPrivilege.getByName("BREAK") + + if (!island.hasPermission(superiorPlayer, islandPermission)) { + return false + } + + if (SuperiorSkyblockAPI.getSuperiorSkyblock().settings.valuableBlocks + .contains(Key.of(block)) && + !island.hasPermission(superiorPlayer, IslandPrivilege.getByName("VALUABLE_BREAK")) + ) { + return false + } + + if (!island.isInsideRange(block.location)) { + return false + } + + return true } override fun canCreateExplosion(player: Player, location: Location): Boolean { @@ -32,11 +64,29 @@ 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 { @@ -45,13 +95,14 @@ class AntigriefSuperiorSkyblock2 : AntigriefWrapper { } 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")) + else -> { + val island: Island? = SuperiorSkyblockAPI.getSuperiorSkyblock().grid.getIslandAt(victim.location) + val islandPermission = if (victim is Monster) IslandPrivilege.getByName("MONSTER_DAMAGE") else IslandPrivilege.getByName("ANIMAL_DAMAGE") + if (island != null ) { + return island.hasPermission(player, islandPermission) + } + return true } - is Monster -> { - return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("MONSTER_DAMAGE")) - } - else -> true } } } \ No newline at end of file