From 1e00615aaac83cf94e50c3419a42933e773f5aab Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 2 Aug 2016 01:22:50 +0200 Subject: [PATCH] Added the ability to add text replacements via the API --- .../api/booklet/BookletPage.java | 18 ++++++++++++++++++ .../mod/booklet/page/BookletPageAA.java | 18 +----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/BookletPage.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/BookletPage.java index bc8aaee35..d7a1a0966 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/BookletPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/BookletPage.java @@ -16,10 +16,14 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.HashMap; + public abstract class BookletPage{ public boolean arePageStacksWildcard; protected IBookletChapter chapter; + protected final HashMap textReplacements = new HashMap(); + protected boolean hasNoText; public void onOpened(IBookletGui gui){ @@ -88,4 +92,18 @@ public abstract class BookletPage{ this.arePageStacksWildcard = true; return this; } + + public BookletPage setNoText(){ + this.hasNoText = true; + return this; + } + + public BookletPage addTextReplacement(String text, int replacement){ + return this.addTextReplacement(text, Integer.toString(replacement)); + } + + public BookletPage addTextReplacement(String text, String replacement){ + this.textReplacements.put(text, replacement); + return this; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPageAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPageAA.java index 806d584d3..7a5440660 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPageAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPageAA.java @@ -26,8 +26,6 @@ import java.util.Map; public class BookletPageAA extends BookletPage{ protected final int localizationKey; - private final HashMap textReplacements = new HashMap(); - private boolean hasNoText; public BookletPageAA(int localizationKey){ this.localizationKey = localizationKey; @@ -39,7 +37,7 @@ public class BookletPageAA extends BookletPage{ } @Override - public final String getText(){ + public String getText(){ if(this.hasNoText){ return null; } @@ -83,20 +81,6 @@ public class BookletPageAA extends BookletPage{ return TextFormatting.GOLD+StringUtil.localize("booklet."+ModUtil.MOD_ID+".clickToSeeRecipe"); } - public BookletPage setNoText(){ - this.hasNoText = true; - return this; - } - - public BookletPageAA addTextReplacement(String text, int replacement){ - return this.addTextReplacement(text, Integer.toString(replacement)); - } - - public BookletPageAA addTextReplacement(String text, String replacement){ - this.textReplacements.put(text, replacement); - return this; - } - public void addToPagesWithItemStackData(){ if(!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_DATA.contains(this)){ ItemStack[] stacks = this.getItemStacksForPage();