forked from unimatrix/web
Fresh production baseline [skip ci]
This commit is contained in:
commit
0a11a18274
1 changed files with 229644 additions and 0 deletions
34
tools/SurvivalFoodProbe.java
Normal file
34
tools/SurvivalFoodProbe.java
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package com.dunerealms.jarvis;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import com.google.gson.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.consumable.ConsumeEffect;
|
||||
|
||||
/** Isolated item/recipe probe, never loaded by the production connector. */
|
||||
public final class SurvivalFoodProbe extends JavaPlugin {
|
||||
private ItemMetadataOverlay metadata;private SurvivalFoodRecipes bridge;
|
||||
public void onEnable(){try{ItemOrigin.configure("arrakis");metadata=new ItemMetadataOverlay(this);bridge=new SurvivalFoodRecipes(this,metadata);Bukkit.getScheduler().runTaskLater(this,()->{try{run();}catch(Throwable failure){getLogger().severe("FOOD_NATIVE_FAIL "+failure);failure.printStackTrace();}finally{Bukkit.shutdown();}},100);}catch(Exception failure){throw new IllegalStateException(failure);}}
|
||||
private static void check(boolean condition,String message){if(!condition)throw new IllegalStateException(message);}
|
||||
private ItemStack item(String id)throws Exception{var method=SurvivalFoodRecipes.class.getDeclaredMethod("nativeItem",String.class);method.setAccessible(true);return (ItemStack)method.invoke(bridge,id);}
|
||||
private static List<org.bukkit.potion.PotionEffect> effects(ItemStack item){return item.getData(DataComponentTypes.CONSUMABLE).consumeEffects().stream().filter(e->e instanceof ConsumeEffect.ApplyStatusEffects).flatMap(e->((ConsumeEffect.ApplyStatusEffects)e).effects().stream()).toList();}
|
||||
private void run()throws Exception{
|
||||
var bread=item("spice_bread");var apple=new ItemStack(Material.ENCHANTED_GOLDEN_APPLE);check(effects(bread).equals(effects(apple)),"Bread differs from native enchanted golden apple effects");
|
||||
var cake=item("spice_cake");check(cake.getData(DataComponentTypes.FOOD).nutrition()==16,"Cake nutrition missing");check(effects(cake).size()==2,"Cake effects missing");
|
||||
for(String file:List.of("jerboa_water_bucket","jerboa_leather","rehydrated_steak","spice_paste","spice_paste_smuggled","bio_paste","spice_dough","spice_dough_smuggled","spice_cake")){
|
||||
var spec=JsonParser.parseString(Files.readString(Path.of("plugins/ExecutableCrafting/recipes/"+file+".yml"))).getAsJsonObject();
|
||||
for(var field:spec.entrySet())if(field.getKey().startsWith("input")||field.getKey().equals("result")){var stack=Bukkit.getItemFactory().createItemStack(field.getValue().getAsString());check(stack!=null&&!stack.isEmpty(),"Invalid native item command: "+file+"/"+field.getKey());}
|
||||
}
|
||||
for(var entry:Map.of("jerboa_leather","jerboa_hide_paste","spice_bread","bio_paste").entrySet()){
|
||||
var recipe=Bukkit.getRecipe(new NamespacedKey("dunerealms",entry.getKey()));check(recipe instanceof SmokingRecipe,"Missing native smoker: "+entry.getKey());var smoker=(SmokingRecipe)recipe;
|
||||
var ingredient=item(entry.getValue());ItemOrigin.created(ingredient);metadata.stamp(ingredient);check(smoker.getInputChoice().test(ingredient),"Stamped custom input cannot enter smoker");check(!smoker.getInputChoice().test(new ItemStack(ingredient.getType())),"Unmarked vanilla material accepted as paste");check(smoker.getResult().getAmount()==(entry.getKey().equals("jerboa_leather")?4:1),"Wrong smoker output quantity");
|
||||
}
|
||||
var leather=item("jerboa_leather");check(leather.getType()==Material.LEATHER,"Jerboa Leather lost vanilla crafting material");var helmet=(ShapedRecipe)Bukkit.getRecipe(NamespacedKey.minecraft("leather_helmet"));check(helmet.getChoiceMap().values().stream().anyMatch(choice->choice!=null&&choice.test(leather)),"Jerboa Leather rejected by native leather armour recipe");
|
||||
check(!SurvivalFoodRecipes.hasRealSpice(new ItemStack[]{new ItemStack(Material.ORANGE_DYE)}),"Ordinary dye passed spice validation");
|
||||
getLogger().info("FOOD_NATIVE_SUCCESS nativeAppleEffects=true richCake=true commandItems=true smokerIdentity=true leatherFour=true vanillaLeatherCrafting=true ordinaryDyeRejected=true");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff