mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 06:38:56 +00:00
Add some Api RecipeName <-> ItemStack
This commit is contained in:
@@ -147,6 +147,21 @@ public class BreweryApi {
|
||||
return Brew.isBrew(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Brew for the given Recipe Name
|
||||
*
|
||||
* @param recipeName The Name of the Recipe to create this Brew from
|
||||
* @return The Brew that was created. Can use brew.createItem() to get an ItemStack
|
||||
*/
|
||||
@Nullable
|
||||
public static Brew createBrew(String recipeName, int quality) {
|
||||
BRecipe matching = BRecipe.getMatching(recipeName);
|
||||
if (matching != null) {
|
||||
return matching.createBrew(quality);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Brew from the given Recipe.
|
||||
*
|
||||
@@ -157,6 +172,62 @@ public class BreweryApi {
|
||||
return recipe.createBrew(quality);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create ItemStack for the given Recipe Name
|
||||
*
|
||||
* @param recipeName The Name of the Recipe to create this Item from
|
||||
* @param quality The Quality of the Brew Item
|
||||
* @return The Brew- ItemStack with Brew information stored on it
|
||||
*/
|
||||
@Nullable
|
||||
public static ItemStack createBrewItem(String recipeName, int quality) {
|
||||
BRecipe matching = BRecipe.getMatching(recipeName);
|
||||
if (matching != null) {
|
||||
return matching.create(quality);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create ItemStack for the given Recipe
|
||||
*
|
||||
* @param recipe The Recipe to create this Item from
|
||||
* @param quality The Quality of the Brew Item
|
||||
* @return The Brew- ItemStack with Brew information stored on it
|
||||
*/
|
||||
public static ItemStack createBrewItem(BRecipe recipe, int quality) {
|
||||
return recipe.create(quality);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Name of the Current Recipe of the given ItemStack
|
||||
*
|
||||
* @param item The ItemStack to get the Recipe Name of
|
||||
* @return The middle-quality name of the current Recipe. Null if it is not a brew, or it currently has no Recipe
|
||||
*/
|
||||
@Nullable
|
||||
public static String getRecipeName(ItemStack item) {
|
||||
Brew brew = Brew.get(item);
|
||||
if (brew != null) {
|
||||
return getRecipeName(brew);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Name of the Current Recipe of the given Brew
|
||||
*
|
||||
* @param brew The Brew to get the Recipe Name of
|
||||
* @return The middle-quality name of the current Brew Recipe. Null if it currently has no Recipe
|
||||
*/
|
||||
@Nullable
|
||||
public static String getRecipeName(Brew brew) {
|
||||
BRecipe recipe = brew.getCurrentRecipe();
|
||||
if (recipe != null) {
|
||||
return recipe.getRecipeName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// # # # # # # # # # # # #
|
||||
// # # # # # Barrel # # # # #
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ShopKeepersListener implements Listener {
|
||||
Set<HumanEntity> openedEditors = new HashSet<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onShopCreated(PlayerOpenUIEvent event) {
|
||||
public void onShopkeeperOpen(PlayerOpenUIEvent event) {
|
||||
try {
|
||||
if (event.getUIType() == DefaultUITypes.EDITOR() || event.getUIType() == DefaultUITypes.TRADING()) {
|
||||
openedEditors.add(event.getPlayer());
|
||||
|
||||
Reference in New Issue
Block a user