From e42701f376cb18372ac837f4fb02bec1cae9e63a Mon Sep 17 00:00:00 2001 From: 17jiong <17jiong@gmail.com> Date: Mon, 29 Jan 2018 00:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8C=B9=E9=85=8D=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E7=89=A9=E5=93=81=E6=98=AF=E5=90=A6=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=201.=20=E5=A2=9E=E5=8A=A0=E5=88=A4?= =?UTF-8?q?=E6=96=ADLore=E4=BF=A1=E6=81=AF=E6=98=AF=E5=90=A6=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=202.=20=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E5=A4=B4?= =?UTF-8?q?=E9=A2=85=E7=9A=84Owner=E6=98=AF=E5=90=A6=E7=9B=B8=E5=90=8C=203?= =?UTF-8?q?.=20=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E6=88=90=E4=B9=A6?= =?UTF-8?q?=E7=9A=84=E6=A0=87=E9=A2=98=E3=80=81=E5=86=85=E5=AE=B9=E3=80=81?= =?UTF-8?q?=E4=BD=9C=E8=80=85=E6=98=AF=E5=90=A6=E7=9B=B8=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/maxgamer/QuickShop/Util/Util.java | 70 ++++++++++++++++++- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/maxgamer/QuickShop/Util/Util.java b/src/main/java/org/maxgamer/QuickShop/Util/Util.java index 524f261..6e0a118 100644 --- a/src/main/java/org/maxgamer/QuickShop/Util/Util.java +++ b/src/main/java/org/maxgamer/QuickShop/Util/Util.java @@ -392,9 +392,7 @@ public class Util { } // Calculate the chunks coordinates. These are 1,2,3 for each chunk, NOT // location rounded to the nearest 16. - final int x = (int) Math.floor((loc.getBlockX()) / 16.0); - final int z = (int) Math.floor((loc.getBlockZ()) / 16.0); - if (loc.getWorld().isChunkLoaded(x, z)) { + if (loc.getWorld().isChunkLoaded(loc.getBlockX() >> 4, loc.getBlockZ() >> 4)) { // System.out.println("Chunk is loaded " + x + ", " + z); return true; } @@ -476,6 +474,72 @@ public class Util { return false; // one of the item stacks have a display name } } + if (stack1.getItemMeta().hasLore() || stack2.getItemMeta().hasLore()) { + if (stack1.getItemMeta().hasLore() && stack2.getItemMeta().hasLore()) { + if (!stack1.getItemMeta().getLore().equals(stack2.getItemMeta().getLore())) { + return false; // items have different lore + } + } else { + return false; // one of the item stacks have lore + } + } + // Not the same material and not same durability has returned to false + if (stack1.getType() == Material.SKULL_ITEM) { + if (stack1.getDurability() == 3) { + SkullMeta skullMeta1 = (SkullMeta) stack1.getItemMeta(); + SkullMeta skullMeta2 = (SkullMeta) stack2.getItemMeta(); + if (skullMeta1.hasOwner() || skullMeta2.hasOwner()) { + if (skullMeta1.hasOwner() && skullMeta2.hasOwner()) { + if (!skullMeta1.getOwner().equals(skullMeta1.getOwner())) { + return false; + } + } else { + return false; + } + } + } + + } + if (stack1.getType() == Material.WRITTEN_BOOK) { + if (stack1.hasItemMeta() || stack2.hasItemMeta()) { + if (stack1.hasItemMeta() && stack2.hasItemMeta()) { + BookMeta bookMeta1 = (BookMeta) stack1.getItemMeta(); + BookMeta bookMeta2 = (BookMeta) stack2.getItemMeta(); + // title + if (bookMeta1.hasTitle() || bookMeta2.hasTitle()) { + if (bookMeta1.hasTitle() && bookMeta2.hasTitle()) { + if (!bookMeta1.getTitle().equals(bookMeta2.getTitle())) { + return false; + } + } else { + return false; + } + } + // author + if (bookMeta1.hasAuthor() || bookMeta2.hasAuthor()) { + if (bookMeta1.hasAuthor() && bookMeta2.hasAuthor()) { + if (!bookMeta1.getAuthor().equals(bookMeta2.getAuthor())) { + return false; + } + } else { + return false; + } + } + // content + if (bookMeta1.hasPages() || bookMeta2.hasPages()) { + if (bookMeta1.hasPages() && bookMeta2.hasPages()) { + if (!bookMeta1.getPages().equals(bookMeta2.getPages())) { + return false; + } + } else { + return false; + } + } + } else { + return false; + } + } + } try { Class.forName("org.bukkit.inventory.meta.EnchantmentStorageMeta"); final boolean book1 = stack1.getItemMeta() instanceof EnchantmentStorageMeta;