From 3c5c8b0ec2f4c67f518df911fabfc4f7c8ebd9ad Mon Sep 17 00:00:00 2001 From: Marcel Konrad Date: Mon, 11 Nov 2019 23:08:20 +0100 Subject: [PATCH] Added option to change back content for usercontent --- .../gui/content/impl/ContentUsercontent.java | 11 +++++++++ .../usercontent/model/JsonTab.java | 24 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentUsercontent.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentUsercontent.java index d94ecd0..b82aa47 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentUsercontent.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentUsercontent.java @@ -180,6 +180,17 @@ public class ContentUsercontent extends Content return Contents.getRegisteredContent(this.content.getGui().getTab().getActiveContent()); } + @Override + public Content getBackContent() + { + if(this.content.getGui().getTab().getActiveContent() == null) + { + return super.getBackContent(); + } + + return Contents.getRegisteredContent(this.content.getGui().getTab().getBackContent()); + } + @Override public void onPlayerNameChanged(String username) { diff --git a/src/main/java/exopandora/worldhandler/usercontent/model/JsonTab.java b/src/main/java/exopandora/worldhandler/usercontent/model/JsonTab.java index a2f809e..a7be4b1 100644 --- a/src/main/java/exopandora/worldhandler/usercontent/model/JsonTab.java +++ b/src/main/java/exopandora/worldhandler/usercontent/model/JsonTab.java @@ -20,12 +20,16 @@ public class JsonTab @SerializedName("active_content") private String activeContent; - public JsonTab(String title, String category, int categoryIndex, String activeContent) + @SerializedName("back_content") + private String backContent; + + public JsonTab(String title, String category, int categoryIndex, String activeContent, String backContent) { this.title = title; this.category = category; this.categoryIndex = categoryIndex; this.activeContent = activeContent; + this.backContent = backContent; } public String getTitle() @@ -68,11 +72,29 @@ public class JsonTab this.activeContent = activeContent; } + public String getBackContent() + { + return this.backContent; + } + + public void setBackContent(String backContent) + { + this.backContent = backContent; + } + public void validate() throws IllegalStateException { if(this.category == null) { throw new IllegalStateException("tab.category is null"); } + else if(this.activeContent != null && this.activeContent.isEmpty()) + { + throw new IllegalStateException("tab.active_content is empty"); + } + else if(this.backContent != null && this.backContent.isEmpty()) + { + throw new IllegalStateException("tab.back_content is empty"); + } } }