ClassySK by novystxr 
Object orientation for skript in the form of classes
Events
0
Expressions
6
Effects
2
Conditions
1
Types
2
Sections
1
Structures
1
Total
13
Object orientation for skript in the form of classes
Events
0
Expressions
6
Effects
2
Conditions
1
Types
2
Sections
1
Structures
1
Total
13
Inheritance pre-release 2
This update took a while to come out with and involved a lot of technical challenges which had to be overcome. The previous major update (1.3.0) addressed a lot of the core internal differences between the two branches, but I feel it's necessary to do this as a pre-release first to iron out bugs and make testing more accessible to those who want to.
Feedback, suggestions and bug reports for the update are welcome! Especially if you have any issues with the language design now is a good time to voice them so we can discuss before it's committed to a full release. If so please make an issue or contact me on discord! (
@novystar
) You can also leave a comment on the current inheritance PR #5 which will remain unmerged until the full release.
Fixes/Changes since last pre-release:
- Fixed the origin of anonymous methods being inaccurate, leading to access-modifiers not behaving as intended
- Fixed
super
not using the context class for the inheritance walk, meaning super calls on anonymous methods would call themselves.
- Methods now support keyed returns
Additions:
- Single class inheritance
- New modifiers:
-
protected
- Restricted to subclasses and field definitions in
new Class
sections
-
override
- In order to override a method you need to use this or you'll get an error.
-
abstract
- Abstract classes can be extended directly in code anonymously, they may also contain abstract methods which have no body and must be implemented by any inheritor.
-
final
- Final classes can't be extended, final methods can't be overridden.
- Super method calls like
super::method()
, for accessing the non-overridden version of a method (from the previous class).
- Anonymous classes: abstract classes can be implemented directly in the
new instance
section (anonymous behaviour is erased on restart)
- A dedicated 'cast' expression for upcasting in strictly typed scenarios (like using type hints):
{_var} as MyClass
Changes/fixes:
- The
instance of
condition now supports
exact instance of
for direct comparisons.
- Removed the
belongs to
pattern for class comparisons
- Method calls now support keyed return values
See the following wiki pages for a more in depth walk through of the new features for this update:
- Inheritance Overview
- Abstract & Anonymous
1.3.2 Patch release
Changes included in this release:
- Fixed dangerous array handling during field serialization which meant an exception would be thrown when serializing numbers.
- The 'instance' part of the class-specific type pattern is no longer case sensitive.
1.3.1 Patch release
Changes included in this release:
- Generated ClassInfos now get partially registered into the
exactClassInfos
map for compatibility reasons.
- A unique language node is now created for every generated classinfo. This means you now get more helpful errors like
The function test(Example instance) does not exist.
.
- Fixed player values in fields becoming stale once they rejoined. Fields now respect the
player variable fix
config option.
- Fixed issue with method arguments getting converted to lowercase before being parsed.
- Reverted change from the previous update of class types no longer being case sensitive. (the previous bug was found to be the real cause)
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.
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:
- 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:
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:
ClassySK is an addon that adds proper object orientation capabilities to skript in the form of classes. Allowing you to write powerful, defensive code and explore OOP concepts within skript!
Roadmap
Nothing here is set in stone but these are my future ambitions regarding the project (in no particular order)
- Inheritance: extending other classes
- Abstract Methods: unimplemented methods that should be implemented by inheritors
- Transient fields: Fields that don't get saved
- Method and Field Reflection
Code Examples