|
4 | 4 | import com.dre.brewery.api.events.brew.BrewModifyEvent; |
5 | 5 | import com.dre.brewery.filedata.BConfig; |
6 | 6 | import com.dre.brewery.recipe.BRecipe; |
| 7 | +import com.dre.brewery.recipe.Ingredient; |
| 8 | +import com.dre.brewery.recipe.RecipeItem; |
7 | 9 | import com.dre.brewery.utility.BUtil; |
8 | 10 | import org.bukkit.Material; |
9 | 11 | import org.bukkit.command.Command; |
10 | 12 | import org.bukkit.command.CommandExecutor; |
11 | 13 | import org.bukkit.command.CommandSender; |
| 14 | +import org.bukkit.command.ConsoleCommandSender; |
12 | 15 | import org.bukkit.entity.Player; |
13 | 16 | import org.bukkit.inventory.ItemStack; |
14 | 17 | import org.bukkit.inventory.meta.ItemMeta; |
@@ -125,6 +128,14 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command |
125 | 128 | p.msg(sender, p.languageReader.get("Error_NoPermissions")); |
126 | 129 | } |
127 | 130 |
|
| 131 | + } else if (cmd.equalsIgnoreCase("debuginfo")) { |
| 132 | + |
| 133 | + debugInfo(sender, args.length > 1 ? args[1] : null); |
| 134 | + |
| 135 | + } else if (cmd.equalsIgnoreCase("showstats")) { |
| 136 | + |
| 137 | + showStats(sender); |
| 138 | + |
128 | 139 | } else { |
129 | 140 |
|
130 | 141 | if (p.getServer().getPlayerExact(cmd) != null || BPlayer.hasPlayerbyName(cmd)) { |
@@ -443,6 +454,70 @@ public void cmdDelete(CommandSender sender) { |
443 | 454 |
|
444 | 455 | } |
445 | 456 |
|
| 457 | + public void debugInfo(CommandSender sender, String recipeName) { |
| 458 | + if (!P.use1_9 || !sender.isOp()) return; |
| 459 | + if (!(sender instanceof Player)) { |
| 460 | + p.msg(sender, p.languageReader.get("Error_PlayerCommand")); |
| 461 | + return; |
| 462 | + } |
| 463 | + Player player = (Player) sender; |
| 464 | + ItemStack hand = player.getInventory().getItemInMainHand(); |
| 465 | + if (hand != null) { |
| 466 | + Brew brew = Brew.get(hand); |
| 467 | + if (brew == null) return; |
| 468 | + P.p.log(brew.toString()); |
| 469 | + BIngredients ingredients = brew.getIngredients(); |
| 470 | + if (recipeName == null) { |
| 471 | + P.p.log("&lIngredients:"); |
| 472 | + for (Ingredient ing : ingredients.getIngredientList()) { |
| 473 | + P.p.log(ing.toString()); |
| 474 | + } |
| 475 | + P.p.log("&lTesting Recipes"); |
| 476 | + for (BRecipe recipe : BRecipe.getAllRecipes()) { |
| 477 | + int ingQ = ingredients.getIngredientQuality(recipe); |
| 478 | + int cookQ = ingredients.getCookingQuality(recipe, false); |
| 479 | + int cookDistQ = ingredients.getCookingQuality(recipe, true); |
| 480 | + P.p.log(recipe.getRecipeName() + ": ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ); |
| 481 | + } |
| 482 | + BRecipe distill = ingredients.getBestRecipe(brew.getWood(), brew.getAgeTime(), true); |
| 483 | + BRecipe nonDistill = ingredients.getBestRecipe(brew.getWood(), brew.getAgeTime(), false); |
| 484 | + P.p.log("&lWould prefer Recipe: " + (nonDistill == null ? "none" : nonDistill.getRecipeName()) + " and Distill-Recipe: " + (distill == null ? "none" : distill.getRecipeName())); |
| 485 | + } else { |
| 486 | + BRecipe recipe = BRecipe.get(recipeName); |
| 487 | + if (recipe == null) { |
| 488 | + P.p.msg(player, "Could not find Recipe " + recipeName); |
| 489 | + return; |
| 490 | + } |
| 491 | + P.p.log("&lIngredients in Recipe " + recipe.getRecipeName() + ":"); |
| 492 | + for (RecipeItem ri : recipe.getIngredients()) { |
| 493 | + P.p.log(ri.toString()); |
| 494 | + } |
| 495 | + P.p.log("&lIngredients in Brew:"); |
| 496 | + for (Ingredient ingredient : ingredients.getIngredientList()) { |
| 497 | + int amountInRecipe = recipe.amountOf(ingredient); |
| 498 | + P.p.log(ingredient.toString() + ": " + amountInRecipe + " of this are in the Recipe"); |
| 499 | + } |
| 500 | + int ingQ = ingredients.getIngredientQuality(recipe); |
| 501 | + int cookQ = ingredients.getCookingQuality(recipe, false); |
| 502 | + int cookDistQ = ingredients.getCookingQuality(recipe, true); |
| 503 | + P.p.log("ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ); |
| 504 | + } |
| 505 | + |
| 506 | + P.p.msg(player, "Debug Info for item written into Log"); |
| 507 | + } |
| 508 | + } |
| 509 | + |
| 510 | + public void showStats(CommandSender sender) { |
| 511 | + if (sender instanceof ConsoleCommandSender && !sender.isOp()) return; |
| 512 | + |
| 513 | + P.p.msg(sender, "Drunk Players: " + BPlayer.numDrunkPlayers()); |
| 514 | + P.p.msg(sender, "Brews created: " + P.p.brewsCreated); |
| 515 | + P.p.msg(sender, "Barrels built: " + Barrel.barrels.size()); |
| 516 | + P.p.msg(sender, "Cauldrons boiling: " + BCauldron.bcauldrons.size()); |
| 517 | + P.p.msg(sender, "Number of Recipes: " + BRecipe.getAllRecipes().size()); |
| 518 | + P.p.msg(sender, "Wakeups: " + Wakeup.wakeups.size()); |
| 519 | + } |
| 520 | + |
446 | 521 | @SuppressWarnings("deprecation") |
447 | 522 | public void cmdStatic(CommandSender sender) { |
448 | 523 |
|
|
0 commit comments