mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 07:49:03 +00:00
Fixed Recipes not reloading on cmd
This commit is contained in:
@@ -38,16 +38,6 @@ public class BIngredients {
|
|||||||
lastId++;
|
lastId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns the recipe with the given name
|
|
||||||
public static BRecipe getRecipeByName(String name) {
|
|
||||||
for (BRecipe recipe : recipes) {
|
|
||||||
if (recipe.getName(5).equalsIgnoreCase(name)) {
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add an ingredient to this
|
// Add an ingredient to this
|
||||||
public void add(Material ingredient) {
|
public void add(Material ingredient) {
|
||||||
if (ingredients.containsKey(ingredient)) {
|
if (ingredients.containsKey(ingredient)) {
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ public class Brew {
|
|||||||
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
|
||||||
|
|
||||||
//public static Map<ItemStack, List<String>> oldLore = new HashMap<ItemStack, List<String>>();
|
|
||||||
|
|
||||||
private BIngredients ingredients;
|
private BIngredients ingredients;
|
||||||
private int quality;
|
private int quality;
|
||||||
private int distillRuns;
|
private int distillRuns;
|
||||||
@@ -54,20 +52,7 @@ public class Brew {
|
|||||||
this.ageTime = ageTime;
|
this.ageTime = ageTime;
|
||||||
this.wood = wood;
|
this.wood = wood;
|
||||||
this.unlabeled = unlabeled;
|
this.unlabeled = unlabeled;
|
||||||
if (recipe != null && !recipe.equals("")) {
|
setRecipeFromString(recipe);
|
||||||
currentRecipe = BIngredients.getRecipeByName(recipe);
|
|
||||||
if (currentRecipe == null) {
|
|
||||||
if (quality > 0) {
|
|
||||||
currentRecipe = ingredients.getBestRecipe(wood, ageTime, distillRuns > 0);
|
|
||||||
if (currentRecipe != null) {
|
|
||||||
this.quality = calcQuality();
|
|
||||||
P.p.log("Brew was made from Recipe: '" + recipe + "' which could not be found. '" + currentRecipe.getName(5) + "' used instead!");
|
|
||||||
} else {
|
|
||||||
P.p.errorLog("Brew was made from Recipe: '" + recipe + "' which could not be found!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns a Brew by its UID
|
// returns a Brew by its UID
|
||||||
@@ -133,6 +118,37 @@ public class Brew {
|
|||||||
return uid;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quality > 0) {
|
||||||
|
currentRecipe = ingredients.getBestRecipe(wood, ageTime, distillRuns > 0);
|
||||||
|
if (currentRecipe != null) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy a Brew with a new unique ID and return its item
|
// Copy a Brew with a new unique ID and return its item
|
||||||
public ItemStack copy(ItemStack item) {
|
public ItemStack copy(ItemStack item) {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class P extends JavaPlugin {
|
|||||||
this.log(this.getDescription().getName() + " disabled!");
|
this.log(this.getDescription().getName() + " disabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload() {
|
public void reload(CommandSender sender) {
|
||||||
BIngredients.possibleIngredients.clear();
|
BIngredients.possibleIngredients.clear();
|
||||||
BIngredients.recipes.clear();
|
BIngredients.recipes.clear();
|
||||||
BIngredients.cookedNames.clear();
|
BIngredients.cookedNames.clear();
|
||||||
@@ -105,6 +105,16 @@ public class P extends JavaPlugin {
|
|||||||
BPlayer.drainItems.clear();
|
BPlayer.drainItems.clear();
|
||||||
|
|
||||||
readConfig();
|
readConfig();
|
||||||
|
|
||||||
|
Boolean successful = true;
|
||||||
|
for (Brew brew : Brew.potions.values()) {
|
||||||
|
if (!brew.reloadRecipe()) {
|
||||||
|
successful = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!successful) {
|
||||||
|
msg(sender, "&cEs konnten nicht alle Rezepte wiederhergesellt werden: Siehe Serverlog!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void msg(CommandSender sender, String msg) {
|
public void msg(CommandSender sender, String msg) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class CommandListener implements CommandExecutor {
|
|||||||
} else if (cmd.equalsIgnoreCase("reload")) {
|
} else if (cmd.equalsIgnoreCase("reload")) {
|
||||||
|
|
||||||
if (p.permission.has(sender, "brewery.cmd.reload")) {
|
if (p.permission.has(sender, "brewery.cmd.reload")) {
|
||||||
p.reload();
|
p.reload(sender);
|
||||||
p.msg(sender, "&aConfig wurde neu eingelesen");
|
p.msg(sender, "&aConfig wurde neu eingelesen");
|
||||||
} else {
|
} else {
|
||||||
p.msg(sender, "&cDu hast keine Rechte dies zu tun!");
|
p.msg(sender, "&cDu hast keine Rechte dies zu tun!");
|
||||||
|
|||||||
Reference in New Issue
Block a user