Skip to content

Commit 825b8a9

Browse files
committed
fix(core): disabled line not being applied on legacy parser
1 parent 19ce1ee commit 825b8a9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

core/src/main/java/com/rexcantor64/triton/language/parser/LegacyParser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.rexcantor64.triton.api.language.Localized;
66
import com.rexcantor64.triton.utils.ComponentUtils;
77
import com.rexcantor64.triton.utils.ParserUtils;
8+
import com.rexcantor64.triton.utils.StringUtils;
89
import lombok.AccessLevel;
910
import lombok.Getter;
1011
import lombok.Setter;
@@ -217,6 +218,9 @@ TranslationResult<SerializedComponent> translateComponent(
217218
}
218219
key = ParserUtils.normalizeTranslationKey(key, configuration);
219220
key = stripFormatting(key);
221+
if (!StringUtils.isEmptyOrNull(configuration.getDisabledLine()) && configuration.getDisabledLine().equals(key)) {
222+
return Optional.empty();
223+
}
220224

221225
val result = configuration.translationSupplier.apply(key, arguments);
222226

core/src/test/java/com/rexcantor64/triton/language/parser/LegacyParserTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,13 @@ public void testParseComponentWithPatterns() {
432432
assertNotNull(result.getResultRaw());
433433
assertEquals(expected.compact(), result.getResultRaw().compact());
434434
}
435+
436+
@Test
437+
public void testParseComponentWithDisabledLine() {
438+
Component comp = Component.text("[lang]disabled.line[/lang]");
439+
440+
TranslationResult<SerializedComponent> result = parser.translateComponent(new SerializedComponent(comp), configuration);
441+
442+
assertEquals(TranslationResult.ResultState.TO_REMOVE, result.getState());
443+
}
435444
}

0 commit comments

Comments
 (0)