generated from sya-ri/KotlinSpigotPluginTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
105 lines (93 loc) · 3.81 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import groovy.lang.Closure
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
import java.net.HttpURLConnection
import java.net.URL
plugins {
kotlin("jvm") version "1.6.10"
id("net.minecrell.plugin-yml.bukkit") version "0.5.1"
id("com.github.ben-manes.versions") version "0.41.0"
id("com.palantir.git-version") version "0.12.3"
id("dev.s7a.gradle.minecraft.server") version "1.2.0"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("org.jmailen.kotlinter") version "3.8.0"
}
val gitVersion: Closure<String> by extra
val pluginVersion: String by project.ext
repositories {
mavenCentral()
maven(url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven(url = "https://oss.sonatype.org/content/groups/public/")
maven(url = "https://repo.dmulloy2.net/repository/public/")
}
val shadowImplementation: Configuration by configurations.creating
configurations["implementation"].extendsFrom(shadowImplementation)
dependencies {
shadowImplementation(kotlin("stdlib"))
compileOnly("org.spigotmc:spigot-api:$pluginVersion-R0.1-SNAPSHOT")
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
}
configure<BukkitPluginDescription> {
main = "com.github.Ringoame196.Main"
version = gitVersion()
apiVersion = "1." + pluginVersion.split(".")[1]
commands {
register("itemName") {
description = "アイテムの名前や説明欄を変更をするコマンド"
usage = "/itemName <種類> <登録したい名前> (<登録したい名前2>).."
permission = "itemName.commandExecution"
}
}
permissions{
register("itemName.commandExecution") {
description = "itemNameコマンドの実行を許可する"
default = BukkitPluginDescription.Permission.Default.OP // TRUE, FALSE, OP or NOT_OP
}
}
}
tasks.withType<ShadowJar> {
configurations = listOf(shadowImplementation)
archiveClassifier.set("")
relocate("kotlin", "com.github.Ringoame196.libs.kotlin")
relocate("org.intellij.lang.annotations", "com.github.Ringoame196.libs.org.intellij.lang.annotations")
relocate("org.jetbrains.annotations", "com.github.Ringoame196.libs.org.jetbrains.annotations")
}
tasks.named("build") {
dependsOn("shadowJar")
// プラグインを特定のパスへ自動コピー
val copyFilePath = "M:/TwitterServer/plugins/" // コピー先のフォルダーパス
val copyFile = File(copyFilePath)
if (copyFile.exists() && copyFile.isDirectory) {
doFirst {
copy {
from(buildDir.resolve("libs/${project.name}.jar"))
into(copyFile)
}
}
doLast { // AutomaticCreatingPluginUpdate連携
// APIリクエストを行う
val port = 25585
val ip = "192.168.0.21"
val apiUrl = "http://$ip:$port/plugin?name=${project.name}"
val url = URL(apiUrl)
val connection = url.openConnection() as HttpURLConnection
try {
connection.requestMethod = "GET"
connection.connect()
// レスポンスコードを確認
if (connection.responseCode == HttpURLConnection.HTTP_OK) {
val response = connection.inputStream.bufferedReader().use { it.readText() }
println("API Response: $response")
} else {
println("Failed to get response: ${connection.responseCode}")
}
} catch (e: Exception) {
e.printStackTrace()
println("Error during API request: ${e.message}")
} finally {
connection.disconnect()
}
}
}
}
task<SetupTask>("setup")