Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51090f4e1d | ||
|
|
6a421a7078 | ||
|
|
b9050a46a9 | ||
|
|
3a4c03affe | ||
|
|
7430e35ec2 | ||
|
|
dc13279d44 | ||
|
|
fad61ee007 | ||
|
|
ef23b69d9c | ||
|
|
5b7003d400 | ||
|
|
e592daad57 |
No files matched your search
@@ -5,14 +5,15 @@ plugins {
|
||||
}
|
||||
|
||||
val kotlinVersion = "1.4.0"
|
||||
val kotlinBukkitAPIVersion = "0.1.0-SNAPSHOT"
|
||||
val bukkriptVersion = "0.1.0-SNAPSHOT"
|
||||
val kotlinBukkitAPIVersion = "0.2.0-SNAPSHOT"
|
||||
val bukkriptVersion = "0.2.0-SNAPSHOT"
|
||||
|
||||
group = "br.com.devsrsouza.kotlinbukkitapi"
|
||||
version = "0.0.3"
|
||||
version = "0.0.6"
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
maven("http://nexus.devsrsouza.com.br/repository/maven-public/")
|
||||
}
|
||||
|
||||
@@ -85,6 +86,25 @@ tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml
|
||||
|
||||
|
||||
changeNotes("""
|
||||
<h3>0.0.6</h3>
|
||||
<br />
|
||||
|
||||
<ul>
|
||||
<li>Update the embedded version of Bukkript and KotlinBukkitAPI.</li>
|
||||
<li>Adding KotlinBukkitAPI 0.2.0-SNAPSHOT to the Project Wizard.</li>
|
||||
<li>Improving overall performance of Menu Preview.</li>
|
||||
</ul>
|
||||
|
||||
<h3>0.0.5</h3>
|
||||
<br />
|
||||
|
||||
<ul>
|
||||
<li>Menu Preview support for 1.13+ Material enum.</li>
|
||||
<li>Increase Menu Preview performance</li>
|
||||
</ul>
|
||||
|
||||
<br />
|
||||
|
||||
<h3>0.0.3</h3>
|
||||
<br />
|
||||
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
@file:DependsOn("io.ktor:ktor-client-core:1.4.0")
|
||||
@file:DependsOn("io.ktor:ktor-client-core-jvm:1.4.0")
|
||||
@file:DependsOn("io.ktor:ktor-client-apache:1.4.0")
|
||||
@file:DependsOn("io.ktor:ktor-client-json-jvm:1.4.0")
|
||||
@file:DependsOn("io.ktor:ktor-client-gson:1.4.0")
|
||||
|
||||
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
|
||||
|
||||
// HTML
|
||||
@file:DependsOn("it.skrape:skrapeit-core:1.0.0-alpha6")
|
||||
@file:DependsOn("io.github.rybalkinsd:kohttp:0.12.0")
|
||||
@file:DependsOn("org.jsoup:jsoup:1.13.1")
|
||||
|
||||
// IMAGE RESIZE
|
||||
@file:DependsOn("com.sksamuel.scrimage:scrimage-core:4.0.6")
|
||||
@file:DependsOn("com.sksamuel.scrimage:scrimage-formats-extra:4.0.6")
|
||||
@file:DependsOn("ar.com.hjg:pngj:2.1.0")
|
||||
@file:DependsOn("com.github.zh79325:open-gif:1.0.4")
|
||||
|
||||
// CODE GENERATIOn
|
||||
@file:DependsOn("com.squareup:kotlinpoet:1.6.0")
|
||||
|
||||
import com.sksamuel.scrimage.ImmutableImage
|
||||
import com.sksamuel.scrimage.ScaleMethod
|
||||
import com.sksamuel.scrimage.nio.PngWriter
|
||||
import com.squareup.kotlinpoet.FileSpec
|
||||
import com.squareup.kotlinpoet.TypeSpec
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.apache.*
|
||||
import io.ktor.client.request.*
|
||||
import it.skrape.core.htmlDocument
|
||||
import it.skrape.extract
|
||||
import it.skrape.skrape
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.awt.Color
|
||||
import java.awt.image.BufferedImage
|
||||
import java.io.File
|
||||
|
||||
data class Item(
|
||||
val id: String,
|
||||
val image: String,
|
||||
)
|
||||
|
||||
var items = skrape {
|
||||
url = "https://www.deadmap.com/idlist"
|
||||
|
||||
extract {
|
||||
htmlDocument {
|
||||
findFirst("#idlist").findAll("tr") {
|
||||
map {
|
||||
val img = it.findFirst("img")
|
||||
.attribute("src")
|
||||
.replace(" ", "%20")
|
||||
|
||||
val id = it.findFirst("i").text
|
||||
|
||||
Item(id.removePrefix("minecraft:"), "https://www.deadmap.com/$img")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println(items.joinToString("\n"))
|
||||
|
||||
// FIXERS
|
||||
val fixers = mapOf(
|
||||
"staned" to "stained",
|
||||
"dandelion_yellow" to "yellow_dye"
|
||||
)
|
||||
|
||||
items = items.map { it.copy(fixers.entries.fold(it.id) { id, entry -> id.replace(entry.key, entry.value) }) }
|
||||
|
||||
runBlocking {
|
||||
val client = HttpClient(Apache)
|
||||
|
||||
val iconsFolder = File("../src/main/resources/assets/items-13").canonicalFile
|
||||
iconsFolder.mkdirs()
|
||||
|
||||
items
|
||||
.withIndex()
|
||||
.asFlow()
|
||||
.onEach { (index, item) ->
|
||||
val (name, imageUrl) = item
|
||||
println("Downloading item: $name ($index/${items.size - 1})")
|
||||
|
||||
val imageBytes = client.get<ByteArray>(imageUrl)
|
||||
|
||||
val image = ImmutableImage.loader()
|
||||
.type(BufferedImage.TYPE_INT_ARGB)
|
||||
.fromBytes(imageBytes)
|
||||
.run {
|
||||
val tags = metadata.tags()
|
||||
val width = tags.first { it.name.contains("Width") }.rawValue.toInt()
|
||||
val height = tags.first { it.name.contains("Height") }.rawValue.toInt()
|
||||
|
||||
if(width > 32 || height > 32) {
|
||||
scaleTo(32, 32, ScaleMethod.FastScale)
|
||||
} else this
|
||||
}
|
||||
|
||||
image.output(PngWriter.NoCompression, File(iconsFolder, "$name.png"))
|
||||
println("Complete download and resize: $name ($index/${items.size - 1})")
|
||||
}
|
||||
.collect()
|
||||
}
|
||||
|
||||
println("Generating MinecrateItem13 Enumeration")
|
||||
|
||||
FileSpec.builder("br.com.devsrsouza.kotlinbukkitapi.tooling.menu", "MinecraftItem13")
|
||||
.addType(
|
||||
TypeSpec.enumBuilder("MinecraftItem13")
|
||||
.apply {
|
||||
for ((id, _) in items) {
|
||||
addEnumConstant(id.toUpperCase())
|
||||
}
|
||||
}
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
.writeTo(File("../src/main/kotlin/").canonicalFile)
|
||||
@@ -7,8 +7,8 @@ data class MenuDeclaration(
|
||||
)
|
||||
|
||||
data class MenuSlotDeclaration(
|
||||
val line: Int,
|
||||
val slot: Int,
|
||||
val itemId: Int?,
|
||||
val isSelected: Boolean = false
|
||||
val line: Int,
|
||||
val slot: Int,
|
||||
val item: String,
|
||||
val isSelected: Boolean = false
|
||||
)
|
||||
@@ -17,6 +17,7 @@ class InventoryComponent(
|
||||
private val minecraftFontResource = "/assets/fonts/Minecraftia-Regular.ttf"
|
||||
private val spritesFolder = "/assets/sprites"
|
||||
private val itemsSpriteFolder = "/assets/items"
|
||||
private val items13SpriteFolder = "/assets/items-13"
|
||||
|
||||
// the selected-border is 36x36 and not 32x32
|
||||
private val selectedBorderSizeDiff = 2
|
||||
@@ -34,8 +35,20 @@ class InventoryComponent(
|
||||
private val itemsImage = declaration.slots.filter {
|
||||
it.line in 1..declaration.lines && it.slot in 1..9
|
||||
}.keysToMap {
|
||||
ImageLoader.loadFromResource("$itemsSpriteFolder/${it.itemId}-0.png")
|
||||
//?.getScaledInstance(16, 16, Image.SCALE_FAST)
|
||||
// TODO: Support data
|
||||
val item13 = runCatching { MinecraftItem13.valueOf(it.item) }.getOrNull()
|
||||
|
||||
if(item13 != null) {
|
||||
ImageLoader.loadFromResource("$items13SpriteFolder/${item13.name.toLowerCase()}.png")
|
||||
} else {
|
||||
val item = runCatching { MinecraftItem.valueOf(it.item) }.getOrNull()
|
||||
|
||||
if (item != null) {
|
||||
ImageLoader.loadFromResource("$itemsSpriteFolder/${item.id}-0.png")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
private val selectionImage = if(declaration.slots.any { it.isSelected })
|
||||
ImageLoader.loadFromResource("$spritesFolder/selected-border.png")
|
||||
|
||||
@@ -24,6 +24,10 @@ class MenuPreviewFileEditor(
|
||||
private val mainEditor: TextEditor
|
||||
) : UserDataHolderBase(), FileEditor {
|
||||
|
||||
companion object {
|
||||
const val REBUILD_DELAY_MILLISECONDS = 80
|
||||
}
|
||||
|
||||
private val mySwingAlarm = Alarm(Alarm.ThreadToUse.SWING_THREAD, this)
|
||||
private val myDocument = FileDocumentManager.getInstance().getDocument(myFile)!!
|
||||
private val myUi = JPanel().apply {
|
||||
@@ -38,31 +42,39 @@ class MenuPreviewFileEditor(
|
||||
private lateinit var currentScroll: JBScrollPane
|
||||
private var currentSelectedLine: Int? = null
|
||||
|
||||
init {
|
||||
private val documentListener = object : DocumentListener {
|
||||
override fun beforeDocumentChange(event: DocumentEvent) {
|
||||
mySwingAlarm.cancelAllRequests()
|
||||
}
|
||||
override fun documentChanged(event: DocumentEvent) {
|
||||
mySwingAlarm.addRequest({
|
||||
rebuild(currentScroll.viewport.viewPosition)
|
||||
}, REBUILD_DELAY_MILLISECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
private val caretListener = object : CaretListener {
|
||||
override fun caretPositionChanged(event: CaretEvent) {
|
||||
currentSelectedLine = event.newPosition.line
|
||||
mySwingAlarm.addRequest({
|
||||
rebuild(currentScroll.viewport.viewPosition)
|
||||
}, REBUILD_DELAY_MILLISECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
fun setup() {
|
||||
rebuild(null)
|
||||
|
||||
// listen to the source code changes to rebuild the UI
|
||||
myDocument.addDocumentListener(object : DocumentListener {
|
||||
override fun beforeDocumentChange(event: DocumentEvent) {
|
||||
mySwingAlarm.cancelAllRequests()
|
||||
}
|
||||
override fun documentChanged(event: DocumentEvent) {
|
||||
mySwingAlarm.addRequest({
|
||||
rebuild(currentScroll.viewport.viewPosition)
|
||||
}, 50)
|
||||
}
|
||||
})
|
||||
myDocument.addDocumentListener(documentListener)
|
||||
|
||||
// listen to cursor changes to make a slot selectable
|
||||
mainEditor.editor.caretModel.addCaretListener(object : CaretListener {
|
||||
override fun caretPositionChanged(event: CaretEvent) {
|
||||
currentSelectedLine = event.newPosition.line
|
||||
rebuild(currentScroll.viewport.viewPosition)
|
||||
}
|
||||
})
|
||||
mainEditor.editor.caretModel.addCaretListener(caretListener)
|
||||
}
|
||||
|
||||
fun rebuild(currentViewPosition: Point?) {
|
||||
if(!myUi.isShowing) return
|
||||
|
||||
val tree = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument) ?: return
|
||||
|
||||
// clear the old UI
|
||||
@@ -142,8 +154,18 @@ class MenuPreviewFileEditor(
|
||||
return null
|
||||
}
|
||||
|
||||
override fun selectNotify() {
|
||||
setup()
|
||||
}
|
||||
|
||||
override fun deselectNotify() {
|
||||
dispose()
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
mySwingAlarm.cancelAllRequests()
|
||||
myDocument.removeDocumentListener(documentListener)
|
||||
mainEditor.editor.caretModel.removeCaretListener(caretListener)
|
||||
}
|
||||
|
||||
private fun JComponent.centerComponent(): JPanel {
|
||||
|
||||
@@ -68,14 +68,12 @@ fun findMenuDeclaration(
|
||||
val typeExpression = materialExpression.selectorExpression as? KtNameReferenceExpression ?: return@mapNotNull null
|
||||
val materialName = typeExpression.text ?: return@mapNotNull null
|
||||
|
||||
val item = runCatching { MinecraftItem.valueOf(materialName) }.getOrNull()
|
||||
|
||||
val isSelected = it.getLineNumber() == currentSelectedLine
|
||||
|
||||
MenuSlotDeclaration(
|
||||
line,
|
||||
slot,
|
||||
item?.id,
|
||||
materialName,
|
||||
isSelected
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard
|
||||
|
||||
object Versions {
|
||||
val `v0_1_0-SNAPSHOT` = KotlinBukkitAPIVersion("0.1.0-SNAPSHOT")
|
||||
val `v0_2_0-SNAPSHOT` = KotlinBukkitAPIVersion("0.2.0-SNAPSHOT")
|
||||
|
||||
val ALL = arrayOf(
|
||||
`v0_1_0-SNAPSHOT`
|
||||
`v0_2_0-SNAPSHOT`,
|
||||
`v0_1_0-SNAPSHOT`
|
||||
)
|
||||
|
||||
val LAST = `v0_1_0-SNAPSHOT`
|
||||
val LAST = `v0_2_0-SNAPSHOT`
|
||||
|
||||
val visitorAll = ALL.associate { it.version to it }
|
||||
|
||||
@@ -15,8 +17,8 @@ object Versions {
|
||||
}
|
||||
|
||||
data class KotlinBukkitAPIVersion(
|
||||
val version: String,
|
||||
val kotlinVersion: String = "1.4.0"
|
||||
val version: String,
|
||||
val kotlinVersion: String = "1.4.0"
|
||||
) {
|
||||
override fun toString(): String {
|
||||
return version
|
||||
@@ -25,16 +27,16 @@ data class KotlinBukkitAPIVersion(
|
||||
private val group = "br.com.devsrsouza.kotlinbukkitapi"
|
||||
|
||||
val repositories = listOf(
|
||||
"http://nexus.devsrsouza.com.br/repository/maven-public/",
|
||||
"https://oss.jfrog.org/oss-snapshot-local/",
|
||||
"http://nexus.okkero.com/repository/maven-releases/",
|
||||
"https://repo.codemc.org/repository/maven-public"
|
||||
"http://nexus.devsrsouza.com.br/repository/maven-public/",
|
||||
/*"https://oss.jfrog.org/oss-snapshot-local/", // TODO: create a option to provide this repositories optionally
|
||||
"http://nexus.okkero.com/repository/maven-releases/",
|
||||
"https://repo.codemc.org/repository/maven-public",*/
|
||||
)
|
||||
|
||||
val dependencies = listOf(
|
||||
"${group}:core:$version",
|
||||
"${group}:serialization:$version",
|
||||
"${group}:plugins:$version",
|
||||
"${group}:exposed:$version",
|
||||
"${group}:core:$version",
|
||||
"${group}:serialization:$version",
|
||||
"${group}:plugins:$version",
|
||||
"${group}:exposed:$version",
|
||||
)
|
||||
}
|
||||
@@ -43,6 +43,7 @@ fun generateGradleBuildFileContent(
|
||||
val plugins = externalPlugins.joinToString { "\"${it.name}\"" }
|
||||
|
||||
return """
|
||||
|// More about the setup here: https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/Getting-Started
|
||||
|plugins {
|
||||
| kotlin("jvm") version "${kbAPIVersion.kotlinVersion}"
|
||||
| kotlin("plugin.serialization") version "${kbAPIVersion.kotlinVersion}"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<depends>org.jetbrains.kotlin</depends>
|
||||
<depends>com.intellij.modules.lang</depends>
|
||||
<depends>com.intellij.modules.externalSystem</depends>
|
||||
<depends>com.intellij.modules.java</depends>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<!-- Add your extensions here -->
|
||||
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |