mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancyholograms-v3: Formatting
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
**ATTENTION**: v3.0.0 is still in development and contains breaking changes and potential bugs. Do not use this version in production at all, or you may lose data!!
|
||||
**ATTENTION**: v3.0.0 is still in development and contains breaking changes and potential bugs. Do not use this version
|
||||
in production at all, or you may lose data!!
|
||||
|
||||
Commit hash: %COMMIT_HASH%
|
||||
|
||||
@@ -6,4 +7,5 @@ Commit message: %COMMIT_MESSAGE%
|
||||
|
||||
*(The last commit message does not always directly reflect the changes related to this version.)*
|
||||
|
||||
Keep in mind that this is a snapshot version. Snapshot versions are **not** meant to be used in production. They are for **testing purposes only** and may contain bugs or incomplete features. Use at your own risk.
|
||||
Keep in mind that this is a snapshot version. Snapshot versions are **not** meant to be used in production. They are for
|
||||
**testing purposes only** and may contain bugs or incomplete features. Use at your own risk.
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
**Traits**
|
||||
Built-in traits:
|
||||
|
||||
- `trait_trait`: Manages the hologram's traits (default)
|
||||
- `multiple_pages_trait`: Allows you to create multiple pages in a hologram
|
||||
- `file_content_trait`: Allows you to display the content of a file in a hologram
|
||||
- `interaction_trait`: Allows you to make clickable holograms
|
||||
@@ -16,13 +16,13 @@ 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);
|
||||
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);
|
||||
void hideHologramFrom(@NotNull final Hologram hologram, @NotNull final Player... players);
|
||||
|
||||
/**
|
||||
* Returns whether the given player should see the hologram.
|
||||
@@ -35,13 +35,13 @@ public interface HologramController {
|
||||
* Be aware that some data changes require the hologram to be fully respawned.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
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.
|
||||
* 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);
|
||||
|
||||
default void refreshHologram(@NotNull final Hologram hologram, @NotNull final Collection<? extends Player> players) {
|
||||
refreshHologram(hologram, players.toArray(new Player[0]));
|
||||
|
||||
@@ -160,7 +160,7 @@ public class DisplayHologramData extends HologramData {
|
||||
int blockBrightness = Math.min(15, section.getInt("block_brightness", -1));
|
||||
int skyBrightness = Math.min(15, section.getInt("sky_brightness", -1));
|
||||
|
||||
if(blockBrightness > -1 || skyBrightness > -1) {
|
||||
if (blockBrightness > -1 || skyBrightness > -1) {
|
||||
brightness = new Display.Brightness(
|
||||
Math.max(0, blockBrightness),
|
||||
Math.max(0, skyBrightness)
|
||||
@@ -183,7 +183,7 @@ public class DisplayHologramData extends HologramData {
|
||||
section.set("shadow_radius", shadowRadius);
|
||||
section.set("shadow_strength", shadowStrength);
|
||||
|
||||
if(brightness != null) {
|
||||
if (brightness != null) {
|
||||
section.set("block_brightness", brightness.getBlockLight());
|
||||
section.set("sky_brightness", brightness.getSkyLight());
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class HologramData implements YamlData {
|
||||
|
||||
private final String name;
|
||||
private final HologramType type;
|
||||
private String filePath;
|
||||
private String filePath;
|
||||
private Location location;
|
||||
private String worldName;
|
||||
private boolean hasChanges = false;
|
||||
|
||||
@@ -4,7 +4,7 @@ import de.oliver.fancyholograms.api.data.BlockHologramData;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class BlockHologramBuilder extends HologramBuilder{
|
||||
public class BlockHologramBuilder extends HologramBuilder {
|
||||
|
||||
private BlockHologramBuilder(String name, Location location) {
|
||||
super();
|
||||
@@ -14,7 +14,7 @@ public class BlockHologramBuilder extends HologramBuilder{
|
||||
/**
|
||||
* Creates a new instance of BlockHologramBuilder with the specified name and location.
|
||||
*
|
||||
* @param name the name of the block hologram
|
||||
* @param name the name of the block hologram
|
||||
* @param location the location of the block hologram
|
||||
* @return a new instance of BlockHologramBuilder
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@ import de.oliver.fancyholograms.api.data.ItemHologramData;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemHologramBuilder extends HologramBuilder{
|
||||
public class ItemHologramBuilder extends HologramBuilder {
|
||||
|
||||
private ItemHologramBuilder(String name, Location location) {
|
||||
super();
|
||||
@@ -14,7 +14,7 @@ public class ItemHologramBuilder extends HologramBuilder{
|
||||
/**
|
||||
* Creates a new instance of ItemHologramBuilder with the specified name and location.
|
||||
*
|
||||
* @param name the name of the item hologram
|
||||
* @param name the name of the item hologram
|
||||
* @param location the location of the item hologram
|
||||
* @return a new instance of ItemHologramBuilder
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.bukkit.entity.TextDisplay;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TextHologramBuilder extends HologramBuilder{
|
||||
public class TextHologramBuilder extends HologramBuilder {
|
||||
|
||||
private TextHologramBuilder(String name, Location location) {
|
||||
super();
|
||||
@@ -17,7 +17,7 @@ public class TextHologramBuilder extends HologramBuilder{
|
||||
/**
|
||||
* Creates a new instance of TextHologramBuilder with the specified name and location.
|
||||
*
|
||||
* @param name the name of the text hologram
|
||||
* @param name the name of the text hologram
|
||||
* @param location the location of the text hologram
|
||||
* @return a new instance of TextHologramBuilder
|
||||
*/
|
||||
@@ -34,7 +34,7 @@ public class TextHologramBuilder extends HologramBuilder{
|
||||
return text(List.of(text));
|
||||
}
|
||||
|
||||
public TextHologramBuilder text(String ... text) {
|
||||
public TextHologramBuilder text(String... text) {
|
||||
return text(List.of(text));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public enum Visibility {
|
||||
* The player needs permission to see a specific hologram.
|
||||
*/
|
||||
PERMISSION_REQUIRED(
|
||||
(player, hologram) -> player.hasPermission("fancyholograms.viewhologram." + hologram.getData().getName())
|
||||
(player, hologram) -> player.hasPermission("fancyholograms.viewhologram." + hologram.getData().getName())
|
||||
),
|
||||
/**
|
||||
* The player needs to be added manually through the API
|
||||
@@ -32,8 +32,8 @@ public enum Visibility {
|
||||
|
||||
public static Optional<Visibility> byString(String value) {
|
||||
return Arrays.stream(Visibility.values())
|
||||
.filter(visibility -> visibility.toString().equalsIgnoreCase(value))
|
||||
.findFirst();
|
||||
.filter(visibility -> visibility.toString().equalsIgnoreCase(value))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
public boolean canSee(Player player, Hologram hologram) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.oliver.fancyholograms.api.events;
|
||||
|
||||
import de.oliver.fancyholograms.api.hologram.Hologram;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -10,7 +10,8 @@ public class HologramTraitAttachedEvent extends HologramEvent {
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
@NotNull private final HologramTrait trait;
|
||||
@NotNull
|
||||
private final HologramTrait trait;
|
||||
private final boolean isDefaultTrait;
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.oliver.fancyholograms.api.events;
|
||||
|
||||
import de.oliver.fancyholograms.api.data.HologramData;
|
||||
import de.oliver.fancyholograms.api.hologram.Hologram;
|
||||
import de.oliver.fancyholograms.api.data.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -116,7 +116,7 @@ public abstract class HologramTrait {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected <T extends HologramTrait> T getTrait(Class<T> trait) {
|
||||
protected <T extends HologramTrait> T getTrait(Class<T> trait) {
|
||||
for (HologramTrait hologramTrait : hologram.getTraitTrait().getTraits()) {
|
||||
if (hologramTrait.getClass().equals(trait)) {
|
||||
return (T) hologramTrait;
|
||||
|
||||
@@ -7,12 +7,14 @@ import java.lang.annotation.RetentionPolicy;
|
||||
public @interface HologramTraitClass {
|
||||
/**
|
||||
* The name of the trait. This is used to identify the trait in the system.
|
||||
*
|
||||
* @return The name of the trait.
|
||||
*/
|
||||
String traitName();
|
||||
|
||||
/**
|
||||
* Whether the trait is a default trait or not. Default traits are automatically attached to holograms.
|
||||
*
|
||||
* @return The description of the trait.
|
||||
*/
|
||||
boolean defaultTrait() default false;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"plugin_jar_path": "../../../../plugins/fancyholograms/build/libs/FancyHolograms-%VERSION%.jar",
|
||||
"changelog_path": "../../../../plugins/fancyholograms/CHANGELOG.md",
|
||||
"version_path": "../../../../plugins/fancyholograms/VERSION",
|
||||
"supported_versions":[
|
||||
"supported_versions": [
|
||||
"1.19.4",
|
||||
"1.20",
|
||||
"1.20.1",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"plugin_jar_path": "../../../../plugins/fancyholograms/build/libs/FancyHolograms-%VERSION%.jar",
|
||||
"changelog_path": "../../../../plugins/fancyholograms/CHANGELOG-SNAPSHOT.md",
|
||||
"version_path": "../../../../plugins/fancyholograms/VERSION",
|
||||
"supported_versions":[
|
||||
"supported_versions": [
|
||||
"1.19.4",
|
||||
"1.20",
|
||||
"1.20.1",
|
||||
|
||||
@@ -67,36 +67,36 @@ public final class FancyHologramsCMD extends Command {
|
||||
|
||||
final String converterId = args[1];
|
||||
FHConversionRegistry.getConverterById(converterId)
|
||||
.ifPresentOrElse((converter) -> {
|
||||
final String[] converterArgs = Arrays.asList(args)
|
||||
.subList(2, args.length)
|
||||
.toArray(String[]::new);
|
||||
.ifPresentOrElse((converter) -> {
|
||||
final String[] converterArgs = Arrays.asList(args)
|
||||
.subList(2, args.length)
|
||||
.toArray(String[]::new);
|
||||
|
||||
final ConverterTarget target = ConverterTarget.ofStringNullable(args[2]);
|
||||
final ConverterTarget target = ConverterTarget.ofStringNullable(args[2]);
|
||||
|
||||
if (target == null) {
|
||||
MessageHelper.error(sender, "Invalid regex for your conversion target!");
|
||||
return;
|
||||
}
|
||||
|
||||
final HologramConversionSession session = new HologramConversionSession(target, sender, converterArgs);
|
||||
|
||||
try {
|
||||
final List<HologramData> holograms = converter.convert(session);
|
||||
|
||||
for (final HologramData data : holograms) {
|
||||
final Hologram hologram = this.plugin.getHologramFactory().apply(data);
|
||||
this.plugin.getRegistry().register(hologram);
|
||||
if (target == null) {
|
||||
MessageHelper.error(sender, "Invalid regex for your conversion target!");
|
||||
return;
|
||||
}
|
||||
|
||||
this.plugin.savePersistentHolograms();
|
||||
// TODO(matt): Give options to delete them or teleport and a list of IDs please
|
||||
final HologramConversionSession session = new HologramConversionSession(target, sender, converterArgs);
|
||||
|
||||
MessageHelper.success(sender, String.format("Converted successfully, produced %s total holograms!", holograms.size()));
|
||||
} catch (Exception error) {
|
||||
MessageHelper.error(sender, error.getMessage());
|
||||
}
|
||||
}, () -> MessageHelper.error(sender, "That converter is not registered. Look at the developer documentation if you are adding converters."));
|
||||
try {
|
||||
final List<HologramData> holograms = converter.convert(session);
|
||||
|
||||
for (final HologramData data : holograms) {
|
||||
final Hologram hologram = this.plugin.getHologramFactory().apply(data);
|
||||
this.plugin.getRegistry().register(hologram);
|
||||
}
|
||||
|
||||
this.plugin.savePersistentHolograms();
|
||||
// TODO(matt): Give options to delete them or teleport and a list of IDs please
|
||||
|
||||
MessageHelper.success(sender, String.format("Converted successfully, produced %s total holograms!", holograms.size()));
|
||||
} catch (Exception error) {
|
||||
MessageHelper.error(sender, error.getMessage());
|
||||
}
|
||||
}, () -> MessageHelper.error(sender, "That converter is not registered. Look at the developer documentation if you are adding converters."));
|
||||
}
|
||||
default -> {
|
||||
MessageHelper.info(sender, FH_COMMAND_USAGE);
|
||||
@@ -125,10 +125,10 @@ public final class FancyHologramsCMD extends Command {
|
||||
} else if (args.length == 3) {
|
||||
final String converterId = args[1];
|
||||
FHConversionRegistry.getConverterById(converterId)
|
||||
.ifPresent((converter) -> {
|
||||
suggestions.addAll(converter.getConvertableHolograms());
|
||||
suggestions.add("*");
|
||||
});
|
||||
.ifPresent((converter) -> {
|
||||
suggestions.addAll(converter.getConvertableHolograms());
|
||||
suggestions.add("*");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public final class FancyHologramsCMD extends Command {
|
||||
String lastArgument = args[args.length - 1];
|
||||
|
||||
return suggestions.stream()
|
||||
.filter(alias -> alias.startsWith(lastArgument.toLowerCase(Locale.ROOT)))
|
||||
.toList();
|
||||
.filter(alias -> alias.startsWith(lastArgument.toLowerCase(Locale.ROOT)))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class FancyHologramsTestCMD extends Command {
|
||||
Player p = (Player) commandSender;
|
||||
|
||||
FHTests tests = new FHTests();
|
||||
if(tests.runAllTests(p)) {
|
||||
if (tests.runAllTests(p)) {
|
||||
MessageHelper.success(p, "All tests have been successfully run!");
|
||||
} else {
|
||||
MessageHelper.error(p, "There was an issue running the tests!");
|
||||
|
||||
@@ -309,12 +309,12 @@ public final class HologramCMD extends Command {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
if(args[2].equalsIgnoreCase("brightness")) {
|
||||
if(args.length == 4) {
|
||||
if (args[2].equalsIgnoreCase("brightness")) {
|
||||
if (args.length == 4) {
|
||||
return List.of("block", "sky");
|
||||
}
|
||||
|
||||
if(args.length > 5) {
|
||||
if (args.length > 5) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.oliver.fancyholograms.commands.hologram;
|
||||
|
||||
import de.oliver.fancyholograms.api.hologram.Hologram;
|
||||
import de.oliver.fancyholograms.api.data.TextHologramData;
|
||||
import de.oliver.fancyholograms.api.hologram.Hologram;
|
||||
import de.oliver.fancyholograms.commands.Subcommand;
|
||||
import de.oliver.fancylib.MessageHelper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -27,28 +27,28 @@ public class BrightnessCMD implements Subcommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args.length < 5) {
|
||||
if (args.length < 5) {
|
||||
MessageHelper.error(player, "You must provide a brightness type and value.");
|
||||
return false;
|
||||
}
|
||||
|
||||
final var brightnessType = args[3];
|
||||
|
||||
if(!brightnessType.equalsIgnoreCase("block") && !brightnessType.equalsIgnoreCase("sky")) {
|
||||
if (!brightnessType.equalsIgnoreCase("block") && !brightnessType.equalsIgnoreCase("sky")) {
|
||||
MessageHelper.error(player, "Invalid brightness type, valid options are BLOCK or SKY");
|
||||
return false;
|
||||
}
|
||||
|
||||
final var parsedNumber = NumberHelper.parseInt(args[4]);
|
||||
|
||||
if(parsedNumber.isEmpty()) {
|
||||
if (parsedNumber.isEmpty()) {
|
||||
MessageHelper.error(player, "Invalid brightness value.");
|
||||
return false;
|
||||
}
|
||||
|
||||
final var brightnessValue = parsedNumber.get();
|
||||
|
||||
if(brightnessValue < 0 || brightnessValue > 15) {
|
||||
if (brightnessValue < 0 || brightnessValue > 15) {
|
||||
MessageHelper.error(player, "Invalid brightness value, must be between 0 and 15");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ public class CenterCMD implements Subcommand {
|
||||
Location location = hologram.getData().getLocation();
|
||||
|
||||
location.set(
|
||||
Math.floor(location.x()) + 0.5,
|
||||
location.y(),
|
||||
Math.floor(location.z()) + 0.5
|
||||
Math.floor(location.x()) + 0.5,
|
||||
location.y(),
|
||||
Math.floor(location.z()) + 0.5
|
||||
);
|
||||
|
||||
hologram.getData().setLocation(location);
|
||||
@@ -41,11 +41,11 @@ public class CenterCMD implements Subcommand {
|
||||
}
|
||||
|
||||
MessageHelper.success(player, "Centered the hologram to %s/%s/%s %s\u00B0 %s\u00B0".formatted(
|
||||
Formats.COORDINATES_DECIMAL.format(location.x()),
|
||||
Formats.COORDINATES_DECIMAL.format(location.y()),
|
||||
Formats.COORDINATES_DECIMAL.format(location.z()),
|
||||
Formats.COORDINATES_DECIMAL.format((location.getYaw() + 180f) % 360f),
|
||||
Formats.COORDINATES_DECIMAL.format((location.getPitch()) % 360f)
|
||||
Formats.COORDINATES_DECIMAL.format(location.x()),
|
||||
Formats.COORDINATES_DECIMAL.format(location.y()),
|
||||
Formats.COORDINATES_DECIMAL.format(location.z()),
|
||||
Formats.COORDINATES_DECIMAL.format((location.getYaw() + 180f) % 360f),
|
||||
Formats.COORDINATES_DECIMAL.format((location.getPitch()) % 360f)
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ public class NearbyCMD implements Subcommand {
|
||||
Location playerLocation = ((Player) player).getLocation().clone();
|
||||
|
||||
List<Map.Entry<Hologram, Double>> nearby = FancyHologramsPlugin.get()
|
||||
.getRegistry()
|
||||
.getAllPersistent()
|
||||
.stream()
|
||||
.filter((holo) -> holo.getData().getWorldName().equals(playerLocation.getWorld().getName()))
|
||||
.map((holo) -> Map.entry(holo, holo.getData().getLocation().distance(playerLocation)))
|
||||
.filter((entry) -> entry.getValue() <= range.get())
|
||||
.sorted(Comparator.comparingInt(a -> a.getValue().intValue()))
|
||||
.toList();
|
||||
.getRegistry()
|
||||
.getAllPersistent()
|
||||
.stream()
|
||||
.filter((holo) -> holo.getData().getWorldName().equals(playerLocation.getWorld().getName()))
|
||||
.map((holo) -> Map.entry(holo, holo.getData().getLocation().distance(playerLocation)))
|
||||
.filter((entry) -> entry.getValue() <= range.get())
|
||||
.sorted(Comparator.comparingInt(a -> a.getValue().intValue()))
|
||||
.toList();
|
||||
|
||||
if (nearby.isEmpty()) {
|
||||
MessageHelper.error(player, "There are no nearby holograms in a radius of %s blocks.".formatted(range.get()));
|
||||
@@ -80,16 +80,16 @@ public class NearbyCMD implements Subcommand {
|
||||
}
|
||||
|
||||
MessageHelper.info(player,
|
||||
"<hover:show_text:'<gray><i>Click to teleport</i></gray>'><click:run_command:'%s'> - %s (%s/%s/%s in %s, %s blocks away)</click></hover>"
|
||||
.formatted(
|
||||
"/hologram teleport " + holo.getData().getName(),
|
||||
holo.getData().getName(),
|
||||
Formats.DECIMAL.format(location.x()),
|
||||
Formats.DECIMAL.format(location.y()),
|
||||
Formats.DECIMAL.format(location.z()),
|
||||
location.getWorld().getName(),
|
||||
Formats.DECIMAL.format(distance)
|
||||
));
|
||||
"<hover:show_text:'<gray><i>Click to teleport</i></gray>'><click:run_command:'%s'> - %s (%s/%s/%s in %s, %s blocks away)</click></hover>"
|
||||
.formatted(
|
||||
"/hologram teleport " + holo.getData().getName(),
|
||||
holo.getData().getName(),
|
||||
Formats.DECIMAL.format(location.x()),
|
||||
Formats.DECIMAL.format(location.y()),
|
||||
Formats.DECIMAL.format(location.z()),
|
||||
location.getWorld().getName(),
|
||||
Formats.DECIMAL.format(distance)
|
||||
));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package de.oliver.fancyholograms.commands.hologram;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import de.oliver.fancyholograms.api.hologram.Hologram;
|
||||
import de.oliver.fancyholograms.api.data.TextHologramData;
|
||||
import de.oliver.fancyholograms.api.hologram.Hologram;
|
||||
import de.oliver.fancyholograms.commands.Subcommand;
|
||||
import de.oliver.fancylib.MessageHelper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -45,8 +45,8 @@ public class TranslateCommand implements Subcommand {
|
||||
}
|
||||
|
||||
if (Float.compare(translateX, displayData.getTranslation().x()) == 0 &&
|
||||
Float.compare(translateY, displayData.getTranslation().y()) == 0 &&
|
||||
Float.compare(translateZ, displayData.getTranslation().z()) == 0) {
|
||||
Float.compare(translateY, displayData.getTranslation().y()) == 0 &&
|
||||
Float.compare(translateZ, displayData.getTranslation().z()) == 0) {
|
||||
MessageHelper.warning(player, "This hologram is already at this translation");
|
||||
return false;
|
||||
}
|
||||
@@ -59,16 +59,16 @@ public class TranslateCommand implements Subcommand {
|
||||
}
|
||||
|
||||
if (Float.compare(copied.getTranslation().x(), displayData.getTranslation().x()) == 0 &&
|
||||
Float.compare(copied.getTranslation().y(), displayData.getTranslation().y()) == 0 &&
|
||||
Float.compare(copied.getTranslation().z(), displayData.getTranslation().z()) == 0) {
|
||||
Float.compare(copied.getTranslation().y(), displayData.getTranslation().y()) == 0 &&
|
||||
Float.compare(copied.getTranslation().z(), displayData.getTranslation().z()) == 0) {
|
||||
MessageHelper.warning(player, "This hologram is already at this translation");
|
||||
return false;
|
||||
}
|
||||
|
||||
displayData.setTranslation(new Vector3f(
|
||||
copied.getTranslation().x(),
|
||||
copied.getTranslation().y(),
|
||||
copied.getTranslation().z()));
|
||||
copied.getTranslation().x(),
|
||||
copied.getTranslation().y(),
|
||||
copied.getTranslation().z()));
|
||||
|
||||
if (FancyHologramsPlugin.get().getHologramConfiguration().isSaveOnChangedEnabled()) {
|
||||
FancyHologramsPlugin.get().getStorage().save(hologram.getData());
|
||||
|
||||
@@ -52,7 +52,7 @@ public class HologramControllerImpl implements HologramController {
|
||||
|
||||
@Override
|
||||
@ApiStatus.Internal
|
||||
public void updateHologramData(@NotNull final Hologram hologram, @NotNull final Player ...players) {
|
||||
public void updateHologramData(@NotNull final Hologram hologram, @NotNull final Player... players) {
|
||||
for (Player player : players) {
|
||||
boolean isVisible = hologram.isViewer(player);
|
||||
boolean shouldSee = shouldSeeHologram(hologram, player);
|
||||
|
||||
@@ -43,20 +43,20 @@ public class DecentHologramsConverter extends HologramConverter {
|
||||
|
||||
if (processIcons) {
|
||||
MessageHelper.warning(
|
||||
spec.getInvoker(),
|
||||
"--processIcons argument is experimental and may produce unexpected results."
|
||||
spec.getInvoker(),
|
||||
"--processIcons argument is experimental and may produce unexpected results."
|
||||
);
|
||||
} else {
|
||||
MessageHelper.info(
|
||||
spec.getInvoker(),
|
||||
"Any lines containing an #ICON will be removed. You may run with --processIcons to attempt conversion, but this is experimental."
|
||||
spec.getInvoker(),
|
||||
"Any lines containing an #ICON will be removed. You may run with --processIcons to attempt conversion, but this is experimental."
|
||||
);
|
||||
}
|
||||
|
||||
final List<String> targetHolograms = getConvertableHolograms()
|
||||
.stream()
|
||||
.filter((id) -> spec.getTarget().matches(id))
|
||||
.toList();
|
||||
.stream()
|
||||
.filter((id) -> spec.getTarget().matches(id))
|
||||
.toList();
|
||||
|
||||
if (targetHolograms.isEmpty()) {
|
||||
throw new RuntimeException("The provided target matches no holograms.");
|
||||
@@ -88,14 +88,14 @@ public class DecentHologramsConverter extends HologramConverter {
|
||||
}
|
||||
|
||||
return Arrays.stream(files)
|
||||
.map((file) -> file.getName().replace(".yml", ""))
|
||||
.toList();
|
||||
.map((file) -> file.getName().replace(".yml", ""))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private @NotNull List<HologramData> convert(@NotNull String hologramId, boolean processIcons) {
|
||||
final File file = DECENT_HOLOGRAMS_DATA.toPath()
|
||||
.resolve(hologramId.endsWith(".yml") ? hologramId : hologramId + ".yml")
|
||||
.toFile();
|
||||
.resolve(hologramId.endsWith(".yml") ? hologramId : hologramId + ".yml")
|
||||
.toFile();
|
||||
|
||||
if (!file.exists() || !file.canRead()) {
|
||||
throw new RuntimeException("File does not exist or is not readable.");
|
||||
@@ -110,10 +110,10 @@ public class DecentHologramsConverter extends HologramConverter {
|
||||
|
||||
// TODO handle exceptions here
|
||||
final Object firstPage = data.getMapList("pages")
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException(String.format("There are no pages for %s!", hologramId)))
|
||||
.get("lines");
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException(String.format("There are no pages for %s!", hologramId)))
|
||||
.get("lines");
|
||||
|
||||
Objects.requireNonNull(firstPage, String.format("There is no first page for %s!", hologramId));
|
||||
|
||||
@@ -126,14 +126,14 @@ public class DecentHologramsConverter extends HologramConverter {
|
||||
}
|
||||
|
||||
List<String> lines = firstPageSections
|
||||
.stream()
|
||||
.map((line) -> (String) line.get("content"))
|
||||
.toList();
|
||||
.stream()
|
||||
.map((line) -> (String) line.get("content"))
|
||||
.toList();
|
||||
|
||||
if (!processIcons) {
|
||||
lines = lines.stream()
|
||||
.map((line) -> line.startsWith(ICON_PREFIX) ? "" : line)
|
||||
.toList();
|
||||
.map((line) -> line.startsWith(ICON_PREFIX) ? "" : line)
|
||||
.toList();
|
||||
}
|
||||
|
||||
final TextHologramData hologram = new TextHologramData(hologramId, location);
|
||||
@@ -163,10 +163,10 @@ public class DecentHologramsConverter extends HologramConverter {
|
||||
* it should be enough to give users an idea of what it would look
|
||||
* like.
|
||||
*
|
||||
* @author MattMX
|
||||
* @param base The root hologram (background)
|
||||
* @param base The root hologram (background)
|
||||
* @param lines lines from the DecentHolograms hologram's first page.
|
||||
* @return A list of created [HologramData] children.
|
||||
* @author MattMX
|
||||
*/
|
||||
private @NotNull List<HologramData> convertSplitLines(@NotNull TextHologramData base, @NotNull List<Map<String, ?>> lines) {
|
||||
final List<HologramData> stack = new ArrayList<>();
|
||||
@@ -224,11 +224,11 @@ public class DecentHologramsConverter extends HologramConverter {
|
||||
for (@NotNull HologramData holo : stack) {
|
||||
if (holo instanceof ItemHologramData itemHolo) {
|
||||
itemHolo.setTranslation(
|
||||
new Vector3f(
|
||||
itemHolo.getTranslation().x,
|
||||
totalHeight - itemHolo.getTranslation().y - 0.25f,
|
||||
itemHolo.getTranslation().z
|
||||
)
|
||||
new Vector3f(
|
||||
itemHolo.getTranslation().x,
|
||||
totalHeight - itemHolo.getTranslation().y - 0.25f,
|
||||
itemHolo.getTranslation().z
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,27 +25,27 @@ public class FHConversionRegistry {
|
||||
|
||||
public static <T extends HologramConverter> @NotNull Optional<T> getConverter(@NotNull String id) {
|
||||
return getConverterById(id)
|
||||
.map((converter) -> {
|
||||
try {
|
||||
return (T) converter;
|
||||
} catch (ClassCastException ignored) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
.map((converter) -> {
|
||||
try {
|
||||
return (T) converter;
|
||||
} catch (ClassCastException ignored) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static <T extends HologramConverter> @NotNull Optional<T> getConverter(@NotNull Class<T> clazz) {
|
||||
return converters.values()
|
||||
.stream()
|
||||
.filter(clazz::isInstance)
|
||||
.findFirst()
|
||||
.map((converter) -> {
|
||||
try {
|
||||
return (T) converter;
|
||||
} catch (ClassCastException ignored) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
.stream()
|
||||
.filter(clazz::isInstance)
|
||||
.findFirst()
|
||||
.map((converter) -> {
|
||||
try {
|
||||
return (T) converter;
|
||||
} catch (ClassCastException ignored) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static @NotNull Set<String> getAllConverterIds() {
|
||||
@@ -54,10 +54,10 @@ public class FHConversionRegistry {
|
||||
|
||||
public static @NotNull Set<String> getAllUsableConverterIds() {
|
||||
return converters
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter((entry) -> entry.getValue().canRunConverter())
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter((entry) -> entry.getValue().canRunConverter())
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,15 @@ public class HologramConversionSession {
|
||||
private final String[] arguments;
|
||||
|
||||
public HologramConversionSession(
|
||||
@NotNull ConverterTarget target
|
||||
@NotNull ConverterTarget target
|
||||
) {
|
||||
this(target, Bukkit.getConsoleSender(), new String[0]);
|
||||
}
|
||||
|
||||
public HologramConversionSession(
|
||||
@NotNull ConverterTarget target,
|
||||
@NotNull CommandSender invoker,
|
||||
@NotNull String[] arguments
|
||||
@NotNull ConverterTarget target,
|
||||
@NotNull CommandSender invoker,
|
||||
@NotNull String[] arguments
|
||||
) {
|
||||
this.target = target;
|
||||
this.invoker = invoker;
|
||||
@@ -45,13 +45,13 @@ public class HologramConversionSession {
|
||||
public void logUnsuccessfulConversion(@NotNull String oldHologram, @Nullable String message) {
|
||||
if (message != null) {
|
||||
MessageHelper.error(
|
||||
getInvoker(),
|
||||
String.format("There was an issue converting %s: %s", oldHologram, message)
|
||||
getInvoker(),
|
||||
String.format("There was an issue converting %s: %s", oldHologram, message)
|
||||
);
|
||||
} else {
|
||||
MessageHelper.error(
|
||||
getInvoker(),
|
||||
String.format("There was an issue converting %s!", oldHologram)
|
||||
getInvoker(),
|
||||
String.format("There was an issue converting %s!", oldHologram)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -62,14 +62,14 @@ public class HologramConversionSession {
|
||||
|
||||
public void logSuccessfulConversion(@NotNull String oldHologram, @NotNull List<HologramData> results) {
|
||||
MessageHelper.info(
|
||||
getInvoker(),
|
||||
String.format("Successfully converted %s to %s hologram(s).", oldHologram, results.size())
|
||||
getInvoker(),
|
||||
String.format("Successfully converted %s to %s hologram(s).", oldHologram, results.size())
|
||||
);
|
||||
|
||||
for (@NotNull HologramData data : results) {
|
||||
MessageHelper.info(
|
||||
getInvoker(),
|
||||
String.format(" - %s type: %s", data.getName(), data.getType().name())
|
||||
getInvoker(),
|
||||
String.format(" - %s type: %s", data.getName(), data.getType().name())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public abstract class HologramConverter {
|
||||
|
||||
/**
|
||||
* Returns a list of converted holograms
|
||||
*
|
||||
* @param spec Configuration of the hologram conversion
|
||||
* @return A list of converted holograms.
|
||||
*/
|
||||
@@ -23,6 +24,7 @@ public abstract class HologramConverter {
|
||||
|
||||
/**
|
||||
* Returns a list of converted holograms
|
||||
*
|
||||
* @param spec Configuration of the hologram conversion
|
||||
* @return A list of converted holograms.
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@ public final class PlayerListener implements Listener {
|
||||
event.getClass().getMethod("getID");
|
||||
return event.getID();
|
||||
} catch (final @NotNull NoSuchMethodException e) {
|
||||
return new UUID(0,0);
|
||||
return new UUID(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public final class PlayerListener implements Listener {
|
||||
// Adding accepted resource-pack to the list of currently loading resource-packs for that player.
|
||||
if (event.getStatus() == Status.ACCEPTED)
|
||||
loadingResourcePacks.computeIfAbsent(playerUniqueId, (___) -> new ArrayList<>()).add(packUniqueId);
|
||||
// Once successfully loaded (or failed to download), removing resource-pack from the map.
|
||||
// Once successfully loaded (or failed to download), removing resource-pack from the map.
|
||||
else if (event.getStatus() == Status.SUCCESSFULLY_LOADED || event.getStatus() == Status.FAILED_DOWNLOAD) {
|
||||
loadingResourcePacks.computeIfAbsent(playerUniqueId, (___) -> new ArrayList<>()).removeIf(uuid -> uuid.equals(packUniqueId));
|
||||
// Refreshing holograms once (possibly) all resource-packs are loaded.
|
||||
|
||||
@@ -200,7 +200,7 @@ public class YamlHologramStorage implements HologramStorage {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
|
||||
if(!FancyHologramsPlugin.canGet()) {
|
||||
if (!FancyHologramsPlugin.canGet()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class JsonAdapter {
|
||||
data.isSeeThrough(),
|
||||
data.getTextAlignment(),
|
||||
data.getTextUpdateInterval(),
|
||||
data.getBackground() == null ? "" : "#"+Integer.toHexString(data.getBackground().asARGB())
|
||||
data.getBackground() == null ? "" : "#" + Integer.toHexString(data.getBackground().asARGB())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class JsonStorage implements HologramStorage {
|
||||
@Override
|
||||
public void saveBatch(Collection<HologramData> holograms) {
|
||||
for (HologramData hologram : holograms) {
|
||||
save(hologram);
|
||||
save(hologram);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.oliver.fancyholograms.storage.json.model;
|
||||
|
||||
public record JsonBlockHologramData(
|
||||
String block_material
|
||||
String block_material
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package de.oliver.fancyholograms.storage.json.model;
|
||||
import org.bukkit.entity.Display;
|
||||
|
||||
public record JsonDisplayHologramData(
|
||||
JsonVec3f scale,
|
||||
JsonVec3f translation,
|
||||
Float shadow_radius,
|
||||
Float shadow_strength,
|
||||
JsonBrightness brightness,
|
||||
Display.Billboard billboard
|
||||
JsonVec3f scale,
|
||||
JsonVec3f translation,
|
||||
Float shadow_radius,
|
||||
Float shadow_strength,
|
||||
JsonBrightness brightness,
|
||||
Display.Billboard billboard
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.oliver.fancyholograms.storage.json.model;
|
||||
|
||||
public record JsonItemHologramData(
|
||||
String item
|
||||
String item
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class HologramBuilderTest {
|
||||
.text("Custom line")
|
||||
.build();
|
||||
|
||||
if(!(hologram.getData() instanceof TextHologramData data)) {
|
||||
if (!(hologram.getData() instanceof TextHologramData data)) {
|
||||
throw new AssertionError("Hologram is not a text hologram");
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class HologramBuilderTest {
|
||||
.text("Custom line", "Another line", "Yet another line")
|
||||
.build();
|
||||
|
||||
if(!(hologram.getData() instanceof TextHologramData data)) {
|
||||
if (!(hologram.getData() instanceof TextHologramData data)) {
|
||||
throw new AssertionError("Hologram is not a text hologram");
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class HologramBuilderTest {
|
||||
.text(List.of("Custom line", "Another line", "Yet another line"))
|
||||
.build();
|
||||
|
||||
if(!(hologram.getData() instanceof TextHologramData data)) {
|
||||
if (!(hologram.getData() instanceof TextHologramData data)) {
|
||||
throw new AssertionError("Hologram is not a text hologram");
|
||||
}
|
||||
|
||||
@@ -99,15 +99,15 @@ public class HologramBuilderTest {
|
||||
.persistent(false)
|
||||
.linkedNpcName("TestNPC")
|
||||
.billboard(Display.Billboard.FIXED)
|
||||
.scale(3,5,6)
|
||||
.translation(1,2,3)
|
||||
.scale(3, 5, 6)
|
||||
.translation(1, 2, 3)
|
||||
.brightness(7, 3)
|
||||
.shadowRadius(0.5f)
|
||||
.shadowStrength(0.7f)
|
||||
.interpolationDuration(100)
|
||||
.build();
|
||||
|
||||
if(!(hologram.getData() instanceof TextHologramData data)) {
|
||||
if (!(hologram.getData() instanceof TextHologramData data)) {
|
||||
throw new AssertionError("Hologram is not a text hologram");
|
||||
}
|
||||
|
||||
@@ -123,9 +123,9 @@ public class HologramBuilderTest {
|
||||
expect(data.isPersistent()).toBe(false);
|
||||
expect(data.getLinkedNpcName()).toEqual("TestNPC");
|
||||
expect(data.getBillboard()).toEqual(Display.Billboard.FIXED);
|
||||
expect(data.getScale()).toEqual(new Vector3f(3,5,6));
|
||||
expect(data.getTranslation()).toEqual(new Vector3f(1,2,3));
|
||||
expect(data.getBrightness()).toEqual(new Display.Brightness(7,3));
|
||||
expect(data.getScale()).toEqual(new Vector3f(3, 5, 6));
|
||||
expect(data.getTranslation()).toEqual(new Vector3f(1, 2, 3));
|
||||
expect(data.getBrightness()).toEqual(new Display.Brightness(7, 3));
|
||||
expect(data.getShadowRadius()).toEqual(0.5f);
|
||||
expect(data.getShadowStrength()).toEqual(0.7f);
|
||||
expect(data.getInterpolationDuration()).toEqual(100);
|
||||
@@ -145,14 +145,14 @@ public class HologramBuilderTest {
|
||||
expect(hologram.getData().getLocation()).toEqual(player.getLocation());
|
||||
expect(hologram.getData().getType()).toEqual(HologramType.ITEM);
|
||||
|
||||
if(!(hologram.getData() instanceof ItemHologramData data)) {
|
||||
if (!(hologram.getData() instanceof ItemHologramData data)) {
|
||||
throw new AssertionError("Hologram is not an item hologram");
|
||||
}
|
||||
|
||||
expect(data.getItemStack()).toEqual(item);
|
||||
}
|
||||
|
||||
@FPTest(name = "Test block hologram builder")
|
||||
@FPTest(name = "Test block hologram builder")
|
||||
public void testBlockHologramBuilder(Player player) {
|
||||
Hologram hologram = BlockHologramBuilder.create("Test", player.getLocation())
|
||||
.block(Material.DIRT)
|
||||
@@ -164,7 +164,7 @@ public class HologramBuilderTest {
|
||||
expect(hologram.getData().getLocation()).toEqual(player.getLocation());
|
||||
expect(hologram.getData().getType()).toEqual(HologramType.BLOCK);
|
||||
|
||||
if(!(hologram.getData() instanceof BlockHologramData data)) {
|
||||
if (!(hologram.getData() instanceof BlockHologramData data)) {
|
||||
throw new AssertionError("Hologram is not a block hologram");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ public class HologramControllerTest {
|
||||
new TextHologramData("Test", player.getLocation().clone()),
|
||||
() -> spawnTo++,
|
||||
() -> despawnFrom++,
|
||||
() -> {}
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
|
||||
this.spawnTo = 0;
|
||||
@@ -52,7 +53,7 @@ public class HologramControllerTest {
|
||||
expect(hologram.isViewer(player)).toBe(true);
|
||||
|
||||
|
||||
hologram.getData().setLocation(new Location(player.getWorld(),0,10000, 0));
|
||||
hologram.getData().setLocation(new Location(player.getWorld(), 0, 10000, 0));
|
||||
|
||||
controller.hideHologramFrom(hologram, player);
|
||||
expect(despawnFrom).toBe(1);
|
||||
|
||||
@@ -26,10 +26,13 @@ public class HologramRegistryTest {
|
||||
public void testRegister(Player player) {
|
||||
Hologram hologram = new HologramMock(
|
||||
new TextHologramData("Test", player.getLocation()),
|
||||
() -> {},
|
||||
() -> {},
|
||||
() -> {}
|
||||
);
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
|
||||
registry.register(hologram);
|
||||
|
||||
@@ -42,10 +45,13 @@ public class HologramRegistryTest {
|
||||
public void testUnregister(Player player) {
|
||||
Hologram hologram = new HologramMock(
|
||||
new TextHologramData("Test", player.getLocation()),
|
||||
() -> {},
|
||||
() -> {},
|
||||
() -> {}
|
||||
);
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
|
||||
registry.register(hologram);
|
||||
expect(registry.get("Test").isPresent()).toBe(true);
|
||||
@@ -60,10 +66,13 @@ public class HologramRegistryTest {
|
||||
public void testContains(Player player) {
|
||||
Hologram hologram = new HologramMock(
|
||||
new TextHologramData("Test", player.getLocation()),
|
||||
() -> {},
|
||||
() -> {},
|
||||
() -> {}
|
||||
);
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
|
||||
registry.register(hologram);
|
||||
expect(registry.contains("Test")).toBe(true);
|
||||
@@ -73,10 +82,13 @@ public class HologramRegistryTest {
|
||||
public void testGet(Player player) {
|
||||
Hologram hologram = new HologramMock(
|
||||
new TextHologramData("Test", player.getLocation()),
|
||||
() -> {},
|
||||
() -> {},
|
||||
() -> {}
|
||||
);
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
|
||||
registry.register(hologram);
|
||||
|
||||
@@ -89,16 +101,22 @@ public class HologramRegistryTest {
|
||||
public void testGetAll(Player player) {
|
||||
Hologram hologram1 = new HologramMock(
|
||||
new TextHologramData("Test1", player.getLocation()),
|
||||
() -> {},
|
||||
() -> {},
|
||||
() -> {}
|
||||
);
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
Hologram hologram2 = new HologramMock(
|
||||
new TextHologramData("Test2", player.getLocation()),
|
||||
() -> {},
|
||||
() -> {},
|
||||
() -> {}
|
||||
);
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
|
||||
registry.register(hologram1);
|
||||
registry.register(hologram2);
|
||||
@@ -112,19 +130,25 @@ public class HologramRegistryTest {
|
||||
public void testGetAllPersistent(Player player) {
|
||||
Hologram hologram1 = new HologramMock(
|
||||
new TextHologramData("Test1", player.getLocation()),
|
||||
() -> {},
|
||||
() -> {},
|
||||
() -> {}
|
||||
);
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
|
||||
TextHologramData data2 = new TextHologramData("Test2", player.getLocation());
|
||||
data2.setPersistent(false);
|
||||
Hologram hologram2 = new HologramMock(
|
||||
data2,
|
||||
() -> {},
|
||||
() -> {},
|
||||
() -> {}
|
||||
);
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
|
||||
registry.register(hologram1);
|
||||
registry.register(hologram2);
|
||||
@@ -138,10 +162,13 @@ public class HologramRegistryTest {
|
||||
public void testMustGet(Player player) {
|
||||
Hologram hologram = new HologramMock(
|
||||
new TextHologramData("Test", player.getLocation()),
|
||||
() -> {},
|
||||
() -> {},
|
||||
() -> {}
|
||||
);
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
() -> {
|
||||
}
|
||||
);
|
||||
|
||||
registry.register(hologram);
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ public class MultiplePagesTrait extends HologramTrait {
|
||||
|
||||
private static final Configuration DEFAULT_CONFIG = new Configuration(
|
||||
Mode.CYCLE,
|
||||
1000,
|
||||
1000,
|
||||
List.of(
|
||||
new Page(List.of("Page 1", "Line 1", "Line 2")),
|
||||
new Page(List.of("Page 2", "Line 1", "Line 2"))
|
||||
new Page(List.of("Page 2", "Line 1", "Line 2"))
|
||||
));
|
||||
|
||||
private Configuration config;
|
||||
@@ -43,7 +43,7 @@ public class MultiplePagesTrait extends HologramTrait {
|
||||
|
||||
currentPageIdx = switch (config.mode()) {
|
||||
case CYCLE -> (currentPageIdx + 1) % config.pages().size();
|
||||
case RANDOM ->(int) (Math.random() * config.pages().size());
|
||||
case RANDOM -> (int) (Math.random() * config.pages().size());
|
||||
default -> currentPageIdx;
|
||||
};
|
||||
}, 0, config.cycleDelay(), TimeUnit.MILLISECONDS);
|
||||
@@ -80,9 +80,9 @@ public class MultiplePagesTrait extends HologramTrait {
|
||||
}
|
||||
|
||||
record Configuration(
|
||||
Mode mode,
|
||||
long cycleDelay,
|
||||
List<Page> pages
|
||||
Mode mode,
|
||||
long cycleDelay,
|
||||
List<Page> pages
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user