Skip to content

Commit

Permalink
Release 1.4.2 for 1.9.x
Browse files Browse the repository at this point in the history
Fixed the BrewEvent firing and double distilling sometimes in 1.9
  • Loading branch information
Sn0wStorm committed May 18, 2016
1 parent bf57320 commit 41660c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.dre</groupId>
<artifactId>brewery</artifactId>
<version>1.4.1</version>
<version>1.4.2</version>
<name>Brewery</name>

<properties>
Expand Down
3 changes: 0 additions & 3 deletions src/com/dre/brewery/P.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 9 additions & 3 deletions src/com/dre/brewery/listeners/InventoryListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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++) {
Expand All @@ -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;
}
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 41660c9

Please sign in to comment.