Skip to content

Commit e98380e

Browse files
committed
Update bstats.
1 parent 2de3783 commit e98380e

File tree

12 files changed

+154
-14
lines changed

12 files changed

+154
-14
lines changed

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/api/script/ScriptManager.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class ScriptManager {
2323

2424
val scripts = mutableMapOf<String, CustomScript>()
2525

26+
// bStats
27+
var evaluateCount = 0
28+
var executeCount = 0
29+
30+
var operationCount = 0
31+
2632
init {
2733
if (!folders[0].exists()) {
2834
folders[0].mkdirs()
@@ -181,9 +187,9 @@ class ScriptManager {
181187

182188

183189
fun eval(script: CustomScript, sign: String, sender: GlobalSender) =
184-
script.eval(sign, sender)
190+
script.eval(sign, sender).also { evaluateCount += 1; operationCount += 1 }
185191

186192
fun execute(script: CustomScript, sign: String, sender: GlobalSender, main: String = script.configOption.main, args: Array<Any?> = arrayOf()) =
187-
script.execute(sign, sender, main, args)
193+
script.execute(sign, sender, main, args).also { executeCount += 1; operationCount += 1 }
188194

189195
}

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/placeholder/Placeholders.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
package me.scoretwo.fastscript.placeholder
22

3+
import me.scoretwo.utils.sender.GlobalPlayer
4+
35
object Placeholders {
46

5-
fun parse(player: Any, params: String): String {
7+
// %fastscript_script_[name]_evaluate(eval)_expansion%
8+
// %fastscript_script_[name]_execute(run)_expansion_<main>_<args...>%
9+
fun parse(player: GlobalPlayer, params: String): String {
10+
var skipIndex = -1
11+
val args = mutableListOf<String>().also { args ->
12+
val split = params.split("_")
13+
split.forEachIndexed { index, string ->
14+
if (string.startsWith("[")) {
15+
split.forEachIndexed { index, s ->
16+
17+
}
18+
}
19+
}
20+
21+
}
22+
23+
624
TODO()
725
}
826

build.gradle.kts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ allprojects {
2424
mavenCentral()
2525
mavenLocal()
2626
maven("http://repo.iroselle.com/snapshots/")
27+
maven("http://repo.iroselle.com/public/")
2728
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/")
2829
maven("https://repo.spongepowered.org/maven")
2930
maven("https://jitpack.io")
3031
maven("https://hub.spigotmc.org/nexus/content/repositories/sonatype-nexus-snapshots/")
3132
maven("https://repo.codemc.io/repository/maven-snapshots/")
33+
maven("https://repo.codemc.io/repository/maven-public/")
3234
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
3335
}
3436

@@ -55,6 +57,9 @@ dependencies {
5557

5658
implementation("net.md-5:bungeecord-chat:1.16-R0.4-SNAPSHOT")
5759
implementation("org.bstats:bstats-bukkit:1.7")
60+
implementation("com.iroselle:cstats-bukkit:1.8")
61+
implementation("org.bstats:bstats-bungeecord:1.8")
62+
implementation("com.iroselle:cstats-bungeecord:1.7")
5863
implementation("commons-io:commons-io:2.7")
5964
implementation("commons-lang:commons-lang:2.6")
6065

@@ -81,7 +86,10 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
8186
include(dependency("me.scoretwo:commons-bukkit-plugin:${rootProject.extra.get("commonsVersion")}"))
8287

8388
include(dependency("net.md-5:bungeecord-chat:1.16-R0.4-SNAPSHOT"))
84-
include(dependency("org.bstats:bstats-bukkit:1.7"))
89+
include(dependency("org.bstats:bstats-bukkit:1.8"))
90+
include(dependency("com.iroselle:cstats-bukkit:1.7"))
91+
include(dependency("org.bstats:bstats-bungeecord:1.8"))
92+
include(dependency("com.iroselle:cstats-bungeecord:1.7"))
8593

8694
include(dependency("commons-io:commons-io:2.7"))
8795
include(dependency("commons-lang:commons-lang:2.6"))
@@ -94,6 +102,7 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
94102
relocate("kotlin", "me.scoretwo.utils.shaded.kotlin")
95103
relocate("org.apache","me.scoretwo.utils.shaded.org.apache")
96104
relocate("org.bstats","me.scoretwo.utils.shaded.org.bstats")
105+
relocate("com.iroselle.cstats","me.scoretwo.utils.shaded.com.iroselle.cstats")
97106

98107
exclude("META-INF/versions/9/module-info.class")
99108
exclude("META-INF/*.kotlin_module")

version-control/FastScript-bukkit/build.gradle.kts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ dependencies {
1212

1313
compileOnly("org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT")
1414
compileOnly("me.clip:placeholderapi:2.10.9")
15-
implementation("org.bstats:bstats-bukkit:1.7")
15+
16+
implementation("org.bstats:bstats-bukkit:1.8")
17+
implementation("com.iroselle:cstats-bukkit:1.7")
18+
1619
implementation("me.scoretwo:commons-bukkit-plugin:${rootProject.extra.get("commonsVersion")}")
1720
}
1821

@@ -29,10 +32,12 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
2932
exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib"))
3033
exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib-common"))
3134

32-
include(dependency("org.bstats:bstats-bukkit:1.7"))
35+
include(dependency("org.bstats:bstats-bukkit:1.8"))
36+
include(dependency("com.iroselle:cstats-bukkit:1.7"))
3337
include(dependency("me.scoretwo:commons-bukkit-plugin:${rootProject.extra.get("commonsVersion")}"))
3438
}
35-
relocate("org.bstats","me.scoretwo.utils.libs.org.bstats")
39+
relocate("org.bstats","me.scoretwo.utils.shaded.org.bstats")
40+
relocate("com.iroselle.cstats","me.scoretwo.utils.shaded.com.iroselle.cstats")
3641

3742
classifier = null
3843
}

version-control/FastScript-bukkit/src/main/kotlin/me/scoretwo/fastscript/bukkit/BukkitBootStrap.kt

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ package me.scoretwo.fastscript.bukkit
22

33
import me.scoretwo.fastscript.FastScript
44
import me.scoretwo.fastscript.api.plugin.ScriptPluginState
5+
import me.scoretwo.fastscript.plugin
56
import me.scoretwo.utils.bukkit.plugin.toGlobalPlugin
6-
import org.bstats.bukkit.Metrics
77
import org.bukkit.plugin.java.JavaPlugin
8+
import org.bukkit.Bukkit
9+
import java.lang.Exception
10+
import java.util.concurrent.Callable
811

912
class BukkitBootStrap: JavaPlugin() {
1013

@@ -17,8 +20,48 @@ class BukkitBootStrap: JavaPlugin() {
1720
override fun onEnable() {
1821
bukkitPlugin.enable()
1922
bukkitPlugin.reload()
20-
// 暂无计划
21-
val metrics = Metrics(this, 9014)
23+
org.bstats.bukkit.Metrics(this, 9014).also { metrics ->
24+
metrics.addCustomChart(org.bstats.bukkit.Metrics.SingleLineChart("Scripts") {
25+
FastScript.instance.scriptManager.scripts.size
26+
})
27+
metrics.addCustomChart(org.bstats.bukkit.Metrics.SingleLineChart("Evaluate and Execute Counts") {
28+
val count = FastScript.instance.scriptManager.operationCount
29+
FastScript.instance.scriptManager.operationCount = 0
30+
count
31+
})
32+
metrics.addCustomChart(org.bstats.bukkit.Metrics.AdvancedPie("Operation Modes") {
33+
mutableMapOf<String, Int>().also {
34+
it["Evaluate"] = FastScript.instance.scriptManager.evaluateCount
35+
FastScript.instance.scriptManager.evaluateCount = 0
36+
it["Execute"] = FastScript.instance.scriptManager.executeCount
37+
FastScript.instance.scriptManager.executeCount = 0
38+
}
39+
})
40+
metrics.addCustomChart(org.bstats.bukkit.Metrics.SimplePie("Server Brand") {
41+
plugin.server.brand.name
42+
})
43+
}
44+
com.iroselle.cstats.bukkit.Metrics(this).also { metrics ->
45+
metrics.addCustomChart(com.iroselle.cstats.bukkit.Metrics.SingleLineChart("Scripts") {
46+
FastScript.instance.scriptManager.scripts.size
47+
})
48+
metrics.addCustomChart(com.iroselle.cstats.bukkit.Metrics.SingleLineChart("Evaluate and Execute Counts") {
49+
val count = FastScript.instance.scriptManager.operationCount
50+
FastScript.instance.scriptManager.operationCount = 0
51+
count
52+
})
53+
metrics.addCustomChart(com.iroselle.cstats.bukkit.Metrics.AdvancedPie("Operation Modes") {
54+
mutableMapOf<String, Int>().also {
55+
it["Evaluate"] = FastScript.instance.scriptManager.evaluateCount
56+
FastScript.instance.scriptManager.evaluateCount = 0
57+
it["Execute"] = FastScript.instance.scriptManager.executeCount
58+
FastScript.instance.scriptManager.executeCount = 0
59+
}
60+
})
61+
metrics.addCustomChart(com.iroselle.cstats.bukkit.Metrics.SimplePie("Server Brand") {
62+
plugin.server.brand.name
63+
})
64+
}
2265
FastScript.stats = ScriptPluginState.RUNNING
2366
}
2467

version-control/FastScript-bukkit/src/main/kotlin/me/scoretwo/fastscript/bukkit/hook/PlaceholderAPIHook.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package me.scoretwo.fastscript.bukkit.hook
33
import me.clip.placeholderapi.PlaceholderAPI
44
import me.clip.placeholderapi.expansion.PlaceholderExpansion
55
import me.scoretwo.fastscript.placeholder.Placeholders
6+
import me.scoretwo.utils.bukkit.command.toGlobalPlayer
67
import org.bukkit.entity.Player
78
import org.bukkit.plugin.Plugin
89

@@ -25,7 +26,7 @@ class PlaceholderAPIHook(val plugin: Plugin): PlaceholderExpansion() {
2526
}
2627

2728
override fun onPlaceholderRequest(player: Player, params: String): String {
28-
return Placeholders.parse(player, params)
29+
return Placeholders.parse(player.toGlobalPlayer(), params)
2930
}
3031

3132
companion object {

version-control/FastScript-bungee/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ dependencies {
1111
implementation(project(":FastScript-common"))
1212
implementation("me.scoretwo:commons-bungee-plugin:${rootProject.extra.get("commonsVersion")}")
1313

14+
implementation("org.bstats:bstats-bungeecord:1.8")
15+
implementation("com.iroselle:cstats-bungeecord:1.7")
16+
1417
compileOnly("net.md-5:bungeecord-api:1.16-R0.4-SNAPSHOT")
1518
}
1619

@@ -26,6 +29,8 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
2629
dependencies {
2730
exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib"))
2831
exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib-common"))
32+
include(dependency("org.bstats:bstats-bungeecord:1.8"))
33+
include(dependency("com.iroselle:cstats-bungeecord:1.7"))
2934

3035
include(dependency("me.scoretwo:commons-bungee-plugin:${rootProject.extra.get("commonsVersion")}"))
3136
}

version-control/FastScript-bungee/src/main/kotlin/me/scoretwo/fastscript/bungee/BungeeBootStrap.kt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package me.scoretwo.fastscript.bungee
22

33
import me.scoretwo.fastscript.FastScript
44
import me.scoretwo.fastscript.api.plugin.ScriptPluginState
5+
import me.scoretwo.fastscript.plugin
56
import me.scoretwo.utils.bungee.plugin.toGlobalPlugin
67
import net.md_5.bungee.api.plugin.Plugin
78

@@ -15,6 +16,49 @@ class BungeeBootStrap: Plugin() {
1516

1617
override fun onEnable() {
1718
bungeePlugin.enable()
19+
bungeePlugin.reload()
20+
org.bstats.bungeecord.Metrics(this, 9014).also { metrics ->
21+
metrics.addCustomChart(org.bstats.bungeecord.Metrics.SingleLineChart("Scripts") {
22+
FastScript.instance.scriptManager.scripts.size
23+
})
24+
metrics.addCustomChart(org.bstats.bungeecord.Metrics.SingleLineChart("Evaluate and Execute Counts") {
25+
val count = FastScript.instance.scriptManager.operationCount
26+
FastScript.instance.scriptManager.operationCount = 0
27+
count
28+
})
29+
metrics.addCustomChart(org.bstats.bungeecord.Metrics.AdvancedPie("Operation Modes") {
30+
mutableMapOf<String, Int>().also {
31+
it["Evaluate"] = FastScript.instance.scriptManager.evaluateCount
32+
FastScript.instance.scriptManager.evaluateCount = 0
33+
it["Execute"] = FastScript.instance.scriptManager.executeCount
34+
FastScript.instance.scriptManager.executeCount = 0
35+
}
36+
})
37+
metrics.addCustomChart(org.bstats.bungeecord.Metrics.SimplePie("Server Brand") {
38+
plugin.server.brand.name
39+
})
40+
}
41+
com.iroselle.cstats.bungeecord.Metrics(this).also { metrics ->
42+
metrics.addCustomChart(com.iroselle.cstats.bungeecord.Metrics.SingleLineChart("Scripts") {
43+
FastScript.instance.scriptManager.scripts.size
44+
})
45+
metrics.addCustomChart(com.iroselle.cstats.bungeecord.Metrics.SingleLineChart("Evaluate and Execute Counts") {
46+
val count = FastScript.instance.scriptManager.operationCount
47+
FastScript.instance.scriptManager.operationCount = 0
48+
count
49+
})
50+
metrics.addCustomChart(com.iroselle.cstats.bungeecord.Metrics.AdvancedPie("Operation Modes") {
51+
mutableMapOf<String, Int>().also {
52+
it["Evaluate"] = FastScript.instance.scriptManager.evaluateCount
53+
FastScript.instance.scriptManager.evaluateCount = 0
54+
it["Execute"] = FastScript.instance.scriptManager.executeCount
55+
FastScript.instance.scriptManager.executeCount = 0
56+
}
57+
})
58+
metrics.addCustomChart(com.iroselle.cstats.bungeecord.Metrics.SimplePie("Server Brand") {
59+
plugin.server.brand.name
60+
})
61+
}
1862
FastScript.stats = ScriptPluginState.RUNNING
1963
}
2064

version-control/FastScript-sponge/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ dependencies {
1313
compileOnly("org.spongepowered:spongeapi:7.3.0")
1414
compileOnly("com.github.rojo8399:PlaceholderAPI:master-SNAPSHOT")
1515
implementation("net.md-5:bungeecord-chat:1.16-R0.4-SNAPSHOT")
16+
17+
implementation("org.bstats:bstats-sponge:1.8")
18+
implementation("com.iroselle:cstats-sponge:1.7")
19+
1620
implementation("me.scoretwo:commons-sponge-plugin:${rootProject.extra.get("commonsVersion")}")
1721
}
1822

@@ -28,6 +32,8 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
2832
dependencies {
2933
exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib"))
3034
exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib-common"))
35+
include(dependency("org.bstats:bstats-sponge:1.8"))
36+
include(dependency("com.iroselle:cstats-sponge:1.7"))
3137

3238
include(dependency("me.scoretwo:commons-sponge-plugin:${rootProject.extra.get("commonsVersion")}"))
3339
}

version-control/FastScript-sponge/src/main/kotlin/me/scoretwo/fastscript/sponge/SpongeBootStrap.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package me.scoretwo.fastscript.sponge
33
import com.google.inject.Inject
44
import me.scoretwo.fastscript.FastScript
55
import me.scoretwo.fastscript.api.plugin.ScriptPluginState
6+
import me.scoretwo.fastscript.plugin
67
import me.scoretwo.utils.sponge.plugin.toGlobalPlugin
78
import org.spongepowered.api.event.Listener
89
import org.spongepowered.api.event.game.state.GameInitializationEvent
@@ -31,6 +32,7 @@ class SpongeBootStrap @Inject constructor(val pluginContainer: PluginContainer)
3132
@Listener
3233
fun onEnable(e: GameInitializationEvent) {
3334
spongePlugin.enable()
35+
spongePlugin.reload()
3436
FastScript.stats = ScriptPluginState.RUNNING
3537
}
3638

0 commit comments

Comments
 (0)