Skip to content

Commit

Permalink
Convert to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jan 1, 2025
1 parent 17121e4 commit 077589e
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 98 deletions.
32 changes: 0 additions & 32 deletions src/main/java/org/polyfrost/example/ExampleMod.java

This file was deleted.

23 changes: 0 additions & 23 deletions src/main/java/org/polyfrost/example/command/ExampleCommand.java

This file was deleted.

38 changes: 0 additions & 38 deletions src/main/java/org/polyfrost/example/config/ExampleConfig.java

This file was deleted.

5 changes: 0 additions & 5 deletions src/main/java/org/polyfrost/example/hud/ExampleHud.java

This file was deleted.

29 changes: 29 additions & 0 deletions src/main/kotlin/org/polyfrost/example/ExampleMod.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.polyfrost.example

import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import org.polyfrost.example.command.ExampleCommand
import org.polyfrost.example.config.ExampleConfig
import org.polyfrost.oneconfig.api.commands.v1.CommandManager

/**
* The entrypoint of the Example Mod which initializes it.
* This is what is run when the game is started and typically how your mod will set up its functionality.
*
* @see Mod
*/
@Mod(modid = ExampleMod.ID, name = ExampleMod.NAME, version = ExampleMod.VERSION, modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter")
object ExampleMod {

// Sets the variables from `gradle.properties`. Depends on the `bloom` DGT plugin.
const val ID = "@MOD_ID@"
const val NAME = "@MOD_NAME@"
const val VERSION = "@MOD_VERSION@"

// Register the config and commands.
@Mod.EventHandler
fun onInit(event: FMLInitializationEvent) {
ExampleConfig.preload()
CommandManager.registerCommand(ExampleCommand())
}
}
21 changes: 21 additions & 0 deletions src/main/kotlin/org/polyfrost/example/command/ExampleCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.polyfrost.example.command

import org.polyfrost.example.ExampleMod
import org.polyfrost.example.config.ExampleConfig
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command
import org.polyfrost.oneconfig.utils.v1.dsl.openUI

/**
* An example command implementing the Command API of OneConfig.
* Registered in ExampleMod.kt with `CommandManager.INSTANCE.registerCommand(new ExampleCommand());`
*
* @see Command
* @see ExampleMod
*/
@Command(value = [ExampleMod.ID], description = "Access the ${ExampleMod.NAME} GUI.")
class ExampleCommand {
@Command
private fun main() {
ExampleConfig.openUI()
}
}
22 changes: 22 additions & 0 deletions src/main/kotlin/org/polyfrost/example/config/ExampleConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.polyfrost.example.config

import org.polyfrost.example.ExampleMod
import org.polyfrost.oneconfig.api.config.v1.Config
import org.polyfrost.oneconfig.api.config.v1.annotations.Dropdown
import org.polyfrost.oneconfig.api.config.v1.annotations.Slider
import org.polyfrost.oneconfig.api.config.v1.annotations.Switch

/**
* The main Config entrypoint that extends the Config type and initializes your config options.
* See [this link](https://docsv1.polyfrost.org/configuration/available-options) for more config options
*/
object ExampleConfig : Config("${ExampleMod.ID}.json", ExampleMod.NAME, Category.OTHER) {
@Switch(title = "Example Switch")
var exampleSwitch = false // The default value for the boolean Switch.

@Slider(title = "Example Slider", min = 0F, max = 100F, step = 10F)
var exampleSlider = 50f // The default value for the float Slider.

@Dropdown(title = "Example Dropdown", options = ["Option 1", "Option 2", "Option 3", "Option 4"])
var exampleDropdown = 1 // Default option (in this case "Option 2")
}
5 changes: 5 additions & 0 deletions src/main/kotlin/org/polyfrost/example/hud/ExampleHud.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.polyfrost.example.hud

// TODO: for nextdayy
class ExampleHud {
}

0 comments on commit 077589e

Please sign in to comment.