Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from TheWylot/dev/v2.0.0
Browse files Browse the repository at this point in the history
Dev/v2.0.0
  • Loading branch information
TheWylot authored Feb 15, 2023
2 parents 401babf + 527c8b3 commit 3633c21
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 267 deletions.
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>ir.wy</groupId>
<artifactId>WyCore</artifactId>
<packaging>jar</packaging>
<version>2.0.5</version>
<version>2.0.6</version>


<properties>
Expand Down Expand Up @@ -173,8 +173,9 @@
<dependency>
<groupId>com.bgsoftware</groupId>
<artifactId>SuperiorSkyblockAPI</artifactId>
<version>latest</version>
<scope>provided</scope>
<version>provided</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/SuperiorSkyblock2API.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package ir.wy.wycore.spigot.support.protection.skyblockcore

import ir.wy.wycore.behind.support.protection.ProtectionSupport
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 org.bukkit.Location
import org.bukkit.block.Block
import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Monster
import org.bukkit.entity.Player

class SuperiorSkyBlock : ProtectionSupport {
override fun getPluginName(): String {
return "SuperiorSkyblock2"
}

override fun canBreakBlock(player: Player, block: Block): Boolean {
val island = SuperiorSkyblockAPI.getIslandAt(block.location)
val superiorPlayer = SuperiorSkyblockAPI.getPlayer(player)

if (island == null) {
if (!superiorPlayer.hasBypassModeEnabled() && SuperiorSkyblockAPI.getSuperiorSkyblock().grid
.isIslandsWorld(superiorPlayer.world)
) {
return false
}
return true
}

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 {
if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) {
return true
}
return SuperiorSkyblockAPI.getIslandAt(location)?.isMember(SuperiorSkyblockAPI.getPlayer(player)) ?: true
}

override fun canPlaceBlock(player: Player, block: Block): Boolean {
val 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
}

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 {

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")
}

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 = SuperiorSkyblockAPI.getSuperiorSkyblock().grid.getIslandAt(location) ?: return true
return island.hasPermission(superiorPlayer, IslandPrivilege.getByName("PICKUP_DROPS"))
}
}
264 changes: 0 additions & 264 deletions src/main/java/ir/wy/wycore/spigot/utils/TimeUtils.java

This file was deleted.

0 comments on commit 3633c21

Please sign in to comment.