-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc4f454
commit 43a47a2
Showing
4 changed files
with
162 additions
and
19 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
api/src/main/java/de/oliver/fancyholograms/api/data/builder/BlockHologramBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
84 changes: 65 additions & 19 deletions
84
api/src/main/java/de/oliver/fancyholograms/api/data/builder/HologramBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
api/src/main/java/de/oliver/fancyholograms/api/data/builder/ItemHologramBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
api/src/main/java/de/oliver/fancyholograms/api/data/builder/TextHologramBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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; | ||
} | ||
|
||
} |