Skip to content

Commit

Permalink
feat: introduce force load
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 committed Jan 20, 2024
1 parent 181c79a commit a41221b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ public static Optional<TranslationConfiguration> fromFileConfiguration(String la
if (itemsSection != null) {
for (var itemId : itemsSection.getKeys(false)) {
SlimefunTranslation.debug("Loading item translation {0}", itemId);

var itemSection = itemsSection.getConfigurationSection(itemId);
boolean forceLoad = itemSection.getBoolean("force", false);

// sfItem
SlimefunItem sfItem = SlimefunItem.getById(itemId);
if (sfItem == null) {
if (sfItem == null && !forceLoad) {
SlimefunTranslation.log(Level.SEVERE, "Invalid item {0}", itemId);
continue;
}

var itemSection = itemsSection.getConfigurationSection(itemId);
// name
String displayName = "";
if (itemSection.contains("name")) {
Expand Down Expand Up @@ -122,7 +125,7 @@ public static Optional<TranslationConfiguration> fromFileConfiguration(String la
}

boolean checkName = itemSection.getBoolean("check-name", false);
boolean partialOverride = SlimefunTranslation.getConfigService().getPartialOverrideMaterials().contains(sfItem.getItem().getType());
boolean partialOverride = forceLoad || SlimefunTranslation.getConfigService().getPartialOverrideMaterials().contains(sfItem.getItem().getType());

var translation = new FixedItemTranslation(displayName, lore, overrides, replacements, checkName, partialOverride);
itemTranslations.put(itemId, translation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name: Slimefun Secret Items
translations:
DEBUG_FISH:
force: true
name: "&3How much is the Fish?"
lore:
- ""
Expand Down

0 comments on commit a41221b

Please sign in to comment.