Merge pull request #6 from DieReicheErethons/master

Syncing with upstream
This commit is contained in:
Daniel Boston 2016-05-20 11:07:54 -04:00
commit 3504a7451e
10 changed files with 129 additions and 66 deletions

46
pom.xml
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>
@ -33,7 +33,7 @@
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version> <version>3.5.1</version>
<configuration> <configuration>
<source>1.7</source> <source>1.7</source>
<target>1.7</target> <target>1.7</target>
@ -44,6 +44,10 @@
</build> </build>
<repositories> <repositories>
<repository>
<id>md_5-releases</id>
<url>http://repo.md-5.net/content/repositories/releases/</url>
</repository>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
@ -52,25 +56,17 @@
<id>vault-repo</id> <id>vault-repo</id>
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url> <url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
</repository> </repository>
<!--<repository> <repository>
<id>dre2n-repo</id> <id>mcstats-repo</id>
<url>http://feuerstern.bplaced.net/repo/</url> <url>http://repo.mcstats.org/content/repositories/public/</url>
</repository>--> </repository>
<repository> <repository>
<id>sk89q-repo</id> <id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url> <url>http://maven.sk89q.com/repo/</url>
</repository> </repository>
<repository> <repository>
<id>addstar-repo</id> <id>dre2n-rpo</id>
<url>http://maven.addstar.com.au/artifactory/ext-release-local/</url> <url>http://feuerstern.bplaced.net/repo/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>md_5-releases</id>
<url>http://repo.md-5.net/content/repositories/releases/</url>
</repository> </repository>
</repositories> </repositories>
@ -78,7 +74,8 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>1.9-R0.1-SNAPSHOT</version> <version>1.9.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.milkbowl.vault</groupId> <groupId>net.milkbowl.vault</groupId>
@ -90,22 +87,31 @@
<groupId>com.sk89q</groupId> <groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId> <artifactId>worldguard</artifactId>
<version>6.1</version> <version>6.1</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.griefcraft.lwc</groupId> <groupId>com.griefcraft.lwc</groupId>
<artifactId>LWCPlugin</artifactId> <artifactId>LWCPlugin</artifactId>
<version>1.7.2</version> <version>4.5.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.ryanhamshire</groupId> <groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId> <artifactId>GriefPrevention</artifactId>
<version>14.5.1</version> <version>14.5.4</version>
<scope>compile</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>de.diddiz</groupId> <groupId>de.diddiz</groupId>
<artifactId>logblock</artifactId> <artifactId>logblock</artifactId>
<version>1.94</version> <version>1.94</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.diddiz</groupId>
<artifactId>questioner</artifactId>
<version>1.94</version>
<scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -203,7 +203,7 @@ public class BRecipe {
BIngredients bIngredients = new BIngredients(list, cookingTime); BIngredients bIngredients = new BIngredients(list, cookingTime);
Brew brew = new Brew(uid, bIngredients, quality, distillruns, getAge(), wood, getName(5), false, false, true); Brew brew = new Brew(uid, bIngredients, quality, distillruns, getAge(), wood, getName(5), false, false, true, 0);
Brew.PotionColor.valueOf(getColor()).colorBrew(potionMeta, potion, false); Brew.PotionColor.valueOf(getColor()).colorBrew(potionMeta, potion, false);
potionMeta.setDisplayName(P.p.color("&f" + getName(quality))); potionMeta.setDisplayName(P.p.color("&f" + getName(quality)));
@ -212,6 +212,7 @@ public class BRecipe {
brew.convertLore(potionMeta, false); brew.convertLore(potionMeta, false);
Brew.addOrReplaceEffects(potionMeta, effects, quality); Brew.addOrReplaceEffects(potionMeta, effects, quality);
brew.touch();
potion.setItemMeta(potionMeta); potion.setItemMeta(potionMeta);
return potion; return potion;

View File

@ -146,7 +146,7 @@ public class Barrel implements InventoryHolder {
} }
} catch (Throwable e) { } catch (Throwable e) {
P.p.errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!"); P.p.errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!");
P.p.errorLog("Brewery was tested with GriefPrevention 14.5.1"); P.p.errorLog("Brewery was tested with GriefPrevention 14.5.4");
P.p.errorLog("Disable the GriefPrevention support in the config and do /brew reload"); P.p.errorLog("Disable the GriefPrevention support in the config and do /brew reload");
e.printStackTrace(); e.printStackTrace();
P.p.msg(player, "&cError opening Barrel, please report to an Admin!"); P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
@ -168,7 +168,7 @@ public class Barrel implements InventoryHolder {
return LWCBarrel.checkAccess(player, sign, event, plugin); return LWCBarrel.checkAccess(player, sign, event, plugin);
} catch (Throwable e) { } catch (Throwable e) {
P.p.errorLog("Failed to Check LWC for Barrel Open Permissions!"); P.p.errorLog("Failed to Check LWC for Barrel Open Permissions!");
P.p.errorLog("Brewery was tested with version 4.3.1 of LWC!"); P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
P.p.errorLog("Disable the LWC support in the config and do /brew reload"); P.p.errorLog("Disable the LWC support in the config and do /brew reload");
e.printStackTrace(); e.printStackTrace();
P.p.msg(player, "&cError opening Barrel, please report to an Admin!"); P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
@ -193,7 +193,7 @@ public class Barrel implements InventoryHolder {
return LWCBarrel.checkDestroy(player, this); return LWCBarrel.checkDestroy(player, this);
} catch (Throwable e) { } catch (Throwable e) {
P.p.errorLog("Failed to Check LWC for Barrel Break Permissions!"); P.p.errorLog("Failed to Check LWC for Barrel Break Permissions!");
P.p.errorLog("Brewery was tested with version 4.3.1 of LWC!"); P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
P.p.errorLog("Disable the LWC support in the config and do /brew reload"); P.p.errorLog("Disable the LWC support in the config and do /brew reload");
e.printStackTrace(); e.printStackTrace();
P.p.msg(player, "&cError breaking Barrel, please report to an Admin!"); P.p.msg(player, "&cError breaking Barrel, please report to an Admin!");
@ -211,7 +211,7 @@ public class Barrel implements InventoryHolder {
LWCBarrel.remove(this); LWCBarrel.remove(this);
} catch (Throwable e) { } catch (Throwable e) {
P.p.errorLog("Failed to Remove LWC Lock from Barrel!"); P.p.errorLog("Failed to Remove LWC Lock from Barrel!");
P.p.errorLog("Brewery was tested with version 4.3.1 of LWC!"); P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -256,7 +256,7 @@ public class Barrel implements InventoryHolder {
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation()); LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
} catch (Throwable e) { } catch (Throwable e) {
P.p.errorLog("Failed to Log Barrel to LogBlock!"); P.p.errorLog("Failed to Log Barrel to LogBlock!");
P.p.errorLog("Brewery was tested with version 1.80 of LogBlock!"); P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -461,7 +461,7 @@ public class Barrel implements InventoryHolder {
LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation()); LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation());
} catch (Throwable e) { } catch (Throwable e) {
P.p.errorLog("Failed to Log Barrel-break to LogBlock!"); P.p.errorLog("Failed to Log Barrel-break to LogBlock!");
P.p.errorLog("Brewery was tested with version 1.80 of LogBlock!"); P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -21,6 +21,7 @@ public class Brew {
// represents the liquid in the brewed Potions // represents the liquid in the brewed Potions
public static Map<Integer, Brew> potions = new HashMap<Integer, Brew>(); public static Map<Integer, Brew> potions = new HashMap<Integer, Brew>();
public static long installTime = System.currentTimeMillis(); // plugin install time in millis after epoch
public static Boolean colorInBarrels; // color the Lore while in Barrels public static Boolean colorInBarrels; // color the Lore while in Barrels
public static Boolean colorInBrewer; // color the Lore while in Brewer public static Boolean colorInBrewer; // color the Lore while in Brewer
@ -33,9 +34,11 @@ public class Brew {
private boolean unlabeled; private boolean unlabeled;
private boolean persistent; private boolean persistent;
private boolean stat; // static potions should not be changed private boolean stat; // static potions should not be changed
private int lastUpdate; // last update in hours after install time
public Brew(int uid, BIngredients ingredients) { public Brew(int uid, BIngredients ingredients) {
this.ingredients = ingredients; this.ingredients = ingredients;
touch();
potions.put(uid, this); potions.put(uid, this);
} }
@ -44,11 +47,12 @@ public class Brew {
this.ingredients = ingredients; this.ingredients = ingredients;
this.quality = quality; this.quality = quality;
this.currentRecipe = recipe; this.currentRecipe = recipe;
touch();
potions.put(uid, this); potions.put(uid, this);
} }
// loading from file // loading from file
public Brew(int uid, BIngredients ingredients, int quality, int distillRuns, float ageTime, float wood, String recipe, boolean unlabeled, boolean persistent, boolean stat) { public Brew(int uid, BIngredients ingredients, int quality, int distillRuns, float ageTime, float wood, String recipe, boolean unlabeled, boolean persistent, boolean stat, int lastUpdate) {
potions.put(uid, this); potions.put(uid, this);
this.ingredients = ingredients; this.ingredients = ingredients;
this.quality = quality; this.quality = quality;
@ -58,6 +62,7 @@ public class Brew {
this.unlabeled = unlabeled; this.unlabeled = unlabeled;
this.persistent = persistent; this.persistent = persistent;
this.stat = stat; this.stat = stat;
this.lastUpdate = lastUpdate;
setRecipeFromString(recipe); setRecipeFromString(recipe);
} }
@ -83,8 +88,7 @@ public class Brew {
public static Brew get(ItemStack item) { public static Brew get(ItemStack item) {
if (item.getType() == Material.POTION) { if (item.getType() == Material.POTION) {
if (item.hasItemMeta()) { if (item.hasItemMeta()) {
PotionMeta potionMeta = (PotionMeta) item.getItemMeta(); return get((PotionMeta) item.getItemMeta());
return get(potionMeta);
} }
} }
return null; return null;
@ -274,6 +278,23 @@ public class Brew {
unlabeled = true; unlabeled = true;
} }
// Do some regular updates
public void touch() {
lastUpdate = (int) ((float) (System.currentTimeMillis() - installTime) / 3600000F);
}
public int getDistillRuns() {
return distillRuns;
}
public float getAgeTime() {
return ageTime;
}
public BRecipe getCurrentRecipe() {
return currentRecipe;
}
public boolean isPersistent() { public boolean isPersistent() {
return persistent; return persistent;
} }
@ -304,6 +325,10 @@ public class Brew {
} }
} }
public int getLastUpdate() {
return lastUpdate;
}
// Distilling section --------------- // Distilling section ---------------
// distill all custom potions in the brewer // distill all custom potions in the brewer
@ -355,6 +380,7 @@ public class Brew {
prefix = getQualityColor(ingredients.getDistillQuality(recipe, distillRuns)); prefix = getQualityColor(ingredients.getDistillQuality(recipe, distillRuns));
} }
updateDistillLore(prefix, potionMeta); updateDistillLore(prefix, potionMeta);
touch();
slotItem.setItemMeta(potionMeta); slotItem.setItemMeta(potionMeta);
} }
@ -410,6 +436,7 @@ public class Brew {
updateWoodLore(potionMeta); updateWoodLore(potionMeta);
} }
} }
touch();
item.setItemMeta(potionMeta); item.setItemMeta(potionMeta);
} }
@ -639,6 +666,9 @@ public class Brew {
if (brew.stat) { if (brew.stat) {
idConfig.set("stat", true); idConfig.set("stat", true);
} }
if (brew.lastUpdate > 0) {
idConfig.set("lastUpdate", brew.lastUpdate);
}
// save the ingredients // save the ingredients
idConfig.set("ingId", brew.ingredients.save(config.getParent())); idConfig.set("ingId", brew.ingredients.save(config.getParent()));
} }

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 {
@ -262,7 +259,7 @@ public class P extends JavaPlugin {
} catch (Throwable e) { } catch (Throwable e) {
wg = null; wg = null;
P.p.errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!"); P.p.errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!");
P.p.errorLog("Brewery was tested with version 5.8 to 6.0 of WorldGuard!"); P.p.errorLog("Brewery was tested with version 5.8 to 6.1 of WorldGuard!");
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload"); P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
e.printStackTrace(); e.printStackTrace();
} }
@ -369,6 +366,8 @@ public class P extends JavaPlugin {
FileConfiguration data = YamlConfiguration.loadConfiguration(file); FileConfiguration data = YamlConfiguration.loadConfiguration(file);
Brew.installTime = data.getLong("installTime", System.currentTimeMillis());
// Check if data is the newest version // Check if data is the newest version
String version = data.getString("Version", null); String version = data.getString("Version", null);
if (version != null) { if (version != null) {
@ -410,8 +409,9 @@ public class P extends JavaPlugin {
boolean unlabeled = section.getBoolean(uid + ".unlabeled", false); boolean unlabeled = section.getBoolean(uid + ".unlabeled", false);
boolean persistent = section.getBoolean(uid + ".persist", false); boolean persistent = section.getBoolean(uid + ".persist", false);
boolean stat = section.getBoolean(uid + ".stat", false); boolean stat = section.getBoolean(uid + ".stat", false);
int lastUpdate = section.getInt("lastUpdate", 0);
new Brew(parseInt(uid), ingredients, quality, distillRuns, ageTime, wood, recipe, unlabeled, persistent, stat); new Brew(parseInt(uid), ingredients, quality, distillRuns, ageTime, wood, recipe, unlabeled, persistent, stat, lastUpdate);
} }
} }

