Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make MethodDescription#description check for a global fallback #158

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@
public @interface MethodDescription {

/**
* The localization key for a description of the compat, will default to generating
* <code>
* groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.{@link Method#getName()}
* </code>
* The localization key for a description of the compat.
* <br>
* Generates a description via minecraft's localization files via
* <code>{@link net.minecraft.client.resources.I18n#format(String, Object...) I18n.format(description())}</code>
* <br>
* If this is empty, will fall back to generating a description based on
* <code>groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.{@link Method#getName()}</code>.
* Then, if that does not have a lang key defined, it will attempt to use a global lang key based on the method name
* <code>groovyscript.wiki.{@link Method#getName()}</code>
* if that also does not have a lang key defined, will log a missing key in the {@code groovy.log} file.
*
* @return localization key for method description
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public boolean removeByInput(IIngredient input) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('actuallyadditions:block_crystal')"))
@MethodDescription(example = @Example("item('actuallyadditions:block_crystal')"))
public boolean removeByOutput(ItemStack output) {
return ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.removeIf(recipe -> {
boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output);
Expand All @@ -76,13 +76,13 @@ public boolean removeByOutput(ItemStack output) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.forEach(this::addBackup);
ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.clear();
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<LensConversionRecipe> streamRecipes() {
return new SimpleObjectStream<>(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES)
.setRemover(this::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public boolean remove(BallOfFurReturn recipe) {
return true;
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('minecraft:feather')"))
@MethodDescription(example = @Example("item('minecraft:feather')"))
public boolean removeByOutput(ItemStack output) {
return ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.removeIf(recipe -> {
boolean found = ItemStack.areItemStacksEqual(recipe.returnItem, output);
Expand All @@ -57,13 +57,13 @@ public boolean removeByOutput(ItemStack output) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.forEach(this::addBackup);
ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.clear();
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<BallOfFurReturn> streamRecipes() {
return new SimpleObjectStream<>(ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS)
.setRemover(this::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean remove(CompostRecipe recipe) {
return true;
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('actuallyadditions:item_canola_seed')"))
@MethodDescription(example = @Example("item('actuallyadditions:item_canola_seed')"))
public boolean removeByInput(IIngredient input) {
return ActuallyAdditionsAPI.COMPOST_RECIPES.removeIf(recipe -> {
boolean found = recipe.getInput().test(IngredientHelper.toItemStack(input));
Expand All @@ -66,7 +66,7 @@ public boolean removeByInput(IIngredient input) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('actuallyadditions:item_fertilizer')"))
@MethodDescription(example = @Example("item('actuallyadditions:item_fertilizer')"))
public boolean removeByOutput(ItemStack output) {
return ActuallyAdditionsAPI.COMPOST_RECIPES.removeIf(recipe -> {
boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output);
Expand All @@ -77,13 +77,13 @@ public boolean removeByOutput(ItemStack output) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ActuallyAdditionsAPI.COMPOST_RECIPES.forEach(this::addBackup);
ActuallyAdditionsAPI.COMPOST_RECIPES.clear();
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<CompostRecipe> streamRecipes() {
return new SimpleObjectStream<>(ActuallyAdditionsAPI.COMPOST_RECIPES)
.setRemover(this::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean remove(CrusherRecipe recipe) {
return true;
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('minecraft:bone')"))
@MethodDescription(example = @Example("item('minecraft:bone')"))
public boolean removeByInput(IIngredient input) {
return ActuallyAdditionsAPI.CRUSHER_RECIPES.removeIf(recipe -> {
boolean found = recipe.getInput().test(IngredientHelper.toItemStack(input));
Expand All @@ -67,7 +67,7 @@ public boolean removeByInput(IIngredient input) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('minecraft:sugar')"))
@MethodDescription(example = @Example("item('minecraft:sugar')"))
public boolean removeByOutput(ItemStack output) {
return ActuallyAdditionsAPI.CRUSHER_RECIPES.removeIf(recipe -> {
boolean matches = ItemStack.areItemStacksEqual(recipe.getOutputOne(), output);
Expand All @@ -78,13 +78,13 @@ public boolean removeByOutput(ItemStack output) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ActuallyAdditionsAPI.CRUSHER_RECIPES.forEach(this::addBackup);
ActuallyAdditionsAPI.CRUSHER_RECIPES.clear();
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<CrusherRecipe> streamRecipes() {
return new SimpleObjectStream<>(ActuallyAdditionsAPI.CRUSHER_RECIPES)
.setRemover(this::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean remove(EmpowererRecipe recipe) {
return true;
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('actuallyadditions:item_crystal')"))
@MethodDescription(example = @Example("item('actuallyadditions:item_crystal')"))
public boolean removeByInput(IIngredient input) {
return ActuallyAdditionsAPI.EMPOWERER_RECIPES.removeIf(recipe -> {
boolean found = recipe.getInput().test(IngredientHelper.toItemStack(input));
Expand All @@ -67,7 +67,7 @@ public boolean removeByInput(IIngredient input) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('actuallyadditions:item_misc:24')"))
@MethodDescription(example = @Example("item('actuallyadditions:item_misc:24')"))
public boolean removeByOutput(ItemStack output) {
return ActuallyAdditionsAPI.EMPOWERER_RECIPES.removeIf(recipe -> {
boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output);
Expand All @@ -78,13 +78,13 @@ public boolean removeByOutput(ItemStack output) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ActuallyAdditionsAPI.EMPOWERER_RECIPES.forEach(this::addBackup);
ActuallyAdditionsAPI.EMPOWERER_RECIPES.clear();
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<EmpowererRecipe> streamRecipes() {
return new SimpleObjectStream<>(ActuallyAdditionsAPI.EMPOWERER_RECIPES)
.setRemover(this::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public boolean remove(WeightedOre recipe) {
return true;
}

@MethodDescription(description = "groovyscript.wiki.removeByOre", example = @Example("ore('oreQuartz')"))
@MethodDescription(example = @Example("ore('oreQuartz')"))
public boolean removeByOre(OreDictIngredient ore) {
return this.removeByOre(ore.getOreDict());
}

@MethodDescription(description = "groovyscript.wiki.removeByOre", example = @Example("'oreQuartz'"))
@MethodDescription(example = @Example("'oreQuartz'"))
public boolean removeByOre(String oreName) {
return ActuallyAdditionsAPI.NETHERRACK_ORES.removeIf(recipe -> {
boolean found = oreName.equals(recipe.name);
Expand All @@ -65,13 +65,13 @@ public boolean removeByOre(String oreName) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ActuallyAdditionsAPI.NETHERRACK_ORES.forEach(this::addBackup);
ActuallyAdditionsAPI.NETHERRACK_ORES.clear();
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<WeightedOre> streamRecipes() {
return new SimpleObjectStream<>(ActuallyAdditionsAPI.NETHERRACK_ORES)
.setRemover(this::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ public boolean remove(OilGenRecipe recipe) {
return true;
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("fluid('canolaoil')"))
@MethodDescription(example = @Example("fluid('canolaoil')"))
public boolean removeByInput(FluidStack fluid) {
return this.removeByInput(fluid.getFluid());
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("fluid('canolaoil').getFluid()"))
@MethodDescription(example = @Example("fluid('canolaoil').getFluid()"))
public boolean removeByInput(Fluid fluid) {
return this.removeByInput(fluid.getName());
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("'refinedcanolaoil'"))
@MethodDescription(example = @Example("'refinedcanolaoil'"))
public boolean removeByInput(String fluid) {
return ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.removeIf(recipe -> {
boolean found = fluid.equals(recipe.fluidName);
Expand All @@ -75,13 +75,13 @@ public boolean removeByInput(String fluid) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.forEach(this::addBackup);
ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.clear();
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<OilGenRecipe> streamRecipes() {
return new SimpleObjectStream<>(ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES)
.setRemover(this::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public boolean remove(WeightedOre recipe) {
return true;
}

@MethodDescription(description = "groovyscript.wiki.removeByOre", example = @Example("ore('oreCoal')"))
@MethodDescription(example = @Example("ore('oreCoal')"))
public boolean removeByOre(OreDictIngredient ore) {
return this.removeByOre(ore.getOreDict());
}

@MethodDescription(description = "groovyscript.wiki.removeByOre", example = @Example("'oreLapis'"))
@MethodDescription(example = @Example("'oreLapis'"))
public boolean removeByOre(String oreName) {
return ActuallyAdditionsAPI.STONE_ORES.removeIf(recipe -> {
boolean found = oreName.equals(recipe.name);
Expand All @@ -65,13 +65,13 @@ public boolean removeByOre(String oreName) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ActuallyAdditionsAPI.STONE_ORES.forEach(this::addBackup);
ActuallyAdditionsAPI.STONE_ORES.clear();
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<WeightedOre> streamRecipes() {
return new SimpleObjectStream<>(ActuallyAdditionsAPI.STONE_ORES)
.setRemover(this::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public boolean remove(TreasureChestLoot recipe) {
return true;
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('minecraft:iron_ingot')"))
@MethodDescription(example = @Example("item('minecraft:iron_ingot')"))
public boolean removeByOutput(ItemStack output) {
return ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.removeIf(recipe -> {
boolean matches = ItemStack.areItemStacksEqual(recipe.returnItem, output);
Expand All @@ -57,13 +57,13 @@ public boolean removeByOutput(ItemStack output) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.forEach(this::addBackup);
ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.clear();
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<TreasureChestLoot> streamRecipes() {
return new SimpleObjectStream<>(ActuallyAdditionsAPI.TREASURE_CHEST_LOOT)
.setRemover(this::remove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void add(ItemStack item, String type) {
add(accessory);
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('aether_legacy:iron_pendant')"))
@MethodDescription(example = @Example("item('aether_legacy:iron_pendant')"))
public void removeByInput(IIngredient input) {
this.getRegistry().getValuesCollection().forEach(accessory -> {
if (input.test(accessory.getAccessoryStack())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void add(ItemStack input, ItemStack output, int timeRequired) {
add(enchantment);
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('aether_legacy:enchanted_gravitite')"))
@MethodDescription(example = @Example("item('aether_legacy:enchanted_gravitite')"))
public void removeByOutput(IIngredient output) {
this.getRegistry().getValuesCollection().forEach(enchantment -> {
if (output.test(enchantment.getOutput())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void add(ItemStack input, ItemStack output, int timeRequired) {
add(freezable);
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('minecraft:obsidian')"))
@MethodDescription(example = @Example("item('minecraft:obsidian')"))
public void removeByOutput(IIngredient output) {
this.getRegistry().getValuesCollection().forEach(freezable -> {
if (output.test(freezable.getOutput())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public boolean remove(AtomizerRecipe recipe) {
return false;
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example(value = "item('alchemistry:compound:7')", commented = true))
@MethodDescription(example = @Example(value = "item('alchemistry:compound:7')", commented = true))
public boolean removeByOutput(IIngredient output) {
return ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> {
if (output.test(r.getOutput())) {
Expand All @@ -63,7 +63,7 @@ public boolean removeByOutput(IIngredient output) {
});
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("fluid('water')"))
@MethodDescription(example = @Example("fluid('water')"))
public boolean removeByInput(FluidStack input) {
return ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> {
if (r.getInput().isFluidEqual(input)) {
Expand All @@ -74,12 +74,12 @@ public boolean removeByInput(FluidStack input) {
});
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<AtomizerRecipe> streamRecipes() {
return new SimpleObjectStream<>(ModRecipes.INSTANCE.getAtomizerRecipes()).setRemover(this::remove);
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ModRecipes.INSTANCE.getAtomizerRecipes().forEach(this::addBackup);
ModRecipes.INSTANCE.getAtomizerRecipes().clear();
Expand Down
Loading