Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e515bba
Move entry point stuff to main package
OliverSchlueter Dec 27, 2024
f1489e2
Move config and fflag to config package
OliverSchlueter Dec 27, 2024
b0e162d
Cleanup plugin main class
OliverSchlueter Dec 27, 2024
2d5f128
Rename main class to FancyHologramsPlugin
OliverSchlueter Dec 27, 2024
397cbb4
Move converter package
OliverSchlueter Dec 27, 2024
f34d7e1
Move and rename storage
OliverSchlueter Dec 27, 2024
d83d077
fix
OliverSchlueter Dec 27, 2024
507fbbd
json storage
OliverSchlueter Dec 27, 2024
9e8504b
work
OliverSchlueter Dec 27, 2024
1492ecd
back to yaml
OliverSchlueter Dec 27, 2024
23c599f
remove getdisplayentity
OliverSchlueter Dec 27, 2024
a2f599d
add registry
OliverSchlueter Dec 27, 2024
2d80564
add controller
OliverSchlueter Dec 27, 2024
0f23aab
get stuff together
OliverSchlueter Dec 27, 2024
8a9aef4
getName
OliverSchlueter Dec 27, 2024
f24d7fa
compile fixes
OliverSchlueter Dec 27, 2024
af952c9
builder
OliverSchlueter Dec 27, 2024
2c32d6c
more fixes
OliverSchlueter Dec 27, 2024
b53cb3f
more more fixes
OliverSchlueter Dec 27, 2024
30cdcce
it compiles
OliverSchlueter Dec 27, 2024
37dbe66
finish builder
OliverSchlueter Dec 28, 2024
8906487
docs and private constructor
OliverSchlueter Dec 28, 2024
de27e59
protected
OliverSchlueter Dec 28, 2024
c61283b
more builder methods
OliverSchlueter Dec 28, 2024
29784b6
fixes
OliverSchlueter Dec 28, 2024
4037e14
more text methods
OliverSchlueter Dec 28, 2024
d06a157
add func support
OliverSchlueter Dec 28, 2024
9b64bde
more internal annotations
OliverSchlueter Dec 28, 2024
5df3233
delete hologram manager
OliverSchlueter Dec 28, 2024
83a8dc1
constants
OliverSchlueter Dec 28, 2024
2de8601
refactor events
OliverSchlueter Dec 28, 2024
c89fa17
Add test system
OliverSchlueter Dec 28, 2024
e64e1a8
test command
OliverSchlueter Dec 28, 2024
3e9c248
More tests
OliverSchlueter Dec 28, 2024
9118b85
Add tests for hologram builders
OliverSchlueter Dec 28, 2024
04a9bf0
Add tests for controller
OliverSchlueter Dec 28, 2024
99e7c3a
Fix deleting holograms
OliverSchlueter Dec 28, 2024
c33ef15
Add json models
OliverSchlueter Dec 28, 2024
37b2758
to json adapter
OliverSchlueter Dec 28, 2024
eed9536
adapter fixes
OliverSchlueter Dec 28, 2024
277bbf2
Add DISABLE_HOLOGRAMS_FOR_OLD_CLIENTS fflag
OliverSchlueter Dec 28, 2024
1b173f4
Add trait system
OliverSchlueter Dec 28, 2024
1a5d4ff
Use scheduleWithFixedDelay
OliverSchlueter Jan 15, 2025
5be4e95
Add multiple pages trait (proof of concept)
OliverSchlueter Jan 15, 2025
3ae1764
Update ci action versions
OliverSchlueter Mar 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Cache Gradle dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package de.oliver.fancyholograms.api;

import de.oliver.fancyanalytics.logger.ExtendedFancyLogger;
import de.oliver.fancyholograms.api.data.HologramData;
import de.oliver.fancyholograms.api.hologram.Hologram;
import de.oliver.fancyholograms.api.trait.HologramTraitRegistry;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.ApiStatus;

import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Function;

