fancyholograms-v3: More javadocs

This commit is contained in:
Oliver
2025-09-14 10:29:27 +02:00
parent e206e8f61c
commit e61b346395
4 changed files with 77 additions and 3 deletions

View File

@@ -13,13 +13,13 @@ import java.util.Collection;
public interface HologramController { public interface HologramController {
/** /**
* Shows the hologram to the given players, if they should see it, and it is not already shown to them. * Shows the hologram to the given players if they should see it, and it is not yet shown to them.
*/ */
@ApiStatus.Internal @ApiStatus.Internal
void showHologramTo(@NotNull final Hologram hologram, @NotNull final Player... players); void showHologramTo(@NotNull final Hologram hologram, @NotNull final Player... players);
/** /**
* Hides the hologram from the given players, if they should not see it, and it is shown to them. * Hides the hologram from the given players if they should not see it, and it is shown to them.
*/ */
@ApiStatus.Internal @ApiStatus.Internal
void hideHologramFrom(@NotNull final Hologram hologram, @NotNull final Player... players); void hideHologramFrom(@NotNull final Hologram hologram, @NotNull final Player... players);
@@ -38,7 +38,7 @@ public interface HologramController {
void updateHologramData(@NotNull final Hologram hologram, @NotNull final Player... players); void updateHologramData(@NotNull final Hologram hologram, @NotNull final Player... players);
/** /**
* Spawns the hologram to the given players, if they should see it, and it is not already shown to them. * Spawns the hologram to the given players if they should see it, and it is not yet shown to them.
* Hide the hologram from the players that should not see it. * Hide the hologram from the players that should not see it.
*/ */
void refreshHologram(@NotNull final Hologram hologram, @NotNull final Player... players); void refreshHologram(@NotNull final Hologram hologram, @NotNull final Player... players);

View File

@@ -22,6 +22,11 @@ public class BlockHologramBuilder extends HologramBuilder {
return new BlockHologramBuilder(name, location); return new BlockHologramBuilder(name, location);
} }
/**
* Sets the block material for the block hologram.
*
* @param block the material of the block
*/
public BlockHologramBuilder block(Material block) { public BlockHologramBuilder block(Material block) {
((BlockHologramData) data).setBlock(block); ((BlockHologramData) data).setBlock(block);
return this; return this;

View File

@@ -39,21 +39,43 @@ public abstract class HologramBuilder {
// The following methods are setters for the HologramData class // The following methods are setters for the HologramData class
/**
* Sets the visibility distance for the hologram
*
* @param distance the visibility distance in blocks
*/
public HologramBuilder visibilityDistance(int distance) { public HologramBuilder visibilityDistance(int distance) {
data.setVisibilityDistance(distance); data.setVisibilityDistance(distance);
return this; return this;
} }
/**
* Sets the visibility mode for the hologram
*
* @param visibility the visibility mode
*/
public HologramBuilder visibility(Visibility visibility) { public HologramBuilder visibility(Visibility visibility) {
data.setVisibility(visibility); data.setVisibility(visibility);
return this; return this;
} }
/**
* Sets whether the hologram is persistent (remains after server restarts)
* Default is true.
*
* @param persistent true if the hologram should be persistent, false otherwise
*/
public HologramBuilder persistent(boolean persistent) { public HologramBuilder persistent(boolean persistent) {
data.setPersistent(persistent); data.setPersistent(persistent);
return this; return this;
} }
/**
* Sets the name of the NPC to which the hologram is linked.
* It will become the NPC's display name.
*
* @param linkedNpcName the name of the NPC to link to
*/
public HologramBuilder linkedNpcName(String linkedNpcName) { public HologramBuilder linkedNpcName(String linkedNpcName) {
data.setLinkedNpcName(linkedNpcName); data.setLinkedNpcName(linkedNpcName);
return this; return this;
@@ -61,6 +83,8 @@ public abstract class HologramBuilder {
/** /**
* Adds a trait to the hologram. * Adds a trait to the hologram.
*
* @param trait the class of the trait to add
*/ */
public final HologramBuilder trait(Class<? extends HologramTrait> trait) { public final HologramBuilder trait(Class<? extends HologramTrait> trait) {
data.addTrait(trait); data.addTrait(trait);
@@ -70,36 +94,76 @@ public abstract class HologramBuilder {
// The following methods are specific to the DisplayHologramData class // The following methods are specific to the DisplayHologramData class
/**
* Sets the display billboard mode for the hologram.
*
* @param billboard the billboard mode
*/
public HologramBuilder billboard(Display.Billboard billboard) { public HologramBuilder billboard(Display.Billboard billboard) {
data.setBillboard(billboard); data.setBillboard(billboard);
return this; return this;
} }
/**
* Sets the display transform for the hologram.
*
* @param x the factor to scale on the x-axis
* @param y the factor to scale on the y-axis
* @param z the factor to scale on the z-axis
*/
public HologramBuilder scale(float x, float y, float z) { public HologramBuilder scale(float x, float y, float z) {
data.setScale(new Vector3f(x, y, z)); data.setScale(new Vector3f(x, y, z));
return this; return this;
} }
/**
* Moves the hologram by the specified amounts along each axis.
*
* @param x the amount to move along the x-axis
* @param y the amount to move along the y-axis
* @param z the amount to move along the z-axis
*/
public HologramBuilder translation(float x, float y, float z) { public HologramBuilder translation(float x, float y, float z) {
data.setTranslation(new Vector3f(x, y, z)); data.setTranslation(new Vector3f(x, y, z));
return this; return this;
} }
/**
* Sets the brightness for the hologram.
*
* @param blockLight the block light level (0-15)
* @param skyLight the skylight level (0-15)
*/
public HologramBuilder brightness(int blockLight, int skyLight) { public HologramBuilder brightness(int blockLight, int skyLight) {
data.setBrightness(new Display.Brightness(blockLight, skyLight)); data.setBrightness(new Display.Brightness(blockLight, skyLight));
return this; return this;
} }
/**
* Sets the shadow properties for the hologram.
*
* @param shadowRadius the radius of the shadow
*/
public HologramBuilder shadowRadius(float shadowRadius) { public HologramBuilder shadowRadius(float shadowRadius) {
data.setShadowRadius(shadowRadius); data.setShadowRadius(shadowRadius);
return this; return this;
} }
/**
* Sets the shadow strength for the hologram.
*
* @param shadowStrength the strength of the shadow
*/
public HologramBuilder shadowStrength(float shadowStrength) { public HologramBuilder shadowStrength(float shadowStrength) {
data.setShadowStrength(shadowStrength); data.setShadowStrength(shadowStrength);
return this; return this;
} }
/**
* Sets the interpolation duration for the hologram.
*
* @param interpolationDuration the duration in ticks
*/
public HologramBuilder interpolationDuration(int interpolationDuration) { public HologramBuilder interpolationDuration(int interpolationDuration) {
data.setInterpolationDuration(interpolationDuration); data.setInterpolationDuration(interpolationDuration);
return this; return this;

View File

@@ -22,6 +22,11 @@ public class ItemHologramBuilder extends HologramBuilder {
return new ItemHologramBuilder(name, location); return new ItemHologramBuilder(name, location);
} }
/**
* Sets the item stack for the item hologram.
*
* @param item the item stack to be displayed
*/
public ItemHologramBuilder item(ItemStack item) { public ItemHologramBuilder item(ItemStack item) {
((ItemHologramData) data).setItemStack(item); ((ItemHologramData) data).setItemStack(item);
return this; return this;