diff options
author | Javacraft <frelling@java-craft.com> | 2018-12-05 19:44:07 -0500 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-12-07 12:59:08 +1100 |
commit | ad7b00b762bb0847049cde1abb0fc2d09ba48b1e (patch) | |
tree | 6a627c5d0cfa159afe706dbb4a69cffe8654765a /src | |
parent | 5f5a6767e8f51bfa5b1c15b0db597cd4a12bf3f2 (diff) | |
download | craftbukkit-ad7b00b762bb0847049cde1abb0fc2d09ba48b1e.tar craftbukkit-ad7b00b762bb0847049cde1abb0fc2d09ba48b1e.tar.gz craftbukkit-ad7b00b762bb0847049cde1abb0fc2d09ba48b1e.tar.lz craftbukkit-ad7b00b762bb0847049cde1abb0fc2d09ba48b1e.tar.xz craftbukkit-ad7b00b762bb0847049cde1abb0fc2d09ba48b1e.zip |
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).
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java index c8654c68..0831e13e 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java @@ -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) { |