public interface FancyHologramsPlugin {
public interface FancyHolograms {

static FancyHologramsPlugin get() {
static FancyHolograms get() {
if (isEnabled()) {
return EnabledChecker.getPlugin();
}
Expand All @@ -25,45 +30,24 @@ static boolean isEnabled() {

ExtendedFancyLogger getFancyLogger();

HologramManager getHologramManager();

/**
* Returns the configuration of the plugin.
*
* @return The configuration.
*/
HologramConfiguration getHologramConfiguration();

/**
* Sets the configuration of the plugin.
*
* @param configuration The new configuration.
* @param reload Whether the configuration should be reloaded.
*/
void setHologramConfiguration(HologramConfiguration configuration, boolean reload);

/**
* @return The hologram storage.
*/
HologramStorage getHologramStorage();

/**
* @return The hologram thread
*/
@ApiStatus.Internal
Function<HologramData, Hologram> getHologramFactory();

ScheduledExecutorService getHologramThread();

/**
* Sets the hologram storage.
*
* @param storage The new hologram storage.
* @param reload Whether the current hologram cache should be reloaded.
*/
void setHologramStorage(HologramStorage storage, boolean reload);
HologramRegistry getRegistry();

HologramController getController();

@ApiStatus.Experimental
HologramTraitRegistry getTraitRegistry();

class EnabledChecker {

private static Boolean enabled;
private static FancyHologramsPlugin plugin;
private static FancyHolograms plugin;

public static Boolean isFancyHologramsEnabled() {
if (enabled != null) return enabled;
Expand All @@ -72,7 +56,7 @@ public static Boolean isFancyHologramsEnabled() {

if (pl != null && pl.isEnabled()) {
try {
plugin = (FancyHologramsPlugin) pl;
plugin = (FancyHolograms) pl;
} catch (ClassCastException e) {
throw new IllegalStateException("API failed to access plugin, if using the FancyHolograms API make sure to set the dependency to compile only.");
}
Expand All @@ -84,7 +68,7 @@ public static Boolean isFancyHologramsEnabled() {
return false;
}

public static FancyHologramsPlugin getPlugin() {
public static FancyHolograms getPlugin() {
return plugin;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface HologramConfiguration {
*
* @param plugin The plugin instance.
*/
void reload(@NotNull FancyHologramsPlugin plugin);
void reload(@NotNull FancyHolograms plugin);

/**
* Returns whether version notifications are muted.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package de.oliver.fancyholograms.api;

import de.oliver.fancyholograms.api.hologram.Hologram;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;

/**
* The controller for holograms, responsible for showing and hiding them to players.
*/
public interface HologramController {

/**
* Shows the hologram to the given players, if they should see it, and it is not already shown to them.
*/
@ApiStatus.Internal
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.
*/
@ApiStatus.Internal
void hideHologramFrom(@NotNull final Hologram hologram, @NotNull final Player ...players);

/**
* Returns whether the given player should see the hologram.
*/
@ApiStatus.Internal
boolean shouldSeeHologram(@NotNull final Hologram hologram, @NotNull final Player player);

/**
* Spawns the hologram to the given players, if they should see it, and it is not already shown to them.
* Hide the hologram from the players that should not see it.
*/
void refreshHologram(@NotNull final Hologram hologram, @NotNull final Player ...players);

default void refreshHologram(@NotNull final Hologram hologram, @NotNull final Collection<? extends Player> players) {
refreshHologram(hologram, players.toArray(new Player[0]));
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package de.oliver.fancyholograms.api;

import de.oliver.fancyholograms.api.hologram.Hologram;

import java.util.Collection;
import java.util.Optional;

/**
* An interface for managing the registration and retrieval of holograms.
* Provides methods to register, unregister, and query holograms by their name.
*/
public interface HologramRegistry {

/**
* Registers a hologram in the registry.
*
* @param hologram the hologram to be registered
* @return {@code true} if the registration was successful, otherwise {@code false}
*/
boolean register(Hologram hologram);

/**
* Unregisters the specified hologram from the registry.
*
* @param hologram the hologram to be unregistered
* @return {@code true} if the hologram was successfully unregistered, otherwise {@code false}
*/
boolean unregister(Hologram hologram);

/**
* Checks if a hologram with the specified name exists in the registry.
*
* @param name the name of the hologram to check for existence
* @return {@code true} if a hologram with the specified name exists, otherwise {@code false}
*/
boolean contains(String name);

/**
* Retrieves a hologram by its name from the registry.
*
* @param name the name of the hologram to retrieve
* @return an {@code Optional} containing the hologram if found, or an empty {@code Optional} if no hologram exists with the specified name
*/
Optional<Hologram> get(String name);

/**
* Retrieves a hologram by its name from the registry, ensuring that the hologram exists.
* If no hologram exists with the specified name, this method will throw an exception.
*
* @param name the name of the hologram to retrieve
* @return the hologram associated with the specified name
* @throws IllegalArgumentException if no hologram exists with the given name
*/
Hologram mustGet(String name);

/**
* Retrieves all holograms currently registered in the registry.
*
* @return a collection containing all registered holograms
*/
Collection<Hologram> getAll();

/**
* Retrieves all persistent holograms currently registered in the registry.
*
* @return a collection containing all persistent holograms
*/
Collection<Hologram> getAllPersistent();

/**
* Removes all holograms from the registry, effectively clearing its contents.
*/
void clear();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.ApiStatus;

import java.util.Objects;

Expand Down Expand Up @@ -36,6 +37,7 @@ public BlockHologramData setBlock(Material block) {
}

@Override
@ApiStatus.Internal
public boolean read(ConfigurationSection section, String name) {
super.read(section, name);
block = Material.getMaterial(section.getString("block", "GRASS_BLOCK").toUpperCase());
Expand All @@ -44,6 +46,7 @@ public boolean read(ConfigurationSection section, String name) {
}

@Override
@ApiStatus.Internal
public boolean write(ConfigurationSection section, String name) {
super.write(section, name);
section.set("block", block.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public DisplayHologramData setInterpolationDuration(int interpolationDuration) {
}

@Override
@ApiStatus.Internal
public boolean read(ConfigurationSection section, String name) {
super.read(section, name);
scale = new Vector3f(
Expand Down Expand Up @@ -170,6 +171,7 @@ public boolean read(ConfigurationSection section, String name) {
}

@Override
@ApiStatus.Internal
public boolean write(ConfigurationSection section, String name) {
super.write(section, name);
section.set("scale_x", scale.x);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package de.oliver.fancyholograms.api.data;

import de.oliver.fancyholograms.api.FancyHologramsPlugin;
import de.oliver.fancyholograms.api.FancyHolograms;
import de.oliver.fancyholograms.api.data.property.Visibility;
import de.oliver.fancyholograms.api.hologram.HologramType;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -23,7 +24,7 @@ public class HologramData implements YamlData {
private final String name;
private final HologramType type;
private Location location;
private boolean hasChanges;
private boolean hasChanges = false;
private int visibilityDistance = DEFAULT_VISIBILITY_DISTANCE;
private Visibility visibility = DEFAULT_VISIBILITY;
private boolean persistent = DEFAULT_PERSISTENCE;
Expand Down Expand Up @@ -78,7 +79,7 @@ public int getVisibilityDistance() {
return visibilityDistance;
}

return FancyHologramsPlugin.get().getHologramConfiguration().getDefaultVisibilityDistance();
return FancyHolograms.get().getHologramConfiguration().getDefaultVisibilityDistance();
}

public HologramData setVisibilityDistance(int visibilityDistance) {
Expand Down Expand Up @@ -135,6 +136,7 @@ public HologramData setLinkedNpcName(String linkedNpcName) {
}

@Override
@ApiStatus.Internal
public boolean read(ConfigurationSection section, String name) {
String worldName = section.getString("location.world", "world");
float x = (float) section.getDouble("location.x", 0);
Expand All @@ -145,7 +147,7 @@ public boolean read(ConfigurationSection section, String name) {

World world = Bukkit.getWorld(worldName);
if (world == null) {
FancyHologramsPlugin.get().getFancyLogger().warn("Could not load hologram '" + name + "', because the world '" + worldName + "' is not loaded");
FancyHolograms.get().getFancyLogger().warn("Could not load hologram '" + name + "', because the world '" + worldName + "' is not loaded");
return false;
}

Expand All @@ -163,6 +165,7 @@ public boolean read(ConfigurationSection section, String name) {
}

@Override
@ApiStatus.Internal
public boolean write(ConfigurationSection section, String name) {
section.set("type", type.name());
section.set("location.world", location.getWorld().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;

import java.util.Objects;

Expand Down Expand Up @@ -37,6 +38,7 @@ public ItemHologramData setItemStack(ItemStack item) {
}

@Override
@ApiStatus.Internal
public boolean read(ConfigurationSection section, String name) {
super.read(section, name);
item = section.getItemStack("item", DEFAULT_ITEM);
Expand All @@ -45,6 +47,7 @@ public boolean read(ConfigurationSection section, String name) {
}

@Override
@ApiStatus.Internal
public boolean write(ConfigurationSection section, String name) {
super.write(section, name);
section.set("item", item);
Expand Down
Loading