Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ allprojects {
maven(url = "https://repo.tcoded.com/releases")
maven(url = "https://repo.william278.net/releases")
maven(url = "https://repo.codemc.org/repository/maven-public")
maven(url = "https://repo.fancyinnovations.com/releases")
exclusiveContent {
forRepository {
maven("https://dependency.download/releases")
Expand Down Expand Up @@ -75,6 +76,7 @@ allprojects {
compileOnly("net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.15.2")
compileOnly("com.github.UlrichBR:UClansV7-API:7.13.0-R1")
compileOnly("dev.kitteh:factions:4.0.0-rc.1")
compileOnly("de.oliver:FancyHolograms:2.7.0")

compileOnly(files("libs/SternalBoard-2.2.8-all.jar"))
compileOnly(files("libs/FeatherBoard.jar"))
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/fr/maxlego08/koth/KothPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import fr.maxlego08.koth.command.commands.CommandKoth;
import fr.maxlego08.koth.hologram.DecentHologram;
import fr.maxlego08.koth.hologram.EmptyHologram;
import fr.maxlego08.koth.hologram.FancyHologram;
import fr.maxlego08.koth.hook.ScoreboardPlugin;
import fr.maxlego08.koth.hook.scoreboard.DefaultHook;
import fr.maxlego08.koth.placeholder.LocalPlaceholder;
Expand Down Expand Up @@ -75,6 +76,10 @@ public void onEnable() {
Logger.info("Register DecentHologram implementation", Logger.LogType.INFO);
this.kothHologram = new DecentHologram();
}
if (this.isEnable(Plugins.FH)) {
Logger.info("Register FancyHologram implementation", Logger.LogType.INFO);
this.kothHologram = new FancyHologram();
}

KothPlaceholder kothPlaceholder = new KothPlaceholder(this.kothManager);
kothPlaceholder.register();
Expand Down
75 changes: 75 additions & 0 deletions src/main/java/fr/maxlego08/koth/hologram/FancyHologram.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package fr.maxlego08.koth.hologram;

import de.oliver.fancyholograms.api.FancyHologramsPlugin;
import de.oliver.fancyholograms.api.HologramManager;
import de.oliver.fancyholograms.api.data.HologramData;
import de.oliver.fancyholograms.api.data.TextHologramData;
import de.oliver.fancyholograms.api.hologram.Hologram;
import fr.maxlego08.koth.api.Koth;
import fr.maxlego08.koth.api.KothHologram;
import fr.maxlego08.koth.api.utils.HologramConfig;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class FancyHologram implements KothHologram {
private final Map<Koth, Hologram> holograms = new HashMap<>();

@Override
public void start(Koth koth) {
HologramConfig config = koth.getHologramConfig();
if (!config.isEnable()) return;

HologramManager manager = FancyHologramsPlugin.get().getHologramManager();
manager.getHologram("ZKOTH-" + koth.getFileName()).ifPresent(manager::removeHologram);

var data = new TextHologramData("ZKOTH-" + koth.getFileName(), config.getLocation());
updateLine(koth, data);
var hologram = manager.create(data);
manager.addHologram(hologram);
this.holograms.put(koth, hologram);
}

@Override
public void end(Koth koth) {
HologramConfig config = koth.getHologramConfig();
if (!config.isEnable()) return;

var manager = FancyHologramsPlugin.get().getHologramManager();
if (this.holograms.containsKey(koth)) {
Hologram hologram = this.holograms.get(koth);
manager.removeHologram(hologram);
}
this.holograms.remove(koth);
}

@Override
public void update(Koth koth) {

HologramConfig config = koth.getHologramConfig();
if (!config.isEnable() || !this.holograms.containsKey(koth)) return;

Hologram hologram = this.holograms.get(koth);
updateLine(koth, hologram.getData());
hologram.forceUpdate();
}

private void updateLine(Koth koth, HologramData hologram) {
HologramConfig config = koth.getHologramConfig();
if (!config.isEnable()) return;

List<String> lines = config.getLines();
if (hologram instanceof TextHologramData data) {
data.setText(lines.stream().map(koth::replaceMessage).collect(Collectors.toList()));
}
}

@Override
public void onDisable() {
var manager = FancyHologramsPlugin.get().getHologramManager();
this.holograms.values().forEach(manager::removeHologram);
this.holograms.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum Plugins {
TRANSLATIONAPI("TranslationAPI"),
ZTRANSLATOR("zTranslator"),
DH("DecentHolograms"),
FH("FancyHolograms"),
ZSCHEDULERS("zSchedulers"),

;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ softdepend:
- HuskTowns
- Lands
- UltimateClans
- FancyHolograms
commands: