diff --git a/api/src/main/java/de/oliver/fancyholograms/api/data/builder/BlockHologramBuilder.java b/api/src/main/java/de/oliver/fancyholograms/api/data/builder/BlockHologramBuilder.java new file mode 100644 index 00000000..715bf9a7 --- /dev/null +++ b/api/src/main/java/de/oliver/fancyholograms/api/data/builder/BlockHologramBuilder.java @@ -0,0 +1,23 @@ +package de.oliver.fancyholograms.api.data.builder; + +import de.oliver.fancyholograms.api.data.BlockHologramData; +import org.bukkit.Location; +import org.bukkit.Material; + +public class BlockHologramBuilder extends HologramBuilder{ + + public BlockHologramBuilder(String name, Location location) { + super(); + this.data = new BlockHologramData(name, location); + } + + public static BlockHologramBuilder create(String name, Location location) { + return new BlockHologramBuilder(name, location); + } + + public BlockHologramBuilder block(Material block) { + ((BlockHologramData) data).setBlock(block); + return this; + } + +} diff --git a/api/src/main/java/de/oliver/fancyholograms/api/data/builder/HologramBuilder.java b/api/src/main/java/de/oliver/fancyholograms/api/data/builder/HologramBuilder.java index c421fb2d..9c93bd24 100644 --- a/api/src/main/java/de/oliver/fancyholograms/api/data/builder/HologramBuilder.java +++ b/api/src/main/java/de/oliver/fancyholograms/api/data/builder/HologramBuilder.java @@ -1,33 +1,79 @@ package de.oliver.fancyholograms.api.data.builder; import de.oliver.fancyholograms.api.FancyHolograms; -import de.oliver.fancyholograms.api.data.BlockHologramData; -import de.oliver.fancyholograms.api.data.HologramData; -import de.oliver.fancyholograms.api.data.ItemHologramData; -import de.oliver.fancyholograms.api.data.TextHologramData; +import de.oliver.fancyholograms.api.data.DisplayHologramData; +import de.oliver.fancyholograms.api.data.property.Visibility; import de.oliver.fancyholograms.api.hologram.Hologram; -import de.oliver.fancyholograms.api.hologram.HologramType; -import org.bukkit.Location; +import org.bukkit.entity.Display; +import org.joml.Vector3f; -public class HologramBuilder { +public abstract class HologramBuilder { - private final HologramData data; + protected DisplayHologramData data; - private HologramBuilder(HologramType type, String name, Location location) { - switch (type){ - case TEXT -> data = new TextHologramData(name, location); - case ITEM -> data = new ItemHologramData(name, location); - case BLOCK -> data = new BlockHologramData(name, location); - default -> throw new UnsupportedOperationException("Unsupported hologram type: " + type); - } - } - - public static HologramBuilder create(HologramType type, String name, Location location) { - return new HologramBuilder(type, name, location); + HologramBuilder() { } public Hologram build() { return FancyHolograms.get().getHologramFactory().apply(data); } + // The following methods are setters for the HologramData class + + public HologramBuilder visibilityDistance(int distance) { + data.setVisibilityDistance(distance); + return this; + } + + public HologramBuilder visibility(Visibility visibility) { + data.setVisibility(visibility); + return this; + } + + public HologramBuilder persistent(boolean persistent) { + data.setPersistent(persistent); + return this; + } + + public HologramBuilder linkedNpcName(String linkedNpcName) { + data.setLinkedNpcName(linkedNpcName); + return this; + } + + // The following methods are specific to the DisplayHologramData class + + public HologramBuilder billboard(Display.Billboard billboard) { + data.setBillboard(billboard); + return this; + } + + public HologramBuilder scale(float x, float y, float z) { + data.setScale(new Vector3f(x, y, z)); + return this; + } + + public HologramBuilder translation(float x, float y, float z) { + data.setTranslation(new Vector3f(x, y, z)); + return this; + } + + public HologramBuilder brightness(int blockLight, int skyLight) { + data.setBrightness(new Display.Brightness(blockLight, skyLight)); + return this; + } + + public HologramBuilder shadowRadius(float shadowRadius) { + data.setShadowRadius(shadowRadius); + return this; + } + + public HologramBuilder shadowStrength(float shadowStrength) { + data.setShadowStrength(shadowStrength); + return this; + } + + public HologramBuilder interpolationDuration(int interpolationDuration) { + data.setInterpolationDuration(interpolationDuration); + return this; + } } diff --git a/api/src/main/java/de/oliver/fancyholograms/api/data/builder/ItemHologramBuilder.java b/api/src/main/java/de/oliver/fancyholograms/api/data/builder/ItemHologramBuilder.java new file mode 100644 index 00000000..cf446448 --- /dev/null +++ b/api/src/main/java/de/oliver/fancyholograms/api/data/builder/ItemHologramBuilder.java @@ -0,0 +1,23 @@ +package de.oliver.fancyholograms.api.data.builder; + +import de.oliver.fancyholograms.api.data.ItemHologramData; +import org.bukkit.Location; +import org.bukkit.inventory.ItemStack; + +public class ItemHologramBuilder extends HologramBuilder{ + + public ItemHologramBuilder(String name, Location location) { + super(); + this.data = new ItemHologramData(name, location); + } + + public static ItemHologramBuilder create(String name, Location location) { + return new ItemHologramBuilder(name, location); + } + + public ItemHologramBuilder item(ItemStack item) { + ((ItemHologramData) data).setItemStack(item); + return this; + } + +} diff --git a/api/src/main/java/de/oliver/fancyholograms/api/data/builder/TextHologramBuilder.java b/api/src/main/java/de/oliver/fancyholograms/api/data/builder/TextHologramBuilder.java new file mode 100644 index 00000000..4081436f --- /dev/null +++ b/api/src/main/java/de/oliver/fancyholograms/api/data/builder/TextHologramBuilder.java @@ -0,0 +1,51 @@ +package de.oliver.fancyholograms.api.data.builder; + +import de.oliver.fancyholograms.api.data.TextHologramData; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.TextDisplay; + +import java.util.List; + +public class TextHologramBuilder extends HologramBuilder{ + + private TextHologramBuilder(String name, Location location) { + super(); + this.data = new TextHologramData(name, location); + } + + public static TextHologramBuilder create(String name, Location location) { + return new TextHologramBuilder(name, location); + } + + public TextHologramBuilder text(List text) { + ((TextHologramData) data).setText(text); + return this; + } + + public TextHologramBuilder background(Color background) { + ((TextHologramData) data).setBackground(background); + return this; + } + + public TextHologramBuilder textAlignment(TextDisplay.TextAlignment textAlignment) { + ((TextHologramData) data).setTextAlignment(textAlignment); + return this; + } + + public TextHologramBuilder textShadow(boolean textShadow) { + ((TextHologramData) data).setTextShadow(textShadow); + return this; + } + + public TextHologramBuilder seeThrough(boolean seeThrough) { + ((TextHologramData) data).setSeeThrough(seeThrough); + return this; + } + + public TextHologramBuilder updateTextInterval(int updateTextInterval) { + ((TextHologramData) data).setTextUpdateInterval(updateTextInterval); + return this; + } + +}