Skip to content

Conversation

@TheLimeGlass
Copy link
Contributor

@TheLimeGlass TheLimeGlass commented Nov 28, 2025

Description

Adds short hand methods for singleton Fields objects, aswell as removing the forced Serializer deserialize method when instantiated == false, when canBeInstantiated is majority of the time returned false, and even if it's true, Yggdrasil will take over on primitives (See number serializers). This removes the need for defining the public void deserialize(Example object, Fields fields) { method.

Before:

public Fields serialize(Example example) {
	Fields fields = new Fields();
	fields.putObject("name", example.getName());
	return fields;
}

After:

public Fields serialize(Example example) {
	return Fields.singletonObject("name", example.getName());
}

Also cleaned up the formatting of BukkitClasses to be like the top 80% of the class.

There is also a new mapper method for collecting singleton objects from Fields

Before:

@Override
protected Example deserialize(Fields fields) throws StreamCorruptedException {
	UUID uuid = fields.getObject("uuid", UUID.class);
	assert uuid != null;
	return ExampleManager.getExample(uuid);
}

After:

@Override
protected Example deserialize(Fields fields) {
	return fields.mapObject("uuid", UUID.class, ExampleManager::getExample);
}

Testing Completed

Skript tests

Other

StreamCorruptedException should be removed in the future with something like an Optional, or having the logger pickup Skript.error. As the main usage is for error reporting. Having try catches on every serialized element is wasteful resources. This will also allow for out of scope erroring, since Functions can't throw to the origin call stack.


Completes: none
Related: none

@TheLimeGlass TheLimeGlass requested review from a team as code owners November 28, 2025 00:56
@TheLimeGlass TheLimeGlass requested review from TheMug06 and sovdeeth and removed request for a team November 28, 2025 00:56
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Nov 28, 2025
Copy link
Member

@sovdeeth sovdeeth 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 to me

@sovdeeth sovdeeth added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request, an issue about something that could be improved, or a PR improving something. needs reviews A PR that needs additional reviews

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants