mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2025-01-16 04:41:22 +01:00
Use enum for enabling placeholder replacement in holograms
This commit is contained in:
parent
b4c8c6ede4
commit
dc9f0fe2b4
@ -81,22 +81,14 @@ public interface Hologram {
|
||||
void setPosition(@NotNull Location location);
|
||||
|
||||
/**
|
||||
* Checks if the hologram will track and replace placeholders.
|
||||
* This is false by default.
|
||||
*
|
||||
* @return if the hologram allows placeholders
|
||||
* @since 1
|
||||
*/
|
||||
boolean isAllowPlaceholders();
|
||||
@NotNull ResolvePlaceholders getResolvePlaceholders();
|
||||
|
||||
/**
|
||||
* Sets if the hologram should track and replace placeholders.
|
||||
* By default, it will not track them.
|
||||
*
|
||||
* @param allowPlaceholders if the hologram should track placeholders
|
||||
* @since 1
|
||||
*/
|
||||
void setAllowPlaceholders(boolean allowPlaceholders);
|
||||
void setResolvePlaceholders(@NotNull ResolvePlaceholders resolvePlaceholders);
|
||||
|
||||
/**
|
||||
* Deletes this hologram. Editing or teleporting the hologram when deleted
|
||||
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.api.hologram;
|
||||
|
||||
public enum ResolvePlaceholders {
|
||||
|
||||
DEFAULT,
|
||||
ALL,
|
||||
NONE
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ package me.filoghost.holographicdisplays.plugin.api.current;
|
||||
import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.holographicdisplays.api.Position;
|
||||
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
||||
import me.filoghost.holographicdisplays.api.hologram.ResolvePlaceholders;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologram;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
||||
@ -22,7 +23,7 @@ public class APIHologram extends BaseHologram implements Hologram {
|
||||
private final APIHologramManager hologramManager;
|
||||
private final DefaultVisibilitySettings visibilitySettings;
|
||||
|
||||
private boolean allowPlaceholders;
|
||||
private @NotNull ResolvePlaceholders resolvePlaceholders;
|
||||
|
||||
protected APIHologram(
|
||||
ImmutablePosition position,
|
||||
@ -35,6 +36,7 @@ public class APIHologram extends BaseHologram implements Hologram {
|
||||
this.plugin = plugin;
|
||||
this.hologramManager = hologramManager;
|
||||
this.visibilitySettings = new DefaultVisibilitySettings();
|
||||
this.resolvePlaceholders = ResolvePlaceholders.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,19 +55,20 @@ public class APIHologram extends BaseHologram implements Hologram {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowPlaceholders() {
|
||||
return allowPlaceholders;
|
||||
public @NotNull ResolvePlaceholders getResolvePlaceholders() {
|
||||
return resolvePlaceholders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllowPlaceholders(boolean allowPlaceholders) {
|
||||
public void setResolvePlaceholders(@NotNull ResolvePlaceholders resolvePlaceholders) {
|
||||
Preconditions.notNull(resolvePlaceholders, "resolvePlaceholders");
|
||||
checkNotDeleted();
|
||||
|
||||
if (this.allowPlaceholders == allowPlaceholders) {
|
||||
if (this.resolvePlaceholders == resolvePlaceholders) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.allowPlaceholders = allowPlaceholders;
|
||||
this.resolvePlaceholders = resolvePlaceholders;
|
||||
for (APIHologramLine line : lines) {
|
||||
line.setChanged();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.plugin.api.current;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.hologram.ResolvePlaceholders;
|
||||
import me.filoghost.holographicdisplays.api.hologram.line.ClickListener;
|
||||
import me.filoghost.holographicdisplays.api.hologram.line.TextHologramLine;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseTextHologramLine;
|
||||
@ -23,7 +24,7 @@ public class APITextHologramLine extends BaseTextHologramLine implements TextHol
|
||||
|
||||
@Override
|
||||
public boolean isAllowPlaceholders() {
|
||||
return hologram.isAllowPlaceholders();
|
||||
return hologram.getResolvePlaceholders() == ResolvePlaceholders.ALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user