Skip to content

Commit a75e5c2

Browse files
authored
Merge pull request #34 from yukonisen/bukkit
IPv6 解析
2 parents 54c1260 + 9e3a9c9 commit a75e5c2

26 files changed

Lines changed: 519 additions & 347 deletions

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "external/ipdb"]
2+
path = external/ipdb
3+
url = https://github.com/yukonisen/ipdb-java.git

.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PLUGIN_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
PLUGIN=1.4.2
1+
PLUGIN=1.5.0

bukkit/build.gradle.kts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
2-
kotlin("jvm") version "1.9.22"
2+
kotlin("jvm") version "2.2.0"
33
id("idea")
4-
id("com.github.johnrengelman.shadow") version "8.1.1"
5-
id("xyz.jpenilla.run-paper") version "2.2.2"
4+
id("com.gradleup.shadow") version "8.3.8"
5+
id("xyz.jpenilla.run-paper") version "2.3.1"
66
}
77

88
repositories {
@@ -14,20 +14,25 @@ repositories {
1414
dependencies {
1515
implementation("com.google.code.gson:gson:2.10.1")
1616
compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT")
17-
compileOnly("me.clip:placeholderapi:2.11.4")
17+
compileOnly("me.clip:placeholderapi:2.11.6")
1818
implementation("org.lionsoul:ip2region:2.7.0")
19+
implementation("org.bstats:bstats-bukkit:3.1.0")
20+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
21+
implementation(project(":ipdb"))
1922
}
23+
2024
val pluginVersion = project.parent?.version
2125

2226
tasks {
2327
shadowJar {
2428
archiveFileName = "PotatoIPDisplay-Bukkit-${pluginVersion}.jar"
29+
relocate("org.bstats","indi.nightfish.potato_ip_display.bstats" )
2530
}
2631
runServer {
2732
// Configure the Minecraft version for our task.
2833
// This is the only required configuration besides applying the plugin.
2934
// Your plugin's jar (or shadowJar if present) will be used automatically.
30-
minecraftVersion("1.20.4")
35+
minecraftVersion("1.21.6")
3136
}
3237
}
3338

bukkit/src/main/kotlin/indi/nightfish/potato_ip_display/PotatoIpDisplay.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package indi.nightfish.potato_ip_display
22

33
import indi.nightfish.potato_ip_display.command.PotatoIpDisplayCommand
4-
import indi.nightfish.potato_ip_display.integration.PlaceholderIntergration
4+
import indi.nightfish.potato_ip_display.integration.PlaceholderIntegration
55
import indi.nightfish.potato_ip_display.listener.MessageListener
66
import indi.nightfish.potato_ip_display.listener.PlayerJoinListener
77
import indi.nightfish.potato_ip_display.util.Config
8+
import indi.nightfish.potato_ip_display.util.ConfigManager
89
import indi.nightfish.potato_ip_display.util.UpdateUtil
9-
import indi.nightfish.potato_ip_display.util.loadConfig
10-
import me.clip.placeholderapi.metrics.bukkit.Metrics
10+
import kotlinx.coroutines.CoroutineScope
11+
import kotlinx.coroutines.Dispatchers
12+
import kotlinx.coroutines.cancel
13+
import org.bstats.bukkit.Metrics
1114
import org.bukkit.Bukkit
1215
import org.bukkit.event.HandlerList
1316
import org.bukkit.plugin.java.JavaPlugin
@@ -20,6 +23,7 @@ class PotatoIpDisplay : JavaPlugin() {
2023
lateinit var instance: PotatoIpDisplay
2124
val plugin by lazy { instance }
2225
}
26+
val pluginScope = CoroutineScope(Dispatchers.Default)
2327

2428
lateinit var conf: Config
2529

@@ -40,10 +44,11 @@ class PotatoIpDisplay : JavaPlugin() {
4044

4145
override fun onDisable() {
4246
super.onDisable()
47+
pluginScope.cancel()
4348
log("Disabled")
4449
}
4550

46-
private fun initResources() {
51+
fun initResources() {
4752
val configFile = File(dataFolder, "config.yml")
4853
val dbFile = File(dataFolder, "ip2region.xdb")
4954
val authors = this.description.authors
@@ -68,12 +73,12 @@ class PotatoIpDisplay : JavaPlugin() {
6873

6974
fun initPlugin() {
7075
val pm = Bukkit.getPluginManager()
71-
conf = loadConfig(config)
76+
conf = ConfigManager.load(this)
7277

73-
PlaceholderIntergration().unregister()
74-
if (conf.papi.enabled) {
75-
if (pm.getPlugin("PlaceholderAPI") != null) {
76-
PlaceholderIntergration().register()
78+
if (pm.getPlugin("PlaceholderAPI") != null) {
79+
PlaceholderIntegration().unregister()
80+
if (conf.papi.enabled) {
81+
PlaceholderIntegration().register()
7782
} else throw RuntimeException("PlaceholderAPI enabled in config but NOT installed!")
7883
}
7984

0 commit comments

Comments
 (0)