From ea06f2d707eb4599b91296263b867f208743049a Mon Sep 17 00:00:00 2001 From: Sn0wStorm Date: Fri, 30 Aug 2013 21:19:49 +0200 Subject: [PATCH] Added cmd Unlabel & Several Fixes --- config.yml | 14 +- readme.md | 6 + src/com/dre/brewery/BIngredients.java | 6 +- src/com/dre/brewery/BPlayer.java | 60 +++-- src/com/dre/brewery/BRecipe.java | 4 +- src/com/dre/brewery/Barrel.java | 13 +- src/com/dre/brewery/Brew.java | 238 ++++++++++-------- src/com/dre/brewery/P.java | 3 +- .../dre/brewery/listeners/BlockListener.java | 10 +- .../brewery/listeners/CommandListener.java | 32 +++ .../brewery/listeners/InventoryListener.java | 10 +- 11 files changed, 245 insertions(+), 151 deletions(-) diff --git a/config.yml b/config.yml index 8c4c21d..a34a0de 100644 --- a/config.yml +++ b/config.yml @@ -41,7 +41,7 @@ drainItems: # Färben der Iteminformationen je nach Qualität während sie sich 1. im Fass und/oder 2. im Braustand befinden colorInBarrels: true -colorInBrewer: true +colorInBrewer: false # Autosave Intervall in Minuten autosave: 3 @@ -49,11 +49,11 @@ autosave: 3 # Rezepte für Getränke -# name: Verschiedene Namen für schlecht/mittel/gut +# name: Verschiedene Namen für schlecht/mittel/gut (Farbcodes möglich: z.b. &6) # ingredients: Auflistung von material/Anzahl # cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen -# distillruns: Wie oft destilliert werden muss 0-10 (0=ohne Destillieren) -# wood: Holz des Fasses 0=alle Holzsorten 1=Birch 2=Oak 3=Jungle 4=Pine +# distillruns: Wie oft destilliert werden muss für vollen Alkoholgehalt (0=ohne Destillieren) +# wood: Holz des Fasses 0=alle Holzsorten 1=Birch 2=Oak 3=Jungle 4=Spruce # age: Zeit in Minecraft-Tagen, die das Getränk im Fass reifen muss 0= kein reifen # color: Farbe des Getränks nach destillieren/reifen. DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY # difficulty: 1-10 Genauigkeit der Einhaltung der Vorgaben (1 = ungenau/einfach 10 = sehr genau/schwer) @@ -97,7 +97,7 @@ recipes: difficulty: 2 alcohol: 7 4: - name: Scheußlicher Met/Met/Goldener Met + name: Scheußlicher Met/Met/&6Goldener Met ingredients: - SUGAR_CANE/6 cookingtime: 3 @@ -108,7 +108,7 @@ recipes: difficulty: 2 alcohol: 9 5: - name: Apfelmet/Süßer Apfelmet/Goldensüßer Apfelmet + name: Apfelmet/Süßer Apfelmet/&6Goldensüßer Apfelmet ingredients: - SUGAR_CANE/6 - APPLE/2 @@ -122,7 +122,7 @@ recipes: effects: - WATER_BREATHINGX/150 6: - name: Bitterer Rum/Würziger Rum/Goldener Rum + name: Bitterer Rum/Würziger Rum/&6Goldener Rum ingredients: - SUGAR_CANE/14 cookingtime: 5 diff --git a/readme.md b/readme.md index 987d08e..be2dca2 100644 --- a/readme.md +++ b/readme.md @@ -64,6 +64,9 @@ Auch hier können anhand der Erklärungen und Beispiele bestehende "Wörter" ver /br [Spieler] [Trunkenheit] [Qualität]Setzen der Spielerwerte. Trunkenheit in %, Qualität von 1-10. + + /br UnLabelVersteckt die genauen Zahlen in der Beschriftung des Trankes in der Hand unwiederbringlich + /br Copy [Anzahl]Kopiert den Trank in der Hand. Optional kann die Anzahl angegeben werden @@ -99,6 +102,9 @@ Auch hier können anhand der Erklärungen und Beispiele bestehende "Wörter" ver PermissionErmöglichter BefehlBeschreibung + + brewery.cmd.unlabelUnLabelTeile der Trankbeschriftung verstecken + brewery.cmd.infoInfoInformationen über die eigene Trunkenheit diff --git a/src/com/dre/brewery/BIngredients.java b/src/com/dre/brewery/BIngredients.java index f52fc95..b85c967 100644 --- a/src/com/dre/brewery/BIngredients.java +++ b/src/com/dre/brewery/BIngredients.java @@ -139,8 +139,8 @@ public class BIngredients { // needs riping in barrel ageQuality = getAgeQuality(recipe, time); woodQuality = getWoodQuality(recipe, wood); - P.p.log("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " Wood Quality: " + getWoodQuality(recipe, wood) + - " age Quality: " + getAgeQuality(recipe, time) + " for " + recipe.getName(5)); + P.p.log("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " Wood Quality: " + woodQuality + + " age Quality: " + ageQuality + " for " + recipe.getName(5)); // is this recipe better than the previous best? if ((((float) ingredientQuality + cookingQuality + woodQuality + ageQuality) / 4) > quality) { @@ -269,7 +269,7 @@ public class BIngredients { // type of wood doesnt matter return 10; } - int quality = 10 - (int) Math.round(recipe.getWoodDiff(wood) * recipe.getDifficulty()); + int quality = 10 - (recipe.getWoodDiff(wood) * recipe.getDifficulty()); if (quality > 0) { return quality; diff --git a/src/com/dre/brewery/BPlayer.java b/src/com/dre/brewery/BPlayer.java index 5f19189..e86f874 100644 --- a/src/com/dre/brewery/BPlayer.java +++ b/src/com/dre/brewery/BPlayer.java @@ -73,8 +73,9 @@ public class BPlayer { return org.bukkit.Bukkit.getPlayer(getPlayerName()); }*/ + // returns the Player if online public static Player getPlayer(String name) { - return org.bukkit.Bukkit.getPlayer(name); + return org.bukkit.Bukkit.getPlayerExact(name); } // returns true if drinking was successful @@ -93,14 +94,16 @@ public class BPlayer { players.put(player.getName(), bPlayer); } bPlayer.drunkeness += brewAlc; - bPlayer.quality += brew.getQuality() * brewAlc; + if (brew.getQuality() > 0) { + bPlayer.quality += brew.getQuality() * brewAlc; + } else { + bPlayer.quality += brewAlc; + } if (bPlayer.drunkeness <= 100) { addBrewEffects(brew, player); - if (brew.getQuality() < 5) { - addQualityEffects(brew.getQuality(), brewAlc, player); - } + addQualityEffects(brew.getQuality(), brewAlc, player); } else { bPlayer.drinkCap(player); @@ -196,6 +199,9 @@ public class BPlayer { passedOut = true; } + + // #### Login #### + // can the player login or is he too drunk public int canJoin() { if (drunkeness <= 70) { @@ -290,13 +296,8 @@ public class BPlayer { } } - public void hangoverEffects(final Player player) { - int duration = offlineDrunk * 50 * getHangoverQuality(); - int amplifier = getHangoverQuality() / 3; - PotionEffectType.SLOW.createEffect(duration, amplifier).apply(player); - PotionEffectType.HUNGER.createEffect(duration, amplifier).apply(player); - } + // #### Puking #### // Chance that players puke on big drunkeness // runs every 6 sec, average chance is 10%, so should puke about every 60 sec @@ -358,6 +359,9 @@ public class BPlayer { item.setPickupDelay(Integer.MAX_VALUE); } + + // #### Effects #### + public void drunkEffects(Player player) { int duration = 10 - getQuality(); duration += drunkeness / 2; @@ -372,17 +376,21 @@ public class BPlayer { public static void addQualityEffects(int quality, int brewAlc, Player player) { int duration = 7 - quality; - duration *= 250; - PotionEffectType.BLINDNESS.createEffect(duration, 0).apply(player); - - if (brewAlc > 15) { - duration = 10 - quality; - duration += brewAlc; - duration *= 40; + if (quality <= 5) { + duration *= 250; } else { duration = 200; } PotionEffectType.POISON.createEffect(duration, 0).apply(player); + + if (brewAlc > 10 && quality <= 5) { + duration = 10 - quality; + duration += brewAlc; + duration *= 60; + } else { + duration = 240; + } + PotionEffectType.BLINDNESS.createEffect(duration, 0).apply(player); } public static void addBrewEffects(Brew brew, Player player) { @@ -396,6 +404,7 @@ public class BPlayer { type.createEffect(0, duration - 1).apply(player); } else { int amplifier = brew.getQuality() / 3; + duration /= type.getDurationModifier(); type.createEffect(duration * 20, amplifier).apply(player); } } @@ -403,6 +412,17 @@ public class BPlayer { } } + public void hangoverEffects(final Player player) { + int duration = offlineDrunk * 50 * getHangoverQuality(); + int amplifier = getHangoverQuality() / 3; + + PotionEffectType.SLOW.createEffect(duration, amplifier).apply(player); + PotionEffectType.HUNGER.createEffect(duration, amplifier).apply(player); + } + + + // #### Sheduled #### + public static void drunkeness() { for (String name : players.keySet()) { BPlayer bplayer = players.get(name); @@ -458,7 +478,9 @@ public class BPlayer { } } - // getter + + // #### getter/setter #### + public int getDrunkeness() { return drunkeness; } diff --git a/src/com/dre/brewery/BRecipe.java b/src/com/dre/brewery/BRecipe.java index d1c489d..bc5415b 100644 --- a/src/com/dre/brewery/BRecipe.java +++ b/src/com/dre/brewery/BRecipe.java @@ -84,7 +84,7 @@ public class BRecipe { } // difference between given and recipe-wanted woodtype - public float getWoodDiff(byte wood) { + public int getWoodDiff(byte wood) { int woodType = 0; if (wood == 0x0) { woodType = 2; @@ -95,7 +95,7 @@ public class BRecipe { } else if (wood == 0x3) { woodType = 3; } - return Math.abs(woodType - wood); + return Math.abs(woodType - this.wood); } public boolean isCookingOnly() { diff --git a/src/com/dre/brewery/Barrel.java b/src/com/dre/brewery/Barrel.java index fa17d3b..6a01f94 100644 --- a/src/com/dre/brewery/Barrel.java +++ b/src/com/dre/brewery/Barrel.java @@ -79,13 +79,13 @@ public class Barrel { if (inventory.getViewers().isEmpty()) { // if inventory contains potions if (inventory.contains(373)) { + byte wood = getWood(); long loadTime = System.nanoTime(); for (ItemStack item : inventory.getContents()) { if (item != null) { - if (item.getTypeId() == 373) { - if (item.hasItemMeta()) { - Brew.age(item, time, getWood()); - } + Brew brew = Brew.get(item); + if (brew != null) { + brew.age(item, time, wood); } } } @@ -129,9 +129,10 @@ public class Barrel { ItemStack[] items = inventory.getContents(); for (ItemStack item : items) { if (item != null) { - if (item.getTypeId() == 373) { + Brew brew = Brew.get(item); + if (brew != null) { // Brew before throwing - Brew.age(item, time, getWood()); + brew.age(item, time, getWood()); } // "broken" is the block that destroyed, throw them there! if (broken != null) { diff --git a/src/com/dre/brewery/Brew.java b/src/com/dre/brewery/Brew.java index f8a70c9..7daf187 100644 --- a/src/com/dre/brewery/Brew.java +++ b/src/com/dre/brewery/Brew.java @@ -29,6 +29,7 @@ public class Brew { private int distillRuns; private float ageTime; private BRecipe currentRecipe; + private boolean unlabeled; public Brew(int uid, BIngredients ingredients) { this.ingredients = ingredients; @@ -44,12 +45,13 @@ public class Brew { } // loading from file - public Brew(int uid, BIngredients ingredients, int quality, int distillRuns, float ageTime, String recipe) { + public Brew(int uid, BIngredients ingredients, int quality, int distillRuns, float ageTime, String recipe, Boolean unlabeled) { this.ingredients = ingredients; this.quality = quality; this.distillRuns = distillRuns; this.ageTime = ageTime; this.currentRecipe = BIngredients.getRecipeByName(recipe); + this.unlabeled = unlabeled; potions.put(uid, this); } @@ -133,21 +135,38 @@ public class Brew { Brew brew = new Brew(uid, quality, currentRecipe, ingredients); brew.distillRuns = distillRuns; brew.ageTime = ageTime; + brew.unlabeled = unlabeled; return brew; } // calculate alcohol from recipe public int calcAlcohol() { + if (quality == 0) { + // Give bad potions some alc + if (distillRuns > 1) { + return distillRuns; + } else { + return 1; + } + } if (currentRecipe != null) { int alc = currentRecipe.getAlcohol(); - alc *= ((float) quality / 10.0); if (currentRecipe.needsDistilling()) { - // distillable Potions should have full alc after 6 distills - float factor = 1.4F / (distillRuns + 1); - factor += 0.8; - alc /= factor; + 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 alc; } return 0; } @@ -171,24 +190,37 @@ public class Brew { } public boolean canDistill() { - if (distillRuns >= 6) { + if (currentRecipe != null) { + return currentRecipe.getDistillRuns() > distillRuns; + } else if (distillRuns >= 6) { return false; - } else { - if (currentRecipe != null) { - return currentRecipe.needsDistilling(); - } } return true; } // return special effect public Map getEffects() { - if (currentRecipe != null) { + 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"), "Destilliert"); + } + if (ageTime >= 1) { + addOrReplaceLore(meta, P.p.color("&7"), "Fassgereift"); + } + item.setItemMeta(meta); + } + unlabeled = true; + } + // Distilling section --------------- // distill all custom potions in the brewer @@ -196,104 +228,87 @@ public class Brew { int slot = 0; while (slot < 3) { if (contents[slot]) { - distillSlot(inv, 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 static void distillSlot(BrewerInventory inv, int slot) { - ItemStack slotItem = inv.getItem(slot); - PotionMeta potionMeta = (PotionMeta) slotItem.getItemMeta(); - Brew brew = get(potionMeta); - BRecipe recipe = brew.ingredients.getdistillRecipe(); - + public void distillSlot(ItemStack slotItem, PotionMeta potionMeta) { + distillRuns += 1; + BRecipe recipe = ingredients.getdistillRecipe(); if (recipe != null) { // distillRuns will have an effect on the amount of alcohol, not the quality - brew.quality = brew.calcQuality(recipe, (byte) 0, true); - brew.distillRuns += 1; - brew.currentRecipe = recipe; + quality = calcQuality(recipe, (byte) 0, true); + currentRecipe = recipe; + P.p.log("destilled " + recipe.getName(5) + " has Quality: " + quality + ", alc: " + calcAlcohol()); - // Distill Lore - if (colorInBrewer != hasColorLore(potionMeta)) { - brew.convertLore(potionMeta, colorInBrewer); - } else { - String prefix = P.p.color("&7"); - if (colorInBrewer) { - prefix = getQualityColor(brew.ingredients.getDistillQuality(recipe, brew.distillRuns)); - } - brew.updateDistillLore(prefix, potionMeta); - } - addOrReplaceEffects(potionMeta, brew.getEffects()); - - P.p.log("destilled " + recipe.getName(5) + " has Quality: " + brew.quality + ", alc: " + brew.calcAlcohol()); - - potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(brew.quality))); - - // if the potion should be further distillable - if (recipe.getDistillRuns() > 1 && brew.distillRuns <= 5) { - slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(true)); - } else { - slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(false)); - } + addOrReplaceEffects(potionMeta, getEffects()); + potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality))); + slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill())); } else { + quality = 0; potionMeta.setDisplayName(P.p.color("&f" + "Undefinierbares Destillat")); - slotItem.setDurability(PotionColor.GREY.getColorId(brew.distillRuns <= 5)); + 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); + slotItem.setItemMeta(potionMeta); } // Ageing Section ------------------ - public static void age(ItemStack item, float time, byte wood) { + public void age(ItemStack item, float time, byte wood) { PotionMeta potionMeta = (PotionMeta) item.getItemMeta(); - Brew brew = get(potionMeta); - if (brew != null) { - brew.ageTime += time; - // if younger than half a day, it shouldnt get aged form - if (brew.ageTime > 0.5) { - BRecipe recipe = brew.ingredients.getAgeRecipe(wood, brew.ageTime, brew.distillRuns > 0); - if (recipe != null) { - brew.quality = brew.calcQuality(recipe, wood, brew.distillRuns > 0); - brew.currentRecipe = recipe; - P.p.log("Final " + recipe.getName(5) + " has Quality: " + brew.quality); + ageTime += time; + + // if younger than half a day, it shouldnt get aged form + if (ageTime > 0.5) { + BRecipe recipe = ingredients.getAgeRecipe(wood, ageTime, distillRuns > 0); + if (recipe != null) { + currentRecipe = recipe; + quality = calcQuality(recipe, wood, distillRuns > 0); + P.p.log("Final " + recipe.getName(5) + " has Quality: " + quality + ", alc: " + calcAlcohol()); - potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(brew.quality))); - item.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(false)); - } - } - - // Lore - if (colorInBarrels != hasColorLore(potionMeta)) { - brew.convertLore(potionMeta, colorInBarrels); + addOrReplaceEffects(potionMeta, getEffects()); + potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality))); + item.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill())); } else { - if (brew.ageTime >= 1) { - String prefix = P.p.color("&7"); - if (colorInBarrels) { - prefix = getQualityColor(brew.ingredients.getAgeQuality(brew.currentRecipe, brew.ageTime)); - } - brew.updateAgeLore(prefix, potionMeta); - addOrReplaceEffects(potionMeta, brew.getEffects()); - } + quality = 0; + potionMeta.setDisplayName(P.p.color("&f" + "Verdorbenes Getränk")); + item.setDurability(PotionColor.GREY.getColorId(canDistill())); } - item.setItemMeta(potionMeta); } - } - public static void addOrReplaceEffects(PotionMeta meta, Map effects) { - if (effects != null) { - for (Map.Entry entry : effects.entrySet()) { - if (!entry.getKey().endsWith("X")) { - PotionEffectType type = PotionEffectType.getByName(entry.getKey()); - if (type != null) { - meta.addCustomEffect(type.createEffect(0, 0), true); - } - } + // 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); + } + item.setItemMeta(potionMeta); } // Lore ----------- @@ -303,17 +318,13 @@ public class Brew { if (currentRecipe == null) { return; } - if (meta == null) { - P.p.log("has no meta"); - return; - } meta.setLore(null); - - // Ingredients int quality; String prefix = P.p.color("&7"); String lore; - if (toQuality) { + + // Ingredients + if (toQuality && !unlabeled) { quality = ingredients.getIngredientQuality(currentRecipe); prefix = getQualityColor(quality); lore = "Zutaten"; @@ -321,7 +332,7 @@ public class Brew { } // Cooking - if (toQuality) { + if (toQuality && !unlabeled) { if (distillRuns > 0 == currentRecipe.needsDistilling()) { quality = ingredients.getCookingQuality(currentRecipe, distillRuns > 0); prefix = getQualityColor(quality) + ingredients.getCookedTime() + " minute"; @@ -354,22 +365,26 @@ public class Brew { // sets the DistillLore. Prefix is the color to be used public void updateDistillLore(String prefix, PotionMeta meta) { - if (distillRuns > 1) { - prefix = prefix + distillRuns + "-fach "; + if (!unlabeled) { + if (distillRuns > 1) { + prefix = prefix + distillRuns + "-fach "; + } } - addOrReplaceLore(meta, prefix, "destilliert"); + addOrReplaceLore(meta, prefix, "Destilliert"); } // sets the AgeLore. Prefix is the color to be used public void updateAgeLore(String prefix, PotionMeta meta) { - if (ageTime >= 1 && ageTime < 2) { - prefix = prefix + "Ein Jahr"; - } else if (ageTime < 201) { - prefix = prefix + (int) Math.floor(ageTime) + " Jahre"; - } else { - prefix = prefix + "Hunderte Jahre"; + if (!unlabeled) { + if (ageTime >= 1 && ageTime < 2) { + prefix = prefix + "Ein Jahr "; + } else if (ageTime < 201) { + prefix = prefix + (int) Math.floor(ageTime) + " Jahre "; + } else { + prefix = prefix + "Hunderte Jahre "; + } } - addOrReplaceLore(meta, prefix, " Fassgereift"); + addOrReplaceLore(meta, prefix, "Fassgereift"); } // Adds or replaces a line of Lore. Searches for Substring lore and replaces it @@ -391,6 +406,20 @@ public class Brew { meta.setLore(newLore); } + // Adds the Effect names to the Items description + public static void addOrReplaceEffects(PotionMeta meta, Map effects) { + if (effects != null) { + for (Map.Entry entry : effects.entrySet()) { + if (!entry.getKey().endsWith("X")) { + PotionEffectType type = PotionEffectType.getByName(entry.getKey()); + if (type != null) { + meta.addCustomEffect(type.createEffect(0, 0), true); + } + } + } + } + } + // 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++) { @@ -445,6 +474,9 @@ public class Brew { if (brew.currentRecipe != null) { idConfig.set("recipe", brew.currentRecipe.getName(5)); } + if (brew.unlabeled) { + idConfig.set("unlabeled", true); + } // save the ingredients brew.ingredients.save(idConfig.createSection("ingredients")); } diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index 15e3caa..8326aa8 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -200,8 +200,9 @@ public class P extends JavaPlugin { int distillRuns = section.getInt(uid + ".distillRuns", 0); float ageTime = (float) section.getDouble(uid + ".ageTime", 0.0); String recipe = section.getString(uid + ".recipe", null); + Boolean unlabeled = section.getBoolean(uid + ".unlabeled", false); - new Brew(parseInt(uid), ingredients, quality, distillRuns, ageTime, recipe); + new Brew(parseInt(uid), ingredients, quality, distillRuns, ageTime, recipe, unlabeled); } } diff --git a/src/com/dre/brewery/listeners/BlockListener.java b/src/com/dre/brewery/listeners/BlockListener.java index 50bbd96..03062cb 100644 --- a/src/com/dre/brewery/listeners/BlockListener.java +++ b/src/com/dre/brewery/listeners/BlockListener.java @@ -7,7 +7,6 @@ import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import com.dre.brewery.BCauldron; import com.dre.brewery.Barrel; @@ -31,12 +30,9 @@ public class BlockListener implements Listener { Block block = event.getBlock(); // remove cauldron if (block.getType() == Material.CAULDRON) { - if (block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || block.getRelative(BlockFace.DOWN).getType() == Material.STATIONARY_LAVA - || block.getRelative(BlockFace.DOWN).getType() == Material.LAVA) { - if (block.getData() != 0) { - // will only remove when existing - BCauldron.remove(block); - } + if (block.getData() != 0) { + // will only remove when existing + BCauldron.remove(block); } // remove barrel and throw potions on the ground } else if (block.getType() == Material.FENCE || block.getType() == Material.NETHER_FENCE) { diff --git a/src/com/dre/brewery/listeners/CommandListener.java b/src/com/dre/brewery/listeners/CommandListener.java index e18ad0e..6823c10 100644 --- a/src/com/dre/brewery/listeners/CommandListener.java +++ b/src/com/dre/brewery/listeners/CommandListener.java @@ -86,6 +86,14 @@ public class CommandListener implements CommandExecutor { p.msg(sender, "&cDu hast keine Rechte dies zu tun!"); } + } else if (cmd.equalsIgnoreCase("unlabel")) { + + if (p.permission.has(sender, "brewery.cmd.unlabel")) { + cmdUnlabel(sender); + } else { + p.msg(sender, "&cDu hast keine Rechte dies zu tun!"); + } + } else { if (p.getServer().getPlayerExact(cmd) != null || BPlayer.players.containsKey(cmd)) { @@ -143,6 +151,10 @@ public class CommandListener implements CommandExecutor { cmds.add ("&6/br Info&9 Zeigt deine aktuelle Trunkenheit und Qualität an"); } + if (p.permission.has(sender, "brewery.cmd.unlabel")) { + cmds.add ("&6/br UnLabel &9Entfernt die genaue Beschriftung des Trankes"); + } + if (p.permission.has(sender, "brewery.cmd.copy")) { cmds.add ("&6/br Copy &9 Kopiert den Trank in deiner Hand"); } @@ -335,4 +347,24 @@ public class CommandListener implements CommandExecutor { } + public void cmdUnlabel(CommandSender sender) { + + if (sender instanceof Player) { + Player player = (Player) sender; + ItemStack hand = player.getItemInHand(); + if (hand != null) { + Brew brew = Brew.get(hand); + if (brew != null) { + brew.unLabel(hand); + p.msg(sender, "&aDas Label wurde entfernt"); + return; + } + } + p.msg(sender, "&cDas Item in deiner Hand konnte nicht als Trank identifiziert werden"); + } else { + p.msg(sender, "&cDieser Befehl kann nur als Spieler ausgeführt werden"); + } + + } + } \ No newline at end of file diff --git a/src/com/dre/brewery/listeners/InventoryListener.java b/src/com/dre/brewery/listeners/InventoryListener.java index 3182bd0..990a675 100644 --- a/src/com/dre/brewery/listeners/InventoryListener.java +++ b/src/com/dre/brewery/listeners/InventoryListener.java @@ -56,10 +56,12 @@ public class InventoryListener implements Listener { if (event.getSlot() > 2) { return; } - } else if (event.getInventory().getType() != InventoryType.CHEST) { + } else if (event.getInventory().getType() == InventoryType.CHEST) { if (!event.getInventory().getTitle().equals("Fass")) { return; } + } else { + return; } ItemStack item = event.getCurrentItem(); @@ -69,8 +71,10 @@ public class InventoryListener implements Listener { PotionMeta meta = (PotionMeta) item.getItemMeta(); Brew brew = Brew.get(meta); if (brew != null) { - brew.convertLore(meta, false); - item.setItemMeta(meta); + if (Brew.hasColorLore(meta)) { + brew.convertLore(meta, false); + item.setItemMeta(meta); + } } } }