Skip to content

Commit 761b066

Browse files
committed
Move all the other project creators to get version data from the API
1 parent e46c9ae commit 761b066

File tree

6 files changed

+65
-49
lines changed

6 files changed

+65
-49
lines changed

src/main/kotlin/com/demonwav/mcdev/creator/BungeeCordProjectSettingsWizard.form

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.demonwav.mcdev.creator.BungeeCordProjectSettingsWizard">
33
<grid id="27dc6" layout-manager="BorderLayout" hgap="0" vgap="0">
44
<constraints>
5-
<xy x="20" y="20" width="765" height="509"/>
5+
<xy x="20" y="20" width="811" height="509"/>
66
</constraints>
77
<properties/>
88
<border type="none"/>
@@ -37,7 +37,7 @@
3737
</constraints>
3838
<properties/>
3939
</component>
40-
<grid id="b9a40" layout-manager="GridLayoutManager" row-count="3" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="5">
40+
<grid id="b9a40" layout-manager="GridLayoutManager" row-count="4" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="5">
4141
<margin top="5" left="5" bottom="5" right="5"/>
4242
<constraints>
4343
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -98,12 +98,7 @@
9898
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
9999
</constraints>
100100
<properties>
101-
<model>
102-
<item value="1.11"/>
103-
<item value="1.10"/>
104-
<item value="1.9"/>
105-
<item value="1.8"/>
106-
</model>
101+
<model/>
107102
</properties>
108103
</component>
109104
<component id="a3371" class="javax.swing.JLabel">
@@ -114,6 +109,16 @@
114109
<text value="Minecraft Version"/>
115110
</properties>
116111
</component>
112+
<component id="234c0" class="javax.swing.JLabel" binding="errorLabel">
113+
<constraints>
114+
<grid row="3" column="0" row-span="1" col-span="5" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
115+
</constraints>
116+
<properties>
117+
<foreground color="-1958631"/>
118+
<text value="There was an error while attempting to retrieve versions."/>
119+
<visible value="false"/>
120+
</properties>
121+
</component>
117122
</children>
118123
</grid>
119124
<component id="bba9f" class="javax.swing.JLabel">

src/main/kotlin/com/demonwav/mcdev/creator/BungeeCordProjectSettingsWizard.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.demonwav.mcdev.platform.bungeecord.BungeeCordProjectConfiguration
1515
import org.apache.commons.lang.WordUtils
1616
import javax.swing.JComboBox
1717
import javax.swing.JComponent
18+
import javax.swing.JLabel
1819
import javax.swing.JPanel
1920
import javax.swing.JTextField
2021

@@ -29,6 +30,7 @@ class BungeeCordProjectSettingsWizard(private val creator: MinecraftProjectCreat
2930
private lateinit var dependField: JTextField
3031
private lateinit var softDependField: JTextField
3132
private lateinit var minecraftVersionBox: JComboBox<String>
33+
private lateinit var errorLabel: JLabel
3234

3335
private var settings: BungeeCordProjectConfiguration? = null
3436

@@ -53,11 +55,16 @@ class BungeeCordProjectSettingsWizard(private val creator: MinecraftProjectCreat
5355
mainClassField.text = mainClassField.text + PlatformType.BUNGEECORD.normalName
5456
}
5557

58+
getVersionSelector(PlatformType.BUNGEECORD)
59+
.done { it.set(minecraftVersionBox) }
60+
.rejected { errorLabel.isVisible = true }
61+
5662
return panel
5763
}
5864

5965
override fun validate(): Boolean {
60-
return validate(pluginNameField, pluginVersionField, mainClassField, authorField, dependField, pattern)
66+
return validate(pluginNameField, pluginVersionField, mainClassField, authorField, dependField, pattern) &&
67+
minecraftVersionBox.selectedItem != null
6168
}
6269

