Added and Fixed lots of JavaDocs

This commit is contained in:
Sn0wStorm
2019-11-25 22:16:16 +01:00
parent c287b6350f
commit 16c03f9da1
32 changed files with 513 additions and 308 deletions
+19 -13
View File
@@ -16,6 +16,9 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* A Recipe for the Base Potion coming out of the Cauldron.
*/
public class BCauldronRecipe {
public static List<BCauldronRecipe> recipes = new ArrayList<>();
public static int numConfigRecipes;
@@ -32,8 +35,8 @@ public class BCauldronRecipe {
/**
* A New Cauldron Recipe with the given name
* Use new BCauldronRecipe.Builder() for easier Cauldron Recipe Creation
* A New Cauldron Recipe with the given name.
* <p>Use new BCauldronRecipe.Builder() for easier Cauldron Recipe Creation
*
* @param name Name of the Cauldron Recipe
*/
@@ -134,9 +137,9 @@ public class BCauldronRecipe {
/**
* Find how much these ingredients match the given ones from 0-10.
* If any ingredient is missing, returns 0
* If all Ingredients and their amounts are equal, returns 10
* Returns something between 0 and 10 if all ingredients present, but differing amounts, depending on how much the amount differs.
* <p>If any ingredient is missing, returns 0
* <br>If all Ingredients and their amounts are equal, returns 10
* <br>Returns something between 0 and 10 if all ingredients present, but differing amounts, depending on how much the amount differs.
*/
public float getIngredientMatch(List<Ingredient> items) {
if (items.size() < ingredients.size()) {
@@ -210,27 +213,27 @@ public class BCauldronRecipe {
}
/**
* Gets a Modifiable Sublist of the CauldronRecipes that are loaded by config
* Changes are directly reflected by the main list of all recipes
* Changes to the main List of all CauldronRecipes will make the reference to this sublist invalid
* Gets a Modifiable Sublist of the CauldronRecipes that are loaded by config.
* <p>Changes are directly reflected by the main list of all recipes
* <br>Changes to the main List of all CauldronRecipes will make the reference to this sublist invalid
*
* After adding or removing elements, CauldronRecipes.numConfigRecipes MUST be updated!
* <p>After adding or removing elements, CauldronRecipes.numConfigRecipes MUST be updated!
*/
public static List<BCauldronRecipe> getConfigRecipes() {
return recipes.subList(0, numConfigRecipes);
}
/**
* Gets a Modifiable Sublist of the CauldronRecipes that are added by plugins
* Changes are directly reflected by the main list of all recipes
* Changes to the main List of all CauldronRecipes will make the reference to this sublist invalid
* Gets a Modifiable Sublist of the CauldronRecipes that are added by plugins.
* <p>Changes are directly reflected by the main list of all recipes
* <br>Changes to the main List of all CauldronRecipes will make the reference to this sublist invalid
*/
public static List<BCauldronRecipe> getAddedRecipes() {
return recipes.subList(numConfigRecipes, recipes.size());
}
/**
* Gets the main List of all CauldronRecipes
* Gets the main List of all CauldronRecipes.
*/
public static List<BCauldronRecipe> getAllRecipes() {
return recipes;
@@ -272,6 +275,9 @@ public class BCauldronRecipe {
return null;
}*/
/**
* Builder to easily create BCauldron recipes.
*/
public static class Builder {
private BCauldronRecipe recipe;
+55 -25
View File
@@ -20,6 +20,9 @@ import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
/**
* A Recipe used to Brew a Brewery Potion.
*/
public class BRecipe {
private static List<BRecipe> recipes = new ArrayList<>();
@@ -54,8 +57,8 @@ public class BRecipe {
}
/**
* New BRecipe with Name
* Use new BRecipe.Builder() for easier Recipe Creation
* New BRecipe with Name.
* <p>Use new BRecipe.Builder() for easier Recipe Creation
*
* @param name The name for all qualities
*/
@@ -66,8 +69,8 @@ public class BRecipe {
}
/**
* New BRecipe with Names
* Use new BRecipe.Builder() for easier Recipe Creation
* New BRecipe with Names.
* <p>Use new BRecipe.Builder() for easier Recipe Creation
*
* @param names {name bad, name normal, name good}
*/
@@ -311,7 +314,9 @@ public class BRecipe {
return null;
}
// check every part of the recipe for validity
/**
* check every part of the recipe for validity.
*/
public boolean isValid() {
if (ingredients == null || ingredients.isEmpty()) {
P.p.errorLog("No ingredients could be loaded for Recipe: " + getRecipeName());
@@ -348,7 +353,9 @@ public class BRecipe {
return true;
}
// allowed deviation to the recipes count of ingredients at the given difficulty
/**
* allowed deviation to the recipes count of ingredients at the given difficulty
*/
public int allowedCountDiff(int count) {
if (count < 8) {
count = 8;
@@ -361,7 +368,9 @@ public class BRecipe {
return allowedCountDiff;
}
// allowed deviation to the recipes cooking-time at the given difficulty
/**
* allowed deviation to the recipes cooking-time at the given difficulty
*/
public int allowedTimeDiff(int time) {
if (time < 8) {
time = 8;
@@ -374,7 +383,9 @@ public class BRecipe {
return allowedTimeDiff;
}
// difference between given and recipe-wanted woodtype
/**
* difference between given and recipe-wanted woodtype
*/
public float getWoodDiff(float wood) {
return Math.abs(wood - this.wood);
}
@@ -391,7 +402,9 @@ public class BRecipe {
return age != 0;
}
// true if given list misses an ingredient
/**
* true if given list misses an ingredient
*/
public boolean isMissingIngredients(List<Ingredient> list) {
if (list.size() < ingredients.size()) {
return true;
@@ -431,7 +444,8 @@ public class BRecipe {
}
/**
* Create a Potion from this Recipe with best values. Quality can be set, but will reset to 10 if put in a barrel
* Create a Potion from this Recipe with best values.
* Quality can be set, but will reset to 10 if unset immutable and put in a barrel
*
* @param quality The Quality of the Brew
* @return The Created Item
@@ -441,7 +455,8 @@ public class BRecipe {
}
/**
* Create a Brew from this Recipe with best values. Quality can be set, but will reset to 10 if unset immutable and put in a barrel
* Create a Brew from this Recipe with best values.
* Quality can be set, but will reset to 10 if unset immutable and put in a barrel
*
* @param quality The Quality of the Brew
* @return The created Brew
@@ -478,7 +493,9 @@ public class BRecipe {
// Getter
// how many of a specific ingredient in the recipe
/**
* how many of a specific ingredient in the recipe
*/
public int amountOf(Ingredient ing) {
for (RecipeItem rItem : ingredients) {
if (rItem.matches(ing)) {
@@ -488,7 +505,9 @@ public class BRecipe {
return 0;
}
// how many of a specific ingredient in the recipe
/**
* how many of a specific ingredient in the recipe
*/
public int amountOf(ItemStack item) {
for (RecipeItem rItem : ingredients) {
if (rItem.matches(item)) {
@@ -498,12 +517,16 @@ public class BRecipe {
return 0;
}
// Same as getName(5)
/**
* Same as getName(5)
*/
public String getRecipeName() {
return getName(5);
}
// name that fits the quality
/**
* name that fits the quality
*/
public String getName(int quality) {
if (name.length > 2) {
if (quality <= 3) {
@@ -518,7 +541,9 @@ public class BRecipe {
}
}
// If one of the quality names equalIgnoreCase given name
/**
* If one of the quality names equalIgnoreCase given name
*/
public boolean hasName(String name) {
for (String test : this.name) {
if (test.equalsIgnoreCase(name)) {
@@ -549,7 +574,9 @@ public class BRecipe {
return color;
}
// get the woodtype
/**
* get the woodtype
*/
public byte getWood() {
return wood;
}
@@ -680,27 +707,27 @@ public class BRecipe {
}
/**
* Gets a Modifiable Sublist of the Recipes that are loaded by config
* Changes are directly reflected by the main list of all recipes
* Changes to the main List of all recipes will make the reference to this sublist invalid
* Gets a Modifiable Sublist of the Recipes that are loaded by config.
* <p>Changes are directly reflected by the main list of all recipes
* <br>Changes to the main List of all recipes will make the reference to this sublist invalid
*
* After adding or removing elements, BRecipe.numConfigRecipes MUST be updated!
* <p>After adding or removing elements, BRecipe.numConfigRecipes MUST be updated!
*/
public static List<BRecipe> getConfigRecipes() {
return recipes.subList(0, numConfigRecipes);
}
/**
* Gets a Modifiable Sublist of the Recipes that are added by plugins
* Changes are directly reflected by the main list of all recipes
* Changes to the main List of all recipes will make the reference to this sublist invalid
* Gets a Modifiable Sublist of the Recipes that are added by plugins.
* <p>Changes are directly reflected by the main list of all recipes
* <br>Changes to the main List of all recipes will make the reference to this sublist invalid
*/
public static List<BRecipe> getAddedRecipes() {
return recipes.subList(numConfigRecipes, recipes.size());
}
/**
* Gets the main List of all recipes
* Gets the main List of all recipes.
*/
public static List<BRecipe> getAllRecipes() {
return recipes;
@@ -725,6 +752,9 @@ public class BRecipe {
}*/
/**
* Builder to easily create Recipes
*/
public static class Builder {
private BRecipe recipe;
+2 -2
View File
@@ -16,7 +16,7 @@ import java.util.Objects;
/**
* Minecraft Item with custon name and lore.
* Mostly used for Custom Items of the Config, but also for general custom items
* <p>Mostly used for Custom Items of the Config, but also for general custom items
*/
public class CustomItem extends RecipeItem implements Ingredient {
@@ -167,7 +167,7 @@ public class CustomItem extends RecipeItem implements Ingredient {
/**
* If this item has lore that matches the given lore.
* It matches if our lore is contained in the given lore consecutively, ignoring color of the given lore.
* <p>It matches if our lore is contained in the given lore consecutively, ignoring color of the given lore.
*
* @param usedLore The given lore to match
* @return True if the given lore contains our lore consecutively
@@ -13,7 +13,7 @@ import java.util.Objects;
/**
* Custom Item that matches any one of the given info.
* Does not implement Ingredient, as it can not directly be added to an ingredient
* <p>Does not implement Ingredient, as it can not directly be added to an ingredient
*/
public class CustomMatchAnyItem extends RecipeItem {
+12 -13
View File
@@ -9,11 +9,11 @@ import java.util.Map;
import java.util.function.Function;
/**
* Item used in a BIngredients, inside BCauldron or Brew.
* Represents the Items used as ingredients in the Brewing process
* Can be a copy of a recipe item
* Will be saved and loaded with a DataStream
* Each implementing class needs to register a static function as Item Loader
* Item used in a BIngredients, inside BCauldron or Brew,
* Represents the Items used as ingredients in the Brewing process.
* <p>Can be a copy of a recipe item
* <p>Will be saved and loaded with a DataStream
* <p>Each implementing class needs to register a static function as Item Loader
*/
public interface Ingredient {
@@ -21,7 +21,7 @@ public interface Ingredient {
/**
* Register a Static function as function that takes an ItemLoader, containing a DataInputStream.
* Using the Stream it constructs a corresponding Ingredient for the chosen SaveID
* <p>Using the Stream it constructs a corresponding Ingredient for the chosen SaveID
*
* @param saveID The SaveID should be a small identifier like "AB"
* @param loadFct The Static Function that loads the Item, i.e.
@@ -43,10 +43,10 @@ public interface Ingredient {
/**
* Saves this Ingredient to the DataOutputStream.
* The first data HAS to be storing the SaveID like:
* <p>The first data HAS to be storing the SaveID like:
* out.writeUTF("AB");
* Amount will be saved automatically and does not have to be saved here.
* Saving is done to Brew or for BCauldron into data.yml
* <p>Amount will be saved automatically and does not have to be saved here.
* <p>Saving is done to Brew or for BCauldron into data.yml
*
* @param out The outputstream to write to
* @throws IOException Any IOException
@@ -67,9 +67,8 @@ public interface Ingredient {
/*
* Does this Item match the given RecipeItem.
* An IngredientItem matches a RecipeItem if all required info of the RecipeItem are fulfilled on this IngredientItem
* This does not imply that the same holds the other way round, as this item might have more info than needed
*
* <p>An IngredientItem matches a RecipeItem if all required info of the RecipeItem are fulfilled on this IngredientItem
* <p>This does not imply that the same holds the other way round, as this item might have more info than needed
*
* @param recipeItem The recipeItem whose requirements need to be fulfilled
* @return True if this matches the required info of the recipeItem
@@ -77,7 +76,7 @@ public interface Ingredient {
//boolean matches(RecipeItem recipeItem);
/**
* The other Ingredient is Similar if it is equal except amount
* The other Ingredient is Similar if it is equal except amount.
*
* @param item The item to check similarity with
* @return True if this is equal to item except for amount
+15 -15
View File
@@ -16,8 +16,8 @@ import java.util.function.Supplier;
/**
* An Item of a Recipe or as Ingredient in a Brew that corresponds to an item from another plugin.
* See /integration/item for examples on how to extend this class.
* This class stores items as name of the plugin and item id
* <p>See /integration/item for examples on how to extend this class.
* <p>This class stores items as name of the plugin and item id
*/
public abstract class PluginItem extends RecipeItem implements Ingredient {
@@ -72,14 +72,14 @@ public abstract class PluginItem extends RecipeItem implements Ingredient {
/**
* Called after Loading this Plugin Item from Config, or (by default) from Ingredients.
* Allows Override to define custom actions after an Item was constructed
* <p>Allows Override to define custom actions after an Item was constructed
*/
protected void onConstruct() {
}
/**
* Does this PluginItem Match the other Ingredient.
* By default it matches exactly when they are similar, i.e. also a PluginItem with same parameters
* <p>By default it matches exactly when they are similar, i.e. also a PluginItem with same parameters
*
* @param ingredient The ingredient that needs to fulfill the requirements
* @return True if the ingredient matches the required info of this
@@ -132,8 +132,8 @@ public abstract class PluginItem extends RecipeItem implements Ingredient {
}
/**
* Called when loading this Plugin Item from Ingredients (of a Brew)
* The default loading is the same as loading from Config
* Called when loading this Plugin Item from Ingredients (of a Brew).
* <p>The default loading is the same as loading from Config
*
* @param loader The ItemLoader from which to load the data, use loader.getInputStream()
* @return The constructed PluginItem
@@ -161,8 +161,8 @@ public abstract class PluginItem extends RecipeItem implements Ingredient {
}
/**
* Needs to be called at Server start
* Registers the chosen SaveID and the loading Method for loading from Brew or BCauldron
* Registers the chosen SaveID and the loading Method for loading from Brew or BCauldron.
* <p>Needs to be called at Server start.
*/
public static void registerItemLoader() {
Ingredient.registerForItemLoader("PI", PluginItem::loadFrom);
@@ -170,8 +170,8 @@ public abstract class PluginItem extends RecipeItem implements Ingredient {
/**
* Called when loading trying to find a config defined Plugin Item, or by default also when loading from ingredients
* Will call a registered constructor matching the given plugin identifier
* Called when loading trying to find a config defined Plugin Item. By default also when loading from ingredients
* <p>Will call a registered constructor matching the given plugin identifier
*
* @param plugin The Identifier of the Plugin used in the config
* @param itemId The Identifier of the Item belonging to this Plugin used in the config
@@ -193,11 +193,11 @@ public abstract class PluginItem extends RecipeItem implements Ingredient {
/**
* This needs to be called at Server Start before Brewery loads its data.
* When implementing this, put Brewery as softdepend in your plugin.yml!
* Registers a Constructor that returns a new or cloned instance of a PluginItem
* This Constructor will be called when loading a Plugin Item from Config or by default from ingredients
* After the Constructor is called, the plugin and itemid will be set on the new instance
* Finally the onConstruct is called.
* <p>When implementing this, put Brewery as softdepend in your plugin.yml!
* <p>Registers a Constructor that returns a new or cloned instance of a PluginItem
* <br>This Constructor will be called when loading a Plugin Item from Config or by default from ingredients
* <br>After the Constructor is called, the plugin and itemid will be set on the new instance
* <p>Finally the onConstruct is called.
*
* @param pluginId The ID to use in the config
* @param constructor The constructor i.e. YourPluginItem::new
+13 -13
View File
@@ -17,8 +17,8 @@ import java.util.stream.Collectors;
/**
* Item that can be used in a Recipe.
* They are not necessarily only loaded from config
* They are immutable if used in a recipe. If one implements Ingredient,
* <p>They are not necessarily only loaded from config
* <p>They are immutable if used in a recipe. If one implements Ingredient,
* it can be used as mutable copy directly in a
* BIngredients. Otherwise it needs to be converted to an Ingredient
*/
@@ -31,7 +31,7 @@ public abstract class RecipeItem implements Cloneable {
/**
* Does this RecipeItem match the given ItemStack?
* Used to determine if the given item corresponds to this recipeitem
* <p>Used to determine if the given item corresponds to this recipeitem
*
* @param item The ItemStack for comparison
* @return True if the given item matches this recipeItem
@@ -39,9 +39,9 @@ public abstract class RecipeItem implements Cloneable {
public abstract boolean matches(ItemStack item);
/**
* Does this Item match the given Ingredient.
* A RecipeItem matches an Ingredient if all required info of the RecipeItem are fulfilled on the Ingredient
* This does not imply that the same holds the other way round, as the ingredient item might have more info than needed
* Does this Item match the given Ingredient?
* <p>A RecipeItem matches an Ingredient if all required info of the RecipeItem are fulfilled on the Ingredient
* <br>This does not imply that the same holds the other way round, as the ingredient item might have more info than needed
*
*
* @param ingredient The ingredient that needs to fulfill the requirements
@@ -51,7 +51,7 @@ public abstract class RecipeItem implements Cloneable {
/**
* Get the Corresponding Ingredient Item. For Items implementing Ingredient, just getMutableCopy()
* This is called when this recipe item is added to a BIngredients
* <p>This is called when this recipe item is added to a BIngredients
*
* @param forItem The ItemStack that has previously matched this RecipeItem. Used if the resulting Ingredient needs more info from the ItemStack
* @return The IngredientItem corresponding to this RecipeItem
@@ -92,9 +92,9 @@ public abstract class RecipeItem implements Cloneable {
}
/**
* Set the Amount of this Item in a Recipe
* The amount can not be set on an existing item in a recipe or existing custom item.
* To change amount you need to use getMutableCopy() and change the amount on the copy
* Set the Amount of this Item in a Recipe.
* <p>The amount can not be set on an existing item in a recipe or existing custom item.
* <br>To change amount you need to use getMutableCopy() and change the amount on the copy
*
* @param amount The new amount
*/
@@ -128,12 +128,12 @@ public abstract class RecipeItem implements Cloneable {
/**
* Tries to find a matching RecipeItem for this item. It checks custom items and if it has found a unique custom item
* it will return that. If there are multiple matching custom items, a new CustomItem with all item info is returned
* If there is no matching CustomItem, it will return a SimpleItem with the items type
* it will return that. If there are multiple matching custom items, a new CustomItem with all item info is returned.
* <br>If there is no matching CustomItem, it will return a SimpleItem with the items type
*
* @param item The Item for which to find a matching RecipeItem
* @param acceptAll If true it will accept any item and return a SimpleItem even if not on the accepted list
* If false it will return null if the item is not acceptable by the Cauldron
* <br>If false it will return null if the item is not acceptable by the Cauldron
* @return The Matched CustomItem, new CustomItem with all item info or SimpleItem
*/
@Nullable