Skip to content

Commit

Permalink
Generate new models, send run metadata as part of scoreboard sync
Browse files Browse the repository at this point in the history
  • Loading branch information
4Ply committed Dec 14, 2024
1 parent c8bcdd6 commit 00fe42d
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 114 deletions.
2 changes: 2 additions & 0 deletions gradle/gradle-daemon-jvm.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#This file is generated by updateDaemonJvm
toolchainVersion=21
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
154 changes: 85 additions & 69 deletions src/main/kotlin/org/trackedout/AgroNet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ object AgroNet : ModInitializer {
// Proceed with mild caution.

serverName = getEnvOrDefault("SERVER_NAME", InetAddress.getLocalHost().hostName)
if (serverName.contains("dungeon-")) {
// dungeon-1 -> d801
// dungeon-14 -> d814
val dungeonId = serverName.replace("dungeon-", "")
serverName = "d8${dungeonId.padStart(2, '0')}"
}

val dungaAPIPath = getEnvOrDefault("DUNGA_API", "http://localhost:3000/v1")

logger.info("Agronet server name: $serverName (run ID: ${runContext.runId})")
Expand Down Expand Up @@ -106,84 +113,90 @@ object AgroNet : ModInitializer {
val removeDeckFromPlayerInventoryAction = RemoveDeckFromPlayerInventoryAction()

CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
dispatcher.register(literal("take-shulker")
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.executes { context ->
val player = context.source.player
if (player != null) {
removeDeckFromPlayerInventoryAction.execute(player)
} else {
logger.warn("Attempting to take shulker but command is not run as a player, ignoring...")
dispatcher.register(
literal("take-shulker")
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.executes { context ->
val player = context.source.player
if (player != null) {
removeDeckFromPlayerInventoryAction.execute(player)
} else {
logger.warn("Attempting to take shulker but command is not run as a player, ignoring...")
}

1
}

1
}
)
}

CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
dispatcher.register(literal("gief-shulker")
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.executes { context ->
val player = context.source.player
if (player != null) {
addDeckToPlayerInventoryAction.execute(context.source, player)
} else {
logger.warn("Attempting to give shulker but command is not run as a player, ignoring...")
}

1
})
dispatcher.register(
literal("gief-shulker")
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.executes { context ->
val player = context.source.player
if (player != null) {
addDeckToPlayerInventoryAction.execute(context.source, player)
} else {
logger.warn("Attempting to give shulker but command is not run as a player, ignoring...")
}

1
})
}

val logEventCommand = LogEventCommand(eventsApi)

CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
dispatcher.register(literal("log-event")
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.then(
argument("event", StringArgumentType.word()) // words_with_underscores
.executes(logEventCommand::run)
.then(
argument(
"count", // Number of units for this event
IntegerArgumentType.integer(1)
dispatcher.register(
literal("log-event")
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.then(
argument("event", StringArgumentType.word()) // words_with_underscores
.executes(logEventCommand::run)
.then(
argument(
"count", // Number of units for this event
IntegerArgumentType.integer(1)
)
.executes(logEventCommand::run)
)
.executes(logEventCommand::run)
)
)
)
)
}

val cardInteractionCommand = CardInteractionCommand(inventoryApi, eventsApi, serverName)

listOf("card-bought", "card-played", "card-available").forEach { action ->
CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
dispatcher.register(literal(action)
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.then(
argument("card", StringArgumentType.word()) // words_with_underscores
.executes { context ->
cardInteractionCommand.run(context, action)
}
)
dispatcher.register(
literal(action)
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.then(
argument("card", StringArgumentType.word()) // words_with_underscores
.executes { context ->
cardInteractionCommand.run(context, action)
}
)
)
}
}

val itemInteractionCommand = CardInteractionCommand(inventoryApi, eventsApi, serverName)
listOf("add-item").forEach { action ->
CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
dispatcher.register(literal(action)
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.then(
argument("card", StringArgumentType.word())
.then(argument("count", IntegerArgumentType.integer(1))
.executes { context ->
itemInteractionCommand.run(context, action)
}
)
)
dispatcher.register(
literal(action)
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.then(
argument("card", StringArgumentType.word())
.then(
argument("count", IntegerArgumentType.integer(1))
.executes { context ->
itemInteractionCommand.run(context, action)
}
)
)
)
}
}
Expand All @@ -199,28 +212,31 @@ object AgroNet : ModInitializer {
// }

CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
dispatcher.register(literal("update-workers")
.requires(Permissions.require("trackedout.serveradmin.update-workers", 4))
.executes { context ->
sendRedisMessage(context.source, "server-hosts", "update-workers")
1
})
dispatcher.register(
literal("update-workers")
.requires(Permissions.require("trackedout.serveradmin.update-workers", 4))
.executes { context ->
sendRedisMessage(context.source, "server-hosts", "update-workers")
1
})
}

CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
dispatcher.register(literal("update-datapack")
.requires(Permissions.require("trackedout.update-datapack", 2))
.executes { context ->
sendRedisMessage(context.source, "datapack-updates", "request-update")
1
})
dispatcher.register(
literal("update-datapack")
.requires(Permissions.require("trackedout.update-datapack", 2))
.executes { context ->
sendRedisMessage(context.source, "datapack-updates", "request-update")
1
})
}

if (!serverName.equals("builders", ignoreCase = true)) {
CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
dispatcher.register(literal("is-dungeon-instance")
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.executes { _ -> 1 })
dispatcher.register(
literal("is-dungeon-instance")
.requires { it.hasPermissionLevel(2) } // Command Blocks have permission level of 2
.executes { _ -> 1 })
}
}

Expand All @@ -237,7 +253,7 @@ object AgroNet : ModInitializer {
}

if (!serverName.equals("builders", ignoreCase = true)) {
val scoreListener = AgroNetPlayerConnectionListener(scoreApi, claimApi, runContext, addDeckToPlayerInventoryAction)
val scoreListener = AgroNetPlayerConnectionListener(scoreApi, claimApi, addDeckToPlayerInventoryAction)
ServerPlayConnectionEvents.JOIN.register(scoreListener)
ServerPlayConnectionEvents.DISCONNECT.register(scoreListener)
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(scoreListener)
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/org/trackedout/client/apis/EventsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import java.io.IOException
import okhttp3.OkHttpClient
import okhttp3.HttpUrl

import org.trackedout.client.models.Error
import org.trackedout.client.models.Event
import org.trackedout.client.models.EventsGet200Response

Expand Down
47 changes: 24 additions & 23 deletions src/main/kotlin/org/trackedout/client/apis/InventoryApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import okhttp3.HttpUrl
import org.trackedout.client.models.Card
import org.trackedout.client.models.Error
import org.trackedout.client.models.InventoryCardsGet200Response
import org.trackedout.client.models.Item
import org.trackedout.client.models.StorageItemsGet200Response

import com.squareup.moshi.Json
Expand Down Expand Up @@ -401,8 +402,8 @@ class InventoryApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClie
/**
* Add an item to a player's deck
* Add an item to a player's deck from one of the Decked Out 2 instances or the lobby server.
* @param body
* @return Card
* @param item
* @return Item
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
Expand All @@ -411,11 +412,11 @@ class InventoryApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClie
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun storageAddItemPost(body: Card) : Card {
val localVarResponse = storageAddItemPostWithHttpInfo(body = body)
fun storageAddItemPost(item: Item) : Item {
val localVarResponse = storageAddItemPostWithHttpInfo(item = item)

return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as Card
ResponseType.Success -> (localVarResponse as Success<*>).data as Item
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
Expand All @@ -432,29 +433,29 @@ class InventoryApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClie
/**
* Add an item to a player&#39;s deck
* Add an item to a player&#39;s deck from one of the Decked Out 2 instances or the lobby server.
* @param body
* @return ApiResponse<Card?>
* @param item
* @return ApiResponse<Item?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun storageAddItemPostWithHttpInfo(body: Card) : ApiResponse<Card?> {
val localVariableConfig = storageAddItemPostRequestConfig(body = body)
fun storageAddItemPostWithHttpInfo(item: Item) : ApiResponse<Item?> {
val localVariableConfig = storageAddItemPostRequestConfig(item = item)

return request<Card, Card>(
return request<Item, Item>(
localVariableConfig
)
}

/**
* To obtain the request config of the operation storageAddItemPost
*
* @param body
* @param item
* @return RequestConfig
*/
fun storageAddItemPostRequestConfig(body: Card) : RequestConfig<Card> {
val localVariableBody = body
fun storageAddItemPostRequestConfig(item: Item) : RequestConfig<Item> {
val localVariableBody = item
val localVariableQuery: MultiValueMap = mutableMapOf()
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
localVariableHeaders["Content-Type"] = "application/json"
Expand All @@ -473,7 +474,7 @@ class InventoryApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClie
/**
* Delete an item
* Remove an item from a player&#39;s deck. If multiple copies of this item exist, only one will be removed.
* @param body
* @param item
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
Expand All @@ -482,8 +483,8 @@ class InventoryApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClie
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun storageDeleteItemPost(body: Card) : Unit {
val localVarResponse = storageDeleteItemPostWithHttpInfo(body = body)
fun storageDeleteItemPost(item: Item) : Unit {
val localVarResponse = storageDeleteItemPostWithHttpInfo(item = item)

return when (localVarResponse.responseType) {
ResponseType.Success -> Unit
Expand All @@ -503,28 +504,28 @@ class InventoryApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClie
/**
* Delete an item
* Remove an item from a player&#39;s deck. If multiple copies of this item exist, only one will be removed.
* @param body
* @param item
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun storageDeleteItemPostWithHttpInfo(body: Card) : ApiResponse<Unit?> {
val localVariableConfig = storageDeleteItemPostRequestConfig(body = body)
fun storageDeleteItemPostWithHttpInfo(item: Item) : ApiResponse<Unit?> {
val localVariableConfig = storageDeleteItemPostRequestConfig(item = item)

return request<Card, Unit>(
return request<Item, Unit>(
localVariableConfig
)
}

/**
* To obtain the request config of the operation storageDeleteItemPost
*
* @param body
* @param item
* @return RequestConfig
*/
fun storageDeleteItemPostRequestConfig(body: Card) : RequestConfig<Card> {
val localVariableBody = body
fun storageDeleteItemPostRequestConfig(item: Item) : RequestConfig<Item> {
val localVariableBody = item
val localVariableQuery: MultiValueMap = mutableMapOf()
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
localVariableHeaders["Content-Type"] = "application/json"
Expand Down
Loading

0 comments on commit 00fe42d

Please sign in to comment.