Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
StillLutto committed Dec 24, 2024
2 parents 7c24950 + 54057f5 commit 73dc576
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ enum class Operation(val string: String, private val application: (a: Float, b:
}

fun apply(a: Float, b: Float): Float = application(a, b)

fun apply(a: Int, b: Int): Float = apply(a.toFloat(), b.toFloat())
}
10 changes: 4 additions & 6 deletions server/src/main/kotlin/com/undefined/stellar/Main.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package com.undefined.stellar

import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import org.bukkit.plugin.java.JavaPlugin

class Main : JavaPlugin() {

override fun onEnable() {
StellarCommand("test")
.addStringArgument(name = "string")
StellarCommand("set-time")
.addTimeArgument("time")
.addExecution<Player> {
sender.sendMessage(getArgument<String>("string"))
val time = getArgument<Long>("time")
sender.world.time = time
}
.register(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name)
is com.undefined.stellar.argument.types.math.RotationArgument -> {
val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source)
Location(context.source.level.world, rotation.x, rotation.y, rotation.z)
val coordinates = RotationArgument.getRotation(context, argument.name)
val position = coordinates.getPosition(context.source)
val rotation = coordinates.getRotation(context.source)
Location(context.source.bukkitWorld, position.x, position.y, position.z, rotation.x, rotation.y)
}
is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name))
is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) {
Expand All @@ -241,7 +243,7 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment
is GameModeArgument -> throwArgumentVersionException(argument)
is com.undefined.stellar.argument.types.math.TimeArgument -> Duration.ofSeconds(IntegerArgumentType.getInteger(context, argument.name).toLong() / 20)
is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong()
is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name)
is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name)
is HeightMapArgument -> throwArgumentVersionException(argument)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name)
is com.undefined.stellar.argument.types.math.RotationArgument -> {
val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source)
Location(context.source.level.world, rotation.x, rotation.y, rotation.z)
val coordinates = RotationArgument.getRotation(context, argument.name)
val position = coordinates.getPosition(context.source)
val rotation = coordinates.getRotation(context.source)
Location(context.source.bukkitWorld, position.x, position.y, position.z, rotation.x, rotation.y)
}
is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name))
is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) {
Expand All @@ -243,7 +245,7 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment
is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id)
is com.undefined.stellar.argument.types.math.TimeArgument -> Duration.ofSeconds(IntegerArgumentType.getInteger(context, argument.name).toLong() / 20)
is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong()
is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name)
is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name)
is HeightMapArgument -> throwArgumentVersionException(argument)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name)
is com.undefined.stellar.argument.types.math.RotationArgument -> {
val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source)
Location(context.source.level.world, rotation.x, rotation.y, rotation.z)
val coordinates = RotationArgument.getRotation(context, argument.name)
val position = coordinates.getPosition(context.source)
val rotation = coordinates.getRotation(context.source)
Location(context.source.bukkitWorld, position.x, position.y, position.z, rotation.x, rotation.y)
}
is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name))
is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) {
Expand All @@ -251,7 +253,7 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment
is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id)
is com.undefined.stellar.argument.types.math.TimeArgument -> Duration.ofSeconds(IntegerArgumentType.getInteger(context, argument.name).toLong() / 20)
is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong()
is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name)
is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name)
is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name)
is com.undefined.stellar.argument.types.math.RotationArgument -> {
val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source)
Location(context.source.level.world, rotation.x, rotation.y, rotation.z)
val coordinates = RotationArgument.getRotation(context, argument.name)
val rotation = coordinates.getRotation(context.source)
Location(context.source.bukkitWorld, 0.0, 0.0, 0.0, rotation.y, rotation.x)
}
is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name))
is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) {
Expand All @@ -248,7 +249,7 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment
is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id)
is com.undefined.stellar.argument.types.math.TimeArgument -> Duration.ofSeconds(IntegerArgumentType.getInteger(context, argument.name).toLong() / 20)
is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong()
is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name)
is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name)
is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name)
Expand Down Expand Up @@ -388,7 +389,24 @@ object ArgumentHelper {

private fun getBukkitDisplaySlot(slot: Int): DisplaySlot = when (slot) {
0 -> DisplaySlot.PLAYER_LIST
1 -> DisplaySlot.SIDEBAR
2 -> DisplaySlot.BELOW_NAME
3 -> DisplaySlot.SIDEBAR_TEAM_BLACK
4 -> DisplaySlot.SIDEBAR_TEAM_DARK_BLUE
5 -> DisplaySlot.SIDEBAR_TEAM_DARK_GREEN
6 -> DisplaySlot.SIDEBAR_TEAM_DARK_AQUA
7 -> DisplaySlot.SIDEBAR_TEAM_DARK_RED
8 -> DisplaySlot.SIDEBAR_TEAM_DARK_PURPLE
9 -> DisplaySlot.SIDEBAR_TEAM_GOLD
10 -> DisplaySlot.SIDEBAR_TEAM_GRAY
11 -> DisplaySlot.SIDEBAR_TEAM_DARK_GRAY
12 -> DisplaySlot.SIDEBAR_TEAM_BLUE
13 -> DisplaySlot.SIDEBAR_TEAM_GREEN
14 -> DisplaySlot.SIDEBAR_TEAM_AQUA
15 -> DisplaySlot.SIDEBAR_TEAM_RED
16 -> DisplaySlot.SIDEBAR_TEAM_LIGHT_PURPLE
17 -> DisplaySlot.SIDEBAR_TEAM_YELLOW
18 -> DisplaySlot.SIDEBAR_TEAM_WHITE
else -> DisplaySlot.SIDEBAR
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name)
is com.undefined.stellar.argument.types.math.RotationArgument -> {
val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source)
Location(context.source.level.world, rotation.x, rotation.y, rotation.z)
val coordinates = RotationArgument.getRotation(context, argument.name)
val position = coordinates.getPosition(context.source)
val rotation = coordinates.getRotation(context.source)
Location(context.source.bukkitWorld, position.x, position.y, position.z, rotation.x, rotation.y)
}
is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name))
is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) {
Expand All @@ -248,7 +250,7 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment
is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id)
is com.undefined.stellar.argument.types.math.TimeArgument -> Duration.ofSeconds(IntegerArgumentType.getInteger(context, argument.name).toLong() / 20)
is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong()
is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name)
is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name)
is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name)
Expand Down Expand Up @@ -388,7 +390,24 @@ object ArgumentHelper {

private fun getBukkitDisplaySlot(slot: Int): DisplaySlot = when (slot) {
0 -> DisplaySlot.PLAYER_LIST
1 -> DisplaySlot.SIDEBAR
2 -> DisplaySlot.BELOW_NAME
3 -> DisplaySlot.SIDEBAR_TEAM_BLACK
4 -> DisplaySlot.SIDEBAR_TEAM_DARK_BLUE
5 -> DisplaySlot.SIDEBAR_TEAM_DARK_GREEN
6 -> DisplaySlot.SIDEBAR_TEAM_DARK_AQUA
7 -> DisplaySlot.SIDEBAR_TEAM_DARK_RED
8 -> DisplaySlot.SIDEBAR_TEAM_DARK_PURPLE
9 -> DisplaySlot.SIDEBAR_TEAM_GOLD
10 -> DisplaySlot.SIDEBAR_TEAM_GRAY
11 -> DisplaySlot.SIDEBAR_TEAM_DARK_GRAY
12 -> DisplaySlot.SIDEBAR_TEAM_BLUE
13 -> DisplaySlot.SIDEBAR_TEAM_GREEN
14 -> DisplaySlot.SIDEBAR_TEAM_AQUA
15 -> DisplaySlot.SIDEBAR_TEAM_RED
16 -> DisplaySlot.SIDEBAR_TEAM_LIGHT_PURPLE
17 -> DisplaySlot.SIDEBAR_TEAM_YELLOW
18 -> DisplaySlot.SIDEBAR_TEAM_WHITE
else -> DisplaySlot.SIDEBAR
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name)
is com.undefined.stellar.argument.types.math.RotationArgument -> {
val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source)
Location(context.source.level.world, rotation.x, rotation.y, rotation.z)
val coordinates = RotationArgument.getRotation(context, argument.name)
val position = coordinates.getPosition(context.source)
val rotation = coordinates.getRotation(context.source)
Location(context.source.bukkitWorld, position.x, position.y, position.z, rotation.x, rotation.y)
}
is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name))
is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) {
Expand All @@ -248,7 +250,7 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment
is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id)
is com.undefined.stellar.argument.types.math.TimeArgument -> Duration.ofSeconds(IntegerArgumentType.getInteger(context, argument.name).toLong() / 20)
is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong()
is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name)
is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name)
is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name)
is com.undefined.stellar.argument.types.math.RotationArgument -> {
val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source)
Location(context.source.level.world, rotation.x, rotation.y, rotation.z)
val coordinates = RotationArgument.getRotation(context, argument.name)
val position = coordinates.getPosition(context.source)
val rotation = coordinates.getRotation(context.source)
Location(context.source.bukkitWorld, position.x, position.y, position.z, rotation.x, rotation.y)
}
is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name))
is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) {
Expand All @@ -248,7 +250,7 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment
is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id)
is com.undefined.stellar.argument.types.math.TimeArgument -> Duration.ofSeconds(IntegerArgumentType.getInteger(context, argument.name).toLong() / 20)
is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong()
is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name)
is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name)
is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.getAngle(context, argument.name)
is com.undefined.stellar.argument.types.math.RotationArgument -> {
val rotation = RotationArgument.getRotation(context, argument.name).getPosition(context.source)
Location(context.source.level.world, rotation.x, rotation.y, rotation.z)
val coordinates = RotationArgument.getRotation(context, argument.name)
val position = coordinates.getPosition(context.source)
val rotation = coordinates.getRotation(context.source)
Location(context.source.bukkitWorld, position.x, position.y, position.z, rotation.x, rotation.y)
}
is DisplaySlotArgument -> getBukkitDisplaySlot(ScoreboardSlotArgument.getDisplaySlot(context, argument.name))
is com.undefined.stellar.argument.types.scoreboard.ScoreHolderArgument -> when (argument.type) {
Expand All @@ -246,7 +248,7 @@ object ArgumentHelper {
}
is com.undefined.stellar.argument.types.world.DimensionArgument -> DimensionArgument.getDimension(context, argument.name).world.environment
is com.undefined.stellar.argument.types.player.GameModeArgument -> GameMode.getByValue(GameModeArgument.getGameMode(context, argument.name).id)
is com.undefined.stellar.argument.types.math.TimeArgument -> Duration.ofSeconds(IntegerArgumentType.getInteger(context, argument.name).toLong() / 20)
is com.undefined.stellar.argument.types.math.TimeArgument -> IntegerArgumentType.getInteger(context, argument.name).toLong()
is MirrorArgument -> Mirror.valueOf(TemplateMirrorArgument.getMirror(context, argument.name).name)
is StructureRotationArgument -> StructureRotation.valueOf(TemplateRotationArgument.getRotation(context, argument.name).name)
is HeightMapArgument -> HeightMap.valueOf(HeightmapTypeArgument.getHeightmap(context, argument.name).name)
Expand Down
Loading

0 comments on commit 73dc576

Please sign in to comment.