mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 09:23:42 +01:00
Use ImmutableList rather than AbstractList for CraftMetaBook
Although the AbstracList implementation does return a list, it is a of a form that does not play well with libraries using reflection, such as Gson. Leveraging a stream and the ImmutableList collector, this process is greatly simplified (and cleaner).
This commit is contained in:
parent
5f5a6767e8
commit
ad7b00b762
1 changed files with 1 additions and 13 deletions
|
@ -256,19 +256,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getPages() {
|
public List<String> getPages() {
|
||||||
final List<IChatBaseComponent> copy = ImmutableList.copyOf(pages);
|
return pages.stream().map(CraftChatMessage::fromComponent).collect(ImmutableList.toImmutableList());
|
||||||
return new AbstractList<String>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get(int index) {
|
|
||||||
return CraftChatMessage.fromComponent(copy.get(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return copy.size();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPages(List<String> pages) {
|
public void setPages(List<String> pages) {
|
||||||
|
|
Loading…
Reference in a new issue