Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +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).
Dieser Commit ist enthalten in:
Ursprung
5f5a6767e8
Commit
ad7b00b762
@ -256,19 +256,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
}
|
||||
|
||||
public List<String> getPages() {
|
||||
final List<IChatBaseComponent> copy = ImmutableList.copyOf(pages);
|
||||
return new AbstractList<String>() {
|
||||
|
||||
@Override
|
||||
public String get(int index) {
|
||||
return CraftChatMessage.fromComponent(copy.get(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return copy.size();
|
||||
}
|
||||
};
|
||||
return pages.stream().map(CraftChatMessage::fromComponent).collect(ImmutableList.toImmutableList());
|
||||
}
|
||||
|
||||
public void setPages(List<String> pages) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren