Skip to content

Commit

Permalink
feat(arguments): add FrogVariantArgument
Browse files Browse the repository at this point in the history
  • Loading branch information
StillLutto committed Dec 9, 2024
1 parent 1556932 commit 73d9725
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,7 @@ open class ArgumentHandler {
fun addCatTypeArgument(name: String): CatTypeArgument =
addArgument { CatTypeArgument(base, name) }

fun addFrogVariantArgument(name: String): FrogVariantArgument =
addArgument { FrogVariantArgument(base, name) }

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.undefined.stellar.argument.AbstractStellarArgument
import java.lang.Enum.valueOf
import kotlin.reflect.KClass

@Suppress("UNCHECKED_CAST")
class EnumArgument<T : Enum<T>>(
parent: AbstractStellarCommand<*>,
name: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.undefined.stellar.argument.types.entity

import com.undefined.stellar.AbstractStellarCommand
import com.undefined.stellar.argument.AbstractStellarArgument

class FrogVariantArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument<FrogVariantArgument>(parent, name)
6 changes: 3 additions & 3 deletions server/src/main/kotlin/com/undefined/stellar/Main.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.undefined.stellar

import org.bukkit.entity.Cat
import org.bukkit.entity.Frog
import org.bukkit.entity.Player
import org.bukkit.plugin.java.JavaPlugin

class Main : JavaPlugin() {

override fun onEnable() {
val main = StellarCommand("test", description = "this is a description", "othertest")
main.addCatTypeArgument("type")
main.addFrogVariantArgument("type")
.addExecution<Player> {
source.sendMessage(getArgument<Cat.Type>("type").key.toString())
source.sendMessage(getArgument<Frog.Variant>("type").key.toString())
}
.register(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.undefined.stellar.argument.types.custom.EnumArgument
import com.undefined.stellar.argument.types.custom.ListArgument
import com.undefined.stellar.argument.types.entity.CatTypeArgument
import com.undefined.stellar.argument.types.entity.EntityDisplayType
import com.undefined.stellar.argument.types.entity.FrogVariantArgument
import com.undefined.stellar.argument.types.entity.PotionEffectTypeArgument
import com.undefined.stellar.argument.types.item.ItemSlotArgument
import com.undefined.stellar.argument.types.item.ItemSlotsArgument
Expand Down Expand Up @@ -155,6 +156,7 @@ object ArgumentHelper {
is BlockTypeArgument -> ResourceKeyArgument.key(Registries.BLOCK_TYPE)
is ItemTypeArgument -> ResourceKeyArgument.key(Registries.ITEM)
is CatTypeArgument -> ResourceKeyArgument.key(Registries.CAT_VARIANT)
is FrogVariantArgument -> ResourceKeyArgument.key(Registries.FROG_VARIANT)
else -> throw UnsupportedArgumentException()
}

Expand Down Expand Up @@ -228,6 +230,7 @@ object ArgumentHelper {
is BlockTypeArgument -> org.bukkit.Registry.BLOCK.get(getId(context, argument.name, Registries.BLOCK_TYPE))
is ItemTypeArgument -> org.bukkit.Registry.ITEM.get(getId(context, argument.name, Registries.ITEM))
is CatTypeArgument -> org.bukkit.Registry.CAT_VARIANT.get(getId(context, argument.name, Registries.CAT_VARIANT))
is FrogVariantArgument -> org.bukkit.Registry.FROG_VARIANT.get(getId(context, argument.name, Registries.FROG_VARIANT))
else -> throw UnsupportedArgumentException()
}
}
Expand Down

0 comments on commit 73d9725

Please sign in to comment.