Skip to content

Twine API#39

Merged
zNotChill merged 24 commits intomainfrom
twine-api
Apr 21, 2025
Merged

Twine API#39
zNotChill merged 24 commits intomainfrom
twine-api

Conversation

@zNotChill
Copy link
Contributor

This PR rewrites the existing codebase to use the Twine API excluding the Events.kt file since that is not my responsibility anymore.

  • Rewritten command handler (@zNotChill)
  • Rewritten HTTP client (@zNotChill)
  • Added JSON -> TwineTable conversion (@zNotChill) (supports arrays, objects, and primitives)
  • Fixed Location global using incorrect return types (@zNotChill)
  • General code cleanup (@zNotChill)
  • Fixed RocketTable using incorrect conversion (now on Twine repo, was originally here) (@zNotChill)
  • Added custom command namespaces (@cerqiest)
  • Added the offline player representation (@cerqiest)
  • Added autoloading scripts (@cerqiest)
  • Added the server global (@cerqiest)

Not sure if this should be merged yet, but its very close

zNotChill and others added 22 commits April 13, 2025 05:54
gibbie please add maps or nested data classes this is awful
Finally removed PlayerManager.kt
Fixed Location.kt using incorrect return types

Signed-off-by: zNotChill <znotchill@znci.dev>
Signed-off-by: zNotChill <znotchill@znci.dev>
feat: server global and implementation
Signed-off-by: zNotChill <znotchill@znci.dev>
Signed-off-by: zNotChill <znotchill@znci.dev>
@zNotChill zNotChill marked this pull request as ready for review April 20, 2025 16:17
@gibbiemonster gibbiemonster requested review from cerqiest, Copilot and gibbiemonster and removed request for gibbiemonster April 20, 2025 16:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR rewrites the codebase to use the Twine API instead of the Rocket API while also cleaning up various sections and improving global and command registration.

  • Replaces Rocket API errors, functions, and tables with their Twine equivalents.
  • Updates command logic including handling aliases, HTTP client requests, and global initialization.
  • Removes deprecated Rocket files and annotations.

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt Updated to use Twine API conventions and adjusted player property access.
src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Location.kt Tweaks to properties and conversion functions with Twine API annotation changes.
src/main/kotlin/dev/znci/rocket/scripting/globals/tables/HTTPClient.kt Refactored GET/POST logic with additional timeout handling using TwineError.
src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Commands.kt Revised command registration and callback handling alongside Twine API changes.
Other files Removal of Rocket-specific API files and adjustments in global initialization, script management, and error handling.
Comments suppressed due to low confidence (1)

src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Commands.kt:134

  • Kotlin arrays are zero-indexed; using aliasList[i] when iterating from 1 to aliasList.size will throw an IndexOutOfBoundsException. Replace aliasList[i] with aliasList[i - 1].
for (i in 1..aliasList.size) { commandReference.aliases = commandReference.aliases.plus(aliasList[i]) }

@github-actions
Copy link

github-actions bot commented Apr 20, 2025

Qodana Community for JVM

50 new problems were found

Inspection name Severity Problems
Unused symbol 🔶 Warning 22
Unused import directive 🔶 Warning 10
Redundant call of conversion method 🔶 Warning 2
Unresolved reference in KDoc 🔶 Warning 1
Usage of redundant or deprecated syntax or deprecated symbols 🔶 Warning 1
Redundant nullable return type 🔶 Warning 1
Class member can have 'private' visibility ◽️ Notice 5
If-Null return/break/... foldable to '?:' ◽️ Notice 2
Redundant lambda arrow ◽️ Notice 2
Condition of 'if' expression is constant ◽️ Notice 1
Variable declaration could be moved inside 'when' ◽️ Notice 1
Redundant empty primary constructor ◽️ Notice 1
Accessor call that can be replaced with property access syntax ◽️ Notice 1

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

Copy link
Collaborator

@cerqiest cerqiest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good mostly. See comments.

@cerqiest
Copy link
Collaborator

Can we also look in to resolving the qodana issues?

Signed-off-by: zNotChill <znotchill@znci.dev>
Signed-off-by: zNotChill <znotchill@znci.dev>
Copy link
Collaborator

@cerqiest cerqiest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zNotChill zNotChill merged commit e97fa42 into main Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants