Release 1.4.2 for 1.9.x

Fixed the BrewEvent firing and double distilling sometimes in 1.9
This commit is contained in:
Sn0wStorm
2016-05-19 01:05:48 +02:00
parent bf57320057
commit 41660c9b4f
3 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<groupId>com.dre</groupId> <groupId>com.dre</groupId>
<artifactId>brewery</artifactId> <artifactId>brewery</artifactId>
<version>1.4.1</version> <version>1.4.2</version>
<name>Brewery</name> <name>Brewery</name>
<properties> <properties>
-3
View File
@@ -69,9 +69,6 @@ public class P extends JavaPlugin {
String v = Bukkit.getBukkitVersion(); String v = Bukkit.getBukkitVersion();
useUUID = !v.matches(".*1\\.[0-6].*") && !v.matches(".*1\\.7\\.[0-5].*"); useUUID = !v.matches(".*1\\.[0-6].*") && !v.matches(".*1\\.7\\.[0-5].*");
use1_9 = !v.matches(".*1\\.[0-8].*"); use1_9 = !v.matches(".*1\\.[0-8].*");
if (use1_9) {
log("&eExperimental support for Bukkit 1.9 enabled.");
}
// load the Config // load the Config
try { try {
@@ -115,7 +115,7 @@ public class InventoryListener implements Listener {
if (now instanceof BrewingStand) { if (now instanceof BrewingStand) {
BrewingStand stand = (BrewingStand) now; BrewingStand stand = (BrewingStand) now;
if (brewTime == DISTILLTIME) { // only check at the beginning (and end) for distillables if (brewTime == DISTILLTIME) { // only check at the beginning (and end) for distillables
if (!isCustomAndDistill(stand.getInventory())) { if (!isCustom(stand.getInventory(), true)) {
this.cancel(); this.cancel();
trackedBrewers.remove(brewery); trackedBrewers.remove(brewery);
P.p.debugLog("nothing to distill"); P.p.debugLog("nothing to distill");
@@ -150,7 +150,7 @@ public class InventoryListener implements Listener {
}.runTaskTimer(P.p, 2L, 1L).getTaskId()); }.runTaskTimer(P.p, 2L, 1L).getTaskId());
} }
private boolean isCustomAndDistill(BrewerInventory brewer) { private boolean isCustom(BrewerInventory brewer, boolean distill) {
ItemStack item = brewer.getItem(3); // ingredient ItemStack item = brewer.getItem(3); // ingredient
if (item == null || Material.GLOWSTONE_DUST != item.getType()) return false; // need dust in the top slot. if (item == null || Material.GLOWSTONE_DUST != item.getType()) return false; // need dust in the top slot.
for (int slot = 0; slot < 3; slot++) { for (int slot = 0; slot < 3; slot++) {
@@ -160,7 +160,7 @@ public class InventoryListener implements Listener {
if (item.hasItemMeta()) { if (item.hasItemMeta()) {
int uid = Brew.getUID(item); int uid = Brew.getUID(item);
Brew pot = Brew.potions.get(uid); 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; return true;
} }
} }
@@ -172,6 +172,12 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBrew(BrewEvent event) { public void onBrew(BrewEvent event) {
if (P.use1_9) {
if (isCustom(event.getContents(), false)) {
event.setCancelled(true);
}
return;
}
if (runDistill(event.getContents())) { if (runDistill(event.getContents())) {
event.setCancelled(true); event.setCancelled(true);
} }