Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1ed771eb3 | ||
|
|
08a4d9d6b1 |
@@ -17,6 +17,14 @@ public interface ServerProfile extends Profile {
|
|||||||
@NotNull
|
@NotNull
|
||||||
String getServerID();
|
String getServerID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the local server ID.
|
||||||
|
*
|
||||||
|
* @return The local server ID.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
String getLocalServerID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the server profile.
|
* Load the server profile.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ private val serverIDKey = PersistentDataKey(
|
|||||||
""
|
""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val localServerIDKey = PersistentDataKey(
|
||||||
|
namespacedKeyOf("eco", "local_server_id"),
|
||||||
|
PersistentDataKeyType.STRING,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
class EcoServerProfile(
|
class EcoServerProfile(
|
||||||
data: MutableMap<PersistentDataKey<*>, Any>,
|
data: MutableMap<PersistentDataKey<*>, Any>,
|
||||||
handler: DataHandler,
|
handler: DataHandler,
|
||||||
@@ -85,10 +91,18 @@ class EcoServerProfile(
|
|||||||
return this.read(serverIDKey)
|
return this.read(serverIDKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getLocalServerID(): String {
|
||||||
|
if (this.read(localServerIDKey).isBlank()) {
|
||||||
|
this.write(localServerIDKey, UUID.randomUUID().toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.read(localServerIDKey)
|
||||||
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "EcoServerProfile"
|
return "EcoServerProfile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val PersistentDataKey<*>.isLocal: Boolean
|
private val PersistentDataKey<*>.isLocal: Boolean
|
||||||
get() = EcoPlugin.getPlugin(this.key.namespace)?.isUsingLocalStorage == true
|
get() = this == localServerIDKey || EcoPlugin.getPlugin(this.key.namespace)?.isUsingLocalStorage == true
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class PlayerflowHandler(
|
|||||||
|
|
||||||
private fun makeRequest() {
|
private fun makeRequest() {
|
||||||
val body = json {
|
val body = json {
|
||||||
"uuid" to ServerProfile.load().serverID
|
"uuid" to ServerProfile.load().localServerID
|
||||||
"players" to Bukkit.getOnlinePlayers().size
|
"players" to Bukkit.getOnlinePlayers().size
|
||||||
"plugins" to Eco.get().loadedPlugins
|
"plugins" to Eco.get().loadedPlugins
|
||||||
}.toPlaintext()
|
}.toPlaintext()
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.61.0
|
version = 6.61.1
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
Reference in New Issue
Block a user