Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c38923b65 | |||
| a5a9f8c393 |
@@ -2,7 +2,6 @@ package xyz.fortern.forternhelper.placeholder
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Chunk
|
||||
import org.bukkit.OfflinePlayer
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
|
||||
@@ -27,7 +26,7 @@ class ForternExpansion(
|
||||
}
|
||||
|
||||
override fun onRequest(player: OfflinePlayer, params: String): String {
|
||||
if (params.startsWith("loadlevel_")) {
|
||||
return if (params.startsWith("loadlevel_")) {
|
||||
// e.g. peace_the_nether_x,z
|
||||
val first = params.indexOf('_')
|
||||
if (first < 0) return "unknown"
|
||||
@@ -39,23 +38,16 @@ class ForternExpansion(
|
||||
val chunkX = split[0]
|
||||
val chunkZ = split[1]
|
||||
val worldName = params.substring(first + 1, last)
|
||||
val world = Bukkit.getWorld(worldName)
|
||||
if (world != null) {
|
||||
return try {
|
||||
val x = Integer.parseInt(chunkX)
|
||||
val z = Integer.parseInt(chunkZ)
|
||||
val loadLevel = world.getChunkAt(x, z).loadLevel
|
||||
if (loadLevel == Chunk.LoadLevel.TICKING || loadLevel == Chunk.LoadLevel.ENTITY_TICKING) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
} catch (_: NumberFormatException) {
|
||||
return "unknown"
|
||||
}
|
||||
val world = Bukkit.getWorld(worldName) ?: return "unknown"
|
||||
try {
|
||||
val x = Integer.parseInt(chunkX)
|
||||
val z = Integer.parseInt(chunkZ)
|
||||
world.getChunkAt(x, z).loadLevel.toString()
|
||||
} catch (_: NumberFormatException) {
|
||||
"unknown"
|
||||
}
|
||||
return "unknown"
|
||||
} else {
|
||||
"unknown"
|
||||
}
|
||||
return "null"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user