WorldEdit icon indicating copy to clipboard operation
WorldEdit copied to clipboard

SchematicsManager: Handling and caching list of known schematics, providing cli suggestions

Open seijikun opened this issue 3 years ago • 3 comments

I implemented a SchematicsManager that handles the listing / caching of known schematic files. The SchematicsManager has multiple possible backends. The preferred backend is:

FileWatcherSchematicsBackend: This backend uses Java's WatchService to listen for changes in the schematics directory. This rids us of any file listing IO.

PollingSchematicsBackend: This is the fallback backend for the previous mentioned that is only used when the previous failed to initialize (for whatever reason that might be). It caches the result and returns the previous result as long as it's not older than 10 seconds. This is basically an Eventually Consistent Cache.

I then went on to implement a SchematicConverter to parse Schematics from arguments and provide suggestions.

This fixes #2095

seijikun avatar Nov 08 '22 00:11 seijikun

This change in action: (The suggestions for //schematics load ... and //schematics delete ...)

https://user-images.githubusercontent.com/820845/200692406-920a1447-10e2-4685-9d22-23ccc53685d6.mp4

seijikun avatar Nov 08 '22 22:11 seijikun

I noticed that the implementation doesn't handle symlinks correctly. With the setting files.allow-symbolic-links the symlinks will be followed.

Another issue with symlinks: Using recursive symlinks doesn't work fine:

  1. Create a folder in schematics (e.g. mkdir dummy)
  2. Create a symlink that points to one directory upwards (e.g. cd dummy && ln -fs ../ test) With this setup WorldEdit will follow the schematic path:
[12:45:30 INFO]: New Schematic found: /home/user/dev/server/paper/plugins/WorldEdit/schematics/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test/dummy/test

Joo200 avatar Jan 01 '23 11:01 Joo200

Has this unfortunately been abandoned now? It seemed like a really good idea.

UntouchedOdin0 avatar Jan 08 '24 15:01 UntouchedOdin0

Closing in favour of https://github.com/EngineHub/WorldEdit/pull/2542

me4502 avatar Jun 01 '24 04:06 me4502