mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-02-09 00:01:19 +01:00
Fixed Recipes not reloading on cmd
This commit is contained in:
parent
a466593920
commit
8ab8fe91a6
@ -38,16 +38,6 @@ public class BIngredients {
|
||||
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
|
||||
public void add(Material 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 colorInBrewer; // color the Lore while in Brewer
|
||||
|
||||
//public static Map<ItemStack, List<String>> oldLore = new HashMap<ItemStack, List<String>>();
|
||||
|
||||
private BIngredients ingredients;
|
||||
private int quality;
|
||||
private int distillRuns;
|
||||
@ -54,20 +52,7 @@ public class Brew {
|
||||
this.ageTime = ageTime;
|
||||
this.wood = wood;
|
||||
this.unlabeled = unlabeled;
|
||||
if (recipe != null && !recipe.equals("")) {
|
||||
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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setRecipeFromString(recipe);
|
||||
}
|
||||
|
||||
// returns a Brew by its UID
|
||||
@ -133,6 +118,37 @@ public class Brew {
|
||||
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
|
||||
public ItemStack copy(ItemStack item) {
|
||||
|
@ -97,7 +97,7 @@ public class P extends JavaPlugin {
|
||||
this.log(this.getDescription().getName() + " disabled!");
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
public void reload(CommandSender sender) {
|
||||
BIngredients.possibleIngredients.clear();
|
||||
BIngredients.recipes.clear();
|
||||
BIngredients.cookedNames.clear();
|
||||
@ -105,6 +105,16 @@ public class P extends JavaPlugin {
|
||||
BPlayer.drainItems.clear();
|
||||
|
||||
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) {
|
||||
|
@ -32,7 +32,7 @@ public class CommandListener implements CommandExecutor {
|
||||
} else if (cmd.equalsIgnoreCase("reload")) {
|
||||
|
||||
if (p.permission.has(sender, "brewery.cmd.reload")) {
|
||||
p.reload();
|
||||
p.reload(sender);
|
||||
p.msg(sender, "&aConfig wurde neu eingelesen");
|
||||
} else {
|
||||
p.msg(sender, "&cDu hast keine Rechte dies zu tun!");
|
||||
|
Loading…
Reference in New Issue
Block a user