Skip to content

Commit fa84280

Browse files
committed
update grande build, fix imports, update readme
1 parent 782ebdf commit fa84280

File tree

13 files changed

+160
-148
lines changed

13 files changed

+160
-148
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ out/
3232

3333
# Linux temp files
3434
*~
35+
36+
jcenter.properties

README.md

+41-47
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features
1111
## Dependencies
1212
| Name | Version |
1313
| --- | --- |
14-
| [Spigot API](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/) | 1.8.8 |
14+
| [Spigot API](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/) | 1.8.8+ |
1515

1616
## Dependencies Embed
1717
| Name | Version |
1818
| --- | --- |
19-
| Kotlin STD | 1.3.71 |
19+
| Kotlin STD + JDK8 | 1.3.71 |
2020
| [Kotlinx-coroutines](https://github.com/Kotlin/kotlinx.coroutines/) | 1.3.5 |
2121
| [Skedule](https://github.com/okkero/Skedule) | 1.2.6 |
22+
| [Kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) | 0.20.0 |
23+
| [KAML](https://github.com/charleskorn/kaml) | 0.18.1 |
2224

2325
## Modules
2426
| Module | Description |
@@ -27,40 +29,22 @@ KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features
2729
| Architecture | Help you with the Architecture of your plugin providing KotlinPlugin base and Lifecycle Listener |
2830
| Plugins | Extensions for others plugins like Vault, PlaceholderAPI and others |
2931
| Exposed(0.21.1) | Extensions for SQL framework [Exposed](https://github.com/JetBrains/Exposed/) |
30-
| Kotlinx.Serialization(0.20.0) | Extensions for [Kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) |
32+
| Serialization(0.20.0) | Extensions for [Kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) |
3133

32-
# Links
33-
- [Starter project using KotlinBukkitAPI](https://github.com/KotlinMinecraft/KBAPI-StarterProject/)
34-
- [Examples and **documentation**](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/)
35-
- [Clone and building](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/Clone-and-build)
34+
## [Documentation](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/)
3635

37-
# [Download](http://jenkins.devsrsouza.com.br/job/KotlinBukkitAPI/)
36+
## [Download](http://jenkins.devsrsouza.com.br/job/KotlinBukkitAPI/)
3837

39-
# Setup for development
38+
## Others resources
39+
- [Starter project using KotlinBukkitAPI](https://github.com/KotlinMinecraft/KBAPI-StarterProject/)
4040

41-
First of all, you need to put KotlinBukkitAPI as a dependency on your **plugin.yml**
42-
```yaml
43-
depend: [KotlinBukkitAPI]
44-
```
41+
## [Setup for development](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/Getting-Started)
4542

46-
### Gradle
43+
# Samples
4744

48-
```groovy
49-
repositories {
50-
maven {
51-
name = "KotlinBukkitAPI"
52-
url = "http://nexus.devsrsouza.com.br/repository/maven-public/"
53-
}
54-
}
45+
KotlinBukkitAPI goes beyond this samples, and you can find all of it in the [wiki/documentation](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/).
5546

56-
dependencies {
57-
compileOnly("br.com.devsrsouza.kotlinbukkitapi:core:0.1.0-SNAPSHOT") // core
58-
}
59-
```
60-
61-
# Examples
62-
63-
Event DSL example
47+
Event DSL sample
6448
```kotlin
6549
plugin.events {
6650
event<PlayerJoinEvent> {
@@ -76,7 +60,7 @@ plugin.events {
7660
Simple Command DSL example
7761
```kotlin
7862
plugin.simpleCommand("twitter") {
79-
sender.msg(+"&eFollow me on Twitter :D &ahttps://twitter.com/DevSrSouza")
63+
sender.msg("&eFollow me on Twitter :D &ahttps://twitter.com/DevSrSouza".translateColor())
8064
}
8165
```
8266

@@ -85,46 +69,56 @@ Item meta DSL and other stuff
8569
val gem = item(Material.DIAMOND).apply {
8670
amount = 5
8771
meta<ItemMeta> {
88-
displayName = +"&bGem"
72+
displayName = "&bGem".translateColor()
8973
}
9074
}
9175
val encbook = item(Material.ENCHANTED_BOOK).meta<EnchantmentStorageMeta> {
92-
displayName = +"&4&lThe powerful BOOK"
76+
displayName = "&4&lThe powerful BOOK".translateColor()
9377
addStoredEnchant(Enchantment.DAMAGE_ALL, 10, true) // putting sharpness 10 to the book
9478
}
9579
```
9680

81+
Another approach:
82+
```
83+
val gem = item(Material.DIAMOND, amount = 5).displayName("&bGem".translateColor())
84+
85+
val encbook = metadataItem<EnchantmentStorageMeta>(Material.ENCHANTED_BOOK) {
86+
displayName = "&4&lThe powerful BOOK".translateColor()
87+
addStoredEnchant(Enchantment.DAMAGE_ALL, 10, true) // putting sharpness 10 to the book
88+
}
89+
```
90+
9791
Menu creator DSL
9892
```kotlin
9993
val myMenu = menu(+"&cWarps", 3, true) {
10094

101-
slot(2, 4) { // Line, Slot
102-
item = ItemStack(Material.DIAMOND_SWORD).apply {
103-
addEnchantment(Enchantment.DAMAGE_ALL, 5)
104-
105-
meta<ItemMeta> {
106-
displayName = +"&4Arena PvP"
107-
}
108-
}
95+
val arenaPvP = item(Material.DIAMOND_SWORD) {
96+
addEnchant(Enchantment.DAMAGE_ALL, 5, true)
97+
displayName = "&4Arena PvP".translateColor()
98+
}
10999

100+
slot(2, 4, arenaPvP) { // Line, Slot
110101
onClick {
111102
player.teleport(Location(player.world, 250, 70, -355))
112103
close() // close the menu
113104
}
114105
}
115106

116-
slot(2, 6) {
117-
item = ItemStack(Material.GOLD).apply {
118-
meta<ItemMeta> {
119-
displayName = +"&6Shop"
120-
}
121-
}
122-
107+
slot(2, 6, item(Material.GOLD).displayName("&6Shop".translateColor())) {
123108
onClick {
124109
player.teleport(Location(player.world, 2399, 70, -1234))
125110
close() // close the menu
126111
}
127112
}
113+
114+
// when the menu renders to a player, will show the Paper item with their name.
115+
slot(3, 9, item(Material.PAPER).displayName("Hello {player}")) {
116+
onRender {
117+
showingItem?.meta<ItemMeta> {
118+
displayName = displayName.replace("{player}", player.name)
119+
}
120+
}
121+
}
128122
}
129123

130124
// open to player

build.gradle.kts

+48-40
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,42 @@
1-
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
21
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
32
import org.gradle.api.tasks.bundling.Jar
4-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
53

64
plugins {
75
id("java")
86
id("maven-publish")
97
kotlin("jvm") version "1.3.71"
108
id("com.github.johnrengelman.shadow") version "4.0.3"
119
id("net.minecrell.plugin-yml.bukkit") version "0.3.0"
10+
id("com.jfrog.bintray") version "1.8.4"
1211
}
1312

14-
val softPlugins by extra(mutableListOf<String>())
15-
1613
val groupPrefix = "br.com.devsrsouza.kotlinbukkitapi"
17-
val pVersion = "0.1.0-SNAPSHOT"
14+
val pVersion = KotlinBukkitAPI.version
1815
group = groupPrefix
1916
version = pVersion
2017

18+
val jcenter = loadProperties("jcenter.properties")
19+
2120
subprojects {
2221
plugins.apply("org.jetbrains.kotlin.jvm")
2322
plugins.apply("maven-publish")
2423
plugins.apply("com.github.johnrengelman.shadow")
24+
plugins.apply("com.jfrog.bintray")
2525

2626
group = groupPrefix
2727
version = pVersion
2828

2929
repositories {
3030
jcenter()
31-
maven {
32-
name = "spigot"
33-
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
34-
}
35-
maven {
36-
name = "sonatype"
37-
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
38-
}
39-
maven {
40-
name = "devsrsouza"
41-
url = uri("http://nexus.devsrsouza.com.br/repository/maven-public/")
42-
}
31+
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
32+
maven("https://oss.sonatype.org/content/repositories/snapshots/")
33+
maven("http://nexus.devsrsouza.com.br/repository/maven-public/")
4334
}
4435

4536
dependencies {
4637
compileOnly(kotlin("stdlib-jdk8"))
4738

4839
compileOnly("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT")
49-
50-
testRuntime(kotlin("stdlib"))
51-
testRuntime("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT")
52-
testRuntime("org.junit.platform:junit-platform-launcher:1.3.2")
53-
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.3.2")
54-
testRuntime("org.junit.vintage:junit-vintage-engine:5.3.2")
55-
56-
testRuntime("org.mockito:mockito-core:2.24.0")
57-
}
58-
59-
tasks.withType<Test> {
60-
useJUnitPlatform()
6140
}
6241

6342
kotlin {
@@ -67,11 +46,14 @@ subprojects {
6746
}
6847

6948
tasks {
70-
withType<KotlinCompile> {
49+
test {
50+
useJUnitPlatform()
51+
}
52+
compileKotlin {
7153
kotlinOptions.jvmTarget = "1.8"
7254
}
7355

74-
withType<ShadowJar> {
56+
shadowJar {
7557
baseName = "KotlinBukkitAPI-${project.name}"
7658
classifier = null
7759
version = null
@@ -98,8 +80,8 @@ subprojects {
9880
version = project.version.toString()
9981
pom {
10082
name.set("KotlinBukkitAPI-${project.name}")
101-
description.set("KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features Kotlin has to make your life more easier.")
102-
url.set("https://github.com/DevSrSouza/KotlinBukkitAPI")
83+
description.set(KotlinBukkitAPI.github)
84+
url.set(KotlinBukkitAPI.github)
10385
licenses {
10486
license {
10587
name.set("MIT License")
@@ -116,7 +98,32 @@ subprojects {
11698
}
11799
scm {
118100
url.set("https://github.com/DevSrSouza/KotlinBukkitAPI/tree/master/" +
119-
"${project.path.removePrefix(":").replace(":", "/")}")
101+
project.path.removePrefix(":").replace(":", "/"))
102+
}
103+
}
104+
}
105+
}
106+
}
107+
108+
if(jcenter != null) {
109+
bintray {
110+
user = jcenter["bintray_user"] as String
111+
key = jcenter["bintray_key"] as String
112+
setPublications("maven")
113+
with(pkg) {
114+
repo = "KotlinBukkitAPI"
115+
name = project.name
116+
websiteUrl = KotlinBukkitAPI.github
117+
vcsUrl = "${KotlinBukkitAPI.github}.git"
118+
issueTrackerUrl = "${KotlinBukkitAPI.github}/issues"
119+
setLicenses("MIT")
120+
121+
with(version) {
122+
name = project.version.toString()
123+
124+
with(gpg) {
125+
sign = (jcenter["gpg_sign"] as String).toBoolean()
126+
passphrase = jcenter["gpg_passphrase"] as String
120127
}
121128
}
122129
}
@@ -129,20 +136,20 @@ repositories {
129136
}
130137

131138
dependencies {
132-
compile(kotlin("stdlib-jdk8"))
139+
implementation(kotlin("stdlib-jdk8"))
133140

134141
subprojects.forEach {
135-
compile(project(it.path, configuration = "shadow"))
142+
implementation(project(it.path, configuration = "shadow"))
136143
}
137144
}
138145

139146
tasks {
140-
"compileKotlin"(KotlinCompile::class) {
147+
compileKotlin {
141148
kotlinOptions {
142149
jvmTarget = "1.8"
143150
}
144151
}
145-
"shadowJar"(ShadowJar::class) {
152+
shadowJar {
146153
baseName = project.name
147154
version += "-b${System.getenv("BUILD_NUMBER")}"
148155
classifier = null
@@ -153,11 +160,12 @@ bukkit {
153160
name = project.name
154161
version = project.version.toString()
155162
main = "br.com.devsrsouza.kotlinbukkitapi.KotlinBukkitAPI"
163+
description = KotlinBukkitAPI.description
156164

157-
website = "https://github.com/DevSrSouza/KotlinBukkitAPI"
165+
website = KotlinBukkitAPI.github
158166
authors = listOf("DevSrSouza")
159167

160-
softDepend = softPlugins
168+
softDepend = KotlinBukkitAPI.plugins.map { it.name }
161169

162170
load = BukkitPluginDescription.PluginLoadOrder.STARTUP
163171
}

buildSrc/build.gradle.kts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
repositories {
5+
jcenter()
6+
google()
7+
}
8+
dependencies {
9+
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
object KotlinBukkitAPI {
2+
val version = "0.0.1"
3+
4+
val displayName = "KotlinBukkitAPI"
5+
val description = "KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features Kotlin has to make your life more easier."
6+
val github = "https://github.com/DevSrSouza/KotlinBukkitAPI"
7+
8+
val plugins = listOf(
9+
Plugin("Vault", setOf("http://nexus.hc.to/content/repositories/pub_releases"), setOf("net.milkbowl.vault:VaultAPI:1.6")),
10+
Plugin("PlaceholderAPI", setOf("http://repo.extendedclip.com/content/repositories/placeholderapi/"), setOf("me.clip:placeholderapi:2.8.5")),
11+
Plugin("MVdWPlaceholderAPI", setOf("http://repo.mvdw-software.be/content/groups/public/"), setOf("be.maximvdw:MVdWPlaceholderAPI:2.5.2-SNAPSHOT")),
12+
Plugin("ActionBarAPI", setOf("https://jitpack.io"), setOf("com.github.ConnorLinfoot:ActionBarAPI:d60c2aedb9")),
13+
Plugin("TitleAPI", setOf("https://jitpack.io"), setOf("com.github.ConnorLinfoot:TitleAPI:1.7.6")),
14+
Plugin("WorldEdit", setOf("http://maven.sk89q.com/repo/"), setOf("com.sk89q.worldedit:worldedit-bukkit:6.1.5")),
15+
Plugin("ViaVersion", setOf("https://repo.viaversion.com/"), setOf("us.myles:viaversion-common:1.4.1")),
16+
Plugin("BossBarAPI", setOf("https://repo.inventivetalent.org/content/groups/public/"), setOf("org.inventivetalent:bossbarapi:2.4.1")),
17+
Plugin("HologramAPI", setOf("https://repo.inventivetalent.org/content/groups/public/"), setOf("org.inventivetalent:hologramapi:1.4.0")),
18+
Plugin("ProtocolLib", setOf("http://repo.dmulloy2.net/nexus/repository/public/"), setOf("com.comphenix.protocol:ProtocolLib:4.4.0"))
19+
)
20+
}

buildSrc/src/main/kotlin/Plugin.kt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
data class Plugin(
2+
val name: String,
3+
val repositories: Set<String>,
4+
val dependencies: Set<String>
5+
)

buildSrc/src/main/kotlin/Utils.kt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import java.io.File
2+
import java.util.*
3+
4+
// null if the file does not exist
5+
fun loadProperties(file: String): Properties? {
6+
val file = File(file).takeIf { it.exists() } ?: return null
7+
8+
return Properties().apply {
9+
load(file.inputStream())
10+
}
11+
}

0 commit comments

Comments
 (0)