Resource icon

Addon ClassySK 1.3.0

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

(Warning) Breaking changes:

- Class hints have been completely removed in this update because they were not an elegant solution and were made much less useful by the type changes in this update. As well as increasing parsing complexity a lot for a feature designed for a fairly niche scenario.
- The user pattern for non-typed instances was changed to instance. This was necessary to fix a bug with typed expressions not converting. Additionally concrete types are no longer required to be in proper case (although this is still good practice). Keep in mind it may not immediately error since class instance now matches as instance of type 'class'.


Improvements​

- Concrete types rework. TypedInstanceWrapper is no longer a thing. Instances now exist as a direct subclass of ClassInstance.
- This will improve performance for typed function arguments as it no longer needs to wrap and unwrap through converters. It should generally be on par with non-typed class arguments.
- As a result of this change, the [un]typed %classinstance% expression has been removed as it no longer serves a purpose.
- An instance's type can now be inferred from the input expressions return type allowing for more accurate parsing if type hints are enabled or the input naturally reports typed class information. This should also make call chains much more reliable.
- Method arguments can now be marked optional by adding a ? to the end of the argument name. For example in public example(arg1?: int), 'arg1' will be not be set if not specified by the caller.
- Static / non-static methods with the same signature can now co-exist on the same class.
- Static constant fields are now re-evaluated each time the script reloads.

Changes/Bugfixes​

- Default value parsing for methods and fields is now delayed until the pre-load stage. This should allow you to reliably reference other classes/functions as default values.
- Significantly cleaned up field & serialization code. Fields no longer have their own signature data, instead it always refers to the class structure. If that field no longer exists on the class it isn't accessible on instances through normal means.
- Optimized method call caching. If a method was already figured out at parse-time it is not re-validated at runtime. Runtime re-validation now only occurs when the class of the given instance is different from the last cached method.
- Changed the new instance section logic to support proper section claiming which allows method chaining on newly created instances, useful for builder-like classes. This also applies to any section-expression parsing throughout the addon.
C#:
set {_item} to new ItemBuilder::build():
    item: diamond
    name: "test"
This release fixes a few bugs that were found while developing a larger update.

Changes included in this release
- Fields are no longer serialized with their type since it lead to an exception being thrown for number fields when attempting to save.
- Fixed an exception which would occur when using type hints due to field/method access expressions returning multiple of the same possible return type.
- Field/method call results are now converted before they are returned to assure runtime type safety.
- Conversion for serialized fields now happens for each element in the field (if it is a list) instead of shortcutting and converting the entire array to one type, which could cause data loss.
Constant fields

This update adds constant fields, along with some bug fixes from the last update.


C#:
public const myField: integer
public static const myField: integer = 5

Constant fields can only be set as default values, or in the new instance section. Meaning they can't be changed after creation.

Changes included in this release
- added const keyword for fields
- the variable toString for class instances no longer uses it's field contents for the hash code, meaning {var::%{_myClass}%} should produce consistent results
- registered a comparator for typed and untyped instances so now %typedinstance% is %classinstance% should consistently be true
- the typed wrapper of a specific instance is now only created once so that comparing typed instances works as intended
- reworded access errors to be more helpful and specific
- changed pattern to support new ClassName as a shortened version of new instance of ClassName
- fixed nested sections in the new instance expression to properly get the source expression before checking if it can be a section
This update primarily adds class-specific types to classysk. This was a *big* maybe for the project so I'm excited to have this working.

Old:
Code:
function example(instance: class instance):

New:
Code:
# only instances of the class Example are accepted
function example(instance: Example instance):

Changes included in this update:
- Concrete, class-specific types
- New typed/untyped instance expression
- Types that are set to serialize as a different type are now properly converted when stored in a field.
- Fields are now properly converted on deserialization, before it would only check *if* they could convert before creating the field.
- Safe calls (like ``{_var}<>::field`` which erase parse-time type information) should now function as intended, no longer throwing a null pointer exception.
- Class names can no longer be case sensitive depending on config options, fields and methods are unaffected.

Note:
- While testing for 1.21.11 on java 25+ i ran into a warning from paper's remapper. This is a minor compatibility issue from paper trying to remap internal helper classes generated by bytebuddy. It shouldn't cause issues with the plugin's functionality. To get rid of the warning, switch to java 21 or update your server.
- fixed an issue where classes would be registered before methods/field were validated meaning if it failed you would get 'A class named '%s' already exists' error. whoops
Changes:

- Fixed index out of bounds exception when performing an add/remove from a single field containing no value
- Changed the method call pattern to support call chaining
- Method arguments are no longer internally formatted as lowercase, which could potentially cause issues
1.0.0 Full Release

Changes since the last pre-release

- New instance now supports nested sections. For example:
Code:
set {_instance} to new instance of Example:
  myField: new instance of Example:
      otherField: 1
      
  otherField: 2

- Methods now support keyed expressions for list arguments
- Runtime integrity check for field/method calls: prints runtime errors if the signature at runtime isn't assignable to the type reported at parse time
- Class de-registration now happens cleanly every time the structure is unloaded, no longer needing a separate clean-up listener and reducing the chance of stale classes being left in server memory. Static fields and tracked instances are now stored independently.
- Class Wrapper has been changed to Class Reference since it no longer actually wraps an instance, this has been reflected in patterns. The class reference object is planned to be used in future updates as an entry point to reflection.
- Minor method optimizations

Features included in this version


- Fields and Methods (can be static or non-static)
- Public/Private access modifiers
- Serialization for instances (can be saved after restarts)
- Parse time instance type guessing (with optional [class hints](https://github.com/novystar/ClassySK/wiki/Class-Hints))
- Ability to get the class of an instance and check what type it is
- A new instance section where you can specify initial values for fields
Potentially Breaking Changes
Class Options have been outright removed. I decided to remove them while the addon is still in pre-release since they were sort of a bandaid solution for things that should really be fleshed out features. I have plans to incorporate the same functionality in better ways (like additional keywords.. etc)

Other Changes:
  • Added -> to the method return pattern so now you can do public myMethod() -> boolean
  • Instead of if {_instance} is an instance of MyClass you can now also do if {_instance} belongs to MyClass
  • Fixed a bug with the cleanup manager where it would throw an exception if the script of a class was deleted or renamed without reloading the script.
  • Now checks the case sensitive config option rather than case-insensitive variables for if classes/methods/fields should be case sensitive.
  • Internal rework of the class structure, better entry validation and actually fails to parse if there was an error. Additionally, SecMethod and EffField are no longer registered globally. In theory this should ensure conflicts dont happen and slightly reduce parse times.