Repository navigation
Fix bugs found in a code review - #177
Conversation
- Database import wiped all of a game mode's generator tiers before loading the file, so a typo in the file name (or an empty/broken file) deleted every generator. Now the file is loaded first and the old generators are only removed once it loaded; the admin is told in chat when the file is not found. - activateGenerator threw a NullPointerException when overwrite-on-active needed to free a slot held by a generator that has since been deleted. The stale id is now dropped instead. - Database import/export and template import accepted file names like "../x", reaching files outside the addon folder. They are now refused. - Height-range error messages in the generator edit panel never showed: wrong key path, a missing min-height key, and [MIN]/[MAX] placeholders that did not match the [min]/[max] constants. The panel now also reopens after the error. - Paged panels showed an empty extra page when the item count was an exact multiple of 21 (reachable through the wrap-around arrows in the generator edit panel, or by deleting items on the last page). - GitHub library downloads ran the import on an async thread; it now runs on the main thread. - Database command tab completion no longer throws if the addon folder cannot be listed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Minimum/Maximum Height buttons on the main generator edit panel accepted any value, so min could be set above max (e.g. min 150, max 100), which stops the generator working at every height. Reject such values with the same error messages as the per-block height panel. Also fix the en-US tooltip for these buttons: they set the range for the whole generator, not "this material". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Found in manual testing: the generator-wide Minimum/Maximum Height buttons on the main edit panel had no min/max check either, so min 150 / max 100 could be saved, and the generator then works at no height. They now reject such values with the same error messages as the per-block panel. Also fixed their en-US tooltip, which said "for this material" instead of "for this generator". |
Titles built from a name ("Generator: Starting Nether Generator") ran past
the edge of the window, because the client does not cut long titles.
- Generator, bundle and island panels now show just the name as the
title, giving it the full width.
- Names are shortened with an ellipsis when they still do not fit,
measured with the default Minecraft font widths (bold). The Height
Range panel keeps its label and shortens the block name the same way.
- The Spanish and Vietnamese titles used translated placeholders
([generador], [paquete], [isla], [gói]), so the name never appeared.
Rewriting the title values fixes them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Added: admin panel titles no longer run past the edge of the inventory window. Generator/bundle/island panels show just the name, shortened with "…" if it still doesn't fit (measured with the default Minecraft font widths). The Height Range panel keeps its label. This also fixes the Spanish and Vietnamese titles, which used translated placeholders and never showed the name. |
The number formatter used owner.getLocale(), but owner is null on spawn islands and islands without an owner. Format with the purchasing user's locale instead: they are the one who receives the messages. Fixes Sonar java:S2259. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reliability (quality gate): - IslandEditPanel: read the island name before getGeneratorData, whose null check made Sonar treat the island as nullable. - IslandEditPanel: null-safe game mode name in three button descriptions. - canPurchaseGenerator NPE: cherry-picked from #176. Code smells in StoneGeneratorImportManager: constants for repeated literals, rename a local that hid a field, extract export error reporting to cut complexity, make DefaultJSONHandler fields final. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|



Summary
Results of a review of the whole addon. Every fix below was checked against the code, and the behavioural ones have tests that fail on
developand pass here.Data loss
database importwiped all generators before loading the file.importDatabaseFilecalledwipeGameModeGenerators(which deletes the tiers from the database) and only then tried to load the file. A typo in the file name, or an empty or broken file, left the game mode with no generators. The admin wasn't told in chat either, because the error only went to the console. The file is now loaded first, the wipe only happens once it loaded, and the admin gets theno-filemessage.Crashes
activateGeneratorNPE: withoverwrite-on-active, if the island was at its limit and the active generator had since been deleted,getGeneratorByIDreturned null anddeactivateGeneratorthrew. The stale id is now removed to free the slot, matchingautoActivateGenerator.databasetab completion:listFiles()can return null.Security (admin-only)
database import/export <file>and templateimport <file>accepted../, so they could read or write files outside the addon folder. A newresolveDataFilehelper rejects any name that doesn't land directly inside the data folder.GUI
admin.errors.*instead ofstone-generator.errors.*,min-height-greater-than-maxdidn't exist in any locale, and every locale used[MIN]/[MAX]whileConstants.MIN/MAXare[min]/[max]. Fixed the key path, added the en-US key, lower-cased the placeholders in all locales, and the panel now reopens after the error instead of staying closed.CommonPagedPanel,PagedSelectorand the block/treasure pages ofGeneratorEditPanelclamped tosize / 21, which is one past the last page whensizeis a multiple of 21. InGeneratorEditPanelthe wrap-around arrows reach it directly (Previous on page 1, or Next on the last page). In the others it shows up after deleting items while on the last page.Threading
Checked and not changed
ceilingEntry: correct for cumulative upper-bound keys, and it can't return null.GeneratorTierObject.clone()skippingblockHeightRanges:clone()is used by database export, butblockHeightRangesisn't read anywhere (per-block heights usematerialHeightMap, which is cloned), so nothing is lost.Test plan
../is rejected for template import and byresolveDataFile; activating over a deleted active generator doesn't throw and frees the slotdevelopmvn test: 171 passed, 0 failuresNote:
min-height-greater-than-maxis only in en-US; other locales fall back to English until synced.🤖 Generated with Claude Code