6370
override fun isStepVisible(): Boolean {
@@ -74,7 +81,7 @@ class BungeeCordProjectSettingsWizard(private val creator: MinecraftProjectCreat
7481
this.settings!!.setAuthors(this.authorField.text)
7582
this.settings!!.setDependencies(this.dependField.text)
7683
this.settings!!.setSoftDependencies(this.softDependField.text)
77-
this.settings!!.minecraftVersion = minecraftVersionBox.selectedItem as String
84+
this.settings!!.minecraftVersion = minecraftVersionBox.selectedItem as? String ?: ""
7885
}
7986

8087
override fun updateDataModel() {}

src/main/kotlin/com/demonwav/mcdev/creator/CanaryProjectSettingsWizard.form

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="0" left="0" bottom="0" right="0"/>
55
<constraints>
6-
<xy x="20" y="20" width="835" height="599"/>
6+
<xy x="20" y="20" width="892" height="599"/>
77
</constraints>
88
<properties/>
99
<border type="none"/>
@@ -32,7 +32,7 @@
3232
</constraints>
3333
<properties/>
3434
</component>
35-
<grid id="9d932" layout-manager="GridLayoutManager" row-count="3" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="5">
35+
<grid id="9d932" layout-manager="GridLayoutManager" row-count="4" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="5">
3636
<margin top="5" left="5" bottom="5" right="5"/>
3737
<constraints>
3838
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -93,26 +93,7 @@
9393
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
9494
</constraints>
9595
<properties>
96-
<model>
97-
<item value="1.2.1-SNAPSHOT"/>
98-
<item value="1.2.0"/>
99-
<item value="1.1.3"/>
100-
<item value="1.1.2"/>
101-
<item value="1.1.1"/>
102-
<item value="1.1.0"/>
103-
<item value="1.0-RC3"/>
104-
<item value="1.0-RC2"/>
105-
<item value="1.0-RC1"/>
106-
<item value="0.9"/>
107-
<item value="0.8"/>
108-
<item value="0.7"/>
109-
<item value="0.6"/>
110-
<item value="0.5"/>
111-
<item value="0.4"/>
112-
<item value="0.3"/>
113-
<item value="0.2"/>
114-
<item value="0.1"/>
115-
</model>
96+
<model/>
11697
</properties>
11798
</component>
11899
<component id="230ec" class="javax.swing.JLabel">
@@ -123,6 +104,16 @@
123104
<text value="Canary Version"/>
124105
</properties>
125106
</component>
107+
<component id="bd355" class="javax.swing.JLabel" binding="errorLabel">
108+
<constraints>
109+
<grid row="3" column="0" row-span="1" col-span="5" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
110+
</constraints>
111+
<properties>
112+
<foreground color="-1958631"/>
113+
<text value="There was an error while attempting to retrieve versions."/>
114+
<visible value="false"/>
115+
</properties>
116+
</component>
126117
</children>
127118
</grid>
128119
<component id="49daa" class="javax.swing.JLabel">

src/main/kotlin/com/demonwav/mcdev/creator/CanaryProjectSettingsWizard.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class CanaryProjectSettingsWizard(private val creator: MinecraftProjectCreator)
3131
private lateinit var dependField: JTextField
3232
private lateinit var title: JLabel
3333
private lateinit var canaryVersionBox: JComboBox<String>
34+
private lateinit var errorLabel: JLabel
3435

3536
private var settings: CanaryProjectConfiguration? = null
3637

@@ -67,6 +68,10 @@ class CanaryProjectSettingsWizard(private val creator: MinecraftProjectCreator)
6768
else -> {}
6869
}
6970

71+
getVersionSelector(settings!!.type)
72+
.done { it.set(canaryVersionBox) }
73+
.rejected { errorLabel.isVisible = true }
74+
7075
return panel
7176
}
7277

@@ -76,7 +81,8 @@ class CanaryProjectSettingsWizard(private val creator: MinecraftProjectCreator)
7681
}
7782

7883
override fun validate(): Boolean {
79-
return validate(pluginNameField, pluginVersionField, mainClassField, authorsField, dependField, MinecraftModuleWizardStep.pattern)
84+
return validate(pluginNameField, pluginVersionField, mainClassField, authorsField, dependField, MinecraftModuleWizardStep.pattern) &&
85+
canaryVersionBox.selectedItem != null
8086
}
8187

8288
override fun onStepLeaving() {
@@ -86,7 +92,7 @@ class CanaryProjectSettingsWizard(private val creator: MinecraftProjectCreator)
8692
this.settings!!.setAuthors(this.authorsField.text)
8793
this.settings!!.isEnableEarly = this.loadOrderBox.selectedIndex != 0
8894
this.settings!!.setDependencies(this.dependField.text)
89-
this.settings!!.canaryVersion = canaryVersionBox.selectedItem as String
95+
this.settings!!.canaryVersion = canaryVersionBox.selectedItem as? String ?: ""
9096
}
9197

9298
override fun updateDataModel() {}