View File

@ -59,6 +59,8 @@ public class DataSave extends BukkitRunnable {
FileConfiguration configFile = new YamlConfiguration(); FileConfiguration configFile = new YamlConfiguration();
configFile.set("installTime", Brew.installTime);
if (!Brew.potions.isEmpty()) { if (!Brew.potions.isEmpty()) {
Brew.save(configFile.createSection("Brew")); Brew.save(configFile.createSection("Brew"));
} }

View File

@ -26,7 +26,7 @@ public class WGBarrelOld implements WGBarrel {
canBuild = ApplicableRegionSet.class.getMethod("canBuild", LocalPlayer.class); canBuild = ApplicableRegionSet.class.getMethod("canBuild", LocalPlayer.class);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
P.p.errorLog("Failed to Hook WorldGuard for Barrel Open Permissions! Opening Barrels will NOT work!"); P.p.errorLog("Failed to Hook WorldGuard for Barrel Open Permissions! Opening Barrels will NOT work!");
P.p.errorLog("Brewery was tested with version 5.8 to 6.0 of WorldGuard!"); P.p.errorLog("Brewery was tested with version 5.8 to 6.1 of WorldGuard!");
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload"); P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -430,6 +430,7 @@ public class CommandListener implements CommandExecutor {
brew.setStatic(true, hand); brew.setStatic(true, hand);
p.msg(sender, p.languageReader.get("CMD_Persistent")); p.msg(sender, p.languageReader.get("CMD_Persistent"));
} }
brew.touch();
return; return;
} }
} }
@ -459,6 +460,7 @@ public class CommandListener implements CommandExecutor {
brew.setStatic(true, hand); brew.setStatic(true, hand);
p.msg(sender, p.languageReader.get("CMD_Static")); p.msg(sender, p.languageReader.get("CMD_Static"));
} }
brew.touch();
return; return;
} }
} }
@ -478,6 +480,7 @@ public class CommandListener implements CommandExecutor {
Brew brew = Brew.get(hand); Brew brew = Brew.get(hand);
if (brew != null) { if (brew != null) {
brew.unLabel(hand); brew.unLabel(hand);
brew.touch();
p.msg(sender, p.languageReader.get("CMD_UnLabel")); p.msg(sender, p.languageReader.get("CMD_UnLabel"));
return; return;
} }

View File

@ -17,13 +17,12 @@ public class DrinkListener1_9 implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDrink(PlayerItemConsumeEvent event) { public void onPlayerDrink(PlayerItemConsumeEvent event) {
ItemStack item = event.getItem(); ItemStack item = event.getItem();
Brew brew = Brew.get(item);
if (brew == null) {
return;
}
if (item.getType() == Material.POTION) { if (item.getType() == Material.POTION) {
PotionMeta meta = (PotionMeta) item.getItemMeta(); PotionMeta meta = (PotionMeta) item.getItemMeta();
Brew brew = Brew.get(meta);
if (brew == null) {
return;
}
// Throw away former "base" effect and replace with MUNDANE. // Throw away former "base" effect and replace with MUNDANE.
meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false)); meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false));
item.setItemMeta(meta); item.setItemMeta(meta);

View File

@ -1,9 +1,12 @@
package com.dre.brewery.listeners; package com.dre.brewery.listeners;
import java.util.HashMap; import com.dre.brewery.BRecipe;
import java.util.HashSet; import com.dre.brewery.Barrel;
import java.util.UUID; import com.dre.brewery.Brew;
import com.dre.brewery.P;
import com.dre.brewery.integration.LogBlockBarrel;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand; import org.bukkit.block.BrewingStand;
@ -11,25 +14,17 @@ import org.bukkit.entity.HumanEntity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.inventory.BrewEvent; import org.bukkit.event.inventory.*;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.BrewerInventory; import org.bukkit.inventory.BrewerInventory;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import com.dre.brewery.Barrel; import java.util.HashMap;
import com.dre.brewery.Brew; import java.util.HashSet;
import com.dre.brewery.P; import java.util.UUID;
import com.dre.brewery.integration.LogBlockBarrel;
/** /**
* Updated for 1.9 to replicate the "Brewing" process for distilling. * Updated for 1.9 to replicate the "Brewing" process for distilling.
@ -120,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");
@ -152,22 +147,20 @@ public class InventoryListener implements Listener {
P.p.debugLog("The block was replaced; not a brewing stand."); P.p.debugLog("The block was replaced; not a brewing stand.");
} }
} }
}.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.
Boolean[] contents = new Boolean[3];
for (int slot = 0; slot < 3; slot++) { for (int slot = 0; slot < 3; slot++) {
item = brewer.getItem(slot); item = brewer.getItem(slot);
contents[slot] = false;
if (item != null) { if (item != null) {
if (item.getType() == Material.POTION) { if (item.getType() == Material.POTION) {
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;
} }
} }
@ -179,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);
} }
@ -216,6 +215,29 @@ public class InventoryListener implements Listener {
return false; return false;
} }
// Clicked a Brew somewhere, do some updating
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = false)
public void onInventoryClickLow(InventoryClickEvent event) {
if (event.getCurrentItem() != null && event.getCurrentItem().getType().equals(Material.POTION)) {
ItemStack item = event.getCurrentItem();
if (item.hasItemMeta()) {
PotionMeta potion = ((PotionMeta) item.getItemMeta());
Brew brew = Brew.get(potion);
if (brew != null) {
// convert potions from 1.8 to 1.9 for color and to remove effect descriptions
if (P.use1_9 && !potion.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
BRecipe recipe = brew.getCurrentRecipe();
if (recipe != null) {
Brew.PotionColor.valueOf(recipe.getColor()).colorBrew(potion, item, brew.canDistill());
item.setItemMeta(potion);
}
}
brew.touch();
}
}
}
}
// convert to non colored Lore when taking out of Barrel/Brewer // convert to non colored Lore when taking out of Barrel/Brewer
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
@ -260,7 +282,7 @@ public class InventoryListener implements Listener {
LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory()); LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory());
} catch (Exception e) { } catch (Exception e) {
P.p.errorLog("Failed to Log Barrel to LogBlock!"); P.p.errorLog("Failed to Log Barrel to LogBlock!");
P.p.errorLog("Brewery was tested with version 1.80 of LogBlock!"); P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
e.printStackTrace(); e.printStackTrace();
} }
} }