-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from flytegg/feat/freeze
Feat/freeze
- Loading branch information
Showing
9 changed files
with
121 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ plugins { | |
} | ||
|
||
group = "gg.flyte" | ||
version = "1.1.7" | ||
version = "1.1.8" | ||
|
||
repositories { | ||
mavenLocal() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/gg/flyte/twilight/event/custom/movement/listener/EntityMoveEventListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package gg.flyte.twilight.event.custom.movement.listener | ||
|
||
import gg.flyte.twilight.Twilight.Companion.isPaper | ||
import gg.flyte.twilight.event.CustomTwilightListener | ||
import gg.flyte.twilight.event.event | ||
import gg.flyte.twilight.extension.frozen | ||
import io.papermc.paper.event.entity.EntityMoveEvent | ||
import org.bukkit.event.player.PlayerMoveEvent | ||
|
||
object EntityMoveEventListener : CustomTwilightListener() { | ||
|
||
init { | ||
if (isPaper()) { | ||
event<EntityMoveEvent> { | ||
if (entity.frozen()) isCancelled = true | ||
} | ||
} else { | ||
event<PlayerMoveEvent> { | ||
if (player.frozen()) isCancelled = true | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package gg.flyte.twilight.extension | ||
|
||
import gg.flyte.twilight.server.ServerSoftware | ||
import org.bukkit.Server | ||
|
||
fun Server.isFolia(): Boolean = ServerSoftware.isFolia() | ||
fun Server.isPaper(): Boolean = ServerSoftware.isPaper() | ||
fun Server.isSpigot(): Boolean = ServerSoftware.isSpigot() | ||
fun Server.isCraftBukkit(): Boolean = ServerSoftware.isCraftBukkit() |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/gg/flyte/twilight/server/ServerSoftware.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package gg.flyte.twilight.server | ||
|
||
enum class ServerSoftware { | ||
|
||
FOLIA, | ||
PAPER, | ||
SPIGOT, | ||
CRAFT_BUKKIT; | ||
|
||
companion object { | ||
val current: ServerSoftware by lazy { | ||
val hasClass = { name: String -> try { Class.forName(name); true } catch (e: ClassNotFoundException) { false } } | ||
|
||
if (hasClass("io.papermc.paper.threadedregions.RegionizedServer")) { | ||
FOLIA | ||
} else if (hasClass("com.destroystokyo.paper.PaperConfig") || hasClass("io.papermc.paper.configuration.Configuration")) { | ||
PAPER | ||
} else if (hasClass("org.spigotmc.SpigotConfig")) { | ||
SPIGOT | ||
} else { | ||
CRAFT_BUKKIT | ||
} | ||
} | ||
|
||
fun isFolia(): Boolean = current == FOLIA | ||
fun isPaper(): Boolean = current == PAPER | ||
fun isSpigot(): Boolean = current == SPIGOT | ||
fun isCraftBukkit(): Boolean = current == CRAFT_BUKKIT | ||
} | ||
|
||
} |