mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-12 00:07:57 +00:00
Improved error handling for the lexicon commands and functions
This commit is contained in:
1 parent
c5a96ec6bb
commit
df85abd8c4
3 files changed
+144
-16
No files matched your search
@@ -64,8 +64,16 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addCraftingPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][][] inputs) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
if(outputs.length!=inputs.length)
|
||||
throw new IllegalArgumentException("Length of input and output must match");
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Length of input and output must match");
|
||||
return;
|
||||
}
|
||||
List<IRecipe> recipes=new ArrayList<IRecipe>();
|
||||
for(int i=0;i<outputs.length;i++)
|
||||
{
|
||||
@@ -78,8 +86,16 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addElvenPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][] inputs) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
if(outputs.length!=inputs.length)
|
||||
throw new IllegalArgumentException("Length of input and output must match");
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Length of input and output must match");
|
||||
return;
|
||||
}
|
||||
List<RecipeElvenTrade> recipes=new ArrayList<RecipeElvenTrade>();
|
||||
for(int i=0;i<outputs.length;i++)
|
||||
{
|
||||
@@ -92,6 +108,11 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addEntityPage(String name, String entry, int page_number, String entity, int size) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
LexiconPage page=new PageEntity(entity, entity, size);
|
||||
MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number));
|
||||
}
|
||||
@@ -99,6 +120,11 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addImagePage(String name, String entry, int page_number, String resource) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
LexiconPage page=new PageImage(name, resource);
|
||||
MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number));
|
||||
}
|
||||
@@ -106,6 +132,11 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addLorePage(String name, String entry, int page_number) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
LexiconPage page=new PageLoreText(name);
|
||||
MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number));
|
||||
}
|
||||
@@ -113,8 +144,16 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addInfusionPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[] inputs, int[] mana) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
if(outputs.length!=inputs.length || outputs.length!=mana.length)
|
||||
throw new IllegalArgumentException("Length of input and output must match");
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Length of input and output must match");
|
||||
return;
|
||||
}
|
||||
List<RecipeManaInfusion> recipes=new ArrayList<RecipeManaInfusion>();
|
||||
for(int i=0;i<outputs.length;i++)
|
||||
{
|
||||
@@ -127,8 +166,16 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addAlchemyPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[] inputs, int[] mana) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
if(outputs.length!=inputs.length || outputs.length!=mana.length)
|
||||
throw new IllegalArgumentException("Length of input and output must match");
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Length of input and output must match");
|
||||
return;
|
||||
}
|
||||
List<RecipeManaInfusion> recipes=new ArrayList<RecipeManaInfusion>();
|
||||
for(int i=0;i<outputs.length;i++)
|
||||
{
|
||||
@@ -143,8 +190,16 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addConjurationPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[] inputs, int[] mana) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
if(outputs.length!=inputs.length || outputs.length!=mana.length)
|
||||
throw new IllegalArgumentException("Length of input and output must match");
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Length of input and output must match");
|
||||
return;
|
||||
}
|
||||
List<RecipeManaInfusion> recipes=new ArrayList<RecipeManaInfusion>();
|
||||
for(int i=0;i<outputs.length;i++)
|
||||
{
|
||||
@@ -159,8 +214,16 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addPetalPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][] inputs) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
if(outputs.length!=inputs.length)
|
||||
throw new IllegalArgumentException("Length of input and output must match");
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Length of input and output must match");
|
||||
return;
|
||||
}
|
||||
List<RecipePetals> recipes=new ArrayList<RecipePetals>();
|
||||
for(int i=0;i<outputs.length;i++)
|
||||
{
|
||||
@@ -173,8 +236,16 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addRunePage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][] inputs, int[] mana) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
if(outputs.length!=inputs.length || outputs.length!=mana.length)
|
||||
throw new IllegalArgumentException("Length of input and output must match");
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Length of input and output must match");
|
||||
return;
|
||||
}
|
||||
List<RecipeRuneAltar> recipes=new ArrayList<RecipeRuneAltar>();
|
||||
for(int i=0;i<outputs.length;i++)
|
||||
{
|
||||
@@ -187,6 +258,11 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void addTextPage(String name, String entry, int page_number) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
LexiconPage page=new PageText(name);
|
||||
MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number));
|
||||
}
|
||||
@@ -194,13 +270,23 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void removePage(String entry, int page_number) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
MineTweakerAPI.apply(new RemovePage(lexiconEntry,page_number));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addEntry(String entry, String catagory) {
|
||||
LexiconCategory lexiconCatagory=BotaniaHelper.findCatagory(catagory);
|
||||
LexiconEntry lexiconEntry=new LexiconEntry(entry,lexiconCatagory);
|
||||
LexiconCategory lexiconCategory=BotaniaHelper.findCatagory(catagory);
|
||||
if(lexiconCategory==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon category "+catagory);
|
||||
return;
|
||||
}
|
||||
LexiconEntry lexiconEntry=new LexiconEntry(entry,lexiconCategory);
|
||||
MineTweakerAPI.apply(new AddEntry(lexiconEntry));
|
||||
}
|
||||
|
||||
@@ -213,6 +299,11 @@ public class Lexicon {
|
||||
@ZenMethod
|
||||
public static void setEntryKnowledgeType(String entry, String knowledgeType) {
|
||||
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry);
|
||||
if(lexiconEntry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
|
||||
return;
|
||||
}
|
||||
KnowledgeType type=BotaniaHelper.findKnowledgeType(knowledgeType);
|
||||
MineTweakerAPI.apply(new SetEntryKnowledgeType(lexiconEntry,type));
|
||||
}
|
||||
@@ -225,20 +316,35 @@ public class Lexicon {
|
||||
|
||||
@ZenMethod
|
||||
public static void removeCategory(String name) {
|
||||
LexiconCategory lexiconCatagory=BotaniaHelper.findCatagory(name);
|
||||
MineTweakerAPI.apply(new RemoveCategory(lexiconCatagory));
|
||||
LexiconCategory lexiconCategory=BotaniaHelper.findCatagory(name);
|
||||
if(lexiconCategory==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon category "+name);
|
||||
return;
|
||||
}
|
||||
MineTweakerAPI.apply(new RemoveCategory(lexiconCategory));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void setCategoryPriority(String name, int priority) {
|
||||
LexiconCategory lexiconCatagory=BotaniaHelper.findCatagory(name);
|
||||
MineTweakerAPI.apply(new SetCategoryPriority(lexiconCatagory,priority));
|
||||
LexiconCategory lexiconCategory=BotaniaHelper.findCatagory(name);
|
||||
if(lexiconCategory==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon category "+name);
|
||||
return;
|
||||
}
|
||||
MineTweakerAPI.apply(new SetCategoryPriority(lexiconCategory,priority));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void setCategoryIcon(String name, String icon) {
|
||||
LexiconCategory lexiconCatagory=BotaniaHelper.findCatagory(name);
|
||||
MineTweakerAPI.apply(new SetCategoryIcon(lexiconCatagory,icon));
|
||||
LexiconCategory lexiconCategory=BotaniaHelper.findCatagory(name);
|
||||
if(lexiconCategory==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Cannot find lexicon category "+name);
|
||||
return;
|
||||
}
|
||||
MineTweakerAPI.apply(new SetCategoryIcon(lexiconCategory,icon));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,14 @@ public class LexiconEntryLogger implements ICommandFunction{
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
LexiconCategory category=null;
|
||||
if(arguments.length>0)
|
||||
{
|
||||
category=BotaniaHelper.findCatagory(arguments[0]);
|
||||
if(category==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Category not found (" + arguments[0]+")");
|
||||
return;
|
||||
}
|
||||
}
|
||||
List<LexiconEntry> entries=BotaniaAPI.getAllEntries();
|
||||
System.out.println("Entries: " + entries.size());
|
||||
for (LexiconEntry entry : entries) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package modtweaker.mods.botania.lexicon.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,9 +20,23 @@ public class LexiconPageLogger implements ICommandFunction{
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
LexiconEntry entry=null;
|
||||
if(arguments.length>0)
|
||||
{
|
||||
entry=BotaniaHelper.findEntry(arguments[0]);
|
||||
List<LexiconPage> pages=entry.pages;
|
||||
if(entry==null)
|
||||
{
|
||||
MineTweakerAPI.getLogger().logError("Entry not found (" + arguments[0]+")");
|
||||
return;
|
||||
}
|
||||
}
|
||||
List<LexiconEntry> entries;
|
||||
List<LexiconPage> pages=new ArrayList();
|
||||
if(entry!=null)
|
||||
pages.addAll(entry.pages);
|
||||
else
|
||||
for (LexiconEntry current_Entry : BotaniaAPI.getAllEntries())
|
||||
pages.addAll(current_Entry.pages);
|
||||
System.out.println("Pages: " + pages.size());
|
||||
|
||||
for (LexiconPage page : pages) {
|
||||
System.out.println("Page " + page.getUnlocalizedName() + " (" + page.getClass() + ")");
|
||||
MineTweakerAPI.logCommand(page.getUnlocalizedName() + " (" + page.getClass() + ")");
|
||||
|
||||
Reference in new issue
Block a user