Added option to change back content for usercontent

This commit is contained in:
Marcel Konrad
2019-11-11 23:08:20 +01:00
parent 6a3c762559
commit 3c5c8b0ec2
2 changed files with 34 additions and 1 deletions

View File

@@ -180,6 +180,17 @@ public class ContentUsercontent extends Content
return Contents.getRegisteredContent(this.content.getGui().getTab().getActiveContent()); 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 @Override
public void onPlayerNameChanged(String username) public void onPlayerNameChanged(String username)
{ {

View File

@@ -20,12 +20,16 @@ public class JsonTab
@SerializedName("active_content") @SerializedName("active_content")
private String activeContent; 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.title = title;
this.category = category; this.category = category;
this.categoryIndex = categoryIndex; this.categoryIndex = categoryIndex;
this.activeContent = activeContent; this.activeContent = activeContent;
this.backContent = backContent;
} }
public String getTitle() public String getTitle()
@@ -68,11 +72,29 @@ public class JsonTab
this.activeContent = activeContent; this.activeContent = activeContent;
} }
public String getBackContent()
{
return this.backContent;
}
public void setBackContent(String backContent)
{
this.backContent = backContent;
}
public void validate() throws IllegalStateException public void validate() throws IllegalStateException
{ {
if(this.category == null) if(this.category == null)
{ {
throw new IllegalStateException("tab.category is 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");
}
} }
} }