From 41660c9b4f701a28edd1aa0fb0c1720e99c48463 Mon Sep 17 00:00:00 2001 From: Sn0wStorm Date: Thu, 19 May 2016 01:05:48 +0200 Subject: [PATCH] Release 1.4.2 for 1.9.x Fixed the BrewEvent firing and double distilling sometimes in 1.9 --- pom.xml | 2 +- src/com/dre/brewery/P.java | 3 --- src/com/dre/brewery/listeners/InventoryListener.java | 12 +++++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index dcc310bc..aa5be235 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.dre brewery - 1.4.1 + 1.4.2 Brewery diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index 2fd11c79..bc3c9e37 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -69,9 +69,6 @@ public void onEnable() { String v = Bukkit.getBukkitVersion(); useUUID = !v.matches(".*1\\.[0-6].*") && !v.matches(".*1\\.7\\.[0-5].*"); use1_9 = !v.matches(".*1\\.[0-8].*"); - if (use1_9) { - log("&eExperimental support for Bukkit 1.9 enabled."); - } // load the Config try { diff --git a/src/com/dre/brewery/listeners/InventoryListener.java b/src/com/dre/brewery/listeners/InventoryListener.java index bfb7482e..6092ee04 100644 --- a/src/com/dre/brewery/listeners/InventoryListener.java +++ b/src/com/dre/brewery/listeners/InventoryListener.java @@ -115,7 +115,7 @@ public void run() { if (now instanceof BrewingStand) { BrewingStand stand = (BrewingStand) now; if (brewTime == DISTILLTIME) { // only check at the beginning (and end) for distillables - if (!isCustomAndDistill(stand.getInventory())) { + if (!isCustom(stand.getInventory(), true)) { this.cancel(); trackedBrewers.remove(brewery); P.p.debugLog("nothing to distill"); @@ -150,7 +150,7 @@ public void run() { }.runTaskTimer(P.p, 2L, 1L).getTaskId()); } - private boolean isCustomAndDistill(BrewerInventory brewer) { + private boolean isCustom(BrewerInventory brewer, boolean distill) { ItemStack item = brewer.getItem(3); // ingredient if (item == null || Material.GLOWSTONE_DUST != item.getType()) return false; // need dust in the top slot. for (int slot = 0; slot < 3; slot++) { @@ -160,7 +160,7 @@ private boolean isCustomAndDistill(BrewerInventory brewer) { if (item.hasItemMeta()) { int uid = Brew.getUID(item); Brew pot = Brew.potions.get(uid); - if (pot != null && pot.canDistill()) { // need at least one distillable potion. + if (pot != null && (!distill || pot.canDistill())) { // need at least one distillable potion. return true; } } @@ -172,6 +172,12 @@ private boolean isCustomAndDistill(BrewerInventory brewer) { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBrew(BrewEvent event) { + if (P.use1_9) { + if (isCustom(event.getContents(), false)) { + event.setCancelled(true); + } + return; + } if (runDistill(event.getContents())) { event.setCancelled(true); }