Skip to content

Commit 077589e

Browse files
committed
Convert to Kotlin
1 parent 17121e4 commit 077589e

File tree

8 files changed

+77
-98
lines changed

8 files changed

+77
-98
lines changed

src/main/java/org/polyfrost/example/ExampleMod.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/main/java/org/polyfrost/example/command/ExampleCommand.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/java/org/polyfrost/example/config/ExampleConfig.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/main/java/org/polyfrost/example/hud/ExampleHud.java

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.polyfrost.example
2+
3+
import net.minecraftforge.fml.common.Mod
4+
import net.minecraftforge.fml.common.event.FMLInitializationEvent
5+
import org.polyfrost.example.command.ExampleCommand
6+
import org.polyfrost.example.config.ExampleConfig
7+
import org.polyfrost.oneconfig.api.commands.v1.CommandManager
8+
9+
/**
10+
* The entrypoint of the Example Mod which initializes it.
11+
* This is what is run when the game is started and typically how your mod will set up its functionality.
12+
*
13+
* @see Mod
14+
*/
15+
@Mod(modid = ExampleMod.ID, name = ExampleMod.NAME, version = ExampleMod.VERSION, modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter")
16+
object ExampleMod {
17+
18+
// Sets the variables from `gradle.properties`. Depends on the `bloom` DGT plugin.
19+
const val ID = "@MOD_ID@"
20+
const val NAME = "@MOD_NAME@"
21+
const val VERSION = "@MOD_VERSION@"
22+
23+
// Register the config and commands.
24+
@Mod.EventHandler
25+
fun onInit(event: FMLInitializationEvent) {
26+
ExampleConfig.preload()
27+
CommandManager.registerCommand(ExampleCommand())
28+
}
29+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.polyfrost.example.command
2+
3+
import org.polyfrost.example.ExampleMod
4+
import org.polyfrost.example.config.ExampleConfig
5+
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command
6+
import org.polyfrost.oneconfig.utils.v1.dsl.openUI
7+
8+
/**
9+
* An example command implementing the Command API of OneConfig.
10+
* Registered in ExampleMod.kt with `CommandManager.INSTANCE.registerCommand(new ExampleCommand());`
11+
*
12+
* @see Command
13+
* @see ExampleMod
14+
*/
15+
@Command(value = [ExampleMod.ID], description = "Access the ${ExampleMod.NAME} GUI.")
16+
class ExampleCommand {
17+
@Command
18+
private fun main() {
19+
ExampleConfig.openUI()
20+
}
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.polyfrost.example.config
2+
3+
import org.polyfrost.example.ExampleMod
4+
import org.polyfrost.oneconfig.api.config.v1.Config
5+
import org.polyfrost.oneconfig.api.config.v1.annotations.Dropdown
6+
import org.polyfrost.oneconfig.api.config.v1.annotations.Slider
7+
import org.polyfrost.oneconfig.api.config.v1.annotations.Switch
8+
9+
/**
10+
* The main Config entrypoint that extends the Config type and initializes your config options.
11+
* See [this link](https://docsv1.polyfrost.org/configuration/available-options) for more config options
12+
*/
13+
object ExampleConfig : Config("${ExampleMod.ID}.json", ExampleMod.NAME, Category.OTHER) {
14+
@Switch(title = "Example Switch")
15+
var exampleSwitch = false // The default value for the boolean Switch.
16+
17+
@Slider(title = "Example Slider", min = 0F, max = 100F, step = 10F)
18+
var exampleSlider = 50f // The default value for the float Slider.
19+
20+
@Dropdown(title = "Example Dropdown", options = ["Option 1", "Option 2", "Option 3", "Option 4"])
21+
var exampleDropdown = 1 // Default option (in this case "Option 2")
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.polyfrost.example.hud
2+
3+
// TODO: for nextdayy
4+
class ExampleHud {
5+
}

0 commit comments

Comments
 (0)