Koulis2000 / MCScripts

1 stars 0 forks source link

Duplicate code for pausing, unpausing, removing items #15

Closed Bjonnfesk closed 1 year ago

Bjonnfesk commented 1 year ago

Dossier uses its own code for pausing, unpausing and removing items:

https://github.com/Koulis2000/MCScripts/blob/2cab7ac9e6ae84828c9103f0acb3eb29f155f8ba/CCTweaked/janus-dossier.lua#L84-L127

This is duplicate code, as the capability to do that already exists in janus/commands.lua. Dossier should call these existing methods instead.

Koulis2000 commented 1 year ago

The commands.lua file actually uses these functions to pause/unpause/remove items when provided only with a name. Maybe I should move them in that file.

Bjonnfesk commented 1 year ago

Then this issue is even deeper. That means at least some of those functions in commands.lua are loading and saving the requested items file twice per operation.

Koulis2000 commented 1 year ago

I have reworked the whole file. Will push the changes after I do some testing.

Koulis2000 commented 1 year ago

Moved all the related functions to commands.lua and reduced janus.load() and janus.save() calls significantly.