diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..03a93b3
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+
+[*.java]
+indent_style = tab
+indent_size = 4
+trim_trailing_whitespace = true
+
+[*.yml]
+indent_style = spaces
+indent_size = 2
+trim_trailing_whitespace = true
+
diff --git a/pom.xml b/pom.xml
index d77833b..aa38ef3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,111 +1,111 @@
- 4.0.0
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
- com.dre
- brewery
- 1.4-SNAPSHOT
- Brewery
+ com.dre
+ brewery
+ 1.4-SNAPSHOT
+ Brewery
-
- UTF-8
- UTF-8
-
+
+ UTF-8
+ UTF-8
+
-
- src
+
+ src
-
-
-
- false
- ${project.basedir}/resources
-
- **/*.yml
-
-
- target/**
- .travis.yml
-
-
-
+
+
+
+ false
+ ${project.basedir}/resources
+
+ **/*.yml
+
+
+ target/**
+ .travis.yml
+
+
+
-
-
- maven-compiler-plugin
- 2.5.1
-
- 1.7
- 1.7
- UTF-8
-
-
-
-
+
+
+ maven-compiler-plugin
+ 2.5.1
+
+ 1.7
+ 1.7
+ UTF-8
+
+
+
+
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/groups/public/
-
-
- vault-repo
- http://nexus.theyeticave.net/content/repositories/pub_releases
-
-
- dre2n-repo
- http://feuerstern.bplaced.net/repo/
-
-
- sk89q-repo
- http://maven.sk89q.com/artifactory/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/
-
-
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/groups/public/
+
+
+ vault-repo
+ http://nexus.theyeticave.net/content/repositories/pub_releases
+
+
+ dre2n-repo
+ http://feuerstern.bplaced.net/repo/
+
+
+ sk89q-repo
+ http://maven.sk89q.com/artifactory/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/
+
+
-
-
- org.bukkit
- bukkit
- 1.9-R0.1-SNAPSHOT
-
-
- net.milkbowl.vault
- VaultAPI
- 1.5
- provided
-
-
- com.sk89q
- worldguard
- 6.1
-
-
- com.griefcraft
- entitylwc
- 1.7.2
-
-
- me.ryanhamshire
- GriefPrevention
- 13.9.1
- compile
-
-
- de.diddiz
- logblock
- 1.94
-
-
+
+
+ org.bukkit
+ bukkit
+ 1.9-R0.1-SNAPSHOT
+
+
+ net.milkbowl.vault
+ VaultAPI
+ 1.5
+ provided
+
+
+ com.sk89q
+ worldguard
+ 6.1
+
+
+ com.griefcraft
+ entitylwc
+ 1.7.2
+
+
+ me.ryanhamshire
+ GriefPrevention
+ 13.9.1
+ compile
+
+
+ de.diddiz
+ logblock
+ 1.94
+
+
diff --git a/src/com/dre/brewery/Brew.java b/src/com/dre/brewery/Brew.java
index 435932a..eb89a14 100644
--- a/src/com/dre/brewery/Brew.java
+++ b/src/com/dre/brewery/Brew.java
@@ -14,686 +14,686 @@ import org.bukkit.potion.PotionEffectType;
public class Brew {
- // represents the liquid in the brewed Potions
- public static Map potions = new HashMap();
- public static Boolean colorInBarrels; // color the Lore while in Barrels
- public static Boolean colorInBrewer; // color the Lore while in Brewer
+ // represents the liquid in the brewed Potions
+ public static Map potions = new HashMap();
+ public static Boolean colorInBarrels; // color the Lore while in Barrels
+ public static Boolean colorInBrewer; // color the Lore while in Brewer
- private BIngredients ingredients;
- private int quality;
- private int distillRuns;
- private float ageTime;
- private float wood;
- private BRecipe currentRecipe;
- private boolean unlabeled;
- private boolean persistent;
- private boolean stat; // static potions should not be changed
+ private BIngredients ingredients;
+ private int quality;
+ private int distillRuns;
+ private float ageTime;
+ private float wood;
+ private BRecipe currentRecipe;
+ private boolean unlabeled;
+ private boolean persistent;
+ private boolean stat; // static potions should not be changed
- public Brew(int uid, BIngredients ingredients) {
- this.ingredients = ingredients;
- potions.put(uid, this);
- }
+ public Brew(int uid, BIngredients ingredients) {
+ this.ingredients = ingredients;
+ potions.put(uid, this);
+ }
- // quality already set
- public Brew(int uid, int quality, BRecipe recipe, BIngredients ingredients) {
- this.ingredients = ingredients;
- this.quality = quality;
- this.currentRecipe = recipe;
- potions.put(uid, this);
- }
+ // quality already set
+ public Brew(int uid, int quality, BRecipe recipe, BIngredients ingredients) {
+ this.ingredients = ingredients;
+ this.quality = quality;
+ this.currentRecipe = recipe;
+ 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) {
- potions.put(uid, this);
- this.ingredients = ingredients;
- this.quality = quality;
- this.distillRuns = distillRuns;
- this.ageTime = ageTime;
- this.wood = wood;
- this.unlabeled = unlabeled;
- this.persistent = persistent;
- this.stat = stat;
- setRecipeFromString(recipe);
- }
+ // 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) {
+ potions.put(uid, this);
+ this.ingredients = ingredients;
+ this.quality = quality;
+ this.distillRuns = distillRuns;
+ this.ageTime = ageTime;
+ this.wood = wood;
+ this.unlabeled = unlabeled;
+ this.persistent = persistent;
+ this.stat = stat;
+ setRecipeFromString(recipe);
+ }
- // returns a Brew by its UID
- public static Brew get(int uid) {
- if (uid < -1) {
- if (!potions.containsKey(uid)) {
- P.p.errorLog("Database failure! unable to find UID " + uid + " of a custom Potion!");
- return null;// throw some exception?
- }
- } else {
- return null;
- }
- return potions.get(uid);
- }
+ // returns a Brew by its UID
+ public static Brew get(int uid) {
+ if (uid < -1) {
+ if (!potions.containsKey(uid)) {
+ P.p.errorLog("Database failure! unable to find UID " + uid + " of a custom Potion!");
+ return null;// throw some exception?
+ }
+ } else {
+ return null;
+ }
+ return potions.get(uid);
+ }
- // returns a Brew by PotionMeta
- public static Brew get(PotionMeta meta) {
- return get(getUID(meta));
- }
+ // returns a Brew by PotionMeta
+ public static Brew get(PotionMeta meta) {
+ return get(getUID(meta));
+ }
- // returns a Brew by ItemStack
- public static Brew get(ItemStack item) {
- if (item.getType() == Material.POTION) {
- if (item.hasItemMeta()) {
- PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
- return get(potionMeta);
- }
- }
- return null;
- }
+ // returns a Brew by ItemStack
+ public static Brew get(ItemStack item) {
+ if (item.getType() == Material.POTION) {
+ if (item.hasItemMeta()) {
+ PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
+ return get(potionMeta);
+ }
+ }
+ return null;
+ }
- // returns UID of custom Potion item
- public static int getUID(ItemStack item) {
- return getUID((PotionMeta) item.getItemMeta());
- }
+ // returns UID of custom Potion item
+ public static int getUID(ItemStack item) {
+ return getUID((PotionMeta) item.getItemMeta());
+ }
- // returns UID of custom Potion meta
- public static int getUID(PotionMeta potionMeta) {
- if (potionMeta.hasCustomEffect(PotionEffectType.REGENERATION)) {
- for (PotionEffect effect : potionMeta.getCustomEffects()) {
- if (effect.getType().equals(PotionEffectType.REGENERATION)) {
- if (effect.getDuration() < -1) {
- return effect.getDuration();
- }
- }
- }
- }
- return 0;
- }
+ // returns UID of custom Potion meta
+ public static int getUID(PotionMeta potionMeta) {
+ if (potionMeta.hasCustomEffect(PotionEffectType.REGENERATION)) {
+ for (PotionEffect effect : potionMeta.getCustomEffects()) {
+ if (effect.getType().equals(PotionEffectType.REGENERATION)) {
+ if (effect.getDuration() < -1) {
+ return effect.getDuration();
+ }
+ }
+ }
+ }
+ return 0;
+ }
- // generate an UID
- public static int generateUID() {
- int uid = -2;
- while (potions.containsKey(uid)) {
- uid -= 1;
- }
- return uid;
- }
+ // generate an UID
+ public static int generateUID() {
+ int uid = -2;
+ while (potions.containsKey(uid)) {
+ uid -= 1;
+ }
+ return uid;
+ }
- //returns the recipe with the given name, recalculates if not found
- public boolean setRecipeFromString(String name) {
- currentRecipe = null;
- if (name != null && !name.equals("")) {
- for (BRecipe recipe : BIngredients.recipes) {
- if (recipe.getName(5).equalsIgnoreCase(name)) {
- currentRecipe = recipe;
- return true;
- }
- }
+ //returns the recipe with the given name, recalculates if not found
+ public boolean setRecipeFromString(String name) {
+ currentRecipe = null;
+ if (name != null && !name.equals("")) {
+ for (BRecipe recipe : BIngredients.recipes) {
+ if (recipe.getName(5).equalsIgnoreCase(name)) {
+ currentRecipe = recipe;
+ return true;
+ }
+ }
- if (quality > 0) {
- currentRecipe = ingredients.getBestRecipe(wood, ageTime, distillRuns > 0);
- if (currentRecipe != null) {
- if (!stat) {
- this.quality = calcQuality();
- }
- P.p.log("Brew was made from Recipe: '" + name + "' which could not be found. '" + currentRecipe.getName(5) + "' used instead!");
- return true;
- } else {
- P.p.errorLog("Brew was made from Recipe: '" + name + "' which could not be found!");
- }
- }
- }
- return false;
- }
+ if (quality > 0) {
+ currentRecipe = ingredients.getBestRecipe(wood, ageTime, distillRuns > 0);
+ if (currentRecipe != null) {
+ if (!stat) {
+ this.quality = calcQuality();
+ }
+ P.p.log("Brew was made from Recipe: '" + name + "' which could not be found. '" + currentRecipe.getName(5) + "' used instead!");
+ return true;
+ } else {
+ P.p.errorLog("Brew was made from Recipe: '" + name + "' which could not be found!");
+ }
+ }
+ }
+ return false;
+ }
- public boolean reloadRecipe() {
- if (currentRecipe != null) {
- return setRecipeFromString(currentRecipe.getName(5));
- }
- return true;
- }
+ public boolean reloadRecipe() {
+ if (currentRecipe != null) {
+ return setRecipeFromString(currentRecipe.getName(5));
+ }
+ return true;
+ }
- // Copy a Brew with a new unique ID and return its item
- public ItemStack copy(ItemStack item) {
- ItemStack copy = item.clone();
- int uid = generateUID();
- clone(uid);
- PotionMeta meta = (PotionMeta) copy.getItemMeta();
- meta.addCustomEffect((PotionEffectType.REGENERATION).createEffect((uid * 4), 0), true);
- copy.setItemMeta(meta);
- return copy;
- }
+ // Copy a Brew with a new unique ID and return its item
+ public ItemStack copy(ItemStack item) {
+ ItemStack copy = item.clone();
+ int uid = generateUID();
+ clone(uid);
+ PotionMeta meta = (PotionMeta) copy.getItemMeta();
+ meta.addCustomEffect((PotionEffectType.REGENERATION).createEffect((uid * 4), 0), true);
+ copy.setItemMeta(meta);
+ return copy;
+ }
- // Clones this instance with a new unique ID
- public Brew clone(int uid) {
- Brew brew = new Brew(uid, quality, currentRecipe, ingredients);
- brew.distillRuns = distillRuns;
- brew.ageTime = ageTime;
- brew.unlabeled = unlabeled;
- if (!brew.persistent) {
- brew.stat = stat;
- }
- return brew;
- }
+ // Clones this instance with a new unique ID
+ public Brew clone(int uid) {
+ Brew brew = new Brew(uid, quality, currentRecipe, ingredients);
+ brew.distillRuns = distillRuns;
+ brew.ageTime = ageTime;
+ brew.unlabeled = unlabeled;
+ if (!brew.persistent) {
+ brew.stat = stat;
+ }
+ return brew;
+ }
- // remove potion from file (drinking, despawning, combusting, cmdDeleting, should be more!)
- public void remove(ItemStack item) {
- if (!persistent) {
- potions.remove(getUID(item));
- }
- }
+ // remove potion from file (drinking, despawning, combusting, cmdDeleting, should be more!)
+ public void remove(ItemStack item) {
+ if (!persistent) {
+ potions.remove(getUID(item));
+ }
+ }
- // calculate alcohol from recipe
- public int calcAlcohol() {
- if (quality == 0) {
- // Give bad potions some alc
- int badAlc = 0;
- if (distillRuns > 1) {
- badAlc = distillRuns;
- }
- if (ageTime > 10) {
- badAlc += 5;
- } else if (ageTime > 2) {
- badAlc += 3;
- }
- if (currentRecipe != null) {
- return badAlc;
- } else {
- return badAlc / 2;
- }
- }
+ // calculate alcohol from recipe
+ public int calcAlcohol() {
+ if (quality == 0) {
+ // Give bad potions some alc
+ int badAlc = 0;
+ if (distillRuns > 1) {
+ badAlc = distillRuns;
+ }
+ if (ageTime > 10) {
+ badAlc += 5;
+ } else if (ageTime > 2) {
+ badAlc += 3;
+ }
+ if (currentRecipe != null) {
+ return badAlc;
+ } else {
+ return badAlc / 2;
+ }
+ }
- if (currentRecipe != null) {
- int alc = currentRecipe.getAlcohol();
- if (currentRecipe.needsDistilling()) {
- if (distillRuns == 0) {
- return 0;
- }
- // bad quality can decrease alc by up to 40%
- alc *= 1 - ((float) (10 - quality) * 0.04);
- // distillable Potions should have half alc after one and full alc after all needed distills
- alc /= 2;
- alc *= 1.0F + ((float) distillRuns / currentRecipe.getDistillRuns());
- } else {
- // quality decides 10% - 100%
- alc *= ((float) quality / 10.0);
- }
- if (alc > 0) {
- return alc;
- }
- }
- return 0;
- }
+ if (currentRecipe != null) {
+ int alc = currentRecipe.getAlcohol();
+ if (currentRecipe.needsDistilling()) {
+ if (distillRuns == 0) {
+ return 0;
+ }
+ // bad quality can decrease alc by up to 40%
+ alc *= 1 - ((float) (10 - quality) * 0.04);
+ // distillable Potions should have half alc after one and full alc after all needed distills
+ alc /= 2;
+ alc *= 1.0F + ((float) distillRuns / currentRecipe.getDistillRuns());
+ } else {
+ // quality decides 10% - 100%
+ alc *= ((float) quality / 10.0);
+ }
+ if (alc > 0) {
+ return alc;
+ }
+ }
+ return 0;
+ }
- // calculating quality
- public int calcQuality() {
- // calculate quality from all of the factors
- float quality = ingredients.getIngredientQuality(currentRecipe) + ingredients.getCookingQuality(currentRecipe, distillRuns > 0);
- if (currentRecipe.needsToAge() || ageTime > 0.5) {
- quality += ingredients.getWoodQuality(currentRecipe, wood) + ingredients.getAgeQuality(currentRecipe, ageTime);
- quality /= 4;
- } else {
- quality /= 2;
- }
- return Math.round(quality);
- }
+ // calculating quality
+ public int calcQuality() {
+ // calculate quality from all of the factors
+ float quality = ingredients.getIngredientQuality(currentRecipe) + ingredients.getCookingQuality(currentRecipe, distillRuns > 0);
+ if (currentRecipe.needsToAge() || ageTime > 0.5) {
+ quality += ingredients.getWoodQuality(currentRecipe, wood) + ingredients.getAgeQuality(currentRecipe, ageTime);
+ quality /= 4;
+ } else {
+ quality /= 2;
+ }
+ return Math.round(quality);
+ }
- public int getQuality() {
- return quality;
- }
+ public int getQuality() {
+ return quality;
+ }
- public boolean canDistill() {
- if (currentRecipe != null) {
- return currentRecipe.getDistillRuns() > distillRuns;
- } else if (distillRuns >= 6) {
- return false;
- }
- return true;
- }
+ public boolean canDistill() {
+ if (currentRecipe != null) {
+ return currentRecipe.getDistillRuns() > distillRuns;
+ } else if (distillRuns >= 6) {
+ return false;
+ }
+ return true;
+ }
- // return special effect
- public ArrayList getEffects() {
- if (currentRecipe != null && quality > 0) {
- return currentRecipe.getEffects();
- }
- return null;
- }
+ // return special effect
+ public ArrayList getEffects() {
+ if (currentRecipe != null && quality > 0) {
+ return currentRecipe.getEffects();
+ }
+ return null;
+ }
- // Set unlabeled to true to hide the numbers in Lore
- public void unLabel(ItemStack item) {
- PotionMeta meta = (PotionMeta) item.getItemMeta();
- if (meta.hasLore()) {
- if (distillRuns > 0) {
- addOrReplaceLore(meta, P.p.color("&7"), P.p.languageReader.get("Brew_Distilled"));
- }
- if (ageTime >= 1) {
- addOrReplaceLore(meta, P.p.color("&7"), P.p.languageReader.get("Brew_BarrelRiped"));
- }
- item.setItemMeta(meta);
- }
- unlabeled = true;
- }
+ // Set unlabeled to true to hide the numbers in Lore
+ public void unLabel(ItemStack item) {
+ PotionMeta meta = (PotionMeta) item.getItemMeta();
+ if (meta.hasLore()) {
+ if (distillRuns > 0) {
+ addOrReplaceLore(meta, P.p.color("&7"), P.p.languageReader.get("Brew_Distilled"));
+ }
+ if (ageTime >= 1) {
+ addOrReplaceLore(meta, P.p.color("&7"), P.p.languageReader.get("Brew_BarrelRiped"));
+ }
+ item.setItemMeta(meta);
+ }
+ unlabeled = true;
+ }
- public boolean isPersistent() {
- return persistent;
- }
+ public boolean isPersistent() {
+ return persistent;
+ }
- // Make a potion persistent to not delete it when drinking it
- public void makePersistent() {
- persistent = true;
- }
+ // Make a potion persistent to not delete it when drinking it
+ public void makePersistent() {
+ persistent = true;
+ }
- // Remove the Persistence Flag from a brew, so it will be normally deleted when drinking it
- public void removePersistence() {
- persistent = false;
- }
+ // Remove the Persistence Flag from a brew, so it will be normally deleted when drinking it
+ public void removePersistence() {
+ persistent = false;
+ }
- public boolean isStatic() {
- return stat;
- }
+ public boolean isStatic() {
+ return stat;
+ }
- // Set the Static flag, so potion is unchangeable
- public void setStatic(boolean stat, ItemStack potion) {
- this.stat = stat;
- if (currentRecipe != null && canDistill()) {
- if (stat) {
- if (P.use1_9) {
- PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
- potionMeta.setMainEffect(PotionColor.valueOf(currentRecipe.getColor()).getEffect());
- } else {
- potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(false));
- }
- } else if (P.use1_9) {
- PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
- potionMeta.setMainEffect(PotionColor.valueOf(currentRecipe.getColor()).getEffect());
- } else {
- potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(true));
- }
- }
- }
+ // Set the Static flag, so potion is unchangeable
+ public void setStatic(boolean stat, ItemStack potion) {
+ this.stat = stat;
+ if (currentRecipe != null && canDistill()) {
+ if (stat) {
+ if (P.use1_9) {
+ PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
+ potionMeta.setMainEffect(PotionColor.valueOf(currentRecipe.getColor()).getEffect());
+ } else {
+ potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(false));
+ }
+ } else if (P.use1_9) {
+ PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
+ potionMeta.setMainEffect(PotionColor.valueOf(currentRecipe.getColor()).getEffect());
+ } else {
+ potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(true));
+ }
+ }
+ }
- // Distilling section ---------------
- // distill all custom potions in the brewer
- public static void distillAll(BrewerInventory inv, Boolean[] contents) {
- int slot = 0;
- while (slot < 3) {
- if (contents[slot]) {
- ItemStack slotItem = inv.getItem(slot);
- PotionMeta potionMeta = (PotionMeta) slotItem.getItemMeta();
- Brew brew = get(potionMeta);
- brew.distillSlot(slotItem, potionMeta);
- }
- slot++;
- }
- }
+ // Distilling section ---------------
+ // distill all custom potions in the brewer
+ public static void distillAll(BrewerInventory inv, Boolean[] contents) {
+ int slot = 0;
+ while (slot < 3) {
+ if (contents[slot]) {
+ ItemStack slotItem = inv.getItem(slot);
+ PotionMeta potionMeta = (PotionMeta) slotItem.getItemMeta();
+ Brew brew = get(potionMeta);
+ brew.distillSlot(slotItem, potionMeta);
+ }
+ slot++;
+ }
+ }
- // distill custom potion in given slot
- public void distillSlot(ItemStack slotItem, PotionMeta potionMeta) {
- if (stat) {
- return;
- }
+ // distill custom potion in given slot
+ public void distillSlot(ItemStack slotItem, PotionMeta potionMeta) {
+ if (stat) {
+ return;
+ }
- distillRuns += 1;
- BRecipe recipe = ingredients.getdistillRecipe(wood, ageTime);
- if (recipe != null) {
- // distillRuns will have an effect on the amount of alcohol, not the quality
- currentRecipe = recipe;
- quality = calcQuality();
+ distillRuns += 1;
+ BRecipe recipe = ingredients.getdistillRecipe(wood, ageTime);
+ if (recipe != null) {
+ // distillRuns will have an effect on the amount of alcohol, not the quality
+ currentRecipe = recipe;
+ quality = calcQuality();
- addOrReplaceEffects(potionMeta, getEffects(), quality);
- potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
- if (P.use1_9) {
- potionMeta.setMainEffect(PotionColor.valueOf(recipe.getColor()).getEffect());
- } else {
- slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
- }
+ addOrReplaceEffects(potionMeta, getEffects(), quality);
+ potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
+ if (P.use1_9) {
+ potionMeta.setMainEffect(PotionColor.valueOf(recipe.getColor()).getEffect());
+ } else {
+ slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
+ }
- } else {
- quality = 0;
- removeEffects(potionMeta);
- potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_DistillUndefined")));
- if (P.use1_9) {
- potionMeta.setMainEffect(PotionColor.GREY.getEffect());
- } else {
- slotItem.setDurability(PotionColor.GREY.getColorId(canDistill()));
- }
- }
+ } else {
+ quality = 0;
+ removeEffects(potionMeta);
+ potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_DistillUndefined")));
+ if (P.use1_9) {
+ potionMeta.setMainEffect(PotionColor.GREY.getEffect());
+ } else {
+ slotItem.setDurability(PotionColor.GREY.getColorId(canDistill()));
+ }
+ }
- // Distill Lore
- if (currentRecipe != null) {
- if (colorInBrewer != hasColorLore(potionMeta)) {
- convertLore(potionMeta, colorInBrewer);
- }
- }
- String prefix = P.p.color("&7");
- if (colorInBrewer && currentRecipe != null) {
- prefix = getQualityColor(ingredients.getDistillQuality(recipe, distillRuns));
- }
- updateDistillLore(prefix, potionMeta);
+ // Distill Lore
+ if (currentRecipe != null) {
+ if (colorInBrewer != hasColorLore(potionMeta)) {
+ convertLore(potionMeta, colorInBrewer);
+ }
+ }
+ String prefix = P.p.color("&7");
+ if (colorInBrewer && currentRecipe != null) {
+ prefix = getQualityColor(ingredients.getDistillQuality(recipe, distillRuns));
+ }
+ updateDistillLore(prefix, potionMeta);
- slotItem.setItemMeta(potionMeta);
- }
+ slotItem.setItemMeta(potionMeta);
+ }
- // Ageing Section ------------------
- public void age(ItemStack item, float time, byte woodType) {
- if (stat) {
- return;
- }
+ // Ageing Section ------------------
+ public void age(ItemStack item, float time, byte woodType) {
+ if (stat) {
+ return;
+ }
- PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
- ageTime += time;
+ PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
+ ageTime += time;
- // if younger than half a day, it shouldnt get aged form
- if (ageTime > 0.5) {
- if (wood == 0) {
- wood = woodType;
- } else if (wood != woodType) {
- woodShift(time, woodType);
- }
- BRecipe recipe = ingredients.getAgeRecipe(wood, ageTime, distillRuns > 0);
- if (recipe != null) {
- currentRecipe = recipe;
- quality = calcQuality();
+ // if younger than half a day, it shouldnt get aged form
+ if (ageTime > 0.5) {
+ if (wood == 0) {
+ wood = woodType;
+ } else if (wood != woodType) {
+ woodShift(time, woodType);
+ }
+ BRecipe recipe = ingredients.getAgeRecipe(wood, ageTime, distillRuns > 0);
+ if (recipe != null) {
+ currentRecipe = recipe;
+ quality = calcQuality();
- addOrReplaceEffects(potionMeta, getEffects(), quality);
- potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
- if (P.use1_9) {
- potionMeta.setMainEffect(PotionColor.valueOf(recipe.getColor()).getEffect());
- } else {
- item.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
- }
- } else {
- quality = 0;
- removeEffects(potionMeta);
- potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_BadPotion")));
- if (P.use1_9) {
- potionMeta.setMainEffect(PotionColor.GREY.getEffect());
- } else {
- item.setDurability(PotionColor.GREY.getColorId(canDistill()));
- }
- }
- }
+ addOrReplaceEffects(potionMeta, getEffects(), quality);
+ potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
+ if (P.use1_9) {
+ potionMeta.setMainEffect(PotionColor.valueOf(recipe.getColor()).getEffect());
+ } else {
+ item.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
+ }
+ } else {
+ quality = 0;
+ removeEffects(potionMeta);
+ potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_BadPotion")));
+ if (P.use1_9) {
+ potionMeta.setMainEffect(PotionColor.GREY.getEffect());
+ } else {
+ item.setDurability(PotionColor.GREY.getColorId(canDistill()));
+ }
+ }
+ }
- // Lore
- if (currentRecipe != null) {
- if (colorInBarrels != hasColorLore(potionMeta)) {
- convertLore(potionMeta, colorInBarrels);
- }
- }
- if (ageTime >= 1) {
- String prefix = P.p.color("&7");
- if (colorInBarrels && currentRecipe != null) {
- prefix = getQualityColor(ingredients.getAgeQuality(currentRecipe, ageTime));
- }
- updateAgeLore(prefix, potionMeta);
- }
- if (ageTime > 0.5) {
- if (colorInBarrels && !unlabeled && currentRecipe != null) {
- updateWoodLore(potionMeta);
- }
- }
- item.setItemMeta(potionMeta);
- }
+ // Lore
+ if (currentRecipe != null) {
+ if (colorInBarrels != hasColorLore(potionMeta)) {
+ convertLore(potionMeta, colorInBarrels);
+ }
+ }
+ if (ageTime >= 1) {
+ String prefix = P.p.color("&7");
+ if (colorInBarrels && currentRecipe != null) {
+ prefix = getQualityColor(ingredients.getAgeQuality(currentRecipe, ageTime));
+ }
+ updateAgeLore(prefix, potionMeta);
+ }
+ if (ageTime > 0.5) {
+ if (colorInBarrels && !unlabeled && currentRecipe != null) {
+ updateWoodLore(potionMeta);
+ }
+ }
+ item.setItemMeta(potionMeta);
+ }
- // Slowly shift the wood of the Brew to the new Type
- public void woodShift(float time, byte to) {
- byte factor = 1;
- if (ageTime > 5) {
- factor = 2;
- } else if (ageTime > 10) {
- factor = 2;
- factor += Math.round(ageTime / 10);
- }
- if (wood > to) {
- wood -= time / factor;
- if (wood < to) {
- wood = to;
- }
- } else {
- wood += time / factor;
- if (wood > to) {
- wood = to;
- }
- }
- }
+ // Slowly shift the wood of the Brew to the new Type
+ public void woodShift(float time, byte to) {
+ byte factor = 1;
+ if (ageTime > 5) {
+ factor = 2;
+ } else if (ageTime > 10) {
+ factor = 2;
+ factor += Math.round(ageTime / 10);
+ }
+ if (wood > to) {
+ wood -= time / factor;
+ if (wood < to) {
+ wood = to;
+ }
+ } else {
+ wood += time / factor;
+ if (wood > to) {
+ wood = to;
+ }
+ }
+ }
- // Lore -----------
- // Converts to/from qualitycolored Lore
- public void convertLore(PotionMeta meta, Boolean toQuality) {
- if (currentRecipe == null) {
- return;
- }
- meta.setLore(null);
- int quality;
- String prefix = P.p.color("&7");
- String lore;
+ // Lore -----------
+ // Converts to/from qualitycolored Lore
+ public void convertLore(PotionMeta meta, Boolean toQuality) {
+ if (currentRecipe == null) {
+ return;
+ }
+ meta.setLore(null);
+ int quality;
+ String prefix = P.p.color("&7");
+ String lore;
- // Ingredients
- if (toQuality && !unlabeled) {
- quality = ingredients.getIngredientQuality(currentRecipe);
- prefix = getQualityColor(quality);
- lore = P.p.languageReader.get("Brew_Ingredients");
- addOrReplaceLore(meta, prefix, lore);
- }
+ // Ingredients
+ if (toQuality && !unlabeled) {
+ quality = ingredients.getIngredientQuality(currentRecipe);
+ prefix = getQualityColor(quality);
+ lore = P.p.languageReader.get("Brew_Ingredients");
+ addOrReplaceLore(meta, prefix, lore);
+ }
- // Cooking
- if (toQuality && !unlabeled) {
- if (distillRuns > 0 == currentRecipe.needsDistilling()) {
- quality = ingredients.getCookingQuality(currentRecipe, distillRuns > 0);
- prefix = getQualityColor(quality) + ingredients.getCookedTime() + " " + P.p.languageReader.get("Brew_minute");
- if (ingredients.getCookedTime() > 1) {
- prefix = prefix + P.p.languageReader.get("Brew_MinutePluralPostfix");
- }
- lore = " " + P.p.languageReader.get("Brew_fermented");
- addOrReplaceLore(meta, prefix, lore);
- }
- }
+ // Cooking
+ if (toQuality && !unlabeled) {
+ if (distillRuns > 0 == currentRecipe.needsDistilling()) {
+ quality = ingredients.getCookingQuality(currentRecipe, distillRuns > 0);
+ prefix = getQualityColor(quality) + ingredients.getCookedTime() + " " + P.p.languageReader.get("Brew_minute");
+ if (ingredients.getCookedTime() > 1) {
+ prefix = prefix + P.p.languageReader.get("Brew_MinutePluralPostfix");
+ }
+ lore = " " + P.p.languageReader.get("Brew_fermented");
+ addOrReplaceLore(meta, prefix, lore);
+ }
+ }
- // Distilling
- if (distillRuns > 0) {
- if (toQuality) {
- quality = ingredients.getDistillQuality(currentRecipe, distillRuns);
- prefix = getQualityColor(quality);
- }
- updateDistillLore(prefix, meta);
- }
+ // Distilling
+ if (distillRuns > 0) {
+ if (toQuality) {
+ quality = ingredients.getDistillQuality(currentRecipe, distillRuns);
+ prefix = getQualityColor(quality);
+ }
+ updateDistillLore(prefix, meta);
+ }
- // Ageing
- if (ageTime >= 1) {
- if (toQuality) {
- quality = ingredients.getAgeQuality(currentRecipe, ageTime);
- prefix = getQualityColor(quality);
- }
- updateAgeLore(prefix, meta);
- }
+ // Ageing
+ if (ageTime >= 1) {
+ if (toQuality) {
+ quality = ingredients.getAgeQuality(currentRecipe, ageTime);
+ prefix = getQualityColor(quality);
+ }
+ updateAgeLore(prefix, meta);
+ }
- // WoodType
- if (toQuality && !unlabeled) {
- if (ageTime > 0.5) {
- updateWoodLore(meta);
- }
- }
- }
+ // WoodType
+ if (toQuality && !unlabeled) {
+ if (ageTime > 0.5) {
+ updateWoodLore(meta);
+ }
+ }
+ }
- // sets the DistillLore. Prefix is the color to be used
- public void updateDistillLore(String prefix, PotionMeta meta) {
- if (!unlabeled) {
- if (distillRuns > 1) {
- prefix = prefix + distillRuns + P.p.languageReader.get("Brew_-times") + " ";
- }
- }
- addOrReplaceLore(meta, prefix, P.p.languageReader.get("Brew_Distilled"));
- }
+ // sets the DistillLore. Prefix is the color to be used
+ public void updateDistillLore(String prefix, PotionMeta meta) {
+ if (!unlabeled) {
+ if (distillRuns > 1) {
+ prefix = prefix + distillRuns + P.p.languageReader.get("Brew_-times") + " ";
+ }
+ }
+ addOrReplaceLore(meta, prefix, P.p.languageReader.get("Brew_Distilled"));
+ }
- // sets the AgeLore. Prefix is the color to be used
- public void updateAgeLore(String prefix, PotionMeta meta) {
- if (!unlabeled) {
- if (ageTime >= 1 && ageTime < 2) {
- prefix = prefix + P.p.languageReader.get("Brew_OneYear") + " ";
- } else if (ageTime < 201) {
- prefix = prefix + (int) Math.floor(ageTime) + " " + P.p.languageReader.get("Brew_Years") + " ";
- } else {
- prefix = prefix + P.p.languageReader.get("Brew_HundredsOfYears") + " ";
- }
- }
- addOrReplaceLore(meta, prefix, P.p.languageReader.get("Brew_BarrelRiped"));
- }
+ // sets the AgeLore. Prefix is the color to be used
+ public void updateAgeLore(String prefix, PotionMeta meta) {
+ if (!unlabeled) {
+ if (ageTime >= 1 && ageTime < 2) {
+ prefix = prefix + P.p.languageReader.get("Brew_OneYear") + " ";
+ } else if (ageTime < 201) {
+ prefix = prefix + (int) Math.floor(ageTime) + " " + P.p.languageReader.get("Brew_Years") + " ";
+ } else {
+ prefix = prefix + P.p.languageReader.get("Brew_HundredsOfYears") + " ";
+ }
+ }
+ addOrReplaceLore(meta, prefix, P.p.languageReader.get("Brew_BarrelRiped"));
+ }
- // updates/sets the color on WoodLore
- public void updateWoodLore(PotionMeta meta) {
- if (currentRecipe.getWood() > 0) {
- int quality = ingredients.getWoodQuality(currentRecipe, wood);
- addOrReplaceLore(meta, getQualityColor(quality), P.p.languageReader.get("Brew_Woodtype"));
- } else if (meta.hasLore()) {
- List existingLore = meta.getLore();
- int index = indexOfSubstring(existingLore, P.p.languageReader.get("Brew_Woodtype"));
- if (index > -1) {
- existingLore.remove(index);
- meta.setLore(existingLore);
- }
- }
- }
+ // updates/sets the color on WoodLore
+ public void updateWoodLore(PotionMeta meta) {
+ if (currentRecipe.getWood() > 0) {
+ int quality = ingredients.getWoodQuality(currentRecipe, wood);
+ addOrReplaceLore(meta, getQualityColor(quality), P.p.languageReader.get("Brew_Woodtype"));
+ } else if (meta.hasLore()) {
+ List existingLore = meta.getLore();
+ int index = indexOfSubstring(existingLore, P.p.languageReader.get("Brew_Woodtype"));
+ if (index > -1) {
+ existingLore.remove(index);
+ meta.setLore(existingLore);
+ }
+ }
+ }
- // Adds or replaces a line of Lore. Searches for Substring lore and replaces it
- public static void addOrReplaceLore(PotionMeta meta, String prefix, String lore) {
- if (meta.hasLore()) {
- List existingLore = meta.getLore();
- int index = indexOfSubstring(existingLore, lore);
- if (index > -1) {
- existingLore.set(index, prefix + lore);
- } else {
- existingLore.add(prefix + lore);
- }
- meta.setLore(existingLore);
- return;
- }
- List newLore = new ArrayList();
- newLore.add("");
- newLore.add(prefix + lore);
- meta.setLore(newLore);
- }
+ // Adds or replaces a line of Lore. Searches for Substring lore and replaces it
+ public static void addOrReplaceLore(PotionMeta meta, String prefix, String lore) {
+ if (meta.hasLore()) {
+ List existingLore = meta.getLore();
+ int index = indexOfSubstring(existingLore, lore);
+ if (index > -1) {
+ existingLore.set(index, prefix + lore);
+ } else {
+ existingLore.add(prefix + lore);
+ }
+ meta.setLore(existingLore);
+ return;
+ }
+ List newLore = new ArrayList();
+ newLore.add("");
+ newLore.add(prefix + lore);
+ meta.setLore(newLore);
+ }
- // Adds the Effect names to the Items description
- public static void addOrReplaceEffects(PotionMeta meta, ArrayList effects, int quality) {
- if (effects != null) {
- for (BEffect effect : effects) {
- if (!effect.isHidden()) {
- effect.writeInto(meta, quality);
- }
- }
- }
- }
+ // Adds the Effect names to the Items description
+ public static void addOrReplaceEffects(PotionMeta meta, ArrayList effects, int quality) {
+ if (effects != null) {
+ for (BEffect effect : effects) {
+ if (!effect.isHidden()) {
+ effect.writeInto(meta, quality);
+ }
+ }
+ }
+ }
- // Removes all effects except regeneration which stores data
- public static void removeEffects(PotionMeta meta) {
- if (meta.hasCustomEffects()) {
- for (PotionEffect effect : meta.getCustomEffects()) {
- PotionEffectType type = effect.getType();
- if (!type.equals(PotionEffectType.REGENERATION)) {
- meta.removeCustomEffect(type);
- }
- }
- }
- }
+ // Removes all effects except regeneration which stores data
+ public static void removeEffects(PotionMeta meta) {
+ if (meta.hasCustomEffects()) {
+ for (PotionEffect effect : meta.getCustomEffects()) {
+ PotionEffectType type = effect.getType();
+ if (!type.equals(PotionEffectType.REGENERATION)) {
+ meta.removeCustomEffect(type);
+ }
+ }
+ }
+ }
- // Returns the Index of a String from the list that contains this substring
- public static int indexOfSubstring(List list, String substring) {
- for (int index = 0; index < list.size(); index++) {
- String string = list.get(index);
- if (string.contains(substring)) {
- return index;
- }
- }
- return -1;
- }
+ // Returns the Index of a String from the list that contains this substring
+ public static int indexOfSubstring(List list, String substring) {
+ for (int index = 0; index < list.size(); index++) {
+ String string = list.get(index);
+ if (string.contains(substring)) {
+ return index;
+ }
+ }
+ return -1;
+ }
- // True if the PotionMeta has colored Lore
- public static Boolean hasColorLore(PotionMeta meta) {
- return meta.hasLore() && !meta.getLore().get(1).startsWith(P.p.color("&7"));
- }
+ // True if the PotionMeta has colored Lore
+ public static Boolean hasColorLore(PotionMeta meta) {
+ return meta.hasLore() && !meta.getLore().get(1).startsWith(P.p.color("&7"));
+ }
- // gets the Color that represents a quality in Lore
- public static String getQualityColor(int quality) {
- String color;
- if (quality > 8) {
- color = "&a";
- } else if (quality > 6) {
- color = "&e";
- } else if (quality > 4) {
- color = "&6";
- } else if (quality > 2) {
- color = "&c";
- } else {
- color = "&4";
- }
- return P.p.color(color);
- }
+ // gets the Color that represents a quality in Lore
+ public static String getQualityColor(int quality) {
+ String color;
+ if (quality > 8) {
+ color = "&a";
+ } else if (quality > 6) {
+ color = "&e";
+ } else if (quality > 4) {
+ color = "&6";
+ } else if (quality > 2) {
+ color = "&c";
+ } else {
+ color = "&4";
+ }
+ return P.p.color(color);
+ }
- // Saves all data
- public static void save(ConfigurationSection config) {
- for (Map.Entry entry : potions.entrySet()) {
- int uid = entry.getKey();
- Brew brew = entry.getValue();
- ConfigurationSection idConfig = config.createSection("" + uid);
- // not saving unneccessary data
- if (brew.quality != 0) {
- idConfig.set("quality", brew.quality);
- }
- if (brew.distillRuns != 0) {
- idConfig.set("distillRuns", brew.distillRuns);
- }
- if (brew.ageTime != 0) {
- idConfig.set("ageTime", brew.ageTime);
- }
- if (brew.wood != -1) {
- idConfig.set("wood", brew.wood);
- }
- if (brew.currentRecipe != null) {
- idConfig.set("recipe", brew.currentRecipe.getName(5));
- }
- if (brew.unlabeled) {
- idConfig.set("unlabeled", true);
- }
- if (brew.persistent) {
- idConfig.set("persist", true);
- }
- if (brew.stat) {
- idConfig.set("stat", true);
- }
- // save the ingredients
- idConfig.set("ingId", brew.ingredients.save(config.getParent()));
- }
- }
+ // Saves all data
+ public static void save(ConfigurationSection config) {
+ for (Map.Entry entry : potions.entrySet()) {
+ int uid = entry.getKey();
+ Brew brew = entry.getValue();
+ ConfigurationSection idConfig = config.createSection("" + uid);
+ // not saving unneccessary data
+ if (brew.quality != 0) {
+ idConfig.set("quality", brew.quality);
+ }
+ if (brew.distillRuns != 0) {
+ idConfig.set("distillRuns", brew.distillRuns);
+ }
+ if (brew.ageTime != 0) {
+ idConfig.set("ageTime", brew.ageTime);
+ }
+ if (brew.wood != -1) {
+ idConfig.set("wood", brew.wood);
+ }
+ if (brew.currentRecipe != null) {
+ idConfig.set("recipe", brew.currentRecipe.getName(5));
+ }
+ if (brew.unlabeled) {
+ idConfig.set("unlabeled", true);
+ }
+ if (brew.persistent) {
+ idConfig.set("persist", true);
+ }
+ if (brew.stat) {
+ idConfig.set("stat", true);
+ }
+ // save the ingredients
+ idConfig.set("ingId", brew.ingredients.save(config.getParent()));
+ }
+ }
- public static enum PotionColor {
- PINK(1, PotionEffectType.REGENERATION),
- CYAN(2, PotionEffectType.SPEED),
- ORANGE(3, PotionEffectType.FIRE_RESISTANCE),
- GREEN(4, PotionEffectType.POISON),
- BRIGHT_RED(5, PotionEffectType.HEAL),
- BLUE(6, PotionEffectType.NIGHT_VISION),
- BLACK(8, PotionEffectType.WEAKNESS),
- RED(9, PotionEffectType.INCREASE_DAMAGE),
- GREY(10, PotionEffectType.SLOW),
- WATER(11, PotionEffectType.WATER_BREATHING),
- DARK_RED(12, PotionEffectType.HARM),
- BRIGHT_GREY(14, PotionEffectType.INVISIBILITY);
+ public static enum PotionColor {
+ PINK(1, PotionEffectType.REGENERATION),
+ CYAN(2, PotionEffectType.SPEED),
+ ORANGE(3, PotionEffectType.FIRE_RESISTANCE),
+ GREEN(4, PotionEffectType.POISON),
+ BRIGHT_RED(5, PotionEffectType.HEAL),
+ BLUE(6, PotionEffectType.NIGHT_VISION),
+ BLACK(8, PotionEffectType.WEAKNESS),
+ RED(9, PotionEffectType.INCREASE_DAMAGE),
+ GREY(10, PotionEffectType.SLOW),
+ WATER(11, PotionEffectType.WATER_BREATHING),
+ DARK_RED(12, PotionEffectType.HARM),
+ BRIGHT_GREY(14, PotionEffectType.INVISIBILITY);
- private final int colorId;
- private final PotionEffectType effect;
+ private final int colorId;
+ private final PotionEffectType effect;
- private PotionColor(int colorId, PotionEffectType effect) {
- this.colorId = colorId;
- this.effect = effect;
- }
+ private PotionColor(int colorId, PotionEffectType effect) {
+ this.colorId = colorId;
+ this.effect = effect;
+ }
- // gets the Damage Value, that sets a color on the potion
- // offset +32 is not accepted by brewer, so not further destillable
- public short getColorId(boolean destillable) {
- if (destillable) {
- return (short) (colorId + 64);
- }
- return (short) (colorId + 32);
- }
+ // gets the Damage Value, that sets a color on the potion
+ // offset +32 is not accepted by brewer, so not further destillable
+ public short getColorId(boolean destillable) {
+ if (destillable) {
+ return (short) (colorId + 64);
+ }
+ return (short) (colorId + 32);
+ }
- public PotionEffectType getEffect() {
- return effect;
- }
+ public PotionEffectType getEffect() {
+ return effect;
+ }
- }
+ }
}
diff --git a/src/com/dre/brewery/integration/GriefPreventionBarrel.java b/src/com/dre/brewery/integration/GriefPreventionBarrel.java
index bbd8978..421c42f 100644
--- a/src/com/dre/brewery/integration/GriefPreventionBarrel.java
+++ b/src/com/dre/brewery/integration/GriefPreventionBarrel.java
@@ -9,39 +9,39 @@ import org.bukkit.entity.Player;
public class GriefPreventionBarrel {
- static P brewery = P.p;
- static GriefPrevention griefPrevention = GriefPrevention.instance;
+ static P brewery = P.p;
+ static GriefPrevention griefPrevention = GriefPrevention.instance;
- public static boolean checkAccess(Player player, Block sign) {
- PlayerData playerData = griefPrevention.dataStore.getPlayerData(player.getUniqueId());
+ public static boolean checkAccess(Player player, Block sign) {
+ PlayerData playerData = griefPrevention.dataStore.getPlayerData(player.getUniqueId());
- if (!griefPrevention.claimsEnabledForWorld(player.getWorld()) || playerData.ignoreClaims || !griefPrevention.config_claims_preventTheft) {
- return true;
- }
+ if (!griefPrevention.claimsEnabledForWorld(player.getWorld()) || playerData.ignoreClaims || !griefPrevention.config_claims_preventTheft) {
+ return true;
+ }
- // block container use during pvp combat
- if (playerData.inPvpCombat()) {
- brewery.msg(player, brewery.languageReader.get("Error_NoBarrelAccess"));
- return false;
- }
+ // block container use during pvp combat
+ if (playerData.inPvpCombat()) {
+ brewery.msg(player, brewery.languageReader.get("Error_NoBarrelAccess"));
+ return false;
+ }
- // check permissions for the claim the Barrel is in
- Claim claim = griefPrevention.dataStore.getClaimAt(sign.getLocation(), false, playerData.lastClaim);
- if (claim != null) {
- playerData.lastClaim = claim;
- String noContainersReason = claim.allowContainers(player);
- if (noContainersReason != null) {
- brewery.msg(player, brewery.languageReader.get("Error_NoBarrelAccess"));
- return false;
- }
- }
+ // check permissions for the claim the Barrel is in
+ Claim claim = griefPrevention.dataStore.getClaimAt(sign.getLocation(), false, playerData.lastClaim);
+ if (claim != null) {
+ playerData.lastClaim = claim;
+ String noContainersReason = claim.allowContainers(player);
+ if (noContainersReason != null) {
+ brewery.msg(player, brewery.languageReader.get("Error_NoBarrelAccess"));
+ return false;
+ }
+ }
- // drop any pvp protection, as the player opens a barrel
- if (playerData.pvpImmune) {
- playerData.pvpImmune = false;
- }
+ // drop any pvp protection, as the player opens a barrel
+ if (playerData.pvpImmune) {
+ playerData.pvpImmune = false;
+ }
- return true;
- }
+ return true;
+ }
}
diff --git a/src/com/dre/brewery/listeners/Compat1_9.java b/src/com/dre/brewery/listeners/Compat1_9.java
index bc8686b..c42fca8 100644
--- a/src/com/dre/brewery/listeners/Compat1_9.java
+++ b/src/com/dre/brewery/listeners/Compat1_9.java
@@ -11,21 +11,21 @@ import org.bukkit.inventory.meta.PotionMeta;
// Workaround to remove unwanted potion effects
public class Compat1_9 implements Listener {
- @EventHandler
- public void onPlayerDrink(PlayerItemConsumeEvent event) {
- ItemStack item = event.getItem();
- Brew brew = Brew.get(item);
- if (brew == null) {
- return;
- }
+ @EventHandler
+ public void onPlayerDrink(PlayerItemConsumeEvent event) {
+ ItemStack item = event.getItem();
+ Brew brew = Brew.get(item);
+ if (brew == null) {
+ return;
+ }
- if (item.getType() == Material.POTION) {
- try {
- PotionMeta meta = (PotionMeta) item.getItemMeta();
- meta.setMainEffect(null);
- item.setItemMeta(meta);
- } catch (Exception exception) {}
- }
- }
+ if (item.getType() == Material.POTION) {
+ try {
+ PotionMeta meta = (PotionMeta) item.getItemMeta();
+ meta.setMainEffect(null);
+ item.setItemMeta(meta);
+ } catch (Exception exception) {}
+ }
+ }
}