Skip to content

Commit

Permalink
feat(arguments): add PotionEffectTypeArgument
Browse files Browse the repository at this point in the history
  • Loading branch information
StillLutto committed Dec 9, 2024
1 parent c57c952 commit d60735a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.undefined.stellar.argument.types.custom.OnlinePlayersArgument
import com.undefined.stellar.argument.types.entity.EntityAnchorArgument
import com.undefined.stellar.argument.types.entity.EntityArgument
import com.undefined.stellar.argument.types.entity.EntityDisplayType
import com.undefined.stellar.argument.types.entity.PotionEffectTypeArgument
import com.undefined.stellar.argument.types.item.ItemArgument
import com.undefined.stellar.argument.types.item.ItemPredicateArgument
import com.undefined.stellar.argument.types.item.ItemSlotArgument
Expand Down Expand Up @@ -208,4 +209,7 @@ open class ArgumentHandler {
fun addStructureTypeArgument(name: String): StructureTypeArgument =
addArgument { StructureTypeArgument(base, name) }

fun addPotionEffectTypeArgument(name: String): PotionEffectTypeArgument =
addArgument { PotionEffectTypeArgument(base, name) }

}
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 PotionEffectTypeArgument(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarArgument<PotionEffectTypeArgument>(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.Player
import org.bukkit.generator.structure.StructureType
import org.bukkit.plugin.java.JavaPlugin
import org.bukkit.potion.PotionEffectType

class Main : JavaPlugin() {

override fun onEnable() {
val main = StellarCommand("test", description = "this is a description", "othertest")
main.addStructureTypeArgument("type")
main.addPotionEffectTypeArgument("type")
.addExecution<Player> {
source.sendMessage(getArgument<StructureType>("type").key.toString())
source.sendMessage(getArgument<PotionEffectType>("type").key.toString())
}
.register(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.undefined.stellar.argument.types.custom.CustomArgument
import com.undefined.stellar.argument.types.custom.EnumArgument
import com.undefined.stellar.argument.types.custom.ListArgument
import com.undefined.stellar.argument.types.entity.EntityDisplayType
import com.undefined.stellar.argument.types.entity.PotionEffectTypeArgument
import com.undefined.stellar.argument.types.item.ItemSlotArgument
import com.undefined.stellar.argument.types.item.ItemSlotsArgument
import com.undefined.stellar.argument.types.math.AxisArgument
Expand Down Expand Up @@ -148,6 +149,7 @@ object ArgumentHelper {
is UUIDArgument -> UuidArgument.uuid()
is GameEventArgument -> ResourceKeyArgument.key(Registries.GAME_EVENT)
is StructureTypeArgument -> ResourceKeyArgument.key(Registries.STRUCTURE_TYPE)
is PotionEffectTypeArgument -> ResourceKeyArgument.key(Registries.MOB_EFFECT)
else -> throw UnsupportedArgumentException()
}

Expand Down Expand Up @@ -217,6 +219,7 @@ object ArgumentHelper {
is UUIDArgument -> UuidArgument.getUuid(context, argument.name)
is GameEventArgument -> org.bukkit.Registry.GAME_EVENT.get(getId(context, argument.name, Registries.GAME_EVENT))
is StructureTypeArgument -> org.bukkit.Registry.STRUCTURE_TYPE.get(getId(context, argument.name, Registries.STRUCTURE_TYPE))
is PotionEffectTypeArgument -> org.bukkit.Registry.POTION_EFFECT_TYPE.get(getId(context, argument.name, Registries.MOB_EFFECT))
else -> throw UnsupportedArgumentException()
}
}
Expand Down

0 comments on commit d60735a

Please sign in to comment.