Skip to content

Commit

Permalink
Fix minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Exceptionflug committed Jun 27, 2024
1 parent 3abe241 commit efc4781
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public interface ComponentConverter<T> {

T fromNbt(Tag<?> tag);

void disableItalic(T component);
T disableItalic(T component);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ public synchronized void registerMapping(Object mappable, ProtocolMapping mappin

@Override
public <T extends ProtocolMapping> T mapping(Object mappable, int protocolVersion) {
return (T) mappingMultimap.get(mappable).parallelStream()
.filter(protocolMapping -> protocolMapping.inRange(protocolVersion))
.findFirst().orElse(null);
for (ProtocolMapping mapping : mappingMultimap.get(mappable)) {
if (mapping.inRange(protocolVersion)) {
return (T) mapping;
}
}
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static <T> ChatElement<T> ofNbt(Tag<?> tag) {

@Override
public ChatElement<T> disableItalic() {
componentConverter.disableItalic(component);
component = componentConverter.disableItalic(component);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ public BaseComponent[] fromNbt(Tag<?> tag) {

@SneakyThrows
@Override
public void disableItalic(BaseComponent[] component) {
public BaseComponent[] disableItalic(BaseComponent[] component) {
for (BaseComponent c : component) {
if (c.isItalicRaw() == null) {
c.setItalic(false);
}
}
return component;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ public Component fromNbt(Tag<?> tag) {
}

@Override
public void disableItalic(Component component) {
public Component disableItalic(Component component) {
if (component.decoration(TextDecoration.ITALIC) == TextDecoration.State.NOT_SET) {
component.decoration(TextDecoration.ITALIC, TextDecoration.State.FALSE);
return component.decoration(TextDecoration.ITALIC, TextDecoration.State.FALSE);
}
return component;
}

}
Expand Down

0 comments on commit efc4781

Please sign in to comment.