1.0.0
This commit is contained in:
1 parent
5532f33f82
commit
e61c1d2657
44 files changed
+303
-1462
No files matched your search
@@ -1,22 +1,5 @@
|
||||
# KotlinBukkitAPI-Tooling
|
||||
|
||||
[](https://plugins.jetbrains.com/plugin/14913-kotlinbukkitapi-tooling/)
|
||||
|
||||
The KotlinBukkitAPI Tooling is plugin for IntelliJ that helps developers using [KotlinBukkitAPI](https://github.com/DevSrSouza/KotlinBukkitAPI) and scripts for [Bukkript](https://github.com/DevSrSouza/Bukkript).
|
||||
|
||||
## Features
|
||||
|
||||
- [Menu Preview](#Menu-Preview)
|
||||
- Tooling for [Bukkript Scripts](#Bukkript-Script).
|
||||
|
||||
## Menu Preview
|
||||
|
||||
When using KotlinBukkitAPI Menu DSL you have a good preview of how the slots are arranged in the Menu in the game.
|
||||
|
||||

|
||||
|
||||
## [Bukkript Script](https://github.com/DevSrSouza/Bukkript/)
|
||||
|
||||
The plugin provides out of the box Bukkript Script resolution (`.bk.kts` files).
|
||||
|
||||

|
||||
+46
-55
@@ -1,65 +1,73 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id("org.jetbrains.intellij") version "0.4.21"
|
||||
id("org.jetbrains.intellij") version "1.17.2"
|
||||
java
|
||||
kotlin("jvm") version "1.4.0"
|
||||
kotlin("jvm") version "1.9.0"
|
||||
}
|
||||
|
||||
val kotlinVersion = "1.4.0"
|
||||
val kotlinBukkitAPIVersion = "0.2.0-SNAPSHOT"
|
||||
val bukkriptVersion = "0.2.0-SNAPSHOT"
|
||||
val kotlinVersion = "1.9.0"
|
||||
val kotlinBukkitAPIVersion = "1.0.0.2"
|
||||
|
||||
group = "br.com.devsrsouza.kotlinbukkitapi"
|
||||
version = "0.0.7"
|
||||
group = "tech.carcadex.kotlinbukkitkit"
|
||||
version = "0.0.1"
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
maven("http://nexus.devsrsouza.com.br/repository/maven-public/")
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
|
||||
val changing = Action<ExternalModuleDependency> { isChanging = true }
|
||||
api("br.com.devsrsouza.bukkript:script-definition-embedded:$bukkriptVersion", changing)
|
||||
|
||||
testCompile("junit", "junit", "4.12")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
|
||||
}
|
||||
|
||||
// See https://github.com/JetBrains/gradle-intellij-plugin/
|
||||
intellij {
|
||||
version = "2020.2.1"
|
||||
|
||||
setPlugins("java", "Kotlin")
|
||||
// version = "2023.3.3"
|
||||
version.set("2023.3.3")
|
||||
plugins.set(listOf("java", "Kotlin"))
|
||||
}
|
||||
|
||||
configure<JavaPluginConvention> {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "17"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
sourceCompatibility = "17"
|
||||
targetCompatibility = "17"
|
||||
}
|
||||
jar {
|
||||
duplicatesStrategy = (DuplicatesStrategy.EXCLUDE)
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
runIde {
|
||||
jbrVersion.set("jbr_jcef-17.0.9-windows-x64-b1087.11")
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
tasks {
|
||||
publishPlugin {
|
||||
token(System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken"))
|
||||
token.set(System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken"))
|
||||
channels.set(listOf("stable"))
|
||||
}
|
||||
}
|
||||
tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml") {
|
||||
sinceBuild("201")
|
||||
untilBuild("203.*")
|
||||
|
||||
pluginDescription("""
|
||||
|
||||
pluginDescription.set("""
|
||||
<img src="https://github.com/DevSrSouza/KotlinBukkitAPI/raw/master/logo.png" width="417" height="161"/>
|
||||
|
||||
<br />
|
||||
|
||||
The KotlinBukkitAPI Tooling is plugin for IntelliJ that helps
|
||||
The KotlinBukkitKit Tooling is plugin for IntelliJ that helps
|
||||
<br />
|
||||
developers using <a href="https://github.com/DevSrSouza/KotlinBukkitAPI">KotlinBukkitAPI</a> and scripts for <a href="https://github.com/DevSrSouza/Bukkript">Bukkript</a>.
|
||||
developers using <a href="https://github.com/CarcadeX/KotlinBukkitKit-Tooling</a>.
|
||||
<br />
|
||||
This libraries help build extensions for Minecraft Server using Spigot server.
|
||||
|
||||
@@ -68,7 +76,8 @@ tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml
|
||||
<br />
|
||||
|
||||
<ul>
|
||||
<li><a href='https://github.com/DevSrSouza/Bukkript'>Bukkript</a></li>
|
||||
|
||||
<li<a href='https://github.com/CarcadeX/KotlinBukkitKit'>KotlinBukkitKit</a></li>
|
||||
<li<a href='https://github.com/DevSrSouza/KotlinBukkitAPI-Tooling'>KotlinBukkitAPI-Tooling (this plugin)</a></li>
|
||||
<li<a href='https://github.com/DevSrSouza/KotlinBukkitAPI'>KotlinBukkitAPI</a></li>
|
||||
<li><a href='https://github.com/KotlinMinecraft/KotlinBukkitAPI-Examples'>KotlinBukkitAPI Examples</a></li>
|
||||
@@ -85,33 +94,12 @@ tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml
|
||||
""".trimIndent())
|
||||
|
||||
|
||||
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 />
|
||||
changeNotes.set("""
|
||||
<h3>0.0.1</h3>
|
||||
|
||||
<ul>
|
||||
<li>KotlinBukkitAPI Project Wizard</li>
|
||||
<li>Menu Preview tab only avaiable on projects that was KotlinBukkitAPI or is a Bukkript script.</li>
|
||||
<li>Custom folder icons for highlight the Bukkript related folders.</li>
|
||||
<li>Menu Preview tab only avaiable on projects that was KotlinBukkitAPI.</li>
|
||||
</ul>
|
||||
""".trimIndent())
|
||||
}
|
||||
@@ -119,3 +107,6 @@ tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml
|
||||
configurations.all {
|
||||
resolutionStrategy.cacheChangingModulesFor(120, "seconds")
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -18,7 +18,7 @@
|
||||
@file:DependsOn("com.github.zh79325:open-gif:1.0.4")
|
||||
|
||||
// CODE GENERATIOn
|
||||
@file:DependsOn("com.squareup:kotlinpoet:1.6.0")
|
||||
@file:DependsOn("com.squareup:kotlinpoet:0.6.0")
|
||||
|
||||
import com.sksamuel.scrimage.ImmutableImage
|
||||
import com.sksamuel.scrimage.ScaleMethod
|
||||
@@ -45,7 +45,7 @@ data class Item(
|
||||
)
|
||||
|
||||
var items = skrape {
|
||||
url = "https://www.deadmap.com/idlist"
|
||||
val url = "https://www.deadmap.com/idlist"
|
||||
|
||||
extract {
|
||||
htmlDocument {
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
rootProject.name = "KotlinBukkitAPI-Tooling"
|
||||
rootProject.name = "KBK-Menu-Preview Bukkit"
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling
|
||||
|
||||
import com.intellij.ui.IconManager
|
||||
import javax.swing.Icon
|
||||
|
||||
object Assets {
|
||||
private fun load(path: String): Icon {
|
||||
return IconManager.getInstance().getIcon(path, Assets::class.java)
|
||||
}
|
||||
|
||||
private const val assetFolder = "/assets"
|
||||
|
||||
val KotlinBukkitAPIIcon = load("$assetFolder/icons/kotlinbukkitapi-icon.svg")
|
||||
val Bukkript = load("$assetFolder/icons/bukkript.svg")
|
||||
val FolderScript = load("$assetFolder/icons/folderScript.svg")
|
||||
val FolderPlugins = load("$assetFolder/icons/folderPlugins.svg")
|
||||
val FolderBukkript = load("$assetFolder/icons/folderBukkript.svg")
|
||||
}
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript
|
||||
|
||||
import com.intellij.ide.actions.CreateFileFromTemplateAction
|
||||
import com.intellij.ide.actions.CreateFileFromTemplateDialog
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiDirectory
|
||||
import com.intellij.psi.PsiFile
|
||||
|
||||
class BukkriptCreateNewFileAction : CreateFileFromTemplateAction(
|
||||
BUKKRIPT_SCRIPT,
|
||||
BUKKRIPT_DESCRIPTION,
|
||||
BukkriptFileType.INSTANCE.icon
|
||||
) {
|
||||
override fun getActionName(
|
||||
directory: PsiDirectory?,
|
||||
newName: String,
|
||||
templateName: String?
|
||||
): String = BUKKRIPT_CREATE_SCRIPT_DESCRIPTION
|
||||
|
||||
override fun createFile(
|
||||
name: String,
|
||||
templateName: String,
|
||||
dir: PsiDirectory
|
||||
): PsiFile? = super.createFile("$name.bk", templateName, dir)
|
||||
|
||||
override fun buildDialog(
|
||||
project: Project,
|
||||
directory: PsiDirectory,
|
||||
builder: CreateFileFromTemplateDialog.Builder
|
||||
) {
|
||||
builder.setTitle(BUKKRIPT_SCRIPT)
|
||||
.addKind(
|
||||
BUKKRIPT_FILE,
|
||||
BukkriptFileType.INSTANCE.icon,
|
||||
BUKKRIPT_SCRIPT
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.Assets
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType
|
||||
import com.intellij.openapi.fileTypes.ex.FileTypeIdentifiableByVirtualFile
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import javax.swing.Icon
|
||||
|
||||
class BukkriptFileType : LanguageFileType(KotlinLanguage.INSTANCE), FileTypeIdentifiableByVirtualFile {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val INSTANCE = BukkriptFileType()
|
||||
}
|
||||
|
||||
override fun getIcon(): Icon? = Assets.Bukkript
|
||||
|
||||
override fun getName(): String = BUKKRIPT_FILE
|
||||
|
||||
override fun getDefaultExtension(): String = BUKKRIPT_EXTENSION
|
||||
|
||||
override fun getDescription(): String = BUKKRIPT_DESCRIPTION
|
||||
|
||||
override fun isMyFileType(file: VirtualFile): Boolean = file.name.isBukkriptScript()
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.Assets
|
||||
import com.intellij.ide.IconProvider
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import javax.swing.Icon
|
||||
|
||||
class BukkriptIconProvider : IconProvider(), DumbAware {
|
||||
override fun getIcon(element: PsiElement, flags: Int): Icon? {
|
||||
if(element is PsiFile) {
|
||||
val file = element.virtualFile
|
||||
return when {
|
||||
file.isBukkriptScript() -> BukkriptFileType.INSTANCE.icon
|
||||
file.isScriptFolder() -> Assets.FolderScript
|
||||
file.isPluginsFolder() -> Assets.FolderPlugins
|
||||
file.isBukkriptFolder() -> Assets.FolderBukkript
|
||||
else -> null
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript
|
||||
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
import kotlin.script.experimental.intellij.ScriptDefinitionsProvider
|
||||
import br.com.devsrsouza.bukkript.script.definition.BukkriptScript
|
||||
|
||||
class BukkriptScriptDefinitionProvider : ScriptDefinitionsProvider {
|
||||
|
||||
companion object {
|
||||
const val ID = "BukkriptScriptDefinition"
|
||||
}
|
||||
|
||||
override val id: String
|
||||
get() = ID
|
||||
|
||||
override fun getDefinitionClasses(): Iterable<String> {
|
||||
return listOf("br.com.devsrsouza.bukkript.script.definition.BukkriptScript")
|
||||
}
|
||||
|
||||
override fun getDefinitionsClassPath(): Iterable<File> {
|
||||
val jarFile = PathUtil.getResourcePathForClass(BukkriptScript::class.java)
|
||||
|
||||
return listOf(jarFile)
|
||||
}
|
||||
|
||||
override fun useDiscovery(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.Assets
|
||||
import com.intellij.ide.projectView.PresentationData
|
||||
import com.intellij.ide.projectView.ProjectViewNode
|
||||
import com.intellij.ide.projectView.ProjectViewNodeDecorator
|
||||
import com.intellij.packageDependencies.ui.PackageDependenciesNode
|
||||
import com.intellij.ui.ColoredTreeCellRenderer
|
||||
|
||||
class BukkriptViewNodeDecorator : ProjectViewNodeDecorator {
|
||||
override fun decorate(node: ProjectViewNode<*>, data: PresentationData) {
|
||||
val file = node.virtualFile ?: return
|
||||
|
||||
val icon = when {
|
||||
file.isScriptFolder() -> Assets.FolderScript
|
||||
file.isPluginsFolder() -> Assets.FolderPlugins
|
||||
file.isBukkriptFolder() -> Assets.FolderBukkript
|
||||
else -> null
|
||||
}
|
||||
|
||||
if(icon != null) {
|
||||
node.icon = icon
|
||||
data.setIcon(icon)
|
||||
}
|
||||
}
|
||||
|
||||
override fun decorate(node: PackageDependenciesNode, cellRenderer: ColoredTreeCellRenderer) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript
|
||||
|
||||
const val BUKKRIPT_EXTENSION = "bk.kts"
|
||||
|
||||
const val BUKKRIPT_SCRIPT = "Bukkript Script"
|
||||
const val BUKKRIPT_FILE = "Bukkript File"
|
||||
const val BUKKRIPT_DESCRIPTION = "Bukkript Script File for Bukkit"
|
||||
const val BUKKRIPT_CREATE_SCRIPT_DESCRIPTION = "Create Bukkript Script"
|
||||
@@ -1,32 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import java.io.File
|
||||
|
||||
fun String.isBukkriptScript() = endsWith(".$BUKKRIPT_EXTENSION", true)
|
||||
|
||||
fun VirtualFile.isBukkriptScript() = name.isBukkriptScript()
|
||||
|
||||
fun VirtualFile.isScriptFolder(): Boolean {
|
||||
if(name != "scripts") return false
|
||||
|
||||
val bukkriptFodler = parent ?: return false
|
||||
|
||||
return bukkriptFodler.isBukkriptFolder()
|
||||
}
|
||||
|
||||
fun VirtualFile.isPluginsFolder(): Boolean {
|
||||
if(name != "plugins") return false
|
||||
|
||||
val rootServerFolder = parent ?: return false
|
||||
|
||||
return rootServerFolder.children?.find { it.name == "server.properties" } != null
|
||||
}
|
||||
|
||||
fun VirtualFile.isBukkriptFolder(): Boolean {
|
||||
if(name != "Bukkript") return false
|
||||
|
||||
val pluginsFolder = parent ?: return false
|
||||
|
||||
return pluginsFolder.name == "plugins"
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.menu
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript.BukkriptFileType
|
||||
import com.intellij.openapi.fileEditor.*
|
||||
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider
|
||||
import com.intellij.openapi.module.ModuleUtilCore
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
|
||||
class MenuPreviewFileEditorProvider : WeighedFileEditorProvider() {
|
||||
|
||||
companion object {
|
||||
const val ID = "kotlinbukkitapi-menu-preview"
|
||||
}
|
||||
|
||||
override fun getEditorTypeId(): String = ID
|
||||
|
||||
override fun accept(project: Project, file: VirtualFile): Boolean {
|
||||
|
||||
val type = file.fileType
|
||||
|
||||
if(type == BukkriptFileType.INSTANCE) return true
|
||||
|
||||
if(type != KotlinFileType.INSTANCE) return false
|
||||
|
||||
val module = ModuleUtilCore.findModuleForFile(file, project) ?: return false
|
||||
|
||||
val root = ModuleRootManager.getInstance(module)
|
||||
var hasKotlinBukkitAPI = false
|
||||
|
||||
root.orderEntries().withoutSdk().forEachLibrary {
|
||||
if((it.name ?: "").contains("kotlinbukkitapi", true)) {
|
||||
hasKotlinBukkitAPI = true
|
||||
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
return hasKotlinBukkitAPI
|
||||
}
|
||||
|
||||
override fun createEditor(project: Project, file: VirtualFile): FileEditor {
|
||||
val editor: TextEditor = TextEditorProvider.getInstance().createEditor(project, file) as TextEditor
|
||||
val preview =
|
||||
MenuPreviewFileEditor(project, file, editor)
|
||||
|
||||
return TextEditorWithPreview(editor, preview, "KotlinBukkitAPI")
|
||||
}
|
||||
|
||||
//override fun getPolicy(): FileEditorPolicy = FileEditorPolicy.HIDE_DEFAULT_EDITOR
|
||||
override fun getPolicy(): FileEditorPolicy = FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR
|
||||
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.utils.addAtGrid
|
||||
import com.intellij.ide.util.projectWizard.*
|
||||
import com.intellij.uiDesigner.core.*
|
||||
import javax.swing.*
|
||||
|
||||
/**
|
||||
* https://github.com/ktorio/ktor-init-tools/blob/master/ktor-intellij-plugin/src/io/ktor/start/intellij/KtorArtifactWizardStep.kt
|
||||
*/
|
||||
class KBAPIArtifactWizard(val config: KBAPIModuleConfig) : ModuleWizardStep() {
|
||||
val groupId: JTextField
|
||||
val artifactId: JTextField
|
||||
val version: JTextField
|
||||
val author: JTextField
|
||||
val website: JTextField
|
||||
val description: JTextField
|
||||
|
||||
val panel = JPanel().apply {
|
||||
layout = GridLayoutManager(8, 2)
|
||||
|
||||
fun addLabelText(name: String, value: String, row: Int): JTextField {
|
||||
val tfield = JTextField(value)
|
||||
addAtGrid(
|
||||
JLabel(name),
|
||||
row = row,
|
||||
column = 0,
|
||||
anchor = GridConstraints.ANCHOR_WEST,
|
||||
fill = GridConstraints.FILL_NONE,
|
||||
HSizePolicy = GridConstraints.SIZEPOLICY_FIXED,
|
||||
VSizePolicy = GridConstraints.SIZEPOLICY_FIXED
|
||||
)
|
||||
addAtGrid(
|
||||
tfield,
|
||||
row = row,
|
||||
column = 1,
|
||||
anchor = GridConstraints.ANCHOR_WEST,
|
||||
fill = GridConstraints.FILL_HORIZONTAL,
|
||||
HSizePolicy = GridConstraints.SIZEPOLICY_CAN_GROW or GridConstraints.SIZEPOLICY_WANT_GROW,
|
||||
VSizePolicy = GridConstraints.SIZEPOLICY_FIXED
|
||||
)
|
||||
return tfield
|
||||
}
|
||||
|
||||
addAtGrid(
|
||||
JLabel(""),
|
||||
row = 0,
|
||||
column = 0,
|
||||
HSizePolicy = GridConstraints.SIZEPOLICY_FIXED,
|
||||
VSizePolicy = GridConstraints.SIZEPOLICY_FIXED
|
||||
)
|
||||
|
||||
artifactId = addLabelText("Plugin Name", config.artifactId, row = 1)
|
||||
groupId = addLabelText("GroupId", config.artifactGroup, row = 2)
|
||||
version = addLabelText("Version", config.artifactVersion, row = 3)
|
||||
author = addLabelText("Author", config.author, row = 4)
|
||||
website = addLabelText("Website", config.author, row = 5)
|
||||
description = addLabelText("Description", config.description, row = 6)
|
||||
|
||||
add(Spacer().apply {}, GridConstraints().apply {
|
||||
colSpan = 2
|
||||
row = 7
|
||||
column = 0
|
||||
fill = GridConstraints.FILL_VERTICAL
|
||||
})
|
||||
}
|
||||
|
||||
override fun updateDataModel() {
|
||||
config.artifactGroup = groupId.text
|
||||
config.artifactId = artifactId.text
|
||||
config.artifactVersion = version.text
|
||||
config.author = author.text
|
||||
config.website = website.text
|
||||
config.description = description.text
|
||||
}
|
||||
|
||||
override fun getComponent() = panel
|
||||
}
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.creator.*
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.utils.backgroundTask
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.utils.get
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.utils.invokeLater
|
||||
import com.intellij.codeInsight.actions.ReformatCodeProcessor
|
||||
import com.intellij.ide.actions.ImportModuleAction
|
||||
import com.intellij.ide.util.projectWizard.JavaModuleBuilder
|
||||
import com.intellij.ide.util.projectWizard.WizardContext
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.project.DumbAwareRunnable
|
||||
import com.intellij.openapi.projectRoots.JavaSdk
|
||||
import com.intellij.openapi.projectRoots.SdkTypeId
|
||||
import com.intellij.openapi.roots.ModifiableRootModel
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider
|
||||
import com.intellij.openapi.util.Computable
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.projectImport.ProjectImportProvider
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import javax.swing.Icon
|
||||
|
||||
class KBAPIModuleBuilder : JavaModuleBuilder() {
|
||||
override fun getPresentableName(): String = KBAPIModuleType.NAME
|
||||
override fun getNodeIcon(): Icon = KBAPIModuleType.ICON
|
||||
override fun getGroupName(): String = KBAPIModuleType.NAME
|
||||
override fun getBuilderId(): String? = "KOTLINBUKKITAPI_MODULE"
|
||||
override fun getWeight() = BUILD_SYSTEM_WEIGHT - 1
|
||||
override fun isSuitableSdkType(sdkType: SdkTypeId?): Boolean = sdkType === JavaSdk.getInstance()
|
||||
|
||||
val config = KBAPIModuleConfig()
|
||||
|
||||
override fun setupRootModel(rootModel: ModifiableRootModel) {
|
||||
val project = rootModel.project
|
||||
val (rootPath, vFile) = createAndGetRoot()
|
||||
val root = rootPath.toFile()
|
||||
rootModel.addContentEntry(vFile)
|
||||
if (moduleJdk != null) rootModel.sdk = moduleJdk
|
||||
|
||||
project.backgroundTask("Setting Up Project") { progress ->
|
||||
progress.text = "Generating Gradle"
|
||||
|
||||
val gradleBuildFile = generateGradleBuildFile(root).createIfNotExists()
|
||||
val gradleSettingFile = generateGradleSettingsFile(root).createIfNotExists()
|
||||
|
||||
gradleBuildFile.appendText(generateGradleBuildFileContent(config))
|
||||
gradleSettingFile.appendText(generateGradleSettingsFileContent(config))
|
||||
|
||||
progress.text = "Generating Plugin Main"
|
||||
|
||||
val pluginMain = generatePluginMainFile(root, config).createIfNotExists()
|
||||
|
||||
pluginMain.appendText(generatePluginMainFileContent(config))
|
||||
|
||||
progress.text = "Configuring project gradle"
|
||||
vFile.refresh(false, true)
|
||||
|
||||
val buildGradle = vFile["build.gradle.kts"]
|
||||
if (buildGradle != null)
|
||||
invokeLater {
|
||||
val provider = ProjectImportProvider.PROJECT_IMPORT_PROVIDER.extensions
|
||||
.firstOrNull { it.canImport(buildGradle, project) }
|
||||
?: return@invokeLater
|
||||
|
||||
val wizard = ImportModuleAction.createImportWizard(
|
||||
project,
|
||||
null,
|
||||
buildGradle,
|
||||
provider
|
||||
)
|
||||
|
||||
if (wizard != null && (wizard.stepCount <= 0 || wizard.showAndGet())) {
|
||||
ImportModuleAction.createFromWizard(project, wizard)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun getParentGroup() = KBAPIModuleType.NAME
|
||||
|
||||
override fun createWizardSteps(wizardContext: WizardContext, modulesProvider: ModulesProvider) = arrayOf(
|
||||
KBAPIArtifactWizard(config)
|
||||
)
|
||||
|
||||
override fun getCustomOptionsStep(context: WizardContext, parentDisposable: Disposable?) =
|
||||
KBAPIWizardStep(config)
|
||||
|
||||
|
||||
private fun createAndGetRoot(): Pair<Path, VirtualFile> {
|
||||
val temp = contentEntryPath ?: throw IllegalStateException("Failed to get content entry path")
|
||||
|
||||
val pathName = FileUtil.toSystemIndependentName(temp)
|
||||
|
||||
val path = Paths.get(pathName)
|
||||
Files.createDirectories(path)
|
||||
val vFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(pathName)
|
||||
?: throw IllegalStateException("Failed to refresh and file file: $path")
|
||||
|
||||
return path to vFile
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit.Plugin
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit.ServerType
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit.ServerVersion
|
||||
|
||||
data class KBAPIModuleConfig(
|
||||
var artifactGroup: String = "com.example",
|
||||
var artifactId: String = "MyPlugin",
|
||||
var artifactVersion: String = "0.0.1",
|
||||
var externalPlugins: List<Plugin> = listOf<Plugin>(),
|
||||
var kbAPIVersion: KotlinBukkitAPIVersion = Versions.LAST,
|
||||
var serverVersion: ServerVersion = ServerVersion.v1_8,
|
||||
var serverType: ServerType = ServerType.PAPERMC,
|
||||
var author: String = "",
|
||||
var website: String = "",
|
||||
var description: String = ""
|
||||
)
|
||||
@@ -1,22 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.Assets
|
||||
import com.intellij.openapi.module.ModuleType
|
||||
import javax.swing.Icon
|
||||
|
||||
class KBAPIModuleType : ModuleType<KBAPIModuleBuilder>("kotlinbukkitapi") {
|
||||
|
||||
companion object {
|
||||
val NAME = "KotlinBukkitAPI"
|
||||
val DESCRIPTION = "KotlinBukkitAPI Quick"
|
||||
val ICON = Assets.KotlinBukkitAPIIcon
|
||||
val INSTANCE = KBAPIModuleType()
|
||||
}
|
||||
|
||||
override fun createModuleBuilder(): KBAPIModuleBuilder = KBAPIModuleBuilder()
|
||||
override fun getName(): String = NAME
|
||||
override fun getDescription(): String = DESCRIPTION
|
||||
override fun getNodeIcon(isOpened: Boolean): Icon = ICON
|
||||
override fun getIcon(): Icon = ICON
|
||||
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit.*
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.utils.*
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep
|
||||
import com.intellij.openapi.ui.Splitter
|
||||
import com.intellij.ui.IdeBorderFactory
|
||||
import java.awt.BorderLayout
|
||||
import javax.swing.*
|
||||
|
||||
/**
|
||||
* https://github.com/ktorio/ktor-init-tools/blob/master/ktor-intellij-plugin/src/io/ktor/start/intellij/KtorModuleWizardStep.kt
|
||||
*/
|
||||
class KBAPIWizardStep(
|
||||
val config: KBAPIModuleConfig
|
||||
) : ModuleWizardStep() {
|
||||
lateinit var serverApiVersionCB: JComboBox<ServerVersion>
|
||||
lateinit var serverForkCB: JComboBox<ServerType>
|
||||
lateinit var kotlinBukkitAPIVersionCB: JComboBox<KotlinBukkitAPIVersion>
|
||||
lateinit var externalPluginList: PluginCheckboxList
|
||||
|
||||
override fun updateDataModel() {
|
||||
config.serverVersion = serverApiVersionCB.selectedItem as ServerVersion
|
||||
config.externalPlugins = externalPluginList.pluginsToCheckbox.keys.filter { it.isSelected }
|
||||
config.serverType = serverForkCB.selectedItem as ServerType
|
||||
config.kbAPIVersion = kotlinBukkitAPIVersionCB.selectedItem as KotlinBukkitAPIVersion
|
||||
}
|
||||
|
||||
val panel by lazy {
|
||||
JPanel().apply {
|
||||
val description = JPanel().apply {
|
||||
layout = BoxLayout(this, BoxLayout.Y_AXIS)
|
||||
border = IdeBorderFactory.createBorder()
|
||||
}
|
||||
|
||||
externalPluginList = object : PluginCheckboxList(ALL_PLUGINS) {
|
||||
override fun onSelected(feature: Plugin?, node: ThreeStateCheckedTreeNode) {
|
||||
// TODO: Show source link?
|
||||
}
|
||||
override fun onChanged(feature: Plugin, node: ThreeStateCheckedTreeNode) {
|
||||
feature.isSelected = !feature.isSelected
|
||||
|
||||
externalPluginList.repaint()
|
||||
}
|
||||
}
|
||||
|
||||
this.layout = BorderLayout(0, 0)
|
||||
|
||||
add(table {
|
||||
tr(
|
||||
policy = TdSize.FIXED,
|
||||
fill = TdFill.NONE,
|
||||
align = TdAlign.CENTER_LEFT
|
||||
) {
|
||||
td(JLabel("Server API Version:"))
|
||||
td(JComboBox(ServerVersion.values()).apply { serverApiVersionCB = this })
|
||||
td(JLabel("Server:"))
|
||||
td(JComboBox(ServerType.values()).apply { serverForkCB = this })
|
||||
td(JLabel("KotlinBukkitAPI:"))
|
||||
td(JComboBox(Versions.ALL).apply {
|
||||
kotlinBukkitAPIVersionCB = this
|
||||
selectedItem = Versions.LAST
|
||||
})
|
||||
}
|
||||
}, BorderLayout.NORTH)
|
||||
|
||||
add(Splitter(true, 0.8f, 0.2f, 0.8f).apply {
|
||||
this.firstComponent = table {
|
||||
tr(
|
||||
policy = TdSize.FIXED,
|
||||
minHeight = 24,
|
||||
maxHeight = 24,
|
||||
fill = TdFill.NONE,
|
||||
align = TdAlign.CENTER_LEFT
|
||||
) {
|
||||
td(JLabel("Plugins:"))
|
||||
}
|
||||
tr {
|
||||
td(externalPluginList.scrollVertical())
|
||||
}
|
||||
}
|
||||
this.secondComponent = description
|
||||
}, BorderLayout.CENTER)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getComponent(): JComponent {
|
||||
return panel
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard
|
||||
|
||||
const val PLUGIN_YML = "0.3.0"
|
||||
const val SHADOW_PLUGIN = "6.0.0"
|
||||
@@ -1,42 +0,0 @@
|
||||
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_2_0-SNAPSHOT`,
|
||||
`v0_1_0-SNAPSHOT`
|
||||
)
|
||||
|
||||
val LAST = `v0_2_0-SNAPSHOT`
|
||||
|
||||
val visitorAll = ALL.associate { it.version to it }
|
||||
|
||||
fun fromString(version: String) = visitorAll[version]
|
||||
}
|
||||
|
||||
data class KotlinBukkitAPIVersion(
|
||||
val version: String,
|
||||
val kotlinVersion: String = "1.4.0"
|
||||
) {
|
||||
override fun toString(): String {
|
||||
return version
|
||||
}
|
||||
|
||||
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/", // 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",
|
||||
)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit
|
||||
|
||||
data class Plugin(
|
||||
val name: String,
|
||||
val versions: List<PluginVersion>,
|
||||
val repositories: Set<String>,
|
||||
val displayName: String = name
|
||||
) {
|
||||
var isSelected = false
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit.ServerVersion.*
|
||||
|
||||
private val worldEdit = "com.sk89q.worldedit"
|
||||
|
||||
// TODO: plotsquared, multiverse
|
||||
|
||||
val ALL_PLUGINS = listOf(
|
||||
Plugin(
|
||||
"Vault",
|
||||
allVersion("1.7") { setOf("com.github.MilkBowl:VaultAPI:$it") },
|
||||
setOf("https://jitpack.io"),
|
||||
),
|
||||
Plugin(
|
||||
"WorldEdit",
|
||||
listOf(v1_8, v1_9, v1_12).asPluginVersion("6.1.5") { setOf("$worldEdit:worldedit-core:$it", "$worldEdit:worldedit-bukkit:$it") }
|
||||
+ listOf(v1_13, v1_14, v1_15, v1_16).asPluginVersion("7.2.0-SNAPSHOT") { setOf("$worldEdit:worldedit-core:$it", "$worldEdit:worldedit-bukkit:$it") }
|
||||
,
|
||||
setOf("http://maven.sk89q.com/repo/")
|
||||
),
|
||||
Plugin(
|
||||
"WorldGuard",
|
||||
listOf(v1_8, v1_9, v1_12).asPluginVersion("6.1") { setOf("com.sk89q:worldguard:$it") }
|
||||
+ listOf(v1_13, v1_14, v1_15, v1_16).asPluginVersion("7.0.4-SNAPSHOT") { setOf("com.sk89q.worldguard:worldguard-core:$it", "com.sk89q.worldguard:worldguard-bukkit:$it") }
|
||||
,
|
||||
setOf("http://maven.sk89q.com/repo/")
|
||||
),
|
||||
Plugin(
|
||||
"Citizens",
|
||||
allVersion("2.0.27-SNAPSHOT") { setOf("net.citizensnpcs:citizensapi:$it", "net.citizensnpcs:citizens:$it") },
|
||||
setOf("http://repo.citizensnpcs.co/")
|
||||
),
|
||||
Plugin(
|
||||
"LuckPerms",
|
||||
allVersion("5.1") { setOf("net.luckperms:api:$it") },
|
||||
setOf() // mavenCentral
|
||||
),
|
||||
Plugin(
|
||||
"ProtocolLib",
|
||||
allVersion("4.5.1") { setOf("com.comphenix.protocol:ProtocolLib:$it") },
|
||||
setOf("http://repo.dmulloy2.net/nexus/repository/public/")
|
||||
),
|
||||
Plugin(
|
||||
"PlaceholderAPI",
|
||||
allVersion("2.9.2") { setOf("me.clip:placeholderapi:$it") },
|
||||
setOf("http://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
),
|
||||
Plugin(
|
||||
"MVdWPlaceholderAPI",
|
||||
allVersion("3.1.1") { setOf("be.maximvdw:MVdWPlaceholderAPI:$it") },
|
||||
setOf("http://repo.mvdw-software.be/content/groups/public/")),
|
||||
Plugin(
|
||||
"ActionBarAPI",
|
||||
allVersion("d60c2aedb9") { setOf("com.github.ConnorLinfoot:ActionBarAPI:$it") },
|
||||
setOf("https://jitpack.io")
|
||||
),
|
||||
Plugin(
|
||||
"TitleAPI",
|
||||
allVersion("1.7.6") { setOf("com.github.ConnorLinfoot:TitleAPI:$it") },
|
||||
setOf("https://jitpack.io")),
|
||||
Plugin(
|
||||
"ViaVersion",
|
||||
allVersion("3.1.0") { setOf("us.myles:viaversion-common:$it") },
|
||||
setOf("https://repo.viaversion.com/")
|
||||
),
|
||||
Plugin(
|
||||
"BossBarAPI",
|
||||
allVersion("2.4.2") { setOf("org.inventivetalent:bossbarapi:$it") },
|
||||
setOf("https://repo.inventivetalent.org/content/groups/public/")
|
||||
),
|
||||
Plugin(
|
||||
"HologramAPI",
|
||||
allVersion("1.6.0") { setOf("org.inventivetalent:hologramapi:$it") },
|
||||
setOf("https://repo.inventivetalent.org/content/groups/public/")
|
||||
),
|
||||
)
|
||||
|
||||
inline fun allVersion(version: String, dependencies: (String) -> Set<String>): List<PluginVersion> = ServerVersion.values().map { PluginVersion(version, it, dependencies(version)) }
|
||||
inline fun List<ServerVersion>.asPluginVersion(version: String, dependencies: (String) -> Set<String>): List<PluginVersion> = map { PluginVersion(version, it, dependencies(version)) }
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit
|
||||
|
||||
class PluginVersion(
|
||||
val version: String,
|
||||
val serverVersion: ServerVersion,
|
||||
val dependencies: Set<String>
|
||||
)
|
||||
@@ -1,47 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit
|
||||
|
||||
data class ServerAPI(
|
||||
val version: ServerVersion,
|
||||
val serverType: ServerType
|
||||
)
|
||||
|
||||
val ServerAPI.dependencies: List<String> get() {
|
||||
|
||||
val versionName = when(version) {
|
||||
ServerVersion.v1_8 -> "1.8.8-R0.1-SNAPSHOT"
|
||||
ServerVersion.v1_9 -> "1.9.4-R0.1-SNAPSHOT"
|
||||
ServerVersion.v1_12 -> "1.12.2-R0.1-SNAPSHOT"
|
||||
ServerVersion.v1_13 -> "1.13.2-R0.1-SNAPSHOT"
|
||||
ServerVersion.v1_14 -> "1.14.4-R0.1-SNAPSHOT"
|
||||
ServerVersion.v1_15 -> "1.15.2-R0.1-SNAPSHOT"
|
||||
ServerVersion.v1_16 -> "1.16.2-R0.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
val dependency = when(serverType) {
|
||||
ServerType.SPIGOT -> "org.spigotmc:spigot-api:$versionName"
|
||||
ServerType.PAPERMC -> {
|
||||
val v17 = "org.github.paperspigot:paperspigot-api"
|
||||
val v19 = "com.destroystokyo.paper:paper-api"
|
||||
|
||||
when(version) {
|
||||
ServerVersion.v1_8 -> "$v17:$versionName"
|
||||
else -> "$v19:$versionName"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return listOf(dependency)
|
||||
}
|
||||
|
||||
val ServerAPI.repositories: List<String> get() {
|
||||
return when(serverType) {
|
||||
ServerType.SPIGOT -> listOf(
|
||||
"https://hub.spigotmc.org/nexus/content/repositories/snapshots/",
|
||||
"https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
)
|
||||
ServerType.PAPERMC -> listOf(
|
||||
"https://papermc.io/repo/repository/maven-public/",
|
||||
"https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit
|
||||
|
||||
enum class ServerType {
|
||||
SPIGOT, PAPERMC
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit
|
||||
|
||||
enum class ServerVersion(val displayName: String) {
|
||||
v1_8("1.8"),
|
||||
v1_9("1.9"),
|
||||
v1_12("1.12"),
|
||||
v1_13("1.13"),
|
||||
v1_14("1.14"),
|
||||
v1_15("1.15"),
|
||||
v1_16("1.16");
|
||||
|
||||
override fun toString(): String {
|
||||
return displayName
|
||||
}
|
||||
}
|
||||
-134
@@ -1,134 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.creator
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.KBAPIModuleConfig
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.PLUGIN_YML
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.SHADOW_PLUGIN
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit.ServerAPI
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit.dependencies
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit.repositories
|
||||
import java.io.File
|
||||
|
||||
fun generateGradleBuildFile(
|
||||
root: File
|
||||
): File = File(root, "build.gradle.kts")
|
||||
|
||||
fun generateGradleSettingsFile(
|
||||
root: File
|
||||
): File = File(root, "settings.gradle.kts")
|
||||
|
||||
fun generateGradleBuildFileContent(
|
||||
config: KBAPIModuleConfig
|
||||
): String = with(config) {
|
||||
val kbapiDependencies = kbAPIVersion.dependencies
|
||||
.dependenciesAsGradle(with = ", changing")
|
||||
|
||||
val kbapiRepositories = kbAPIVersion.repositories
|
||||
.repositoriesAsGradle()
|
||||
|
||||
val serverApi = ServerAPI(config.serverVersion, config.serverType)
|
||||
val serverRepositories = serverApi.repositories.repositoriesAsGradle()
|
||||
val serverDependencies = serverApi.dependencies.dependenciesAsGradle()
|
||||
|
||||
val pluginDependencies = "${DEFAULT_INDENTATION}val transitive = Action<ExternalModuleDependency> { isTransitive = false }\n" + externalPlugins
|
||||
.flatMap { it.versions.first { it.serverVersion == serverVersion }.dependencies }
|
||||
.distinct()
|
||||
.dependenciesAsGradle(with = ", transitive")
|
||||
|
||||
val pluginRepositories = externalPlugins
|
||||
.flatMap { it.repositories }
|
||||
.distinct()
|
||||
.repositoriesAsGradle()
|
||||
|
||||
|
||||
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}"
|
||||
| id("net.minecrell.plugin-yml.bukkit") version "$PLUGIN_YML"
|
||||
| id("com.github.johnrengelman.shadow") version "$SHADOW_PLUGIN"
|
||||
|}
|
||||
|
|
||||
|group = "$artifactGroup"
|
||||
|version = "$artifactVersion"
|
||||
|
|
||||
|repositories {
|
||||
| jcenter()
|
||||
| // minecraft
|
||||
|$serverRepositories
|
||||
|
|
||||
| //kotlinbukkitapi with backup repo
|
||||
|$kbapiRepositories
|
||||
|
|
||||
| //plugins
|
||||
|$pluginRepositories
|
||||
|}
|
||||
|
|
||||
|dependencies {
|
||||
| compileOnly(kotlin("stdlib-jdk8"))
|
||||
|
|
||||
| //minecraft
|
||||
|$serverDependencies
|
||||
|
|
||||
| //kotlinbukkitapi
|
||||
| val changing = Action<ExternalModuleDependency> { isChanging = true }
|
||||
|$kbapiDependencies
|
||||
|
|
||||
| //plugins
|
||||
|$pluginDependencies
|
||||
|}
|
||||
|
|
||||
|bukkit {
|
||||
| main = "${packageName}.${pluginMainName}"
|
||||
| depend = listOf("KotlinBukkitAPI"${plugins.mapIfNotBlank { ", $it" }})
|
||||
| description = "$description"
|
||||
| author = "$author"
|
||||
| website = "$website"
|
||||
|}
|
||||
|
|
||||
|tasks {
|
||||
| compileKotlin {
|
||||
| kotlinOptions.jvmTarget = "1.8"
|
||||
| kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.time.ExperimentalTime,kotlin.ExperimentalStdlibApi"
|
||||
| }
|
||||
| compileTestKotlin {
|
||||
| kotlinOptions.jvmTarget = "1.8"
|
||||
| kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.time.ExperimentalTime,kotlin.ExperimentalStdlibApi"
|
||||
| }
|
||||
| shadowJar {
|
||||
| classifier = null
|
||||
| }
|
||||
|}
|
||||
|
|
||||
|configurations.all {
|
||||
| resolutionStrategy.cacheChangingModulesFor(120, "seconds")
|
||||
|}
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
private inline fun List<String>.dependenciesAsGradle(configuration: String = "compileOnly", with: String = ""): String =
|
||||
joinToString("\n") {
|
||||
"$configuration(\"${it}\"$with)"
|
||||
}.prependIndent(DEFAULT_INDENTATION)
|
||||
|
||||
private inline fun List<String>.repositoriesAsGradle(): String =
|
||||
joinToString("\n") {
|
||||
"maven(\"${it}\")"
|
||||
}.prependIndent(DEFAULT_INDENTATION)
|
||||
|
||||
fun generateGradleSettingsFileContent(
|
||||
config: KBAPIModuleConfig
|
||||
): String = with(config) {
|
||||
return """
|
||||
rootProject.name = "$artifactId"
|
||||
""".trimSource()
|
||||
}
|
||||
|
||||
fun String.trimSource(): String {
|
||||
val lines = lines()
|
||||
val indentation = lines[1].indexOfFirst { !it.isWhitespace() }
|
||||
|
||||
return lines.joinToString("\n") { it.removePrefix(" ".repeat(indentation)) }
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.creator
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.KBAPIModuleConfig
|
||||
import java.io.File
|
||||
|
||||
fun generatePluginPackageFolder(
|
||||
root: File,
|
||||
config: KBAPIModuleConfig
|
||||
): File = File(root, "src/main/kotlin/${config.packageName.replace(".", "/")}")
|
||||
|
||||
fun generatePluginMainFile(
|
||||
root: File,
|
||||
config: KBAPIModuleConfig
|
||||
): File = File(generatePluginPackageFolder(root, config), "${config.pluginMainName}.kt")
|
||||
|
||||
fun generatePluginMainFileContent(
|
||||
config: KBAPIModuleConfig
|
||||
): String = with(config) {
|
||||
return """
|
||||
package $packageName
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.architecture.KotlinPlugin
|
||||
|
||||
class $pluginMainName : KotlinPlugin() {
|
||||
override fun onPluginEnable() {
|
||||
|
||||
}
|
||||
|
||||
override fun onPluginDisable() {
|
||||
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.creator
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.KBAPIModuleConfig
|
||||
import java.io.File
|
||||
|
||||
const val DEFAULT_INDENTATION = " "
|
||||
|
||||
inline fun String.mapIfNotBlank(block: (String) -> String): String =
|
||||
if(isNotBlank())
|
||||
block(this)
|
||||
else
|
||||
this
|
||||
|
||||
fun File.createIfNotExists(): File = apply {
|
||||
if(!exists()) {
|
||||
parentFile.mkdirs()
|
||||
createNewFile()
|
||||
}
|
||||
}
|
||||
|
||||
val KBAPIModuleConfig.packageName get() = "${artifactGroup}.${artifactId.toLowerCase()}"
|
||||
val KBAPIModuleConfig.pluginMainName get() = "${artifactId}Plugin"
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.utils
|
||||
|
||||
import br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.bukkit.Plugin
|
||||
import com.intellij.ui.CheckboxTree
|
||||
import com.intellij.ui.CheckedTreeNode
|
||||
import com.intellij.ui.SimpleTextAttributes
|
||||
import com.intellij.util.ui.ThreeStateCheckBox
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import javax.swing.JTree
|
||||
import javax.swing.tree.DefaultTreeModel
|
||||
import javax.swing.tree.TreePath
|
||||
|
||||
open class ThreeStateCheckedTreeNode : CheckedTreeNode {
|
||||
constructor() : super()
|
||||
constructor(userObject: Any?) : super(userObject)
|
||||
|
||||
var indeterminate = false
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on Ktor FeatureCheckboxList
|
||||
* https://github.com/ktorio/ktor-init-tools/blob/master/ktor-intellij-plugin/src/io/ktor/start/intellij/KtorModuleWizardStep.kt#L175
|
||||
*/
|
||||
abstract class PluginCheckboxList(val plugins: List<Plugin>) : CheckboxTree(
|
||||
object : CheckboxTree.CheckboxTreeCellRenderer() {
|
||||
override fun customizeRenderer(
|
||||
tree: JTree?,
|
||||
value: Any?,
|
||||
selected: Boolean,
|
||||
expanded: Boolean,
|
||||
leaf: Boolean,
|
||||
row: Int,
|
||||
hasFocus: Boolean
|
||||
) {
|
||||
if (value is ThreeStateCheckedTreeNode) {
|
||||
val plugin = value.userObject
|
||||
val tscheckbox = checkbox as ThreeStateCheckBox
|
||||
if (plugin is Plugin) {
|
||||
val style: SimpleTextAttributes = when {
|
||||
value.indeterminate -> SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES
|
||||
else -> SimpleTextAttributes.REGULAR_ATTRIBUTES
|
||||
}
|
||||
textRenderer.append(plugin.name, style)
|
||||
textRenderer.isEnabled = true
|
||||
tscheckbox.isVisible = true
|
||||
tscheckbox.state = when {
|
||||
value.indeterminate -> ThreeStateCheckBox.State.DONT_CARE
|
||||
value.isChecked -> ThreeStateCheckBox.State.SELECTED
|
||||
else -> ThreeStateCheckBox.State.NOT_SELECTED
|
||||
}
|
||||
textRenderer.foreground = UIUtil.getTreeForeground()
|
||||
} else if (plugin is String) {
|
||||
textRenderer.append(plugin)
|
||||
textRenderer.isEnabled = false
|
||||
isEnabled = false
|
||||
tscheckbox.isVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
ThreeStateCheckedTreeNode()
|
||||
) {
|
||||
val CheckedTreeNode?.plugin: Plugin? get() = this?.userObject as? Plugin?
|
||||
|
||||
val pluginsToCheckbox = LinkedHashMap<Plugin, ThreeStateCheckedTreeNode>()
|
||||
val root = (this.model as DefaultTreeModel).root as ThreeStateCheckedTreeNode
|
||||
init {
|
||||
this.model = object : DefaultTreeModel(root) {
|
||||
override fun valueForPathChanged(path: TreePath, newValue: Any) {
|
||||
super.valueForPathChanged(path, newValue)
|
||||
val node = path.lastPathComponent as ThreeStateCheckedTreeNode
|
||||
val plugin = node.plugin
|
||||
if (plugin != null) {
|
||||
onChanged(plugin, node)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
for (plugin in plugins) {
|
||||
root.add(ThreeStateCheckedTreeNode(plugin).apply { isChecked = false; pluginsToCheckbox[plugin] = this })
|
||||
}
|
||||
(this.model as DefaultTreeModel).reload(root)
|
||||
|
||||
addTreeSelectionListener { e ->
|
||||
val node = (e.newLeadSelectionPath.lastPathComponent as? ThreeStateCheckedTreeNode)
|
||||
val plugin = node?.userObject as? Plugin?
|
||||
|
||||
if (node != null) {
|
||||
onSelected(plugin, node)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun onSelected(feature: Plugin?, node: ThreeStateCheckedTreeNode)
|
||||
open fun onChanged(feature: Plugin, node: ThreeStateCheckedTreeNode) {
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.utils
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.progress.Task
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
|
||||
/**
|
||||
* https://github.com/ktorio/ktor-init-tools/blob/master/ktor-intellij-plugin/src/io/ktor/start/intellij/util/Utils.kt
|
||||
*/
|
||||
|
||||
operator fun VirtualFile?.get(path: String?): VirtualFile? {
|
||||
if (this == null || path == null || path == "" || path == ".") return this
|
||||
val parts = path.split('/', limit = 2)
|
||||
val firstName = parts[0]
|
||||
val lastName = parts.getOrNull(1)
|
||||
val child = this.findChild(firstName)
|
||||
return if (lastName != null) child[lastName] else child
|
||||
}
|
||||
|
||||
|
||||
fun Project.backgroundTask(
|
||||
name: String,
|
||||
indeterminate: Boolean = true,
|
||||
cancellable: Boolean = false,
|
||||
background: Boolean = false,
|
||||
callback: (indicator: ProgressIndicator) -> Unit
|
||||
) {
|
||||
ProgressManager.getInstance().run(object : Task.Backgroundable(this, name, cancellable, { background }) {
|
||||
override fun shouldStartInBackground() = background
|
||||
|
||||
override fun run(indicator: ProgressIndicator) {
|
||||
try {
|
||||
if (indeterminate) indicator.isIndeterminate = true
|
||||
callback(indicator)
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
inline fun invokeLater(crossinline func: () -> Unit) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread) {
|
||||
func()
|
||||
} else {
|
||||
ApplicationManager.getApplication().invokeLater({ func() }, ModalityState.defaultModalityState())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.utils
|
||||
|
||||
import com.intellij.ui.ScrollPaneFactory
|
||||
import com.intellij.ui.components.JBScrollPane
|
||||
import com.intellij.uiDesigner.core.*
|
||||
import java.awt.*
|
||||
import javax.swing.*
|
||||
|
||||
data class TdPos(val col: Int, val row: Int)
|
||||
|
||||
@DslMarker
|
||||
annotation class TableTagMarker
|
||||
|
||||
@TableTagMarker
|
||||
class TableBuilder {
|
||||
val items = LinkedHashMap<TdPos, Pair<Component, GridConstraints>>()
|
||||
var row = 0
|
||||
var col = 0
|
||||
|
||||
var fill: TdFill = TdFill.BOTH
|
||||
var anchor: TdAlign = TdAlign.CENTER_CENTER
|
||||
var hpolicy: TdSize = TdSize.CAN_SHRINK_GROW
|
||||
var vpolicy: TdSize = TdSize.CAN_SHRINK_GROW
|
||||
var minWidth: Int? = null
|
||||
var minHeight: Int? = null
|
||||
var maxWidth: Int? = null
|
||||
var maxHeight: Int? = null
|
||||
|
||||
val nrows get() = items.values.map { it.second.row + it.second.rowSpan }.max() ?: 0
|
||||
val ncols get() = items.values.map { it.second.column + it.second.colSpan }.max() ?: 0
|
||||
}
|
||||
|
||||
fun table(callback: TableBuilder.() -> Unit): JPanel {
|
||||
val tb = TableBuilder()
|
||||
tb.callback()
|
||||
val panel = JPanel(GridLayoutManager(tb.nrows, tb.ncols, Insets(0, 0, 0, 0), 0, 0, false, false))
|
||||
for (item in tb.items.values) {
|
||||
panel.add(item.first, item.second)
|
||||
}
|
||||
//add(panel)
|
||||
return panel
|
||||
}
|
||||
|
||||
fun TableBuilder.tr(
|
||||
fill: TdFill = TdFill.BOTH,
|
||||
align: TdAlign = TdAlign.CENTER_CENTER,
|
||||
policy: TdSize = TdSize.CAN_SHRINK_GROW,
|
||||
hpolicy: TdSize = policy,
|
||||
vpolicy: TdSize = policy,
|
||||
minWidth: Int? = null,
|
||||
maxWidth: Int? = null,
|
||||
minHeight: Int? = null,
|
||||
maxHeight: Int? = null,
|
||||
callback: TableBuilder.() -> Unit
|
||||
) {
|
||||
this.fill = fill
|
||||
this.anchor = align
|
||||
this.hpolicy = hpolicy
|
||||
this.vpolicy = vpolicy
|
||||
this.minWidth = minWidth
|
||||
this.maxWidth = maxWidth
|
||||
this.minHeight = minHeight
|
||||
this.maxHeight = maxHeight
|
||||
callback()
|
||||
row++
|
||||
col = 0
|
||||
}
|
||||
|
||||
//fun TableBuilder.td(colspan: Int = 1, rowspan: Int = 1, callback: TableBuilder.() -> Unit) {
|
||||
// GridConstraints()
|
||||
//}
|
||||
|
||||
fun TableBuilder.td(
|
||||
component: Component, colspan: Int = 1, rowspan: Int = 1,
|
||||
fill: TdFill? = null,
|
||||
anchor: TdAlign? = null,
|
||||
hpolicy: TdSize? = null,
|
||||
vpolicy: TdSize? = null,
|
||||
minWidth: Int? = null,
|
||||
maxWidth: Int? = null,
|
||||
minHeight: Int? = null,
|
||||
maxHeight: Int? = null
|
||||
) {
|
||||
items[TdPos(col, row)] = Pair(
|
||||
component, GridConstraints(
|
||||
row, col,
|
||||
rowspan, colspan,
|
||||
(anchor ?: this.anchor).value,
|
||||
(fill ?: this.fill).value,
|
||||
(hpolicy ?: this.hpolicy).value,
|
||||
(vpolicy ?: this.vpolicy).value,
|
||||
Dimension((minWidth ?: this.minWidth) ?: -1, (minHeight ?: this.minHeight) ?: -1),
|
||||
Dimension(-1, -1),
|
||||
Dimension((maxWidth ?: this.maxWidth) ?: -1, (maxHeight ?: this.maxHeight) ?: -1),
|
||||
0,
|
||||
false
|
||||
)
|
||||
)
|
||||
col++
|
||||
}
|
||||
|
||||
enum class TdFill(val value: Int) {
|
||||
NONE(GridConstraints.FILL_NONE),
|
||||
HORIZONTAL(GridConstraints.FILL_HORIZONTAL),
|
||||
VERTICAL(GridConstraints.FILL_VERTICAL),
|
||||
BOTH(GridConstraints.FILL_BOTH)
|
||||
}
|
||||
|
||||
enum class TdAlign(val value: Int) {
|
||||
TOP_LEFT(GridConstraints.ANCHOR_NORTHWEST),
|
||||
TOP_CENTER(GridConstraints.ANCHOR_NORTH),
|
||||
TOP_RIGHT(GridConstraints.ANCHOR_NORTHEAST),
|
||||
|
||||
CENTER_LEFT(GridConstraints.ANCHOR_WEST),
|
||||
CENTER_CENTER(GridConstraints.ANCHOR_CENTER),
|
||||
CENTER_RIGHT(GridConstraints.ANCHOR_EAST),
|
||||
|
||||
BOTTOM_LEFT(GridConstraints.ANCHOR_SOUTHWEST),
|
||||
BOTTOM_CENTER(GridConstraints.ANCHOR_SOUTH),
|
||||
BOTTOM_RIGHT(GridConstraints.ANCHOR_SOUTHEAST),
|
||||
}
|
||||
|
||||
enum class TdSize(val value: Int) {
|
||||
FIXED(GridConstraints.SIZEPOLICY_FIXED),
|
||||
CAN_SHRINK(GridConstraints.SIZEPOLICY_CAN_SHRINK),
|
||||
CAN_GROW(GridConstraints.SIZEPOLICY_CAN_GROW),
|
||||
CAN_SHRINK_GROW(GridConstraints.SIZEPOLICY_CAN_SHRINK or GridConstraints.SIZEPOLICY_CAN_SHRINK),
|
||||
WANT_GROW(GridConstraints.SIZEPOLICY_WANT_GROW),
|
||||
}
|
||||
|
||||
val <T> JComboBox<T>.items get() = (0 until this.itemCount).map { getItemAt(it) }
|
||||
|
||||
/**
|
||||
* API from: https://github.com/ktorio/ktor-init-tools/blob/master/ktor-intellij-plugin/src/io/ktor/start/intellij/util/Utils.kt
|
||||
*/
|
||||
|
||||
fun JPanel.addAtGrid(
|
||||
item: JComponent,
|
||||
row: Int, column: Int,
|
||||
rowSpan: Int = 1, colSpan: Int = 1,
|
||||
anchor: Int = GridConstraints.ANCHOR_CENTER,
|
||||
fill: Int = GridConstraints.FILL_NONE,
|
||||
HSizePolicy: Int = GridConstraints.SIZEPOLICY_CAN_GROW or GridConstraints.SIZEPOLICY_CAN_SHRINK,
|
||||
VSizePolicy: Int = GridConstraints.SIZEPOLICY_CAN_GROW or GridConstraints.SIZEPOLICY_CAN_SHRINK,
|
||||
minimumSize: Dimension = Dimension(-1, -1),
|
||||
preferredSize: Dimension = Dimension(-1, -1),
|
||||
maximumSize: Dimension = Dimension(-1, -1)
|
||||
) {
|
||||
add(
|
||||
item,
|
||||
GridConstraints(
|
||||
row,
|
||||
column,
|
||||
rowSpan,
|
||||
colSpan,
|
||||
anchor,
|
||||
fill,
|
||||
HSizePolicy,
|
||||
VSizePolicy,
|
||||
minimumSize,
|
||||
preferredSize,
|
||||
maximumSize
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun Component.scrollVertical() = ScrollPaneFactory.createScrollPane(
|
||||
this,
|
||||
JBScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
package tech.carcadex.kotlinbukkitkit.tooling
|
||||
|
||||
import com.intellij.ui.IconManager
|
||||
import javax.swing.Icon
|
||||
|
||||
object Assets {
|
||||
private fun load(path: String): Icon {
|
||||
return IconManager.getInstance().getIcon(path, ClassLoader.getSystemClassLoader())
|
||||
}
|
||||
|
||||
private const val assetFolder = "/assets"
|
||||
|
||||
val KotlinBukkitAPIIcon =
|
||||
tech.carcadex.kotlinbukkitkit.tooling.Assets.load("${tech.carcadex.kotlinbukkitkit.tooling.Assets.assetFolder}/icons/kotlinbukkitapi-icon.svg")
|
||||
val Bukkript =
|
||||
tech.carcadex.kotlinbukkitkit.tooling.Assets.load("${tech.carcadex.kotlinbukkitkit.tooling.Assets.assetFolder}/icons/bukkript.svg")
|
||||
val FolderScript =
|
||||
tech.carcadex.kotlinbukkitkit.tooling.Assets.load("${tech.carcadex.kotlinbukkitkit.tooling.Assets.assetFolder}/icons/folderScript.svg")
|
||||
val FolderPlugins =
|
||||
tech.carcadex.kotlinbukkitkit.tooling.Assets.load("${tech.carcadex.kotlinbukkitkit.tooling.Assets.assetFolder}/icons/folderPlugins.svg")
|
||||
val FolderBukkript =
|
||||
tech.carcadex.kotlinbukkitkit.tooling.Assets.load("${tech.carcadex.kotlinbukkitkit.tooling.Assets.assetFolder}/icons/folderBukkript.svg")
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.menu
|
||||
package tech.carcadex.kotlinbukkitkit.tooling.menu
|
||||
|
||||
data class MenuDeclaration(
|
||||
val displayname: String,
|
||||
@@ -0,0 +1,29 @@
|
||||
package tech.carcadex.kotlinbukkitkit.tooling.menu
|
||||
|
||||
import com.intellij.util.ImageLoader
|
||||
import tech.carcadex.kotlinbukkitkit.tooling.Assets
|
||||
import java.awt.Graphics
|
||||
import java.awt.Image
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import javax.imageio.ImageIO
|
||||
import javax.swing.JPanel
|
||||
|
||||
|
||||
class ImagePanel : JPanel() {
|
||||
private var image: Image? = null
|
||||
|
||||
init {
|
||||
|
||||
try {
|
||||
image = ImageIO.read((File(MenuPreviewFileEditorProvider.ASSETS_FOLDER.absolutePath + "/items-13/acacia_boat.png")))
|
||||
} catch (ex: IOException) {
|
||||
// handle exception...
|
||||
}
|
||||
}
|
||||
|
||||
override fun paintComponent(g: Graphics) {
|
||||
super.paintComponent(g)
|
||||
g.drawImage(image, 0, 0, this) // see javadoc for more info on the parameters
|
||||
}
|
||||
}
|
||||
+15
-12
@@ -1,8 +1,11 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.menu
|
||||
package tech.carcadex.kotlinbukkitkit.tooling.menu
|
||||
|
||||
import com.intellij.util.ImageLoader
|
||||
import org.jetbrains.kotlin.utils.keysToMap
|
||||
import tech.carcadex.kotlinbukkitkit.tooling.Assets
|
||||
import java.awt.*
|
||||
import java.io.File
|
||||
import javax.imageio.ImageIO
|
||||
import javax.swing.JPanel
|
||||
|
||||
class InventoryComponent(
|
||||
@@ -14,13 +17,13 @@ class InventoryComponent(
|
||||
val CHEST_LINE_DIFF = 18
|
||||
val CHEST_WIDTH = 176
|
||||
|
||||
private val minecraftFontResource = "/assets/fonts/Minecraftia-Regular.ttf"
|
||||
private val spritesFolder = "/assets/sprites"
|
||||
private val itemsSpriteFolder = "/assets/items"
|
||||
private val items13SpriteFolder = "/assets/items-13"
|
||||
private val minecraftFontResource = MenuPreviewFileEditorProvider.ASSETS_FOLDER.absolutePath + "/fonts/Minecraftia-Regular.ttf"
|
||||
private val spritesFolder = MenuPreviewFileEditorProvider.ASSETS_FOLDER.absolutePath + "/sprites"
|
||||
private val itemsSpriteFolder = MenuPreviewFileEditorProvider.ASSETS_FOLDER.absolutePath + "/items"
|
||||
private val items13SpriteFolder = MenuPreviewFileEditorProvider.ASSETS_FOLDER.absolutePath + "/items-13"
|
||||
|
||||
// the selected-border is 36x36 and not 32x32
|
||||
private val selectedBorderSizeDiff = 2
|
||||
private const val selectedBorderSizeDiff = 2
|
||||
}
|
||||
|
||||
private val lines = when {
|
||||
@@ -29,8 +32,8 @@ class InventoryComponent(
|
||||
else -> declaration.lines
|
||||
}
|
||||
|
||||
private val spriteImage = ImageLoader.loadFromResource(
|
||||
"$spritesFolder/chest-${lines}.png"
|
||||
private val spriteImage = ImageIO.read(File(
|
||||
"$spritesFolder/chest-${lines}.png")
|
||||
)!!
|
||||
private val itemsImage = declaration.slots.filter {
|
||||
it.line in 1..declaration.lines && it.slot in 1..9
|
||||
@@ -39,24 +42,24 @@ class InventoryComponent(
|
||||
val item13 = runCatching { MinecraftItem13.valueOf(it.item) }.getOrNull()
|
||||
|
||||
if(item13 != null) {
|
||||
ImageLoader.loadFromResource("$items13SpriteFolder/${item13.name.toLowerCase()}.png")
|
||||
ImageIO.read(File("$items13SpriteFolder/${item13.name.lowercase()}.png"))
|
||||
} else {
|
||||
val item = runCatching { MinecraftItem.valueOf(it.item) }.getOrNull()
|
||||
|
||||
if (item != null) {
|
||||
ImageLoader.loadFromResource("$itemsSpriteFolder/${item.id}-0.png")
|
||||
ImageIO.read(File("$itemsSpriteFolder/${item.id}-0.png"))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
private val selectionImage = if(declaration.slots.any { it.isSelected })
|
||||
ImageLoader.loadFromResource("$spritesFolder/selected-border.png")
|
||||
ImageIO.read(File("$spritesFolder/selected-border.png"))
|
||||
else null
|
||||
|
||||
private val minecraftFont = Font.createFont(
|
||||
Font.TRUETYPE_FONT,
|
||||
this::class.java.getResource(minecraftFontResource).openStream()
|
||||
File(minecraftFontResource)
|
||||
).deriveFont(18.5f)
|
||||
|
||||
init {
|
||||
+33
-12
@@ -1,5 +1,8 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.menu
|
||||
package tech.carcadex.kotlinbukkitkit.tooling.menu
|
||||
|
||||
import com.esotericsoftware.kryo.kryo5.minlog.Log
|
||||
import com.intellij.codeInsight.codeVision.ui.mouseClicked
|
||||
import com.intellij.collaboration.ui.VerticalListPanel
|
||||
import com.intellij.openapi.editor.event.CaretEvent
|
||||
import com.intellij.openapi.editor.event.CaretListener
|
||||
import com.intellij.openapi.editor.event.DocumentEvent
|
||||
@@ -8,12 +11,13 @@ import com.intellij.openapi.fileEditor.*
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.UserDataHolderBase
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.platform.ide.progress.ModalTaskOwner.component
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.util.forEachDescendantOfType
|
||||
import com.intellij.ui.components.JBScrollPane
|
||||
import com.intellij.ui.layout.panel
|
||||
import com.intellij.util.Alarm
|
||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
||||
import java.awt.*
|
||||
import java.beans.PropertyChangeListener
|
||||
import javax.swing.*
|
||||
@@ -39,7 +43,7 @@ class MenuPreviewFileEditor(
|
||||
)
|
||||
}
|
||||
|
||||
private lateinit var currentScroll: JBScrollPane
|
||||
private var currentScroll: JBScrollPane? = null
|
||||
private var currentSelectedLine: Int? = null
|
||||
|
||||
private val documentListener = object : DocumentListener {
|
||||
@@ -48,21 +52,24 @@ class MenuPreviewFileEditor(
|
||||
}
|
||||
override fun documentChanged(event: DocumentEvent) {
|
||||
mySwingAlarm.addRequest({
|
||||
rebuild(currentScroll.viewport.viewPosition)
|
||||
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(currentScroll?.viewport?.viewPosition)
|
||||
}, REBUILD_DELAY_MILLISECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
var registered = false
|
||||
fun setup() {
|
||||
if(registered) return
|
||||
rebuild(null)
|
||||
|
||||
// listen to the source code changes to rebuild the UI
|
||||
@@ -70,6 +77,7 @@ class MenuPreviewFileEditor(
|
||||
|
||||
// listen to cursor changes to make a slot selectable
|
||||
mainEditor.editor.caretModel.addCaretListener(caretListener)
|
||||
registered = true
|
||||
}
|
||||
|
||||
fun rebuild(currentViewPosition: Point?) {
|
||||
@@ -82,13 +90,15 @@ class MenuPreviewFileEditor(
|
||||
|
||||
// create the scroll pane with a centralized component with the inventories
|
||||
var menuCount = 0
|
||||
|
||||
currentScroll = JBScrollPane(
|
||||
panel {
|
||||
tree.forEachDescendantOfType<KtCallExpression> {
|
||||
val declaration =
|
||||
findMenuDeclaration(
|
||||
it,
|
||||
currentSelectedLine
|
||||
currentSelectedLine,
|
||||
myFile
|
||||
)
|
||||
if (declaration != null) {
|
||||
row {
|
||||
@@ -109,6 +119,8 @@ class MenuPreviewFileEditor(
|
||||
viewport.viewPosition = currentViewPosition
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(menuCount > 0) {
|
||||
// add the scroll pane to the UI
|
||||
myUi.add(
|
||||
@@ -117,11 +129,13 @@ class MenuPreviewFileEditor(
|
||||
)
|
||||
} else {
|
||||
myUi.add(
|
||||
JLabel("Currently this source code has no menu declaration!")
|
||||
.centerComponent(),
|
||||
BorderLayout.CENTER
|
||||
JLabel("Could not render menu preview")
|
||||
)
|
||||
}
|
||||
// val p = Panel()
|
||||
// p.setSize(50, 100)
|
||||
// p.background = Color.CYAN
|
||||
// myUi.add(p)
|
||||
}
|
||||
|
||||
|
||||
@@ -162,10 +176,17 @@ class MenuPreviewFileEditor(
|
||||
dispose()
|
||||
}
|
||||
|
||||
|
||||
override fun dispose() {
|
||||
mySwingAlarm.cancelAllRequests()
|
||||
myDocument.removeDocumentListener(documentListener)
|
||||
mainEditor.editor.caretModel.removeCaretListener(caretListener)
|
||||
// mySwingAlarm.cancelAllRequests()
|
||||
// try {
|
||||
// if(!registered) return
|
||||
// myDocument.removeDocumentListener(documentListener)
|
||||
// mainEditor.editor.caretModel.removeCaretListener(caretListener)
|
||||
// } catch (e: Throwable) {
|
||||
// Log.warn(e.message)
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private fun JComponent.centerComponent(): JPanel {
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package tech.carcadex.kotlinbukkitkit.tooling.menu
|
||||
|
||||
import com.intellij.openapi.fileEditor.*
|
||||
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider
|
||||
import com.intellij.openapi.module.ModuleUtilCore
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.readText
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.incremental.createDirectory
|
||||
import tech.carcadex.kotlinbukkitkit.tooling.Assets
|
||||
import java.io.*
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
|
||||
class MenuPreviewFileEditorProvider : WeighedFileEditorProvider() {
|
||||
|
||||
companion object {
|
||||
val MAIN_FOLDER = File("kbk-assets")
|
||||
val ASSETS_FOLDER = File("kbk-assets/assets")
|
||||
const val ID = "kotlinbukkitkit-menu-preview"
|
||||
init {
|
||||
MAIN_FOLDER.createDirectory()
|
||||
val zip = File(MAIN_FOLDER, "assets.zip")
|
||||
if(!zip.exists()) {
|
||||
zip.createNewFile()
|
||||
val input: InputStream = Assets::class.java.getResourceAsStream("/assets.zip")
|
||||
zip.writeBytes(input.readAllBytes())
|
||||
|
||||
fun unzip(`is`: InputStream?, targetDir: Path) {
|
||||
var targetDir: Path = targetDir
|
||||
targetDir = targetDir.toAbsolutePath()
|
||||
ZipInputStream(`is`).use { zipIn ->
|
||||
var ze: ZipEntry
|
||||
while (zipIn.nextEntry.also {
|
||||
if (it != null) {
|
||||
ze = it
|
||||
val resolvedPath: Path = targetDir.resolve(ze.name).normalize()
|
||||
if (!resolvedPath.startsWith(targetDir)) {
|
||||
throw RuntimeException(
|
||||
"Entry with an illegal path: "
|
||||
+ ze.name
|
||||
)
|
||||
}
|
||||
if (ze.isDirectory) {
|
||||
Files.createDirectories(resolvedPath)
|
||||
} else {
|
||||
Files.createDirectories(resolvedPath.getParent())
|
||||
Files.copy(zipIn, resolvedPath)
|
||||
}
|
||||
}
|
||||
} != null) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unzip(FileInputStream(zip), MAIN_FOLDER.toPath())
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getEditorTypeId(): String = ID
|
||||
|
||||
override fun accept(project: Project, file: VirtualFile): Boolean {
|
||||
val type = file.fileType
|
||||
|
||||
if(type != KotlinFileType.INSTANCE) return false
|
||||
|
||||
val module = ModuleUtilCore.findModuleForFile(file, project) ?: return false
|
||||
|
||||
val root = ModuleRootManager.getInstance(module)
|
||||
var hasKotlinBukkitAPI = false
|
||||
|
||||
root.orderEntries().withoutSdk().forEachLibrary {
|
||||
if((it.name ?: "").contains("kotlinbukkitkit", true)) {
|
||||
hasKotlinBukkitAPI = true
|
||||
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
if(!file.readText().contains("tech.carcadex.kotlinbukkitkit.menu.dsl.menu")) hasKotlinBukkitAPI = false;
|
||||
|
||||
return hasKotlinBukkitAPI
|
||||
}
|
||||
|
||||
override fun createEditor(project: Project, file: VirtualFile): FileEditor {
|
||||
val editor: TextEditor = TextEditorProvider.getInstance().createEditor(project, file) as TextEditor
|
||||
val preview = MenuPreviewFileEditor(project, file, editor)
|
||||
val result = TextEditorWithPreview(editor, preview, "KotlinBukkitKit")
|
||||
return result
|
||||
}
|
||||
|
||||
//override fun getPolicy(): FileEditorPolicy = FileEditorPolicy.HIDE_DEFAULT_EDITOR
|
||||
override fun getPolicy(): FileEditorPolicy = FileEditorPolicy.HIDE_DEFAULT_EDITOR
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.menu
|
||||
package tech.carcadex.kotlinbukkitkit.tooling.menu
|
||||
|
||||
enum class MinecraftItem(val id: Int) {
|
||||
AIR(0),
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.menu
|
||||
package tech.carcadex.kotlinbukkitkit.tooling.menu
|
||||
|
||||
enum class MinecraftItem13 {
|
||||
MUSIC_DISC_11,
|
||||
+38
-28
@@ -1,32 +1,41 @@
|
||||
package br.com.devsrsouza.kotlinbukkitapi.tooling.menu
|
||||
package tech.carcadex.kotlinbukkitkit.tooling.menu
|
||||
|
||||
import com.intellij.psi.util.collectDescendantsOfType
|
||||
import com.intellij.psi.util.findDescendantOfType
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.readText
|
||||
import org.jetbrains.kotlin.builtins.getReceiverTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
|
||||
import org.jetbrains.kotlin.idea.core.util.getLineNumber
|
||||
import org.jetbrains.kotlin.idea.debugger.sequence.psi.resolveType
|
||||
import org.jetbrains.kotlin.idea.intentions.isMethodCall
|
||||
import org.jetbrains.kotlin.idea.base.psi.getLineNumber
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.resolveType
|
||||
import org.jetbrains.kotlin.idea.inspections.collections.isCalling
|
||||
import org.jetbrains.kotlin.idea.refactoring.fqName.fqName
|
||||
import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
|
||||
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
||||
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.findDescendantOfType
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
|
||||
private val menuFqSupportedNames = listOf(
|
||||
"br.com.devsrsouza.kotlinbukkitapi.dsl.menu.menu",
|
||||
"br.com.devsrsouza.bukkript.script.definition.api.menu"
|
||||
"tech.carcadex.kotlinbukkitkit.dsl.menu"
|
||||
)
|
||||
|
||||
fun findMenuDeclaration(
|
||||
element: KtCallExpression,
|
||||
currentSelectedLine: Int? = null
|
||||
currentSelectedLine: Int? = null,
|
||||
file: VirtualFile
|
||||
): MenuDeclaration? {
|
||||
val simpleName = "menu"
|
||||
|
||||
val nm = file.readText()
|
||||
if (!element.isCallFrom(simpleName, menuFqSupportedNames)) return null
|
||||
|
||||
if (!nm.contains("tech.carcadex.kotlinbukkitkit.menu.dsl.menu"))
|
||||
return null;
|
||||
val menuFunction = element.findDescendantOfType<KtCallExpression> {
|
||||
isMenuCall(it)
|
||||
} ?: return null
|
||||
@@ -37,10 +46,10 @@ fun findMenuDeclaration(
|
||||
val lines = menuFunction.valueArguments.getOrNull(1)?.text?.toIntOrNull() ?: return null
|
||||
|
||||
val menuLambdaBlock = element.findDescendantOfType<KtLambdaExpression> {
|
||||
it.isBuilderBlockFor("br.com.devsrsouza.kotlinbukkitapi.dsl.menu.MenuDSL")
|
||||
it.isBuilderBlockFor("tech.carcadex.kotlinbukkitkit.menu.dsl.MenuDSL")
|
||||
} ?: return null
|
||||
|
||||
val slotFqName = listOf("br.com.devsrsouza.kotlinbukkitapi.dsl.menu.slot")
|
||||
val slotFqName = listOf("tech.carcadex.kotlinbukkitkit.menu.dsl.menu.slot")
|
||||
val slotSimpleName = "slot"
|
||||
|
||||
val slotCalls = menuLambdaBlock.collectDescendantsOfType<KtCallExpression> {
|
||||
@@ -61,8 +70,6 @@ fun findMenuDeclaration(
|
||||
|
||||
val materialExpression = expression.findDescendantOfType<KtDotQualifiedExpression> {
|
||||
it.text.startsWith("Material")
|
||||
&& it.receiverExpression.mainReference?.resolve()?.getKotlinFqName()?.asString()
|
||||
?.equals("org.bukkit.Material") == true
|
||||
} ?: return@mapNotNull null
|
||||
|
||||
val typeExpression = materialExpression.selectorExpression as? KtNameReferenceExpression ?: return@mapNotNull null
|
||||
@@ -85,22 +92,25 @@ fun isMenuCall(it: KtCallExpression) =
|
||||
it.isCallFrom("menu", menuFqSupportedNames)
|
||||
|
||||
fun KtLambdaExpression.isBuilderBlockFor(fqName: String): Boolean {
|
||||
val type = resolveType()
|
||||
|
||||
val extensionFunctionType = type.isExtensionFunctionType
|
||||
|
||||
if(!extensionFunctionType) return false
|
||||
|
||||
val returnTypeFromFunctionType = type.getReturnTypeFromFunctionType()
|
||||
val receiverTypeFromFunctionType = type.getReceiverTypeFromFunctionType() ?: return false
|
||||
val receiverFqName = receiverTypeFromFunctionType.fqName ?: return false
|
||||
|
||||
return returnTypeFromFunctionType.isUnit() && receiverFqName.asString().equals(fqName)
|
||||
return (text.replace(" ", "").replace("\t", "").replace("\n", "")
|
||||
.contains(Regex("\\{[\\s\\S]*?slot"))) && (parent.parent.text.contains("menu"))
|
||||
// val type = resolveType()
|
||||
//
|
||||
// val extensionFunctionType = type?.isExtensionFunctionType
|
||||
//
|
||||
// if (extensionFunctionType != true) return false
|
||||
//
|
||||
// val returnTypeFromFunctionType = type.getReturnTypeFromFunctionType()
|
||||
// val receiverTypeFromFunctionType = type.getReceiverTypeFromFunctionType() ?: return false
|
||||
// val receiverFqName = receiverTypeFromFunctionType.fqName ?: return false
|
||||
//
|
||||
// return returnTypeFromFunctionType.isUnit() && receiverFqName.asString().equals(fqName)
|
||||
}
|
||||
|
||||
fun KtCallExpression.isCallFrom(
|
||||
simpleName: String,
|
||||
fqNames: List<String>
|
||||
|
||||
): Boolean {
|
||||
return text.startsWith(simpleName) && fqNames.any { isMethodCall(it) }
|
||||
return text.startsWith(simpleName)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<idea-plugin>
|
||||
<id>br.com.devsrsouza.kotlinbukkitapi.tooling</id>
|
||||
<name>KotlinBukkitAPI Tooling</name>
|
||||
<vendor>DevSrSouza</vendor>
|
||||
<id>tech.carcadex.kotlinbukkitkit.tooling.menu</id>
|
||||
<name>KBK-Menu-Preview Bukkit</name>
|
||||
<vendor>Denis Istratov</vendor>
|
||||
|
||||
<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
|
||||
on how to target different products -->
|
||||
@@ -11,28 +11,12 @@
|
||||
<depends>com.intellij.modules.externalSystem</depends>
|
||||
<depends>com.intellij.modules.java</depends>
|
||||
|
||||
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<!-- Add your extensions here -->
|
||||
<fileEditorProvider implementation="br.com.devsrsouza.kotlinbukkitapi.tooling.menu.MenuPreviewFileEditorProvider"/>
|
||||
|
||||
<fileType language="kotlin" extensions="bk.kts" name="Bukkript File" fieldName="INSTANCE"
|
||||
implementationClass="br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript.BukkriptFileType" />
|
||||
<internalFileTemplate name="Bukkript Script" />
|
||||
<iconProvider implementation="br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript.BukkriptIconProvider" order="first"/>
|
||||
|
||||
<moduleBuilder builderClass="br.com.devsrsouza.kotlinbukkitapi.tooling.wizard.KBAPIModuleBuilder" />
|
||||
|
||||
<projectViewNodeDecorator implementation="br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript.BukkriptViewNodeDecorator" />
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||
<scriptDefinitionsProvider implementation="br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript.BukkriptScriptDefinitionProvider" />
|
||||
<fileEditorProvider implementation="tech.carcadex.kotlinbukkitkit.tooling.menu.MenuPreviewFileEditorProvider"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<!-- Add your actions here -->
|
||||
<action id="Bukkript.NewScript" class="br.com.devsrsouza.kotlinbukkitapi.tooling.bukkript.BukkriptCreateNewFileAction">
|
||||
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFromTemplate"/>
|
||||
</action>
|
||||
</actions>
|
||||
</idea-plugin>
|
||||
Binary file not shown.
Reference in new issue
Block a user