src/main/kotlin/com/demonwav/mcdev/creator/SpongeProjectSettingsWizard.form

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<properties/>
99
<border type="none"/>
1010
<children>
11-
<grid id="c94c0" layout-manager="GridLayoutManager" row-count="8" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="10" vgap="10">
11+
<grid id="c94c0" layout-manager="GridLayoutManager" row-count="9" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="10" vgap="10">
1212
<margin top="5" left="10" bottom="10" right="10"/>
1313
<constraints>
1414
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
@@ -92,15 +92,15 @@
9292
</grid>
9393
<component id="223e8" class="javax.swing.JLabel">
9494
<constraints>
95-
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
95+
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
9696
</constraints>
9797
<properties>
9898
<text value="Optional Settings"/>
9999
</properties>
100100
</component>
101101
<component id="fc22a" class="javax.swing.JSeparator">
102102
<constraints>
103-
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
103+
<grid row="7" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
104104
<maximum-size width="-1" height="5"/>
105105
</grid>
106106
</constraints>
@@ -118,7 +118,7 @@
118118
<grid id="a7f71" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="5">
119119
<margin top="5" left="5" bottom="5" right="5"/>
120120
<constraints>
121-
<grid row="7" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
121+
<grid row="8" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
122122
</constraints>
123123
<properties/>
124124
<border type="none"/>
@@ -211,6 +211,16 @@
211211
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
212212
</constraints>
213213
</hspacer>
214+
<component id="e3737" class="javax.swing.JLabel" binding="errorLabel">
215+
<constraints>
216+
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
217+
</constraints>
218+
<properties>
219+
<foreground color="-1958631"/>
220+
<text value="There was an error while attempting to retrieve versions."/>
221+
<visible value="false"/>
222+
</properties>
223+
</component>
214224
</children>
215225
</grid>
216226
<grid id="ccdb2" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

src/main/kotlin/com/demonwav/mcdev/creator/SpongeProjectSettingsWizard.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,10 @@ class SpongeProjectSettingsWizard(private val creator: MinecraftProjectCreator)
3535
private lateinit var dependField: JTextField
3636
private lateinit var generateDocumentedListenersCheckBox: JCheckBox
3737
private lateinit var spongeApiVersionBox: JComboBox<String>
38+
private lateinit var errorLabel: JLabel
3839

3940
private var settings: SpongeProjectConfiguration? = null
4041

41-
init {
42-
spongeApiVersionBox.addItem("4.1.0")
43-
spongeApiVersionBox.addItem("5.0.0")
44-
spongeApiVersionBox.addItem("5.1.0")
45-
spongeApiVersionBox.addItem("5.2.0-SNAPSHOT")
46-
spongeApiVersionBox.addItem("6.0.0-SNAPSHOT")
47-
spongeApiVersionBox.selectedIndex = 2
48-
}
49-
5042
override fun getComponent(): JComponent {
5143
settings = creator.settings[PlatformType.SPONGE] as? SpongeProjectConfiguration
5244
if (settings == null) {
@@ -74,11 +66,16 @@ class SpongeProjectSettingsWizard(private val creator: MinecraftProjectCreator)
7466
title.icon = PlatformAssets.SPONGE_ICON_2X
7567
}
7668

69+
getVersionSelector(PlatformType.SPONGE)
70+
.done { it.set(spongeApiVersionBox) }
71+
.rejected { errorLabel.isVisible = true }
72+
7773
return panel
7874
}
7975

8076
override fun validate(): Boolean {
81-
return validate(pluginNameField, pluginVersionField, mainClassField, authorsField, dependField, MinecraftModuleWizardStep.pattern)
77+
return validate(pluginNameField, pluginVersionField, mainClassField, authorsField, dependField, MinecraftModuleWizardStep.pattern) &&
78+
spongeApiVersionBox.selectedItem != null
8279
}
8380

8481
override fun isStepVisible(): Boolean {
@@ -97,7 +94,7 @@ class SpongeProjectSettingsWizard(private val creator: MinecraftProjectCreator)
9794
settings!!.website = websiteField.text
9895

9996
settings!!.generateDocumentedListeners = this.generateDocumentedListenersCheckBox.isSelected
100-
settings!!.spongeApiVersion = spongeApiVersionBox.selectedItem as String
97+
settings!!.spongeApiVersion = spongeApiVersionBox.selectedItem as? String ?: ""
10198
}
10299

103100
override fun updateDataModel() {}

0 commit comments

Comments
 (0)