Skip to content

Commit

Permalink
[+] Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lrdcxdes committed Jan 6, 2024
1 parent 6b6584f commit 6f4341a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 32 deletions.
67 changes: 39 additions & 28 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions src/main/java/com/tierlistmc/papi/expansion/TierlistMC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.bukkit.OfflinePlayer
import org.bukkit.event.Listener
import org.bukkit.scheduler.BukkitRunnable
import org.bukkit.scheduler.BukkitTask
import java.util.concurrent.CompletableFuture
import java.util.logging.Logger


Expand Down Expand Up @@ -73,10 +74,10 @@ class TierlistMC : PlaceholderExpansion(), Listener, Taskable {

if (playerId == null) {
playerId = args.getOrNull(1) ?: return "%player_is_invalid%"
}

if (playerId.isBlank() || playerId.length < 3 || playerId.length > 16) {
return "%player_is_invalid%"
}
if (playerId.isBlank() || playerId.length < 3 || playerId.length > 16) {
return "%player_is_invalid%"
}

if (!cache.containsKey(playerId)) {
Expand Down Expand Up @@ -118,7 +119,16 @@ class TierlistMC : PlaceholderExpansion(), Listener, Taskable {
batchPlayers.add(playerId)
}

val future = api.batchRequest(Batch(batchPlayers))
val future: CompletableFuture<List<Player>>

try {
future = api.batchRequest(Batch(batchPlayers))
} catch (e: Exception) {
logger.warning("Failed to get JSON")
e.printStackTrace()
logger.warning("BatchPlayers: $batchPlayers")
return
}

future.thenAcceptAsync { players ->
for (player in players) {
Expand Down

0 comments on commit 6f4341a

Please sign in to comment.