mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancydialogs: Introduce DialogBody and its implementations
This commit is contained in:
@@ -1,25 +1,30 @@
|
||||
package com.fancyinnovations.fancydialogs.api;
|
||||
|
||||
import com.fancyinnovations.fancydialogs.api.body.DialogBody;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Dialog {
|
||||
|
||||
private final @NotNull String id;
|
||||
private @NotNull String title;
|
||||
private @Nullable String externalTitle;
|
||||
private boolean canCloseWithEscape;
|
||||
private @NotNull List<DialogBody> body;
|
||||
|
||||
/**
|
||||
* @param externalTitle if null, the title will be used
|
||||
* @param canCloseWithEscape default is true
|
||||
*/
|
||||
public Dialog(@NotNull String id, @NotNull String title, @Nullable String externalTitle, @Nullable Boolean canCloseWithEscape) {
|
||||
public Dialog(@NotNull String id, @NotNull String title, @Nullable String externalTitle, @Nullable Boolean canCloseWithEscape, @NotNull List<DialogBody> body) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.externalTitle = externalTitle == null ? title : externalTitle;
|
||||
this.canCloseWithEscape = canCloseWithEscape == null || canCloseWithEscape;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
abstract public void show(Player player);
|
||||
@@ -53,4 +58,12 @@ public abstract class Dialog {
|
||||
public void setCanCloseWithEscape(boolean canCloseWithEscape) {
|
||||
this.canCloseWithEscape = canCloseWithEscape;
|
||||
}
|
||||
|
||||
public @NotNull List<DialogBody> getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(@NotNull List<DialogBody> body) {
|
||||
this.body = body;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.fancyinnovations.fancydialogs.api.body;
|
||||
|
||||
public abstract class DialogBody {
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.fancyinnovations.fancydialogs.api.body;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ItemBody extends DialogBody {
|
||||
|
||||
private @NotNull ItemStack item;
|
||||
private @Nullable TextBody description;
|
||||
boolean showDecorations;
|
||||
boolean showTooltip;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
public ItemBody(@NotNull ItemStack item, @Nullable TextBody description, boolean showDecorations, boolean showTooltip, int width, int height) {
|
||||
this.item = item;
|
||||
this.description = description;
|
||||
this.showDecorations = showDecorations;
|
||||
this.showTooltip = showTooltip;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public @NotNull ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void setItem(@NotNull ItemStack item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public @Nullable TextBody getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable TextBody description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isShowDecorations() {
|
||||
return showDecorations;
|
||||
}
|
||||
|
||||
public void setShowDecorations(boolean showDecorations) {
|
||||
this.showDecorations = showDecorations;
|
||||
}
|
||||
|
||||
public boolean isShowTooltip() {
|
||||
return showTooltip;
|
||||
}
|
||||
|
||||
public void setShowTooltip(boolean showTooltip) {
|
||||
this.showTooltip = showTooltip;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.fancyinnovations.fancydialogs.api.body;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TextBody extends DialogBody {
|
||||
|
||||
private @NotNull String content;
|
||||
private int width;
|
||||
|
||||
public TextBody(@NotNull String content, int width) {
|
||||
this.content = content;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public @NotNull String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(@NotNull String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user