Skip to content

Abstract data actions - #124

Open
davight wants to merge 11 commits into
DenizenScript:masterfrom
davight:abstract_data_actions
Open

Abstract data actions#124
davight wants to merge 11 commits into
DenizenScript:masterfrom
davight:abstract_data_actions

Conversation

@davight

@davight davight commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

This Pull-Request adds support for ObjectTag to define its own data actions.
(Keeping this as draft for now to hear your opinions on the design and everything)

Related discussion thread: https://discord.com/channels/315163488085475337/1468638851802075270

Additions:

  • New interface Actionable<T extends ObjectTag> that provides 4 methods xOperation(ObjectTag value, TagContext context), where x is substraction, multiplication, division, addition. With default implementation of throwing exception that the given object does not support given operation.
  • DurationTag support for addition and subtraction operation. (DurationTag:+:DurationTag, DurationTag:-:DurationTag)
  • TimeTag support for addition and subtraction operation. (TimeTag:+:DurationTag, TimeTag:-:DurationTag)
  • VectorTag support for addition, subtraction, multiplication and division (VectorTag:+:VectorTag, VectorTag:-:VectorTag, VectorTag:*:ElementTag, VectorTag:/:ElementTag)
  • Support for accessing first value of ListTag (in DataActionHelper) using first just like we have for last using last

Changes:

  • Moved ElementTag support for addition, subtraction, multiplication and division to the ElementTag.class (for the new Actionable system)
  • Cleaned up the DataAction.class
  • Minor cleanup of DataActionHelper.class

@davight
davight marked this pull request as ready for review May 30, 2026 11:49
@mcmonkey4eva

Copy link
Copy Markdown
Member

Please run before/after tests on common cases and edge cases for basic numeric element handling. How is invalid data (eg add/mul/div/whatever on a flag but the flag's value is not a number) handled? How is initial value handled (- flag server myval:+:1 when the flag doesn't exist yet)? etc.
All these tests should be the same before & after, unless there's an intentional deviation. Also test to make sure that the handling of the different odd cases is consistent between data types and makes sense (what happens if you have a nonexistent flag and - flag server myval:+:5s?)

if (index != 0) {
if (index == Integer.MAX_VALUE && !list.isEmpty()) {
list.remove(list.size() - 1);
list.removeLast();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is a jdk version break

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.

2 participants