-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
108 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
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
45 changes: 45 additions & 0 deletions
45
...e/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/metrics/PlayerflowHandler.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,45 @@ | ||
package com.willfp.eco.internal.spigot.metrics | ||
|
||
import com.willfp.eco.core.Eco | ||
import com.willfp.eco.core.config.json | ||
import com.willfp.eco.core.data.ServerProfile | ||
import com.willfp.eco.core.scheduling.Scheduler | ||
import org.bukkit.Bukkit | ||
import java.net.URI | ||
import java.net.http.HttpClient | ||
import java.net.http.HttpRequest | ||
import java.net.http.HttpResponse | ||
|
||
private const val PLAYERFLOW_URL = "https://playerflow.auxilor.io/api/v1/ping" | ||
|
||
private val client = HttpClient.newBuilder().build() | ||
|
||
class PlayerflowHandler( | ||
private val scheduler: Scheduler | ||
) { | ||
internal fun startTicking() { | ||
scheduler.runAsyncTimer(1200L, 1200L) { | ||
makeRequest() | ||
} | ||
} | ||
|
||
private fun makeRequest() { | ||
val body = json { | ||
"uuid" to ServerProfile.load().serverID | ||
"players" to Bukkit.getOnlinePlayers().size | ||
"plugins" to Eco.get().loadedPlugins | ||
}.toPlaintext() | ||
|
||
val request = HttpRequest.newBuilder() | ||
.uri(URI.create(PLAYERFLOW_URL)) | ||
.header("Content-Type", "application/json") | ||
.POST(HttpRequest.BodyPublishers.ofString(body)) | ||
.build() | ||
|
||
try { | ||
client.send(request, HttpResponse.BodyHandlers.ofString()) | ||
} catch (e: Exception) { | ||
// Silently fail | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1,7 @@ | ||
multiple-in-craft: '&l&c! &fThis recipe requires &a%amount%&f of this item.' | ||
multiple-in-craft: '&l&c! &fThis recipe requires &a%amount%&f of this item.' | ||
|
||
# Specify default display names for prices made through ConfiguredPrice#create | ||
# These will override any custom configured price display names. | ||
price-display: | ||
- type: example_type | ||
display: "&e%value% Price" |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
version = 6.60.4 | ||
version = 6.61.0 | ||
plugin-name = eco | ||
kotlin.code.style = official |