Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unused (de)serialization methodes #147

Open
wants to merge 6 commits into
base: 2.6.0
Choose a base branch
from

Conversation

BoyStijn
Copy link

@BoyStijn BoyStijn commented Nov 26, 2022

Pull Request Etiquette

There are several guidelines you should follow in order for your Pull Request to be merged.
Replace [ ] with [x] to cross the checkbox.

It is sometimes better to include more related changes in a single commit.
If you find yourself having an overwhelming amount of commits, you
can rebase your branch.

Changes

Removed unused (de)serialization methodes

  • removed java.io.Serializable interface from classes
  • removed serialization method from classes (or changed to toString if the method was used)
  • removed deserialization method from classes (or changed to fromString if the method was used)

SparklingComet and others added 3 commits July 6, 2022 13:40
removed java.io.Serializable interface from classes
removed serialization method from classes (or changed to `toString` if the method was used)
removed deserialization method from classes (or changed to `fromString` if the method was used)
@SparklingComet SparklingComet mentioned this pull request Nov 26, 2022
2 tasks
@KillerOfPie
Copy link
Collaborator

Were these changes tested? Removing serializable and not replacing it with something else is a significant change and needs to be reasonably tested to make sure that the data output isn't changing/breaking shops that previously existed.

@BoyStijn
Copy link
Author

Yes i have ran it on a new paper server. The config and Data is both saved and loaded properly. I already mentioned in issue #145 that if you want custom JSON de(serialization) you'll have to implement the com.google.gson.JsonDeserializer<T> and com.google.gson.JsonSerializer<T> interfaces

@KillerOfPie
Copy link
Collaborator

Yes i have ran it on a new paper server. The config and Data is both saved and loaded properly. I already mentioned in issue #145 that if you want custom JSON de(serialization) you'll have to implement the com.google.gson.JsonDeserializer<T> and com.google.gson.JsonSerializer<T> interfaces

Update this with 2.6 since I had to make an adapter for itemstacks.

As long as it works without the serializable extensions then I'm fine with those being removed.

Changing (de)serializable methods feels unnecessary and even if they aren't being used by gson they roll in and out of usage for debugging data output. toString should focus more on a readable format for debugging(with an exception for smaller objects that are easily readable in their serialized form in which case it can redirect to that)

I didn't make any of these changes myself to avoid stealing credit for your work/testing.

@BoyStijn
Copy link
Author

i wont be able to update it today, ill probably have it finished tomorrow. I might consider making proper Serialization classes if that something you're interested in

@KillerOfPie
Copy link
Collaborator

i wont be able to update it today, ill probably have it finished tomorrow. I might consider making proper Serialization classes if that something you're interested in

That's fine, it's not looking like I'll get a release out before the end of the week anyways.

I already added on for Configuration Serializable. I don't think any of our stuff needs it since the normal gson handles it pretty well. If you really want to it's fine as long as the output and input don't change, I just don't see any benefits that would justify the work needed for it.

@BoyStijn
Copy link
Author

Merge Conflicts have been resolved. Tested on 1.19.2. Maybe do another test yourself, but i would say you're ready for release with 1.19 support

Copy link
Collaborator

@KillerOfPie KillerOfPie left a comment

Choose a reason for hiding this comment

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

@SparklingComet Can you look this over too and let me know if you don't agree.

Comment on lines -127 to -137
public static ShopItemStack deserialize(String serialized) {
ShopItemStack item = new GsonProcessor().fromJson(serialized, ShopItemStack.class);
item.loadLegacyData();
item.buildMap();
return item;
}

public String serialize() {
return new GsonProcessor().toJson(this);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Removing Serializable is good if it's not being used, but I see no point in removing the (de)serialize methods since at worst they just waste space. They do occasionally get used when I need to add debug to a section. In most cases when I do that they have to be removed soon after for performance like in the Hopper code(where no debug can stay since it runs so often with each hopper)

Comment on lines -83 to -88
public static PlayerSetting deserialize(String serialized) {
PlayerSetting playerSetting = new GsonProcessor().fromJson(serialized, PlayerSetting.class);
playerSetting.load();
return playerSetting;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

^

Comment on lines -150 to -153
public String serialize() {
return new GsonProcessor().toJson(this);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

^

Comment on lines -59 to -64
public static ShopUser deserialize(String serialized) {
ShopUser shopUser = new GsonProcessor().fromJson(serialized, ShopUser.class);
shopUser.player = Bukkit.getOfflinePlayer(UUID.fromString(shopUser.playerUUID));
return shopUser;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

^

Comment on lines -88 to -91
public String serialize() {
return new GsonProcessor().toJson(this);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

^

Comment on lines -149 to -162
* Deserializes the object to Json using Gson
*
* @param serialized Shop GSON to be deserialized
*
* @return Shop object from file
*/
public static Shop deserialize(String serialized) {
Shop shop = new GsonProcessor().fromJson(serialized, Shop.class);
shop.fixAfterLoad();

return shop;
}

/**
Copy link
Collaborator

Choose a reason for hiding this comment

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

^

Comment on lines -263 to -271
/**
* Serializes the object to Json using Gson
*
* @return serialized string
*/
public String serialize() {
return new GsonProcessor().toJson(this);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

^

Comment on lines -85 to -88
public static ShopType deserialize(String serialized) {
return new GsonProcessor().fromJson(serialized, ShopType.class);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

^

Comment on lines -108 to -111
public String serialize() {
return new GsonProcessor().toJson(this);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

^

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