diff options
author | Roy Curtis <roy.adrian.curtis+github@gmail.com> | 2016-06-14 22:40:46 +0100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-06-16 10:50:15 +1000 |
commit | 9856d8a18395617ffa0ecc05dcbf9255e6a66d12 (patch) | |
tree | c81d023e796dcc98336cb3e3cfee0758cdc908ff | |
parent | 02f4218da5186d0f7e627fa958e311dd0d7e8c42 (diff) | |
download | craftbukkit-9856d8a18395617ffa0ecc05dcbf9255e6a66d12.tar craftbukkit-9856d8a18395617ffa0ecc05dcbf9255e6a66d12.tar.gz craftbukkit-9856d8a18395617ffa0ecc05dcbf9255e6a66d12.tar.lz craftbukkit-9856d8a18395617ffa0ecc05dcbf9255e6a66d12.tar.xz craftbukkit-9856d8a18395617ffa0ecc05dcbf9255e6a66d12.zip |
Improvements to BookMeta API
* Added hasGeneration()
* Fixed `applyHash()` (used by `CraftMetaItem.hashCode()`) not taking generation into account
* Fixed `equalsCommon()` (used by `CraftMetaItem.equals()`) not taking generation into account
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java index d517d7d5..2ed6ad72 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java @@ -175,6 +175,10 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { return !pages.isEmpty(); } + public boolean hasGeneration() { + return generation != null; + } + public String getTitle() { return this.title; } @@ -292,6 +296,9 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { if (hasPages()) { hash = 61 * hash + 17 * this.pages.hashCode(); } + if (hasGeneration()) { + hash = 61 * hash + 19 * this.generation.hashCode(); + } return original != hash ? CraftMetaBook.class.hashCode() ^ hash : hash; } @@ -305,7 +312,8 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { return (hasTitle() ? that.hasTitle() && this.title.equals(that.title) : !that.hasTitle()) && (hasAuthor() ? that.hasAuthor() && this.author.equals(that.author) : !that.hasAuthor()) - && (hasPages() ? that.hasPages() && this.pages.equals(that.pages) : !that.hasPages()); + && (hasPages() ? that.hasPages() && this.pages.equals(that.pages) : !that.hasPages()) + && (hasGeneration() ? that.hasGeneration() && this.generation.equals(that.generation) : !that.hasGeneration()); } return true; } |