diff --git a/pom.xml b/pom.xml
index 329ffeb..aa5be23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.dre
brewery
- 1.4.1
+ 1.4.2
Brewery
@@ -33,7 +33,7 @@
maven-compiler-plugin
- 2.5.1
+ 3.5.1
1.7
@@ -44,6 +44,10 @@
+
+ md_5-releases
+ http://repo.md-5.net/content/repositories/releases/
+
spigot-repo
https://hub.spigotmc.org/nexus/content/groups/public/
@@ -52,25 +56,17 @@
vault-repo
http://nexus.theyeticave.net/content/repositories/pub_releases
-
+
+ mcstats-repo
+ http://repo.mcstats.org/content/repositories/public/
+
sk89q-repo
http://maven.sk89q.com/repo/
- addstar-repo
- http://maven.addstar.com.au/artifactory/ext-release-local/
-
- true
- always
-
-
-
- md_5-releases
- http://repo.md-5.net/content/repositories/releases/
+ dre2n-rpo
+ http://feuerstern.bplaced.net/repo/
@@ -78,7 +74,8 @@
org.bukkit
bukkit
- 1.9-R0.1-SNAPSHOT
+ 1.9.4-R0.1-SNAPSHOT
+ provided
net.milkbowl.vault
@@ -90,22 +87,31 @@
com.sk89q
worldguard
6.1
+ provided
com.griefcraft.lwc
LWCPlugin
- 1.7.2
+ 4.5.0-SNAPSHOT
+ provided
me.ryanhamshire
GriefPrevention
- 14.5.1
- compile
+ 14.5.4
+ provided
de.diddiz
logblock
1.94
+ provided
+
+
+ de.diddiz
+ questioner
+ 1.94
+ provided
diff --git a/src/com/dre/brewery/BRecipe.java b/src/com/dre/brewery/BRecipe.java
index 9a7c68d..ec2fc5d 100644
--- a/src/com/dre/brewery/BRecipe.java
+++ b/src/com/dre/brewery/BRecipe.java
@@ -203,7 +203,7 @@ public class BRecipe {
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);
potionMeta.setDisplayName(P.p.color("&f" + getName(quality)));
@@ -212,6 +212,7 @@ public class BRecipe {
brew.convertLore(potionMeta, false);
Brew.addOrReplaceEffects(potionMeta, effects, quality);
+ brew.touch();
potion.setItemMeta(potionMeta);
return potion;
diff --git a/src/com/dre/brewery/Barrel.java b/src/com/dre/brewery/Barrel.java
index 689b0a9..a247ea6 100644
--- a/src/com/dre/brewery/Barrel.java
+++ b/src/com/dre/brewery/Barrel.java
@@ -146,7 +146,7 @@ public class Barrel implements InventoryHolder {
}
} catch (Throwable e) {
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");
e.printStackTrace();
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);
} catch (Throwable e) {
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");
e.printStackTrace();
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);
} catch (Throwable e) {
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");
e.printStackTrace();
P.p.msg(player, "&cError breaking Barrel, please report to an Admin!");
@@ -211,7 +211,7 @@ public class Barrel implements InventoryHolder {
LWCBarrel.remove(this);
} catch (Throwable e) {
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();
}
}
@@ -256,7 +256,7 @@ public class Barrel implements InventoryHolder {
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
} catch (Throwable e) {
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();
}
}
@@ -461,7 +461,7 @@ public class Barrel implements InventoryHolder {
LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation());
} catch (Throwable e) {
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();
}
}
diff --git a/src/com/dre/brewery/Brew.java b/src/com/dre/brewery/Brew.java
index 263e096..505c381 100644
--- a/src/com/dre/brewery/Brew.java
+++ b/src/com/dre/brewery/Brew.java
@@ -21,6 +21,7 @@ public class Brew {
// represents the liquid in the brewed Potions
public static Map potions = new HashMap();
+ 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 colorInBrewer; // color the Lore while in Brewer
@@ -33,9 +34,11 @@ public class Brew {
private boolean unlabeled;
private boolean persistent;
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) {
this.ingredients = ingredients;
+ touch();
potions.put(uid, this);
}
@@ -44,11 +47,12 @@ public class Brew {
this.ingredients = ingredients;
this.quality = quality;
this.currentRecipe = recipe;
+ touch();
potions.put(uid, this);
}
// 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);
this.ingredients = ingredients;
this.quality = quality;
@@ -58,6 +62,7 @@ public class Brew {
this.unlabeled = unlabeled;
this.persistent = persistent;
this.stat = stat;
+ this.lastUpdate = lastUpdate;
setRecipeFromString(recipe);
}
@@ -83,8 +88,7 @@ public class Brew {
public static Brew get(ItemStack item) {
if (item.getType() == Material.POTION) {
if (item.hasItemMeta()) {
- PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
- return get(potionMeta);
+ return get((PotionMeta) item.getItemMeta());
}
}
return null;
@@ -274,6 +278,23 @@ public class Brew {
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() {
return persistent;
}
@@ -304,6 +325,10 @@ public class Brew {
}
}
+ public int getLastUpdate() {
+ return lastUpdate;
+ }
+
// Distilling section ---------------
// distill all custom potions in the brewer
@@ -355,6 +380,7 @@ public class Brew {
prefix = getQualityColor(ingredients.getDistillQuality(recipe, distillRuns));
}
updateDistillLore(prefix, potionMeta);
+ touch();
slotItem.setItemMeta(potionMeta);
}
@@ -410,6 +436,7 @@ public class Brew {
updateWoodLore(potionMeta);
}
}
+ touch();
item.setItemMeta(potionMeta);
}
@@ -639,6 +666,9 @@ public class Brew {
if (brew.stat) {
idConfig.set("stat", true);
}
+ if (brew.lastUpdate > 0) {
+ idConfig.set("lastUpdate", brew.lastUpdate);
+ }
// save the ingredients
idConfig.set("ingId", brew.ingredients.save(config.getParent()));
}
diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java
index 499a636..bc3c9e3 100644
--- a/src/com/dre/brewery/P.java
+++ b/src/com/dre/brewery/P.java
@@ -69,9 +69,6 @@ public class P extends JavaPlugin {
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 {
@@ -262,7 +259,7 @@ public class P extends JavaPlugin {
} catch (Throwable e) {
wg = null;
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");
e.printStackTrace();
}
@@ -369,6 +366,8 @@ public class P extends JavaPlugin {
FileConfiguration data = YamlConfiguration.loadConfiguration(file);
+ Brew.installTime = data.getLong("installTime", System.currentTimeMillis());
+
// Check if data is the newest version
String version = data.getString("Version", null);
if (version != null) {
@@ -410,8 +409,9 @@ public class P extends JavaPlugin {
boolean unlabeled = section.getBoolean(uid + ".unlabeled", false);
boolean persistent = section.getBoolean(uid + ".persist", 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);
}
}
diff --git a/src/com/dre/brewery/filedata/DataSave.java b/src/com/dre/brewery/filedata/DataSave.java
index b80e5e8..ea7507f 100644
--- a/src/com/dre/brewery/filedata/DataSave.java
+++ b/src/com/dre/brewery/filedata/DataSave.java
@@ -59,6 +59,8 @@ public class DataSave extends BukkitRunnable {
FileConfiguration configFile = new YamlConfiguration();
+ configFile.set("installTime", Brew.installTime);
+
if (!Brew.potions.isEmpty()) {
Brew.save(configFile.createSection("Brew"));
}
diff --git a/src/com/dre/brewery/integration/WGBarrelOld.java b/src/com/dre/brewery/integration/WGBarrelOld.java
index ed5ccf9..a0f403d 100644
--- a/src/com/dre/brewery/integration/WGBarrelOld.java
+++ b/src/com/dre/brewery/integration/WGBarrelOld.java
@@ -26,7 +26,7 @@ public class WGBarrelOld implements WGBarrel {
canBuild = ApplicableRegionSet.class.getMethod("canBuild", LocalPlayer.class);
} catch (NoSuchMethodException e) {
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");
e.printStackTrace();
}
diff --git a/src/com/dre/brewery/listeners/CommandListener.java b/src/com/dre/brewery/listeners/CommandListener.java
index 93ab388..12b7731 100644
--- a/src/com/dre/brewery/listeners/CommandListener.java
+++ b/src/com/dre/brewery/listeners/CommandListener.java
@@ -430,6 +430,7 @@ public class CommandListener implements CommandExecutor {
brew.setStatic(true, hand);
p.msg(sender, p.languageReader.get("CMD_Persistent"));
}
+ brew.touch();
return;
}
}
@@ -459,6 +460,7 @@ public class CommandListener implements CommandExecutor {
brew.setStatic(true, hand);
p.msg(sender, p.languageReader.get("CMD_Static"));
}
+ brew.touch();
return;
}
}
@@ -478,6 +480,7 @@ public class CommandListener implements CommandExecutor {
Brew brew = Brew.get(hand);
if (brew != null) {
brew.unLabel(hand);
+ brew.touch();
p.msg(sender, p.languageReader.get("CMD_UnLabel"));
return;
}
diff --git a/src/com/dre/brewery/listeners/DrinkListener1_9.java b/src/com/dre/brewery/listeners/DrinkListener1_9.java
index ddaf94e..2533455 100644
--- a/src/com/dre/brewery/listeners/DrinkListener1_9.java
+++ b/src/com/dre/brewery/listeners/DrinkListener1_9.java
@@ -17,13 +17,12 @@ public class DrinkListener1_9 implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDrink(PlayerItemConsumeEvent event) {
ItemStack item = event.getItem();
- Brew brew = Brew.get(item);
- if (brew == null) {
- return;
- }
-
if (item.getType() == Material.POTION) {
PotionMeta meta = (PotionMeta) item.getItemMeta();
+ Brew brew = Brew.get(meta);
+ if (brew == null) {
+ return;
+ }
// Throw away former "base" effect and replace with MUNDANE.
meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false));
item.setItemMeta(meta);
diff --git a/src/com/dre/brewery/listeners/InventoryListener.java b/src/com/dre/brewery/listeners/InventoryListener.java
index 2437615..6092ee0 100644
--- a/src/com/dre/brewery/listeners/InventoryListener.java
+++ b/src/com/dre/brewery/listeners/InventoryListener.java
@@ -1,9 +1,12 @@
package com.dre.brewery.listeners;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.UUID;
-
+import com.dre.brewery.BRecipe;
+import com.dre.brewery.Barrel;
+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.BlockState;
import org.bukkit.block.BrewingStand;
@@ -11,25 +14,17 @@ import org.bukkit.entity.HumanEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.BrewEvent;
-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.event.inventory.*;
import org.bukkit.inventory.BrewerInventory;
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.meta.PotionMeta;
import org.bukkit.scheduler.BukkitRunnable;
-import org.bukkit.Bukkit;
-import org.bukkit.Material;
-import com.dre.brewery.Barrel;
-import com.dre.brewery.Brew;
-import com.dre.brewery.P;
-import com.dre.brewery.integration.LogBlockBarrel;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.UUID;
/**
* Updated for 1.9 to replicate the "Brewing" process for distilling.
@@ -120,7 +115,7 @@ public class InventoryListener implements Listener {
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");
@@ -152,22 +147,20 @@ public class InventoryListener implements Listener {
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
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++) {
item = brewer.getItem(slot);
- contents[slot] = false;
if (item != null) {
if (item.getType() == Material.POTION) {
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;
}
}
@@ -179,6 +172,12 @@ public class InventoryListener implements Listener {
@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);
}
@@ -216,6 +215,29 @@ public class InventoryListener implements Listener {
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
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
@@ -260,7 +282,7 @@ public class InventoryListener implements Listener {
LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory());
} catch (Exception e) {
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();
}
}